Don't modify errno. (#116617, Balazs Scheidler)

Fri Feb 27 00:46:29 2004  Matthias Clasen  <maclas@gmx.de>

	* glib/gstrfuncs.c (g_strerror): Don't modify errno.  (#116617,
	Balazs Scheidler)
This commit is contained in:
Matthias Clasen 2004-02-26 23:43:45 +00:00 committed by Matthias Clasen
parent 960a9899a7
commit 78adb5c69a
7 changed files with 39 additions and 2 deletions

View File

@ -1,3 +1,8 @@
Fri Feb 27 00:46:29 2004 Matthias Clasen <maclas@gmx.de>
* glib/gstrfuncs.c (g_strerror): Don't modify errno. (#116617,
Balazs Scheidler)
2004-02-26 Sebastian Wilhelmi <seppi@seppi.de> 2004-02-26 Sebastian Wilhelmi <seppi@seppi.de>
* glib/gatomic.h: Fix the !G_THREADS_ENABLED case. * glib/gatomic.h: Fix the !G_THREADS_ENABLED case.

View File

@ -1,3 +1,8 @@
Fri Feb 27 00:46:29 2004 Matthias Clasen <maclas@gmx.de>
* glib/gstrfuncs.c (g_strerror): Don't modify errno. (#116617,
Balazs Scheidler)
2004-02-26 Sebastian Wilhelmi <seppi@seppi.de> 2004-02-26 Sebastian Wilhelmi <seppi@seppi.de>
* glib/gatomic.h: Fix the !G_THREADS_ENABLED case. * glib/gatomic.h: Fix the !G_THREADS_ENABLED case.

View File

@ -1,3 +1,8 @@
Fri Feb 27 00:46:29 2004 Matthias Clasen <maclas@gmx.de>
* glib/gstrfuncs.c (g_strerror): Don't modify errno. (#116617,
Balazs Scheidler)
2004-02-26 Sebastian Wilhelmi <seppi@seppi.de> 2004-02-26 Sebastian Wilhelmi <seppi@seppi.de>
* glib/gatomic.h: Fix the !G_THREADS_ENABLED case. * glib/gatomic.h: Fix the !G_THREADS_ENABLED case.

View File

@ -1,3 +1,8 @@
Fri Feb 27 00:46:29 2004 Matthias Clasen <maclas@gmx.de>
* glib/gstrfuncs.c (g_strerror): Don't modify errno. (#116617,
Balazs Scheidler)
2004-02-26 Sebastian Wilhelmi <seppi@seppi.de> 2004-02-26 Sebastian Wilhelmi <seppi@seppi.de>
* glib/gatomic.h: Fix the !G_THREADS_ENABLED case. * glib/gatomic.h: Fix the !G_THREADS_ENABLED case.

View File

@ -1,3 +1,8 @@
Fri Feb 27 00:46:29 2004 Matthias Clasen <maclas@gmx.de>
* glib/gstrfuncs.c (g_strerror): Don't modify errno. (#116617,
Balazs Scheidler)
2004-02-26 Sebastian Wilhelmi <seppi@seppi.de> 2004-02-26 Sebastian Wilhelmi <seppi@seppi.de>
* glib/gatomic.h: Fix the !G_THREADS_ENABLED case. * glib/gatomic.h: Fix the !G_THREADS_ENABLED case.

View File

@ -1,3 +1,8 @@
Fri Feb 27 00:46:29 2004 Matthias Clasen <maclas@gmx.de>
* glib/gstrfuncs.c (g_strerror): Don't modify errno. (#116617,
Balazs Scheidler)
2004-02-26 Sebastian Wilhelmi <seppi@seppi.de> 2004-02-26 Sebastian Wilhelmi <seppi@seppi.de>
* glib/gatomic.h: Fix the !G_THREADS_ENABLED case. * glib/gatomic.h: Fix the !G_THREADS_ENABLED case.

View File

@ -727,13 +727,17 @@ g_strerror (gint errnum)
{ {
static GStaticPrivate msg_private = G_STATIC_PRIVATE_INIT; static GStaticPrivate msg_private = G_STATIC_PRIVATE_INIT;
char *msg; char *msg;
int saved_errno = errno;
#ifdef HAVE_STRERROR #ifdef HAVE_STRERROR
const char *msg_locale; const char *msg_locale;
msg_locale = strerror (errnum); msg_locale = strerror (errnum);
if (g_get_charset (NULL)) if (g_get_charset (NULL))
{
errno = saved_errno;
return msg_locale; return msg_locale;
}
else else
{ {
gchar *msg_utf8 = g_locale_to_utf8 (msg_locale, -1, NULL, NULL, NULL); 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); GQuark msg_quark = g_quark_from_string (msg_utf8);
g_free (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 #elif NO_SYS_ERRLIST
@ -1179,6 +1185,7 @@ g_strerror (gint errnum)
_g_sprintf (msg, "unknown error (%d)", errnum); _g_sprintf (msg, "unknown error (%d)", errnum);
errno = saved_errno;
return msg; return msg;
} }