summaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-07-28 19:40:54 +0000
committerUlrich Drepper <drepper@redhat.com>1999-07-28 19:40:54 +0000
commit0b5f32df49860c09cbd308a047e451df48ac26c3 (patch)
tree0a8738c4c23eebc36437c1d91ee9df84b8f19d08 /stdlib
parent087e27ff2210ea566a871efd7edbc0fdf7ab21ca (diff)
Reset state for s == NULL.
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/mbtowc.c8
-rw-r--r--stdlib/wctomb.c8
2 files changed, 12 insertions, 4 deletions
diff --git a/stdlib/mbtowc.c b/stdlib/mbtowc.c
index 938d54750c..aeac2ce0b8 100644
--- a/stdlib/mbtowc.c
+++ b/stdlib/mbtowc.c
@@ -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')
{
diff --git a/stdlib/wctomb.c b/stdlib/wctomb.c
index b7132e02c4..757e6adaad 100644
--- a/stdlib/wctomb.c
+++ b/stdlib/wctomb.c
@@ -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);