groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Groff-commit] groff ./ChangeLog src/libs/libdriver/printer.cpp


From: Werner LEMBERG
Subject: [Groff-commit] groff ./ChangeLog src/libs/libdriver/printer.cpp
Date: Wed, 02 Mar 2005 02:29:12 -0500

CVSROOT:        /cvsroot/groff
Module name:    groff
Branch:         
Changes by:     Werner LEMBERG <address@hidden> 05/03/02 07:29:09

Modified files:
        .              : ChangeLog 
        src/libs/libdriver: printer.cpp 

Log message:
        * src/libs/libdriver/printer.cpp (check_for_output_error): New
        function.  It has been introduced to catch peculiar error contexts
        on MS-Windows platforms.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/groff/groff/ChangeLog.diff?tr1=1.793&tr2=1.794&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/groff/groff/src/libs/libdriver/printer.cpp.diff?tr1=1.2&tr2=1.3&r1=text&r2=text

Patches:
Index: groff/ChangeLog
diff -u groff/ChangeLog:1.793 groff/ChangeLog:1.794
--- groff/ChangeLog:1.793       Mon Feb 28 13:57:53 2005
+++ groff/ChangeLog     Wed Mar  2 07:29:09 2005
@@ -1,3 +1,9 @@
+2005-03-02  Keith Marshall  <address@hidden>
+
+       * src/libs/libdriver/printer.cpp (check_for_output_error): New
+       function.  It has been introduced to catch peculiar error contexts
+       on MS-Windows platforms.
+
 2005-02-28  Werner LEMBERG  <address@hidden>
 
        * src/roff/troff/input.cpp (string_iterator::fill): Protect against
Index: groff/src/libs/libdriver/printer.cpp
diff -u groff/src/libs/libdriver/printer.cpp:1.2 
groff/src/libs/libdriver/printer.cpp:1.3
--- groff/src/libs/libdriver/printer.cpp:1.2    Thu Dec 16 13:09:54 2004
+++ groff/src/libs/libdriver/printer.cpp        Wed Mar  2 07:29:09 2005
@@ -2,11 +2,11 @@
 
 // <groff_src_dir>/src/libs/libdriver/printer.cpp
 
-/* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002, 2003, 2004
+/* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002, 2003, 2004, 2005
    Free Software Foundation, Inc.
    Written by James Clark (address@hidden)
 
-   Last update: 15 Dec 2004
+   Last update: 02 Mar 2005
 
    This file is part of groff.
 
@@ -28,6 +28,55 @@
 
 #include "driver.h"
 
+/* If we are sending output to an onscreen pager (as is the normal case
+   when reading man pages), then we may get an error state on the output
+   stream, if the user does not read all the way to the end.
+
+   We normally expect to catch this, and clean up the error context, when
+   the pager exits, because we should get, and handle, a SIGPIPE.
+
+   However ...
+*/
+
+#if (defined(_MSC_VER) || defined(_WIN32)) \
+    && !defined(__CYGWIN__) && !defined(_UWIN)
+
+  /* Native MS-Windows doesn't know about SIGPIPE, so we cannot detect the
+     early exit from the pager, and therefore, cannot clean up the error
+     context; thus we use the following static function to identify this
+     particular error context, and so suppress unwanted diagnostics.
+  */
+
+  static int
+  check_for_output_error (FILE* stream)
+  {
+    /* First, clean up any prior error context on the output stream */
+    if (ferror (stream))
+      clearerr (stream);
+    /* Clear errno, in case clearerr() and fflush() don't */
+    errno = 0;
+    /* Flush the output stream, so we can capture any error context, other
+       than the specific case we wish to suppress.
+       
+       Microsoft doesn't document it, but the error code for the specific
+       context we are trying to suppress seems to be EINVAL -- a strange
+       choice, since it is not normally associated with fflush(); of course,
+       it *should* be EPIPE, but this *definitely* is not used, and *is* so
+       documented.
+    */
+    return ((fflush(stream) < 0) && (errno != EINVAL));
+  }
+
+#else
+
+  /* For other systems, we simply assume that *any* output error context
+     is to be reported.
+  */
+# define check_for_output_error(stream) ferror(stream) || fflush(stream) < 0
+
+#endif
+
+
 font_pointer_list::font_pointer_list(font *f, font_pointer_list *fp)
 : p(f), next(fp)
 {
@@ -47,7 +96,7 @@
     delete tem->p;
     delete tem;
   }
-  if (ferror(stdout) || fflush(stdout) < 0)
+  if (check_for_output_error(stdout))
     fatal("output error");
 }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]