From 679e4c434f755644cc2093c9940ac58d0c2b51cf Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 11 Oct 2002 07:22:18 +0000 Subject: * locale/newlocale.c (__newlocale): If setting all categories to "C", just return &_nl_C_locobj instead of copying it. * locale/freelocale.c (__freelocale): Check for &_nl_C_locobj. * locale/duplocale.c (__duplocale): Likewise. 2002-10-07 Roland McGrath * config.h.in (HAVE_I386_SET_GDT): New #undef. * sysdeps/mach/configure.in: Define it with new check for i386_set_gdt. * sysdeps/mach/configure: Regenerated. 2002-10-06 Franz Sirl * sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h (INLINE_SYSCALL): Add all necessary register outputs for syscall-clobbered registers. 2002-10-02 David Mosberger * sysdeps/ia64/bzero.S: Rewritten by Sverre Jarp to tune for Itanium 2 (and Itanium). Fix unwind directives and make it fit in 80 columns. * sysdeps/ia64/memset.S: Ditto. * sysdeps/ia64/memcpy.S: Ditto. Move jump table to .rodata section. 2002-10-03 Roland McGrath * sysdeps/mach/hurd/i386/init-first.c (_hurd_stack_setup): Add clobbers to asm. --- locale/duplocale.c | 4 ++++ locale/freelocale.c | 4 ++++ locale/newlocale.c | 11 +++++++++++ 3 files changed, 19 insertions(+) (limited to 'locale') diff --git a/locale/duplocale.c b/locale/duplocale.c index 2fa29d14d6..77dfc01046 100644 --- a/locale/duplocale.c +++ b/locale/duplocale.c @@ -33,6 +33,10 @@ __libc_lock_define (extern , __libc_setlocale_lock attribute_hidden) __locale_t __duplocale (__locale_t dataset) { + /* This static object is returned for newlocale (LC_ALL_MASK, "C"). */ + if (dataset == &_nl_C_locobj) + return dataset; + __locale_t result; int cnt; size_t names_len = 0; diff --git a/locale/freelocale.c b/locale/freelocale.c index ba0ae85d84..ec169bcb66 100644 --- a/locale/freelocale.c +++ b/locale/freelocale.c @@ -34,6 +34,10 @@ __freelocale (__locale_t dataset) { int cnt; + /* This static object is returned for newlocale (LC_ALL_MASK, "C"). */ + if (dataset == &_nl_C_locobj) + return; + /* We modify global data (the usage counts). */ __libc_lock_lock (__libc_setlocale_lock); diff --git a/locale/newlocale.c b/locale/newlocale.c index 3b8676ceeb..1131f62c0b 100644 --- a/locale/newlocale.c +++ b/locale/newlocale.c @@ -60,6 +60,17 @@ __newlocale (int category_mask, const char *locale, __locale_t base) if (locale == NULL) ERROR_RETURN; + if (base == &_nl_C_locobj) + /* We're to modify BASE, returned for a previous call with "C". + We can't really modify the read-only structure, so instead + start over by copying it. */ + base = NULL; + + if ((base == NULL || category_mask == (1 << __LC_LAST) - 1 - (1 << LC_ALL)) + && (category_mask == 0 || !strcmp (locale, "C"))) + /* Asking for the "C" locale needn't allocate a new object. */ + return &_nl_C_locobj; + /* Allocate memory for the result. */ if (base != NULL) result = *base; -- cgit 1.4.1