about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-12-01 00:43:32 +0000
committerUlrich Drepper <drepper@redhat.com>2000-12-01 00:43:32 +0000
commit411adb106872a8c52e26ca5f7049d5ec0a4a99dd (patch)
tree0b4e68c6bb175004f36e80049cdd14e9680d8cf5
parent9a0fe6a8124692b9b09489f64717af94d1ffac13 (diff)
downloadglibc-411adb106872a8c52e26ca5f7049d5ec0a4a99dd.tar.gz
glibc-411adb106872a8c52e26ca5f7049d5ec0a4a99dd.tar.xz
glibc-411adb106872a8c52e26ca5f7049d5ec0a4a99dd.zip
Update.
2000-11-29  H.J. Lu  <hjl@gnu.org>

	* stdio-common/vfscanf.c (ORIENT): Swap the COMPILE_WSCANF case.

2000-11-30  Jakub Jelinek  <jakub@redhat.com>

	* locale/setlocale.c (setname): Free for all categories, not just
	LC_ALL.
	(setlocale): Store a copy of string passed by user, not the string
	itself.

	* sysdeps/unix/sysv/linux/hppa/brk.c (__brk): Remove unused variable.
-rw-r--r--ChangeLog14
-rw-r--r--locale/setlocale.c25
-rw-r--r--localedata/ChangeLog6
-rw-r--r--localedata/Makefile4
-rw-r--r--stdio-common/vfscanf.c6
5 files changed, 48 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index c87dc67eb9..aefe8bcbf2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2000-11-29  H.J. Lu  <hjl@gnu.org>
+
+	* stdio-common/vfscanf.c (ORIENT): Swap the COMPILE_WSCANF case.
+
+2000-11-30  Jakub Jelinek  <jakub@redhat.com>
+
+	* locale/setlocale.c (setname): Free for all categories, not just
+	LC_ALL.
+	(setlocale): Store a copy of string passed by user, not the string
+	itself.
+
 2000-11-30  Roland McGrath  <roland@frob.com>
 
 	* sysdeps/mach/hurd/defs.c (init_stdio): Put this on __libc_subinit
@@ -16,8 +27,7 @@
 
 2000-11-29  Andreas Jaeger  <aj@suse.de>
 
-	* sysdeps/unix/sysv/linux/hppa/brk.c (__brk): Remove unused
-	variable.
+	* sysdeps/unix/sysv/linux/hppa/brk.c (__brk): Remove unused variable.
 
 2000-11-28  Ulrich Drepper  <drepper@redhat.com>
 
diff --git a/locale/setlocale.c b/locale/setlocale.c
index 3598eceac4..c7848b9a5c 100644
--- a/locale/setlocale.c
+++ b/locale/setlocale.c
@@ -194,7 +194,7 @@ setname (int category, const char *name)
   if (_nl_current_names[category] == name)
     return;
 
-  if (category == LC_ALL && _nl_current_names[category] != _nl_C_name)
+  if (_nl_current_names[category] != _nl_C_name)
     free ((char *) _nl_current_names[category]);
 
   _nl_current_names[category] = name;
@@ -322,6 +322,14 @@ setlocale (int category, const char *locale)
 	       control over the usage.  So we mark it as un-deletable.  */
 	    if (newdata[category]->usage_count != UNDELETABLE)
 	      newdata[category]->usage_count = UNDELETABLE;
+
+	    /* Make a copy of locale name.  */
+	    if (newnames[category] != _nl_C_name)
+	      {
+		newnames[category] = strdup (newnames[category]);
+		if (newnames[category] == NULL)
+		  break;
+	      }
 	  }
 
       /* Create new composite name.  */
@@ -342,6 +350,10 @@ setlocale (int category, const char *locale)
 	     functions know about this.  */
 	  ++_nl_msg_cat_cntr;
 	}
+      else
+	for (++category; category < __LC_LAST; ++category)
+	  if (category != LC_ALL && newnames[category] != _nl_C_name)
+	    free ((char *) newnames[category]);
 
       /* Critical section left.  */
       __libc_lock_unlock (__libc_setlocale_lock);
@@ -376,10 +388,21 @@ setlocale (int category, const char *locale)
 	    newdata->usage_count = UNDELETABLE;
 	}
 
+      /* Make a copy of locale name.  */
+      if (newname[0] != _nl_C_name)
+	{
+	  newname[0] = strdup (newname[0]);
+	  if (newname[0] == NULL)
+	    goto abort_single;
+	}
+
       /* Create new composite name.  */
       composite = new_composite_name (category, newname);
       if (composite == NULL)
 	{
+	  if (newname[0] != _nl_C_name)
+	    free ((char *) newname[0]);
+
 	  /* Say that we don't have any data loaded.  */
 	abort_single:
 	  newname[0] = NULL;
diff --git a/localedata/ChangeLog b/localedata/ChangeLog
index a745e3224c..238facdb2f 100644
--- a/localedata/ChangeLog
+++ b/localedata/ChangeLog
@@ -1,3 +1,9 @@
+2000-11-30  Ulrich Drepper  <drepper@redhat.com>
+
+	* Makefile (tests): Add tst-setlocale.
+	(tst-setlocale-ENV): Define.
+	* tst-setlocale.c: New file.
+
 2000-11-28  Ulrich Drepper  <drepper@redhat.com>
 
 	* Makefile (LOCALES): Add ja_JP.SJIS.
diff --git a/localedata/Makefile b/localedata/Makefile
index 88b369834d..dc8b323b8a 100644
--- a/localedata/Makefile
+++ b/localedata/Makefile
@@ -90,7 +90,7 @@ locale_test_suite := tst_iswalnum tst_iswalpha tst_iswcntrl            \
 		     tst_wcsxfrm tst_wctob tst_wctomb tst_wctrans      \
 		     tst_wctype tst_wcwidth
 
-tests = $(locale_test_suite) tst-digits
+tests = $(locale_test_suite) tst-digits tst-setlocale
 endif
 
 # Files to install.
@@ -254,3 +254,5 @@ tst_wctrans-ENV = $(TEST_MBWC_ENV)
 tst_wctype-ENV = $(TEST_MBWC_ENV)
 tst_wcwidth-ENV = $(TEST_MBWC_ENV)
 tst-digits-ENV = $(TEST_MBWC_ENV)
+
+tst-setlocale-ENV = LOCPATH=$(common-objpfx)localedata LC_ALL=ja_JP.EUC-JP
diff --git a/stdio-common/vfscanf.c b/stdio-common/vfscanf.c
index cf3befd399..2326801580 100644
--- a/stdio-common/vfscanf.c
+++ b/stdio-common/vfscanf.c
@@ -87,8 +87,7 @@
 #  define ISDIGIT(Ch)	  iswdigit (Ch)
 #  define ISXDIGIT(Ch)	  iswxdigit (Ch)
 #  define TOLOWER(Ch)	  towlower (Ch)
-#  define ORIENT	  if (s->_vtable_offset == 0 && _IO_fwide (s, 1) != 1)\
-			    return WEOF
+#  define ORIENT	  if (_IO_fwide (s, -1) != -1) return WEOF
 #  define __strtoll_internal	__wcstoll_internal
 #  define __strtoull_internal	__wcstoull_internal
 #  define __strtol_internal	__wcstol_internal
@@ -117,7 +116,8 @@
 #  define ISDIGIT(Ch)	  isdigit (Ch)
 #  define ISXDIGIT(Ch)	  isxdigit (Ch)
 #  define TOLOWER(Ch)	  tolower (Ch)
-#  define ORIENT	  if (_IO_fwide (s, -1) != -1) return EOF
+#  define ORIENT	  if (s->_vtable_offset == 0 && _IO_fwide (s, 1) != 1)\
+			    return EOF
 
 #  define L_(Str)	  Str
 #  define CHAR_T	  char