]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Reset state for s == NULL.
authorUlrich Drepper <drepper@redhat.com>
Wed, 28 Jul 1999 19:40:54 +0000 (19:40 +0000)
committerUlrich Drepper <drepper@redhat.com>
Wed, 28 Jul 1999 19:40:54 +0000 (19:40 +0000)
stdlib/mbtowc.c
stdlib/wctomb.c

index 938d54750c206c4275292c5f217af4aaffd81544..aeac2ce0b83f34fc23297a342d624a5bdcc6bcd0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 92, 95, 96, 97, 98 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 92, 95, 96, 97, 98, 99 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
@@ -46,7 +46,11 @@ mbtowc (wchar_t *pwc, const char *s, size_t n)
       /* Make sure we use the correct value.  */
       update_conversion_ptrs ();
 
-      result = __wcsmbs_gconv_fcts.towc->stateful;
+      /* 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 b7132e02c43847028cff10d36fc59b3ba8a00e0b..757e6adaad11531548181a7184dc17cc055b7f24 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 92, 95, 96, 97, 98 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 92, 95, 96, 97, 98, 99 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
@@ -42,7 +42,11 @@ wctomb (char *s, wchar_t wchar)
       /* Make sure we use the correct value.  */
       update_conversion_ptrs ();
 
-      return __wcsmbs_gconv_fcts.tomb->stateful;
+      /* 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;
     }
 
   return __wcrtomb (s, wchar, &__no_r_state);