From d5784c9b41b27467b8fa522ca0c90591b50b1d59 Mon Sep 17 00:00:00 2001 From: sam Date: Sun, 7 Sep 2003 14:28:01 +0000 Subject: [PATCH] * Fixed many tests for termio.h, termios.h, TIOCFLUSH, etc. git-svn-id: svn://svn.zoy.org/elk/trunk@122 55e467fa-43c5-0310-a8a2-de718669efc6 --- configure.ac | 43 ++++++++++++++++--------------------------- src/print.c | 25 ++++++++++++------------- src/read.c | 31 +++++++++++++------------------ 3 files changed, 41 insertions(+), 58 deletions(-) diff --git a/configure.ac b/configure.ac index 63bd5b8..bee33f0 100644 --- a/configure.ac +++ b/configure.ac @@ -63,24 +63,7 @@ dnl FIXME AC_CHECK_HEADERS(unistd.h) # If the FIONREAD ioctl command is defined, which file must be included? -AC_MSG_CHECKING(for FIONREAD in termios.h) -AC_EGREP_HEADER(FIONREAD, termios.h, [ - AC_MSG_RESULT(yes) AC_DEFINE(FIONREAD_IN_TERMIOS_H, 1, Define if defines FIONREAD) -],[ - AC_MSG_RESULT(no) - AC_MSG_CHECKING(for FIONREAD in sys/ioctl.h) - AC_EGREP_HEADER(FIONREAD, sys/ioctl.h, [ - AC_MSG_RESULT(yes) AC_DEFINE(FIONREAD_IN_SYS_IOCTL_H, 1, Define if defines FIONREAD) - ],[ - AC_MSG_RESULT(no) - AC_MSG_CHECKING(for FIONREAD in sys/filio.h) - AC_EGREP_HEADER(FIONREAD, sys/filio.h, [ - AC_MSG_RESULT(yes) AC_DEFINE(FIONREAD_IN_SYS_FILIO_H, 1, Define if defines FIONREAD) - ],[ - AC_MSG_RESULT(no) - ]) - ]) -]) +AC_CHECK_HEADERS(termios.h sys/ioctl.h sys/filio.h) # If getdtablesize() is available to determine the maximum number of open # files per process, set getdtablesize=yes. @@ -249,16 +232,22 @@ AC_DEFINE(TERMIO, 1, [FIXME HARD]) # tiocflush use TIOCFLUSH ioctl from # tcflsh use TCFLSH ioctl from # Leave the variable(s) empty if flushing is not supported. -if false; then - AC_DEFINE(FLUSH_BSD, 1, [FIXME HARD]) +AC_CHECK_FUNCS(fpurge) + +AC_CACHE_CHECK([for BSD-style flushing], + [ac_cv_have_bsd_flush], + [AC_TRY_COMPILE( + [#include ], + [FILE *f; + f->_cnt = 0; + f->_ptr = f->_base;], + ac_cv_have_bsd_flush=yes, + ac_cv_have_bsd_flush=no)]) +if test "${ac_cv_have_bsd_flush}" = "yes"; then + AC_DEFINE(HAVE_BSD_FLUSH, 1, [Define if you have BSD-style flushing]) fi -if false; then - AC_DEFINE(FLUSH_FPURGE, 1, [FIXME HARD]) -fi -if false; then - AC_DEFINE(FLUSH_TIOCFLUSH, 1, [FIXME HARD]) -fi -AC_DEFINE(FLUSH_TCFLSH, 1, [FIXME HARD]) + +AC_CHECK_HEADERS(termio.h termios.h) # The interpreter uses the getrlimit function to determine the maximum # stack size of the running program. If this function is not supported, diff --git a/src/print.c b/src/print.c index a57e341..9fbfd8d 100644 --- a/src/print.c +++ b/src/print.c @@ -35,12 +35,14 @@ #include #include -#ifdef FLUSH_TIOCFLUSH -# include -#else -#ifdef FLUSH_TCFLSH -# include +#if defined(HAVE_TERMIO_H) +# include +#elif defined(HAVE_TERMIOS_H) +# include #endif + +#if defined(HAVE_SYS_IOCTL_H) +# include #endif #include "kernel.h" @@ -203,21 +205,18 @@ void Discard_Output (Object port) { if (PORT(port)->flags & P_STRING) return; f = PORT(port)->file; -#ifdef FLUSH_FPURGE +#if defined(HAVE_FPURGE) (void)fpurge (f); -#else -#ifdef FLUSH_BSD +#elif defined(HAVE_BSD_FLUSH) f->_cnt = 0; f->_ptr = f->_base; #endif -#endif -#ifdef FLUSH_TIOCFLUSH + +#if defined(TIOCFLUSH) (void)ioctl (fileno (f), TIOCFLUSH, (char *)0); -#else -#ifdef FLUSH_TCFLSH +#elif defined(TCFLSH) (void)ioctl (fileno (f), TCFLSH, (char *)1); #endif -#endif } Object P_Flush_Output_Port (int argc, Object *argv) { diff --git a/src/read.c b/src/read.c index ceb13e0..8714664 100644 --- a/src/read.c +++ b/src/read.c @@ -34,19 +34,17 @@ #include #include -#ifdef FLUSH_TIOCFLUSH -# include -#else -#ifdef FLUSH_TCFLSH -# include -#endif +#if defined(HAVE_TERMIO_H) +# include +#elif defined(HAVE_TERMIOS_H) +# include #endif -#if defined(FIONREAD_IN_TERMIOS_H) -# include -#elif defined(FIONREAD_IN_SYS_IOCTL_H) +#if defined(HAVE_SYS_IOCTL_H) # include -#elif defined(FIONREAD_IN_SYS_FILIO_H) +#endif + +#if defined(HAVE_SYS_FILIO_H) # include #endif @@ -146,21 +144,18 @@ void Discard_Input (Object port) { if (PORT(port)->flags & P_STRING) return; f = PORT(port)->file; -#ifdef FLUSH_FPURGE +#if defined(HAVE_FPURGE) (void)fpurge (f); -#else -#ifdef FLUSH_BSD +#elif defined(HAVE_BSD_FLUSH) f->_cnt = 0; f->_ptr = f->_base; #endif -#endif -#ifdef FLUSH_TIOCFLUSH + +#if defined(TIOCFLUSH) (void)ioctl (fileno (f), TIOCFLUSH, (char *)0); -#else -#ifdef FLUSH_TCFLSH +#elif defined(TCFLSH) (void)ioctl (fileno (f), TCFLSH, (char *)0); #endif -#endif } Object P_Unread_Char (int argc, Object *argv) {