Ver código fonte

Added support for error_print_progname as proposed
by Will Newton <will.newton@gmail.com>

Carmelo Amoroso 17 anos atrás
pai
commit
98f4a6dc8c
1 arquivos alterados com 9 adições e 3 exclusões
  1. 9 3
      libc/misc/error/error.c

+ 9 - 3
libc/misc/error/error.c

@@ -44,7 +44,7 @@ int error_one_per_line;
 /* If NULL, error will flush stdout, then print on stderr the program
    name, a colon and a space.  Otherwise, error will call this
    function without parameters instead.  */
-/* void (*error_print_progname) (void) = NULL; */
+void (*error_print_progname) (void) = NULL;
 
 extern __typeof(error) __error attribute_hidden;
 void __error (int status, int errnum, const char *message, ...)
@@ -53,7 +53,10 @@ void __error (int status, int errnum, const char *message, ...)
 
     fflush (stdout);
 
-    fprintf (stderr, "%s: ", __uclibc_progname);
+    if (error_print_progname)
+	(*error_print_progname) ();
+    else
+	fprintf (stderr, "%s: ", __uclibc_progname);
 
     va_start (args, message);
     vfprintf (stderr, message, args);
@@ -89,7 +92,10 @@ void __error_at_line (int status, int errnum, const char *file_name,
 
     fflush (stdout);
 
-    fprintf (stderr, "%s:", __uclibc_progname);
+    if (error_print_progname)
+	(*error_print_progname) ();
+    else
+	fprintf (stderr, "%s:", __uclibc_progname);
 
     if (file_name != NULL)
 	fprintf (stderr, "%s:%d: ", file_name, line_number);