Print this page
Fix compile errors, code review feedback, and add basic libc test suite.
*** 112,123 ****
.messages = &lc_messages_posix,
.time = &lc_time_posix,
.runelocale = &_DefaultRuneLocale,
};
! locale_t __global_locale = &posix_locale;
/*
* Category names for getenv() Note that this was modified
* for Solaris. See <iso/locale_iso.h>.
*/
#define NUM_CATS 7
--- 112,129 ----
.messages = &lc_messages_posix,
.time = &lc_time_posix,
.runelocale = &_DefaultRuneLocale,
};
! 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,404 ****
if (catmask & ~(LC_ALL_MASK)) {
errno = EINVAL;
return (NULL);
}
! loc = duplocale(base != NULL ? base : __global_locale);
if (loc == NULL) {
return (NULL);
}
for (i = 0; i < LC_ALL; i++) {
--- 400,410 ----
if (catmask & ~(LC_ALL_MASK)) {
errno = EINVAL;
return (NULL);
}
! loc = duplocale(base != NULL ? base : ___global_locale);
if (loc == NULL) {
return (NULL);
}
for (i = 0; i < LC_ALL; i++) {
*** 416,426 ****
return (NULL);
}
__locdata_release(loc->locdata[i]);
loc->locdata[i] = ldata;
}
! 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];
--- 422,432 ----
return (NULL);
}
__locdata_release(loc->locdata[i]);
loc->locdata[i] = ldata;
}
! 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,442 ****
}
locale_t
uselocale(locale_t loc)
{
! locale_t lastloc = __global_locale;
locale_t *locptr;
locptr = tsdalloc(_T_SETLOCALE, sizeof (locale_t), freelocptr);
/* Should never occur */
if (locptr == NULL) {
--- 438,448 ----
}
locale_t
uselocale(locale_t loc)
{
! locale_t lastloc = ___global_locale;
locale_t *locptr;
locptr = tsdalloc(_T_SETLOCALE, sizeof (locale_t), freelocptr);
/* Should never occur */
if (locptr == NULL) {
*** 451,461 ****
if (loc != NULL) {
/*
* Set it to LC_GLOBAL_LOCAL to return to using
* the global locale (setlocale).
*/
! if (loc == __global_locale) {
*locptr = NULL;
} else {
/* No validation of the provided locale at present */
*locptr = loc;
}
--- 457,467 ----
if (loc != NULL) {
/*
* Set it to LC_GLOBAL_LOCAL to return to using
* the global locale (setlocale).
*/
! if (loc == ___global_locale) {
*locptr = NULL;
} else {
/* No validation of the provided locale at present */
*locptr = loc;
}