[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Changes to m4/modules/m4.c,v
From: |
Eric Blake |
Subject: |
Changes to m4/modules/m4.c,v |
Date: |
Fri, 15 Dec 2006 04:23:49 +0000 |
CVSROOT: /sources/m4
Module name: m4
Changes by: Eric Blake <ericb> 06/12/15 04:23:48
Index: modules/m4.c
===================================================================
RCS file: /sources/m4/m4/modules/m4.c,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -b -r1.93 -r1.94
--- modules/m4.c 11 Nov 2006 16:21:25 -0000 1.93
+++ modules/m4.c 15 Dec 2006 04:23:48 -0000 1.94
@@ -486,9 +486,33 @@
{
FILE *debug_file = m4_get_debug_file (context);
- if (debug_file != stdout) fflush (stdout);
- if (debug_file != stderr) fflush (stderr);
- if (debug_file != NULL) fflush (debug_file);
+ if (debug_file != stdout)
+ fflush (stdout);
+ if (debug_file != stderr)
+ fflush (stderr);
+ if (debug_file != NULL)
+ fflush (debug_file);
+ /* POSIX requires that if m4 doesn't consume all input, but stdin is
+ opened on a seekable file, that the file pointer be left at the
+ next character on exit (but places no restrictions on the file
+ pointer location on a non-seekable file). It also requires that
+ fflush() followed by fseek() on an input file set the underlying
+ file pointer. However, fflush() on a non-seekable file can lose
+ buffered data, which we might otherwise want to process after
+ syscmd. Hence, we must check whether stdin is seekable. We must
+ also be tolerant of operating with stdin closed, so we don't
+ report any failures in this attempt. The stdio-safer module and
+ friends are essential, so that if stdin was closed, this lseek is
+ not on some other file that we have since opened. Mingw has bugs
+ when using fseek on text files, so we only strive for POSIX
+ behavior when we detect a UNIX environment. */
+#if UNIX
+ if (lseek (STDIN_FILENO, 0, SEEK_CUR) >= 0
+ && fflush (stdin) == 0)
+ {
+ fseek (stdin, 0, SEEK_CUR);
+ }
+#endif /* UNIX */
}
M4BUILTIN_HANDLER (syscmd)
- Changes to m4/modules/m4.c,v,
Eric Blake <=
- Changes to m4/modules/m4.c,v, Eric Blake, 2006/12/16
- Changes to m4/modules/m4.c,v, Eric Blake, 2006/12/20
- Changes to m4/modules/m4.c,v, Eric Blake, 2006/12/22
- Changes to m4/modules/m4.c,v, Eric Blake, 2006/12/27