error.c tweak
Bruno Haible
haible@ilog.fr
Mon Apr 9 06:30:00 GMT 2001
The error() function contains code to fflush stdout before starting to
print on stderr. I understand this is necessary for the case when
stdout and stderr go the same device, and one of them happens to be
buffered. But I think this fflush(stdout) should also be executed in
the case that error_print_progname != NULL, because the
error_print_progname() doesn't do it. In particular, gettext defines
error_print_progname to point to an empty function.
2001-04-09 Bruno Haible <haible@clisp.cons.org>
* misc/error.c (error): fflush stdout also if
error_print_progname != NULL.
(error_at_line): Likewise.
*** glibc/misc/error.c.bak Tue Dec 12 19:32:26 2000
--- glibc/misc/error.c Mon Apr 9 15:23:12 2001
***************
*** 1,5 ****
/* Error handler for noninteractive utilities
! Copyright (C) 1990-1998, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library. Its master source is NOT part of
the C library, however. The master source lives in /gd/gnu/lib.
--- 1,5 ----
/* Error handler for noninteractive utilities
! Copyright (C) 1990-1998, 2000, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library. Its master source is NOT part of
the C library, however. The master source lives in /gd/gnu/lib.
***************
*** 139,151 ****
va_list args;
#endif
if (error_print_progname)
(*error_print_progname) ();
else
! {
! fflush (stdout);
! fprintf (stderr, "%s: ", program_name);
! }
#ifdef VA_START
VA_START (args, message);
--- 139,149 ----
va_list args;
#endif
+ fflush (stdout);
if (error_print_progname)
(*error_print_progname) ();
else
! fprintf (stderr, "%s: ", program_name);
#ifdef VA_START
VA_START (args, message);
***************
*** 211,223 ****
old_line_number = line_number;
}
if (error_print_progname)
(*error_print_progname) ();
else
! {
! fflush (stdout);
! fprintf (stderr, "%s:", program_name);
! }
if (file_name != NULL)
fprintf (stderr, "%s:%d: ", file_name, line_number);
--- 209,219 ----
old_line_number = line_number;
}
+ fflush (stdout);
if (error_print_progname)
(*error_print_progname) ();
else
! fprintf (stderr, "%s:", program_name);
if (file_name != NULL)
fprintf (stderr, "%s:%d: ", file_name, line_number);
More information about the Libc-alpha
mailing list