v07i001: ularn - ultra-larn, an enhancement of the larn adventure game, Part01/08
Guy Harris
guy at auspex.auspex.com
Thu Jul 13 08:46:01 AEST 1989
Yes, the author is jumping the gun; the claim seems to be that System V
has "tcflush" and company, but only recent releases have it, i.e. it
must be S5R3.2 or later, since S5R3.1 from AT&T doesn't have that
POSIXism.
The routine "flushall()" is best replaced by something like:
#ifdef BSD
#include <sys/file.h> /* to get FREAD */
#endif
/*
* flushall() Function to flush all type-ahead in the input buffer
*/
flushall()
{
#ifdef BSD
static int fread = FREAD;
ioctl(0, TIOCFLUSH, &fread);
#else /* SYSV */
# ifdef unix
ioctl(0, TCFLSH, 0);
# endif /* unix */
#endif /* BSD */
}
since not only should all System V systems (including Xenix System V, if
it's truly SVID-compatible in its tty driver) have TCFLSH in that form,
even if they don't have POSIX stuff, but BSD has had the ability to
selectively flush the input, output, or both queues since 4.2BSD (if you
have 4.1BSD, you lose here, oh well). If the intent of the "#ifdef
unix" is to eliminate Xenix (although, if Xenix doesn't define "unix",
somebody screwed up), it can be eliminated.
More information about the Comp.sources.bugs
mailing list