]> sourceware.org Git - glibc.git/commitdiff
Update.
authorUlrich Drepper <drepper@redhat.com>
Wed, 28 Jul 1999 19:37:40 +0000 (19:37 +0000)
committerUlrich Drepper <drepper@redhat.com>
Wed, 28 Jul 1999 19:37:40 +0000 (19:37 +0000)
1999-07-28  Ulrich Drepper  <drepper@cygnus.com>

* stdlib/mblen.c: Use static state.
Reported by Bruno Haible <haible@ilog.fr>.

* stdlib/mbtowc.c: Reset state for s == NULL.
* stdlib/wctomb.c: Likewise.
Reported by Bruno Haible <haible@ilog.fr>.

* stdlib/mbstowcs.c: Do not use global state.
Reported by Bruno Haible <haible@ilog.fr>.

ChangeLog
stdlib/mblen.c
stdlib/mbstowcs.c
stdlib/mbtowc.c
stdlib/wctomb.c

index c18c837a8162c420385eb2e3734c187feda44a64..5c6a58b60363a0a2e6376d63d6304e3da8d20911 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+1999-07-28  Ulrich Drepper  <drepper@cygnus.com>
+
+       * stdlib/mblen.c: Use static state.
+       Reported by Bruno Haible <haible@ilog.fr>.
+
+       * stdlib/mbtowc.c: Reset state for s == NULL.
+       * stdlib/wctomb.c: Likewise.
+       Reported by Bruno Haible <haible@ilog.fr>.
+
+       * stdlib/mbstowcs.c: Do not use global state.
+       Reported by Bruno Haible <haible@ilog.fr>.
+
 1999-07-28  Andeas Schwab  <schwab@suse.de>
 
        * iconvdata/Makefile: Don't try to run iconv tests when cross
index 3a9755bcea292d60506c227e31903772b99e7a3d..760da60d738fdf9f783ea76d0554257cc4219888 100644 (file)
    Boston, MA 02111-1307, USA.  */
 
 #include <stdlib.h>
+#include <string.h>
 #include <wchar.h>
 #include <gconv.h>
 #include <wcsmbs/wcsmbsload.h>
 
 
+/* Internal state.  */
+static mbstate_t state;
+
 /* Return the length of the multibyte character (if there is one)
    at S which is no longer than N characters.
    The ISO C standard says that the `mblen' function must not change
-   the global state.  */
+   the state of the `mbtowc' function.  */
 int
 mblen (const char *s, size_t n)
 {
-  mbstate_t state;
   int result;
 
   /* If S is NULL the function has to return null or not null
@@ -40,11 +43,13 @@ mblen (const char *s, size_t n)
       /* Make sure we use the correct value.  */
       update_conversion_ptrs ();
 
+      /* Reset the state.  */
+      memset (&state, '\0', sizeof state);
+
       result = __wcsmbs_gconv_fcts.towc->__stateful;
     }
   else if (*s == '\0')
-    /* According to the ISO C 89 standard this is the expected behaviour.
-       Idiotic, but true.  */
+    /* According to the ISO C 89 standard this is the expected behaviour.  */
     result = 0;
   else
     {
index 7b9d84c259ea47a2b1194e806669d449d5268953..b7e61235177f292352fc8779d7dfaf8fb818d2b7 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1996, 1997, 1999 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
    Boston, MA 02111-1307, USA.  */
 
 #include <stdlib.h>
+#include <string.h>
 #include <wchar.h>
 
 
-extern mbstate_t __no_r_state; /* Defined in mbtowc.c.  */
-
 /* Convert the string of multibyte characters in S to `wchar_t's in
    PWCS, writing no more than N.  Return the number written,
    or (size_t) -1 if an invalid multibyte character is encountered.
@@ -33,14 +32,9 @@ extern mbstate_t __no_r_state;       /* Defined in mbtowc.c.  */
 size_t
 mbstowcs (wchar_t *pwcs, const char *s, size_t n)
 {
-  mbstate_t save_shift = __no_r_state;
-  size_t written;
-
-  written = __mbsrtowcs (pwcs, &s, n, &__no_r_state);
-
-  /* Restore the old shift state.  */
-  __no_r_state = save_shift;
+  mbstate_t state;
 
+  memset (&state, '\0', sizeof state);
   /* Return how many we wrote (or maybe an error).  */
-  return written;
+  return __mbsrtowcs (pwcs, &s, n, &state);
 }
index a8df154b75a13991882e1328180df47e61659537..aeac2ce0b83f34fc23297a342d624a5bdcc6bcd0 100644 (file)
@@ -46,6 +46,10 @@ mbtowc (wchar_t *pwc, const char *s, size_t n)
       /* Make sure we use the correct value.  */
       update_conversion_ptrs ();
 
+      /* This is an extension in the Unix standard which does not directly
+        violate ISO C.  */
+      memset (&__no_r_state, '\0', siyeof __no_r_state);
+
       result = __wcsmbs_gconv_fcts.towc->__stateful;
     }
   else if (*s == '\0')
index 2df8b998d562e93756eec709c40bbe68dbbbbe3c..757e6adaad11531548181a7184dc17cc055b7f24 100644 (file)
@@ -42,6 +42,10 @@ wctomb (char *s, wchar_t wchar)
       /* Make sure we use the correct value.  */
       update_conversion_ptrs ();
 
+      /* This is an extension in the Unix standard which does not directly
+        violate ISO C.  */
+      memset (&__no_r_state, '\0', siyeof __no_r_state);
+
       return __wcsmbs_gconv_fcts.tomb->__stateful;
     }
 
This page took 0.048735 seconds and 5 git commands to generate.