summaryrefslogtreecommitdiffstats
path: root/newlib/libc
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc')
-rw-r--r--newlib/libc/locale/duplocale.c3
-rw-r--r--newlib/libc/locale/locale.c6
2 files changed, 7 insertions, 2 deletions
diff --git a/newlib/libc/locale/duplocale.c b/newlib/libc/locale/duplocale.c
index 06ebfcd6e..9f6156cb4 100644
--- a/newlib/libc/locale/duplocale.c
+++ b/newlib/libc/locale/duplocale.c
@@ -64,7 +64,8 @@ _duplocale_r (struct _reent *p, struct __locale_t *locobj)
__loadlocale. It knows what to do to replicate the category. */
tmp_locale.lc_cat[i].ptr = NULL;
tmp_locale.lc_cat[i].buf = NULL;
- if (!__loadlocale (&tmp_locale, i, tmp_locale.categories[i]))
+ tmp_locale.categories[i][0] = '\0'; /* __loadlocale tests this! */
+ if (!__loadlocale (&tmp_locale, i, locobj->categories[i]))
goto error;
}
#endif /* __HAVE_LOCALE_INFO__ */
diff --git a/newlib/libc/locale/locale.c b/newlib/libc/locale/locale.c
index 857282105..b5402372c 100644
--- a/newlib/libc/locale/locale.c
+++ b/newlib/libc/locale/locale.c
@@ -498,7 +498,11 @@ __loadlocale (struct __locale_t *loc, int category, const char *new_locale)
mbtowc_p l_mbtowc;
int cjknarrow = 0;
- /* Avoid doing everything twice if nothing has changed. */
+ /* Avoid doing everything twice if nothing has changed.
+
+ duplocale relies on this test to go wrong so the locale is actually
+ duplicated when required. Any change here has to be synced with a
+ matching change in duplocale. */
if (!strcmp (new_locale, loc->categories[category]))
return loc->categories[category];