From 98f4a6dc8c4bc9b75a9396ac0f2a7de409bbd1e2 Mon Sep 17 00:00:00 2001
From: Carmelo Amoroso <carmelo.amoroso@st.com>
Date: Tue, 22 Apr 2008 15:13:57 +0000
Subject: Added support for error_print_progname as proposed by Will Newton
 <will.newton@gmail.com>

---
 libc/misc/error/error.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

(limited to 'libc/misc/error')

diff --git a/libc/misc/error/error.c b/libc/misc/error/error.c
index 02b4e8e69..5f0d512e9 100644
--- a/libc/misc/error/error.c
+++ b/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);
-- 
cgit v1.2.3