bug-gnulib
[Top][All Lists]
Advanced

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

Re: typo in error module


From: Eric Blake
Subject: Re: typo in error module
Date: Fri, 28 Jul 2006 22:01:51 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Ben Pfaff <blp <at> cs.stanford.edu> writes:

> 
> Is it useful if it isn't pushed to glibc?  It only updates code
> inside an #ifdef _LIBC block.

Actually, a different bug is present on non glibc platforms.  When file_name is 
NULL, error_at_file omits the required space in "program: message".  My amended 
patch is below:

2006-07-28  Eric Blake  <address@hidden>

        * error.c (error_at_line): Match GNU Coding Standards.


I noticed this while trying to make m4 match GNU coding standards.  Man, I wish 
there were an error() variant that took a va_list.  m4 wants to avoid exporting 
global variables due to dynamic library issues (accessor functions are much 
better than data exports, for platforms like cygwin that use PE-COFF instead of 
elf).  It maintains the current lineno and file in a reentrant context passed 
among the various m4 routines.  Conceptually, I would like:

void m4warn(m4context *context, int status, int errnum,
            const char *message, ...)
{
  if (!suppress_warnings (context))
    error_at_line (status, errnum,
                   current_lineno (context) ? current_file (context) : NULL,
                   current_lineno (context), message, args);
}

However, without a va_list version of error, there is no way for me to access 
the notion of the current file and line number without a global variable read 
by a callback installed in error_print_progname (seeing as how it does not take 
parameters), with the callback repeating some of the logic already available 
free in error_at_line.  And I am reduced to using something gross like:
#define M4WARN(Context, Args) do { \
  global_lineno = current_lineno (Context); \
  global_file = current_file (Context); \
  if (!suppress_warnings (Context)) \
    error Args; \
} while (0)

and my code must use:
M4WARN (context, (status, errno, _("warning: %s"), string));

rather than the nicer-looking:
m4warn (context, status, errno, _("warning: %s"), string);


Index: lib/error.c
===================================================================
RCS file: /sources/gnulib/gnulib/lib/error.c,v
retrieving revision 1.43
diff -u -r1.43 error.c
--- lib/error.c 14 May 2005 06:03:58 -0000      1.43
+++ lib/error.c 28 Jul 2006 21:41:25 -0000
@@ -268,7 +268,7 @@
     {
 #if _LIBC
       if (_IO_fwide (stderr, 0) > 0)
-       __fwprintf (stderr, L"%s: ", program_name);
+       __fwprintf (stderr, L"%s:", program_name);
       else
 #endif
        fprintf (stderr, "%s:", program_name);
@@ -283,6 +283,8 @@
 #endif
        fprintf (stderr, "%s:%d: ", file_name, line_number);
     }
+  else
+    fputc (' ', stderr);
 
   va_start (args, message);
   error_tail (status, errnum, message, args);






reply via email to

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