From 83af35ed9b9b8fc514d94a912f6603c3bb07b2bd Mon Sep 17 00:00:00 2001 From: Kevin Ryde Date: Fri, 26 May 2006 00:24:03 +0000 Subject: [PATCH] (fport_input_waiting): For ioctl, check HAVE_IOCTL as well as defined(FIONREAD), since mingw has FIONREAD but not ioctl(). Reported by "The Senator". For select and ioctl, move fdes into those conditionals, to avoid unused variable warning when neither of those used. --- libguile/fports.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libguile/fports.c b/libguile/fports.c index ffd929e2e..563557e82 100644 --- a/libguile/fports.c +++ b/libguile/fports.c @@ -458,9 +458,8 @@ scm_fdes_to_port (int fdes, char *mode, SCM name) static int fport_input_waiting (SCM port) { - int fdes = SCM_FSTREAM (port)->fdes; - #ifdef HAVE_SELECT + int fdes = SCM_FSTREAM (port)->fdes; struct timeval timeout; SELECT_TYPE read_set; SELECT_TYPE write_set; @@ -480,10 +479,15 @@ fport_input_waiting (SCM port) < 0) scm_syserror ("fport_input_waiting"); return FD_ISSET (fdes, &read_set) ? 1 : 0; -#elif defined (FIONREAD) + +#elif HAVE_IOCTL && defined (FIONREAD) + /* Note: cannot test just defined(FIONREAD) here, since mingw has FIONREAD + (for use with winsock ioctlsocket()) but not ioctl(). */ + int fdes = SCM_FSTREAM (port)->fdes; int remir; ioctl(fdes, FIONREAD, &remir); return remir; + #else scm_misc_error ("fport_input_waiting", "Not fully implemented on this platform",