From 78adb5c69ac87e84f9e36960ec37742028fb4bcd Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 26 Feb 2004 23:43:45 +0000 Subject: [PATCH] Don't modify errno. (#116617, Balazs Scheidler) Fri Feb 27 00:46:29 2004 Matthias Clasen * glib/gstrfuncs.c (g_strerror): Don't modify errno. (#116617, Balazs Scheidler) --- ChangeLog | 5 +++++ ChangeLog.pre-2-10 | 5 +++++ ChangeLog.pre-2-12 | 5 +++++ ChangeLog.pre-2-4 | 5 +++++ ChangeLog.pre-2-6 | 5 +++++ ChangeLog.pre-2-8 | 5 +++++ glib/gstrfuncs.c | 11 +++++++++-- 7 files changed, 39 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index aa8ba005a..7191a3511 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Feb 27 00:46:29 2004 Matthias Clasen + + * glib/gstrfuncs.c (g_strerror): Don't modify errno. (#116617, + Balazs Scheidler) + 2004-02-26 Sebastian Wilhelmi * glib/gatomic.h: Fix the !G_THREADS_ENABLED case. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index aa8ba005a..7191a3511 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,8 @@ +Fri Feb 27 00:46:29 2004 Matthias Clasen + + * glib/gstrfuncs.c (g_strerror): Don't modify errno. (#116617, + Balazs Scheidler) + 2004-02-26 Sebastian Wilhelmi * glib/gatomic.h: Fix the !G_THREADS_ENABLED case. diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index aa8ba005a..7191a3511 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,8 @@ +Fri Feb 27 00:46:29 2004 Matthias Clasen + + * glib/gstrfuncs.c (g_strerror): Don't modify errno. (#116617, + Balazs Scheidler) + 2004-02-26 Sebastian Wilhelmi * glib/gatomic.h: Fix the !G_THREADS_ENABLED case. diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index aa8ba005a..7191a3511 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,8 @@ +Fri Feb 27 00:46:29 2004 Matthias Clasen + + * glib/gstrfuncs.c (g_strerror): Don't modify errno. (#116617, + Balazs Scheidler) + 2004-02-26 Sebastian Wilhelmi * glib/gatomic.h: Fix the !G_THREADS_ENABLED case. diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index aa8ba005a..7191a3511 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,8 @@ +Fri Feb 27 00:46:29 2004 Matthias Clasen + + * glib/gstrfuncs.c (g_strerror): Don't modify errno. (#116617, + Balazs Scheidler) + 2004-02-26 Sebastian Wilhelmi * glib/gatomic.h: Fix the !G_THREADS_ENABLED case. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index aa8ba005a..7191a3511 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,8 @@ +Fri Feb 27 00:46:29 2004 Matthias Clasen + + * glib/gstrfuncs.c (g_strerror): Don't modify errno. (#116617, + Balazs Scheidler) + 2004-02-26 Sebastian Wilhelmi * glib/gatomic.h: Fix the !G_THREADS_ENABLED case. diff --git a/glib/gstrfuncs.c b/glib/gstrfuncs.c index c4854942e..e28f93bca 100644 --- a/glib/gstrfuncs.c +++ b/glib/gstrfuncs.c @@ -727,13 +727,17 @@ g_strerror (gint errnum) { static GStaticPrivate msg_private = G_STATIC_PRIVATE_INIT; char *msg; + int saved_errno = errno; #ifdef HAVE_STRERROR const char *msg_locale; msg_locale = strerror (errnum); if (g_get_charset (NULL)) - return msg_locale; + { + errno = saved_errno; + return msg_locale; + } else { gchar *msg_utf8 = g_locale_to_utf8 (msg_locale, -1, NULL, NULL, NULL); @@ -744,7 +748,9 @@ g_strerror (gint errnum) GQuark msg_quark = g_quark_from_string (msg_utf8); g_free (msg_utf8); - return g_quark_to_string (msg_quark); + msg_utf8 = (gchar *) g_quark_to_string (msg_quark); + errno = saved_errno; + return msg_utf8; } } #elif NO_SYS_ERRLIST @@ -1179,6 +1185,7 @@ g_strerror (gint errnum) _g_sprintf (msg, "unknown error (%d)", errnum); + errno = saved_errno; return msg; } -- 2.34.1