[Xastir-dev] acinclude.m4:XASTIR_DETECT_DEVICES

Curt, WE7U archer at eskimo.com
Tue Mar 23 17:22:38 EST 2004


On Tue, 23 Mar 2004, Jack Twilley wrote:

> No, that's a bad idea.  It goes against the grain of autoconf and good
> software practices.  The code is very simple as it is: Test for the
> presence of /dev/ttyS0 and use it if it's there.  Test for the
> presence of another popular serial file name and use *that* if it's
> there.  I don't see any gain in changing it in any way other than
> adding in future popular serial file names.

I'm trying to wrap my head around the "bad idea" and "against good
software practices" comments.

It _is_ good practice to set default values for variables, then set
them to other values if special conditions are found.  It saves you
from explicitly checking for each and every possibility.  That's
what I'm suggesting doing.  It makes our code shorter.  Something
like this:


  AC_DEFUN([XASTIR_DETECT_DEVICES],
  [
  AC_MSG_CHECKING([for devices])
  ac_tnc_port=/dev/ttyS0
  ac_gps_port=/dev/ttyS1
  if test -d /proc/registry ; then
  elif test -c /dev/cuaa0 ; then
  ac_tnc_port=/dev/cuaa0
  ac_gps_port=/dev/cuaa1
  elif test -c /dev/cua/a ; then
  ac_tnc_port=/dev/cua/a
  ac_gps_port=/dev/cua/b
  fi

  AC_DEFINE_UNQUOTED([TNC_PORT], "$ac_tnc_port", [Default TNC port.])
  AC_DEFINE_UNQUOTED([GPS_PORT], "$ac_gps_port", [Default GPS port.])
  AC_MSG_RESULT(found $ac_tnc_port and $ac_gps_port)
  ])


We may be able to get rid of the test for /proc/registry if the
tests for /dev/cuaa0 and /dev/cua/a when run on Cygwin/WinXP don't
cause a hang.  That hang is the whole reason for changing this
function.

--
Curt, WE7U			    archer at eskimo dot com
Arlington, WA, USA		http://www.eskimo.com/~archer
"Lotto:    A tax on people who are bad at math." -- unknown
"Windows:  Microsoft's tax on computer illiterates." -- WE7U
"The world DOES revolve around me:  I picked the coordinate system!"



More information about the Xastir-dev mailing list