From 98e199aba033daa324ef324658914b05f71025bf Mon Sep 17 00:00:00 2001 From: Manuel Novoa III Date: Tue, 29 Oct 2002 18:59:19 +0000 Subject: Fix a couple of 'restrict' bugs in mbstowcs and wcstombs. --- libc/stdlib/stdlib.c | 13 ++++++++++--- 1 file 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 @@ -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 -- cgit v1.2.3