Print this page
Fix compile errors, code review feedback, and add basic libc test suite.

@@ -112,12 +112,18 @@
         .messages = &lc_messages_posix,
         .time = &lc_time_posix,
         .runelocale = &_DefaultRuneLocale,
 };
 
-locale_t __global_locale = &posix_locale;
+locale_t ___global_locale = &posix_locale;
 
+locale_t
+__global_locale(void)
+{
+        return (___global_locale);
+}
+
 /*
  * Category names for getenv()  Note that this was modified
  * for Solaris.  See <iso/locale_iso.h>.
  */
 #define NUM_CATS        7

@@ -394,11 +400,11 @@
 
         if (catmask & ~(LC_ALL_MASK)) {
                 errno = EINVAL;
                 return (NULL);
         }
-        loc = duplocale(base != NULL ? base : __global_locale);
+        loc = duplocale(base != NULL ? base : ___global_locale);
         if (loc == NULL) {
                 return (NULL);
         }
 
         for (i = 0; i < LC_ALL; i++) {

@@ -416,11 +422,11 @@
                         return (NULL);
                 }
                 __locdata_release(loc->locdata[i]);
                 loc->locdata[i] = ldata;
         }
-        if (base && base != __global_locale) {
+        if (base && base != ___global_locale) {
                 freelocale(base);
         }
         loc->collate = loc->locdata[LC_COLLATE]->l_data[0];
         loc->ctype = loc->locdata[LC_CTYPE]->l_data[0];
         loc->runelocale = loc->locdata[LC_CTYPE]->l_data[1];

@@ -432,11 +438,11 @@
 }
 
 locale_t
 uselocale(locale_t loc)
 {
-        locale_t lastloc = __global_locale;
+        locale_t lastloc = ___global_locale;
         locale_t *locptr;
 
         locptr = tsdalloc(_T_SETLOCALE, sizeof (locale_t), freelocptr);
         /* Should never occur */
         if (locptr == NULL) {

@@ -451,11 +457,11 @@
         if (loc != NULL) {
                 /*
                  * Set it to LC_GLOBAL_LOCAL to return to using
                  * the global locale (setlocale).
                  */
-                if (loc == __global_locale) {
+                if (loc == ___global_locale) {
                         *locptr = NULL;
                 } else {
                         /* No validation of the provided locale at present */
                         *locptr = loc;
                 }