diff options
author | Andreas Schwab <schwab@redhat.com> | 2009-11-30 14:53:29 +0100 |
---|---|---|
committer | Andreas Schwab <schwab@redhat.com> | 2009-11-30 14:54:41 +0100 |
commit | 488fb43a499982e99915c78bb70f04357ac37463 (patch) | |
tree | e356d0f1d327ed3de4a9d5abec1edf346070aa32 /locale | |
parent | eab709096f23a4511adfc547450a83008eae5fb2 (diff) | |
parent | 20af204581e1ba42738c1bfb69cc2f5350f4ffa4 (diff) |
Merge branch 'release/2.11/master' into fedora/2.11/master
Diffstat (limited to 'locale')
-rw-r--r-- | locale/Makefile | 6 | ||||
-rw-r--r-- | locale/duplocale.c | 6 | ||||
-rw-r--r-- | locale/langinfo.h | 3 | ||||
-rw-r--r-- | locale/tst-duplocale.c | 14 | ||||
-rw-r--r-- | locale/tst-locname.c | 20 |
5 files changed, 44 insertions, 5 deletions
diff --git a/locale/Makefile b/locale/Makefile index d9ab1947e7..2dbd8dc6a5 100644 --- a/locale/Makefile +++ b/locale/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1991,1992,1995-2003,2005 Free Software Foundation, Inc. +# Copyright (C) 1991,1992,1995-2003,2005,2009 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -38,7 +38,7 @@ distribute = localeinfo.h categories.def iso-639.def iso-3166.def \ routines = setlocale findlocale loadlocale loadarchive \ localeconv nl_langinfo nl_langinfo_l mb_cur_max \ newlocale duplocale freelocale uselocale -tests = tst-C-locale +tests = tst-C-locale tst-locname tst-duplocale categories = ctype messages monetary numeric time paper name \ address telephone measurement identification collate aux = $(categories:%=lc-%) $(categories:%=C-%) SYS_libc C_name \ @@ -104,7 +104,7 @@ CFLAGS-charmap-dir.c = -Wno-write-strings # This makes sure -DNOT_IN_libc is passed for all these modules. cpp-srcs-left := $(addsuffix .c,$(localedef-modules) $(localedef-aux) \ - $(locale-modules) $(lib-modules)) + $(locale-modules) $(lib-modules)) lib := nonlib include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left)) diff --git a/locale/duplocale.c b/locale/duplocale.c index 61782590d7..63513c539c 100644 --- a/locale/duplocale.c +++ b/locale/duplocale.c @@ -1,5 +1,5 @@ /* Duplicate handle for selection of locales. - Copyright (C) 1997,2000,2001,2002,2005,2008 Free Software Foundation, Inc. + Copyright (C) 1997,2000-2002,2005,2008,2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -37,6 +37,10 @@ __duplocale (__locale_t dataset) if (dataset == _nl_C_locobj_ptr) return dataset; + /* Handle a special value. */ + if (dataset == LC_GLOBAL_LOCALE) + dataset = &_nl_global_locale; + __locale_t result; int cnt; size_t names_len = 0; diff --git a/locale/langinfo.h b/locale/langinfo.h index c940c743aa..0a53365071 100644 --- a/locale/langinfo.h +++ b/locale/langinfo.h @@ -568,7 +568,8 @@ enum /* This macro produces an item you can pass to `nl_langinfo' or `nl_langinfo_l' to get the name of the locale in use for CATEGORY. */ -#define _NL_LOCALE_NAME(category) _NL_ITEM ((category), -1) +#define _NL_LOCALE_NAME(category) _NL_ITEM ((category), \ + _NL_ITEM_INDEX (-1)) #ifdef __USE_GNU # define NL_LOCALE_NAME(category) _NL_LOCALE_NAME (category) #endif diff --git a/locale/tst-duplocale.c b/locale/tst-duplocale.c new file mode 100644 index 0000000000..53e5fbb8fe --- /dev/null +++ b/locale/tst-duplocale.c @@ -0,0 +1,14 @@ +#include <locale.h> +#include <stdio.h> + +static int +do_test (void) +{ + locale_t d = duplocale (LC_GLOBAL_LOCALE); + if (d != (locale_t) 0) + freelocale (d); + return 0; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/locale/tst-locname.c b/locale/tst-locname.c new file mode 100644 index 0000000000..7eb71adfd8 --- /dev/null +++ b/locale/tst-locname.c @@ -0,0 +1,20 @@ +#include <langinfo.h> +#include <locale.h> +#include <stdio.h> +#include <string.h> + +static int +do_test (void) +{ + const char *s = nl_langinfo (_NL_LOCALE_NAME (LC_CTYPE)); + if (s == NULL || strcmp (s, "C") != 0) + { + printf ("incorrect locale name returned: %s, expected \"C\"\n", s); + return 1; + } + + return 0; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" |