diff options
author | tjr <tjr@FreeBSD.org> | 2004-04-07 09:47:56 +0000 |
---|---|---|
committer | tjr <tjr@FreeBSD.org> | 2004-04-07 09:47:56 +0000 |
commit | 47b6d3f343e62032508f100d95214514de623db3 (patch) | |
tree | 11fa0f1538982249c0bab94e73e6639ddeab7213 /lib/libc/locale/wcstof.c | |
parent | c3bbcd6ef65ea72fcde434bb55ca4a100f825f7c (diff) | |
download | FreeBSD-src-47b6d3f343e62032508f100d95214514de623db3.zip FreeBSD-src-47b6d3f343e62032508f100d95214514de623db3.tar.gz |
Prepare to handle state-dependent encodings. This mainly involves not
taking shortcuts when it comes to storing and passing around conversion
states.
Diffstat (limited to 'lib/libc/locale/wcstof.c')
-rw-r--r-- | lib/libc/locale/wcstof.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/libc/locale/wcstof.c b/lib/libc/locale/wcstof.c index 909db0b..ba238d4 100644 --- a/lib/libc/locale/wcstof.c +++ b/lib/libc/locale/wcstof.c @@ -37,6 +37,8 @@ __FBSDID("$FreeBSD$"); float wcstof(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr) { + static const mbstate_t initial; + mbstate_t mbs; float val; char *buf, *end; const wchar_t *wcp; @@ -46,14 +48,16 @@ wcstof(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr) nptr++; wcp = nptr; - if ((len = wcsrtombs(NULL, &wcp, 0, NULL)) == (size_t)-1) { + mbs = initial; + if ((len = wcsrtombs(NULL, &wcp, 0, &mbs)) == (size_t)-1) { if (endptr != NULL) *endptr = (wchar_t *)nptr; return (0.0); } if ((buf = malloc(len + 1)) == NULL) return (0.0); - wcsrtombs(buf, &wcp, len + 1, NULL); + mbs = initial; + wcsrtombs(buf, &wcp, len + 1, &mbs); val = strtof(buf, &end); |