This is the mail archive of the
cygwin-patches@cygwin.com
mailing list for the Cygwin project.
[Patch] cygcheck: eprintf + display_error: Do /something/.
- From: "Buzz" <cygwin-patches dot buzz at bavag dot tmfweb dot nl>
- To: cygwin-patches at cygwin dot com
- Date: Fri, 17 Dec 2004 02:04:40 +0100 (MET)
- Subject: [Patch] cygcheck: eprintf + display_error: Do /something/.
- Organisation: Ehm...
- Reply-to: cygwin-patches mailing-list <cygwin-patches at cygwin dot com>
Hi,
Maybe the previous mail got missed?
Here is another attempt at making eprintf a usable/used function in
cygcheck. It this time just flushes stdout and stderr before/after
output on stderr, when both (stdout and stderr) are ttys.
2004-12-16 Bas van Gompel <cygwin-patch.buzz@bavag.tmfweb.nl>
* cygcheck.cc (eprintf): Flush stdout before, and stderr after output,
when stdout and stderr both refer to tty's.
(display_error): Use eprintf.
--- src/winsup/utils/cygcheck.cc 18 Nov 2004 05:20:23 -0000 1.64
+++ src/winsup/utils/cygcheck.cc 16 Dec 2004 21:48:03 -0000
@@ -9,6 +9,7 @@
details. */
#include <stdio.h>
+#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
@@ -102,9 +103,16 @@ void
eprintf (const char *format, ...)
{
va_list ap;
+
+ if (isatty (fileno (stdout)) && isatty (fileno (stderr)))
+ fflush (stdout);
+
va_start (ap, format);
vfprintf (stderr, format, ap);
va_end (ap);
+
+ if (isatty (fileno (stdout)) && isatty (fileno (stderr)))
+ fflush (stderr);
}
/*
@@ -114,10 +122,10 @@ static int
display_error (const char *name, bool show_error = true, bool print_failed = true)
{
if (show_error)
- fprintf (stderr, "cygcheck: %s%s: %lu\n", name,
+ eprintf ("cygcheck: %s%s: %lu\n", name,
print_failed ? " failed" : "", GetLastError ());
else
- fprintf (stderr, "cygcheck: %s%s\n", name,
+ eprintf ("cygcheck: %s%s\n", name,
print_failed ? " failed" : "");
return 1;
}
L8r,
Buzz.
--
) | | ---/ ---/ Yes, this | This message consists of true | I do not
-- | | / / really is | and false bits entirely. | mail for
) | | / / a 72 by 4 +-------------------------------+ any1 but
-- \--| /--- /--- .sigfile. | |perl -pe "s.u(z)\1.as." | me. 4^re