summaryrefslogtreecommitdiff
path: root/libc/stdlib
diff options
context:
space:
mode:
authorManuel Novoa III <mjn3@codepoet.org>2002-10-29 18:59:19 +0000
committerManuel Novoa III <mjn3@codepoet.org>2002-10-29 18:59:19 +0000
commit98e199aba033daa324ef324658914b05f71025bf (patch)
tree8586d4d2d3df0358737cf83dc71ffe10ecf59e2a /libc/stdlib
parent7ce8fe43bd3e12103cc399165632e0bfbeb1f99e (diff)
Fix a couple of 'restrict' bugs in mbstowcs and wcstombs.
Diffstat (limited to 'libc/stdlib')
-rw-r--r--libc/stdlib/stdlib.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/libc/stdlib/stdlib.c b/libc/stdlib/stdlib.c
index cc465e7a9..e9e6e1c32 100644
--- a/libc/stdlib/stdlib.c
+++ b/libc/stdlib/stdlib.c
@@ -25,6 +25,11 @@
*
* ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION! */
+/* Oct 29, 2002
+ *
+ * Fix a couple of 'restrict' bugs in mbstowcs and wcstombs.
+ */
+
#define _ISOC99_SOURCE /* for ULLONG primarily... */
#define _GNU_SOURCE
#include <limits.h>
@@ -748,10 +753,10 @@ int wctomb(register char *__restrict s, wchar_t swc)
size_t mbstowcs(wchar_t * __restrict pwcs, const char * __restrict s, size_t n)
{
mbstate_t state;
+ const char *e = s; /* Needed because of restrict. */
state.mask = 0; /* Always start in initial shift state. */
-
- return mbsrtowcs(pwcs, &s, n, &state);
+ return mbsrtowcs(pwcs, &e, n, &state);
}
#endif
@@ -762,7 +767,9 @@ size_t mbstowcs(wchar_t * __restrict pwcs, const char * __restrict s, size_t n)
size_t wcstombs(char * __restrict s, const wchar_t * __restrict pwcs, size_t n)
{
- return wcsrtombs(s, &pwcs, n, NULL);
+ const wchar_t *e = pwcs; /* Needed because of restrict. */
+
+ return wcsrtombs(s, &e, n, NULL);
}
#endif