]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
(WITH_CUR_LOCALE): Define.
authorUlrich Drepper <drepper@redhat.com>
Tue, 5 Feb 2002 19:14:27 +0000 (19:14 +0000)
committerUlrich Drepper <drepper@redhat.com>
Tue, 5 Feb 2002 19:14:27 +0000 (19:14 +0000)
locale/programs/localedef.h

index dc631e96ac976830f4eeedb04978962699f9e419..ce58a21b6f7122331f363eeafea91d50f52d2923 100644 (file)
@@ -24,6 +24,7 @@
 /* Get the basic locale definitions.  */
 #include <locale.h>
 #include <stddef.h>
+#include <errno.h>
 
 #include "repertoire.h"
 
@@ -122,6 +123,19 @@ extern void *xrealloc (void *__p, size_t __n);
 extern char *xstrdup (const char *__str);
 
 
+/* Wrapper to switch LC_CTYPE back to the locale specified in the
+   environment for output.  */
+#define WITH_CUR_LOCALE(stmt)                                  \
+  do {                                                         \
+      int saved_errno = errno;                                 \
+      const char *cur_locale_ = setlocale (LC_CTYPE, NULL);    \
+      setlocale (LC_CTYPE, "");                                        \
+      errno = saved_errno;                                     \
+      stmt;                                                    \
+      setlocale (LC_CTYPE, cur_locale_);                       \
+  } while (0)
+
+
 /* Mark given locale as to be read.  */
 extern struct localedef_t *add_to_readlist (int locale, const char *name,
                                            const char *repertoire_name,