diff options
author | Ulrich Drepper <drepper@redhat.com> | 2004-12-22 20:10:10 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2004-12-22 20:10:10 +0000 |
commit | a334319f6530564d22e775935d9c91663623a1b4 (patch) | |
tree | b5877475619e4c938e98757d518bb1e9cbead751 /stdlib/fmtmsg.c | |
parent | 0ecb606cb6cf65de1d9fc8a919bceb4be476c602 (diff) | |
download | glibc-a334319f6530564d22e775935d9c91663623a1b4.tar glibc-a334319f6530564d22e775935d9c91663623a1b4.tar.gz glibc-a334319f6530564d22e775935d9c91663623a1b4.tar.bz2 glibc-a334319f6530564d22e775935d9c91663623a1b4.zip |
(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
Diffstat (limited to 'stdlib/fmtmsg.c')
-rw-r--r-- | stdlib/fmtmsg.c | 78 |
1 files changed, 60 insertions, 18 deletions
diff --git a/stdlib/fmtmsg.c b/stdlib/fmtmsg.c index 2a4d16a461..2ab97b7d90 100644 --- a/stdlib/fmtmsg.c +++ b/stdlib/fmtmsg.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997,1999,2000-2003,2005, 2006 Free Software Foundation, Inc. +/* Copyright (C) 1997,1999,2000,2001,2002,2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -44,7 +44,7 @@ enum static const struct { - uint32_t len; + size_t len; /* Adjust the size if new elements are added. */ const char name[12]; } keywords[] = @@ -154,21 +154,42 @@ fmtmsg (long int classification, const char *label, int severity, int do_action = (print & action_mask) && action != MM_NULLACT; int do_tag = (print & tag_mask) && tag != MM_NULLTAG; - if (__fxprintf (stderr, "%s%s%s%s%s%s%s%s%s%s\n", - do_label ? label : "", - do_label && (do_severity | do_text | do_action | do_tag) - ? ": " : "", - do_severity ? severity_rec->string : "", - do_severity && (do_text | do_action | do_tag) - ? ": " : "", - do_text ? text : "", - do_text && (do_action | do_tag) ? "\n" : "", - do_action ? "TO FIX: " : "", - do_action ? action : "", - do_action && do_tag ? " " : "", - do_tag ? tag : "") < 0) - /* Oh, oh. An error occurred during the output. */ - result = MM_NOMSG; +#ifdef USE_IN_LIBIO + if (_IO_fwide (stderr, 0) > 0) + { + if (__fwprintf (stderr, L"%s%s%s%s%s%s%s%s%s%s\n", + do_label ? label : "", + do_label + && (do_severity | do_text | do_action | do_tag) + ? ": " : "", + do_severity ? severity_rec->string : "", + do_severity && (do_text | do_action | do_tag) + ? ": " : "", + do_text ? text : "", + do_text && (do_action | do_tag) ? "\n" : "", + do_action ? "TO FIX: " : "", + do_action ? action : "", + do_action && do_tag ? " " : "", + do_tag ? tag : "") < 0) + /* Oh, oh. An error occurred during the output. */ + result = MM_NOMSG; + } + else +#endif + if (fprintf (stderr, "%s%s%s%s%s%s%s%s%s%s\n", + do_label ? label : "", + do_label && (do_severity | do_text | do_action | do_tag) + ? ": " : "", + do_severity ? severity_rec->string : "", + do_severity && (do_text | do_action | do_tag) ? ": " : "", + do_text ? text : "", + do_text && (do_action | do_tag) ? "\n" : "", + do_action ? "TO FIX: " : "", + do_action ? action : "", + do_action && do_tag ? " " : "", + do_tag ? tag : "") < 0) + /* Oh, oh. An error occurred during the output. */ + result = MM_NOMSG; } if (classification & MM_CONSOLE) @@ -295,7 +316,7 @@ internal_addseverity (int severity, const char *string) int result = MM_OK; /* First see if there is already a record for the severity level. */ - for (runp = severity_list, lastp = NULL; runp != NULL; runp = runp->next) + for (runp = severity_list, lastp = NULL; runp != NULL; runp = runp-> next) if (runp->severity == severity) break; else @@ -303,6 +324,9 @@ internal_addseverity (int severity, const char *string) if (runp != NULL) { + /* Release old string. */ + free ((char *) runp->string); + if (string != NULL) /* Change the string. */ runp->string = string; @@ -343,17 +367,34 @@ int addseverity (int severity, const char *string) { int result; + const char *new_string; /* Prevent illegal SEVERITY values. */ if (severity <= MM_INFO) return MM_NOTOK; + if (string == NULL) + /* We want to remove the severity class. */ + new_string = NULL; + else + { + new_string = __strdup (string); + + if (new_string == NULL) + /* Allocation failed or illegal value. */ + return MM_NOTOK; + } + /* Protect the global data. */ __libc_lock_lock (lock); /* Do the real work. */ result = internal_addseverity (severity, string); + if (result != MM_OK) + /* Free the allocated string. */ + free ((char *) new_string); + /* Release the lock. */ __libc_lock_unlock (lock); @@ -370,6 +411,7 @@ libc_freeres_fn (free_mem) { /* This is data we have to release. */ struct severity_info *here = runp; + free ((char *) runp->string); runp = runp->next; free (here); } |