about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--ctype/Versions3
-rw-r--r--ctype/ctype-info.c15
-rw-r--r--include/ctype.h20
-rw-r--r--localedata/ChangeLog7
-rw-r--r--localedata/Makefile5
-rw-r--r--localedata/tst-setlocale2.c76
-rw-r--r--nptl/ChangeLog4
-rw-r--r--nptl/pthread_create.c6
-rw-r--r--sysdeps/unix/sysv/linux/init-first.c7
10 files changed, 135 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index 414611a93c..a708003301 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2011-10-15  Ulrich Drepper  <drepper@gmail.com>
+
+	* ctype/ctype-info.c (__ctype_init): Define.
+	* include/ctype.h (__ctype_init): Declare.
+	(__ctype_b_loc): The variable is always initialized.
+	(__ctype_toupper_loc): Likewise.
+	(__ctype_tolower_loc): Likewise.
+	* ctype/Versions: Export __ctype_init for GLIBC_PRIVATE.
+	* sysdeps/unix/sysv/linux/init-first.c (_init): Call __ctype_init.
+
 2011-09-27  Liubov Dmitrieva  <liubov.dmitrieva@gmail.com>
 
 	* sysdeps/x86_64/multiarch/Makefile: (sysdep_routines): Add
diff --git a/ctype/Versions b/ctype/Versions
index 8cf0338b39..84f1e2c7cb 100644
--- a/ctype/Versions
+++ b/ctype/Versions
@@ -21,4 +21,7 @@ libc {
     # functions used by optimized macros in ctype.h
     __ctype_b_loc; __ctype_tolower_loc; __ctype_toupper_loc;
   }
+  GLIBC_PRIVATE {
+    __ctype_init;
+  }
 }
diff --git a/ctype/ctype-info.c b/ctype/ctype-info.c
index 03b67d179f..b64e7439a8 100644
--- a/ctype/ctype-info.c
+++ b/ctype/ctype-info.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,92,95,96,97,99,2000, 2002, 2008
+/* Copyright (C) 1991,92,95,96,97,99,2000, 2002, 2008, 2011
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -26,6 +26,19 @@ __libc_tsd_define (, const int32_t *, CTYPE_TOLOWER)
 __libc_tsd_define (, const int32_t *, CTYPE_TOUPPER)
 
 
+void
+__ctype_init (void)
+{
+  const uint16_t **bp = __libc_tsd_address (const uint16_t *, CTYPE_B);
+  *bp = (const uint16_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_CLASS) + 128;
+  const int32_t **up = __libc_tsd_address (const int32_t *, CTYPE_TOUPPER);
+  *up = ((int32_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TOUPPER) + 128);
+  const int32_t **lp = __libc_tsd_address (const int32_t *, CTYPE_TOLOWER);
+  *lp = ((int32_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TOLOWER) + 128);
+}
+libc_hidden_def (__ctype_init)
+
+
 #include <shlib-compat.h>
 #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3)
 
diff --git a/include/ctype.h b/include/ctype.h
index f4b782e136..4b5abda375 100644
--- a/include/ctype.h
+++ b/include/ctype.h
@@ -1,5 +1,9 @@
 #ifndef _CTYPE_H
 
+/* Initialize ctype locale data.  */
+extern void __ctype_init (void);
+libc_hidden_proto (__ctype_init)
+
 extern int __isctype (int __c, int __mask);
 
 # ifndef NOT_IN_libc
@@ -22,31 +26,23 @@ __libc_tsd_define (extern, const uint16_t *, CTYPE_B)
 __libc_tsd_define (extern, const int32_t *, CTYPE_TOUPPER)
 __libc_tsd_define (extern, const int32_t *, CTYPE_TOLOWER)
 
+
 CTYPE_EXTERN_INLINE const uint16_t ** __attribute__ ((const))
 __ctype_b_loc (void)
 {
-  const uint16_t **tablep = __libc_tsd_address (const uint16_t *, CTYPE_B);
-  if (__builtin_expect (*tablep == NULL, 0))
-    *tablep = (const uint16_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_CLASS) + 128;
-  return tablep;
+  return __libc_tsd_address (const uint16_t *, CTYPE_B);
 }
 
 CTYPE_EXTERN_INLINE const int32_t ** __attribute__ ((const))
 __ctype_toupper_loc (void)
 {
-  const int32_t **tablep = __libc_tsd_address (const int32_t *, CTYPE_TOUPPER);
-  if (__builtin_expect (*tablep == NULL, 0))
-    *tablep = ((int32_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TOUPPER) + 128);
-  return tablep;
+  return __libc_tsd_address (const int32_t *, CTYPE_TOUPPER);
 }
 
 CTYPE_EXTERN_INLINE const int32_t ** __attribute__ ((const))
 __ctype_tolower_loc (void)
 {
-  const int32_t **tablep = __libc_tsd_address (const int32_t *, CTYPE_TOLOWER);
-  if (__builtin_expect (*tablep == NULL, 0))
-    *tablep = ((int32_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TOLOWER) + 128);
-  return tablep;
+  return __libc_tsd_address (const int32_t *, CTYPE_TOLOWER);
 }
 
 # endif	/* Not NOT_IN_libc.  */
diff --git a/localedata/ChangeLog b/localedata/ChangeLog
index e0e22070fd..dc2b8a04bb 100644
--- a/localedata/ChangeLog
+++ b/localedata/ChangeLog
@@ -1,3 +1,10 @@
+2011-10-15  Ulrich Drepper  <drepper@gmail.com>
+
+	* Makefile (tests): Add tst-setlocale2:
+	(LOCALES): Add tr_TR.ISO-8859-9;
+	(tst-setlocale2-ENV): Define.
+	* tst-setlocale2.c: New file.
+
 2011-07-02  Roland McGrath  <roland@hack.frob.com>
 
 	* tests-mbwc/tst_funcs.h (TST_DECL_VARS, TST_HEAD_LOCALE):
diff --git a/localedata/Makefile b/localedata/Makefile
index 81c1377420..51c61a7700 100644
--- a/localedata/Makefile
+++ b/localedata/Makefile
@@ -94,7 +94,7 @@ locale_test_suite := tst_iswalnum tst_iswalpha tst_iswcntrl            \
 
 tests = $(locale_test_suite) tst-digits tst-setlocale bug-iconv-trans \
 	tst-leaks tst-mbswcs6 tst-xlocale1 tst-xlocale2 bug-usesetlocale \
-	tst-strfmon1 tst-sscanf tst-strptime bug-setlocale1
+	tst-strfmon1 tst-sscanf tst-strptime bug-setlocale1 tst-setlocale2
 ifeq (yes,$(build-shared))
 ifneq (no,$(PERL))
 tests: $(objpfx)mtrace-tst-leaks
@@ -137,7 +137,7 @@ LOCALES := de_DE.ISO-8859-1 de_DE.UTF-8 en_US.ANSI_X3.4-1968 \
 	   hr_HR.ISO-8859-2 sv_SE.ISO-8859-1 ja_JP.SJIS fr_FR.ISO-8859-1 \
 	   vi_VN.TCVN5712-1 nb_NO.ISO-8859-1 nn_NO.ISO-8859-1 \
 	   tr_TR.UTF-8 cs_CZ.UTF-8 zh_TW.EUC-TW fa_IR.UTF-8 fr_FR.UTF-8 \
-	   ja_JP.UTF-8 si_LK.UTF-8
+	   ja_JP.UTF-8 si_LK.UTF-8 tr_TR.ISO-8859-9
 LOCALE_SRCS := $(shell echo "$(LOCALES)"|sed 's/\([^ .]*\)[^ ]*/\1/g')
 CHARMAPS := $(shell echo "$(LOCALES)" | \
 		    sed -e 's/[^ .]*[.]\([^ ]*\)/\1/g' -e s/SJIS/SHIFT_JIS/g)
@@ -303,6 +303,7 @@ $(objpfx)mtrace-tst-leaks: $(objpfx)tst-leaks.out
 
 bug-setlocale1-ENV = LOCPATH=$(common-objpfx)localedata
 bug-setlocale1-ARGS = $(common-objpfx)
+tst-setlocale2-ENV = LOCPATH=$(common-objpfx)localedata
 
 $(objdir)/iconvdata/gconv-modules:
 	$(MAKE) -C ../iconvdata subdir=iconvdata $@
diff --git a/localedata/tst-setlocale2.c b/localedata/tst-setlocale2.c
new file mode 100644
index 0000000000..a4eb11fb37
--- /dev/null
+++ b/localedata/tst-setlocale2.c
@@ -0,0 +1,76 @@
+#include <ctype.h>
+#include <locale.h>
+#include <stdio.h>
+#include <wctype.h>
+
+
+static int
+do_test (void)
+{
+  const char *loc = "de_DE.ISO-8859-1";
+  if (setlocale (LC_ALL, loc) == NULL)
+    {
+      printf ("cannot set %s locale\n", loc);
+      return 1;
+    }
+  printf ("selected locale %s\n", loc);
+
+  wint_t win = 0xe4;
+  wint_t wex = 0xc4;
+  wint_t wch = towupper (win);
+  if (wch != wex)
+    {
+      printf ("towupper(%x) = %x, expected %x\n", win, wch, wex);
+      return 1;
+    }
+  wch = toupper (win);
+  if (wch != wex)
+    {
+      printf ("toupper(%x) = %x, expected %x\n", win, wch, wex);
+      return 1;
+    }
+
+  win = 0x69;
+  wex = 0x49;
+  wch = towupper (win);
+  if (wch != wex)
+    {
+      printf ("towupper(%x) = %x, expected %x\n", win, wch, wex);
+      return 1;
+    }
+  wch = toupper (win);
+  if (wch != wex)
+    {
+      printf ("toupper(%x) = %x, expected %x\n", win, wch, wex);
+      return 1;
+    }
+
+  loc = "tr_TR.ISO-8859-9";
+  if (setlocale (LC_ALL, loc) == NULL)
+    {
+      printf ("cannot set %s locale\n", loc);
+      return 1;
+    }
+  printf ("selected locale %s\n", loc);
+
+  win = 0x69;
+  wex = 0x130;
+  wch = towupper (win);
+  if (wch != wex)
+    {
+      printf ("towupper(%x) = %x, expected %x\n", win, wch, wex);
+      return 1;
+    }
+  wch = toupper (win);
+  wex = 0xdd;
+  if (wch != wex)
+    {
+      printf ("toupper(%x) = %x, expected %x\n", win, wch, wex);
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index ae48299a41..7ff251686c 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,3 +1,7 @@
+2011-10-15  Ulrich Drepper  <drepper@gmail.com>
+
+	* pthread_create.c (start_thread): Ca;; __ctype_init.
+
 2011-09-15  Andreas Schwab  <schwab@redhat.com>
 
 	* sysdeps/pthread/list.h: Define only list_t if __need_list_t is
diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
index 34d83f94ad..f1113fb9b4 100644
--- a/nptl/pthread_create.c
+++ b/nptl/pthread_create.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002-2007,2008,2009,2010 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2007,2008,2009,2010,2011 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
 
@@ -17,6 +17,7 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
+#include <ctype.h>
 #include <errno.h>
 #include <stdbool.h>
 #include <stdlib.h>
@@ -239,6 +240,9 @@ start_thread (void *arg)
   /* Initialize resolver state pointer.  */
   __resp = &pd->res;
 
+  /* Initialize pointers to locale data.  */
+  __ctype_init ();
+
   /* Allow setxid from now onwards.  */
   if (__builtin_expect (atomic_exchange_acq (&pd->setxid_futex, 0) == -2, 0))
     lll_futex_wake (&pd->setxid_futex, 1, LLL_PRIVATE);
diff --git a/sysdeps/unix/sysv/linux/init-first.c b/sysdeps/unix/sysv/linux/init-first.c
index a60212f4ed..63cf1ed33a 100644
--- a/sysdeps/unix/sysv/linux/init-first.c
+++ b/sysdeps/unix/sysv/linux/init-first.c
@@ -1,5 +1,5 @@
 /* Initialization code run first thing by the ELF startup code.  Linux version.
-   Copyright (C) 1995-2004, 2005, 2007 Free Software Foundation, Inc.
+   Copyright (C) 1995-2004, 2005, 2007, 2011 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
@@ -17,6 +17,7 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
+#include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <fcntl.h>
@@ -93,12 +94,14 @@ _init (int argc, char **argv, char **envp)
   __getopt_clean_environment (envp);
 #endif
 
+  /* Initialize ctype data.  */
+  __ctype_init ();
+
 #if defined SHARED && !defined NO_CTORS_DTORS_SECTIONS
   __libc_global_ctors ();
 #endif
 }
 
-
 /* This function is defined here so that if this file ever gets into
    ld.so we will get a link error.  Having this file silently included
    in ld.so causes disaster, because the _init definition above will