summaryrefslogtreecommitdiffstats
path: root/lib/libc/locale/wcstold.c
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2003-10-31 13:29:00 +0000
committertjr <tjr@FreeBSD.org>2003-10-31 13:29:00 +0000
commit44278bfe73f956cea7b76d295f2ece178659f4f9 (patch)
treeec2a611770579a4bf72311eb29886037f4ae1701 /lib/libc/locale/wcstold.c
parentcd4a9b77a6df92c6fce807de7c5bf3271dbcb55c (diff)
downloadFreeBSD-src-44278bfe73f956cea7b76d295f2ece178659f4f9.zip
FreeBSD-src-44278bfe73f956cea7b76d295f2ece178659f4f9.tar.gz
Don't bother passing a freshly-zeroed mbstate to mbsrtowcs() etc.
when the current implementation won't use it, anyway. Just pass NULL. This will need to be changed when state-dependent encodings are supported, but there's no need to take the performance hit in the meantime.
Diffstat (limited to 'lib/libc/locale/wcstold.c')
-rw-r--r--lib/libc/locale/wcstold.c24
1 files changed, 3 insertions, 21 deletions
diff --git a/lib/libc/locale/wcstold.c b/lib/libc/locale/wcstold.c
index 9dee722..6228784 100644
--- a/lib/libc/locale/wcstold.c
+++ b/lib/libc/locale/wcstold.c
@@ -37,8 +37,6 @@ __FBSDID("$FreeBSD$");
long double
wcstold(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr)
{
- static const mbstate_t initial;
- mbstate_t state;
long double val;
char *buf, *end, *p;
const wchar_t *wcp;
@@ -47,36 +45,20 @@ wcstold(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr)
while (iswspace(*nptr))
nptr++;
- state = initial;
wcp = nptr;
- if ((len = wcsrtombs(NULL, &wcp, 0, &state)) == (size_t)-1) {
+ if ((len = wcsrtombs(NULL, &wcp, 0, NULL)) == (size_t)-1) {
if (endptr != NULL)
*endptr = (wchar_t *)nptr;
return (0.0);
}
if ((buf = malloc(len + 1)) == NULL)
return (0.0);
- state = initial;
- wcsrtombs(buf, &wcp, len + 1, &state);
+ wcsrtombs(buf, &wcp, len + 1, NULL);
val = strtold(buf, &end);
- if (endptr != NULL) {
-#if 1 /* Fast, assume 1:1 WC:MBS mapping. */
+ if (endptr != NULL)
*endptr = (wchar_t *)nptr + (end - buf);
- (void)clen;
- (void)p;
-#else /* Slow, conservative approach. */
- state = initial;
- *endptr = (wchar_t *)nptr;
- p = buf;
- while (p < end &&
- (clen = mbrlen(p, end - p, &state)) > 0) {
- p += clen;
- (*endptr)++;
- }
-#endif
- }
free(buf);
OpenPOWER on IntegriCloud