diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2009-06-16 17:44:20 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2009-06-16 17:44:20 +0000 |
commit | 1c5e84dd0870cd463d97f2b9183a807c3f711f2f (patch) | |
tree | d85b95c8902bcc48be771c159884be1e4e154713 /newlib/libc/stdlib/gdtoa-gethex.c | |
parent | 1a99b6f85a123a1430ef41a3b2ae79eef7c0f768 (diff) | |
download | cygnal-1c5e84dd0870cd463d97f2b9183a807c3f711f2f.tar.gz cygnal-1c5e84dd0870cd463d97f2b9183a807c3f711f2f.tar.bz2 cygnal-1c5e84dd0870cd463d97f2b9183a807c3f711f2f.zip |
* libc/stdio/vfprintf.c (_VFPRINTF_R): Use actual length of
radix char instead of assuming length 1.
* libc/stdlib/gdtoa-gethex.c: Remove use of USE_LOCALE.
(gethex): Allow multibyte decimal point.
Fix compiler warnings due to different signedness of pointer types.
* libc/stdlib/strtod.c: Remove use of USE_LOCALE.
(_strtod_r): Allow multibyte decimal point.
* libc/stdlib/wcstod.c (_wcstod_r): Evaluate correct wide char
endptr position if the decimal point is a multibyte char.
Diffstat (limited to 'newlib/libc/stdlib/gdtoa-gethex.c')
-rw-r--r-- | newlib/libc/stdlib/gdtoa-gethex.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/newlib/libc/stdlib/gdtoa-gethex.c b/newlib/libc/stdlib/gdtoa-gethex.c index 92f30fca0..c73b11c08 100644 --- a/newlib/libc/stdlib/gdtoa-gethex.c +++ b/newlib/libc/stdlib/gdtoa-gethex.c @@ -35,10 +35,7 @@ THIS SOFTWARE. #include "mprec.h" #include "gdtoa.h" #include "gd_qnan.h" - -#ifdef USE_LOCALE #include "locale.h" -#endif unsigned char hexdig[256]; @@ -151,11 +148,10 @@ _DEFUN(gethex, (ptr, sp, fpi, exp, bp, sign), int esign, havedig, irv, k, n, nbits, up, zret; __ULong L, lostbits, *x; Long e, e1; -#ifdef USE_LOCALE - unsigned char decimalpoint = *localeconv()->decimal_point; -#else -#define decimalpoint '.' -#endif + unsigned char *decimalpoint = (unsigned char *) + _localeconv_r (ptr)->decimal_point; + size_t decp_len = strlen ((const char *) decimalpoint); + unsigned char decp_end = decimalpoint[decp_len - 1]; if (!hexdig['0']) hexdig_init(); @@ -170,9 +166,10 @@ _DEFUN(gethex, (ptr, sp, fpi, exp, bp, sign), e = 0; if (!hexdig[*s]) { zret = 1; - if (*s != decimalpoint) + if (strncmp ((const char *) s, (const char *) decimalpoint, + decp_len) != 0) goto pcheck; - decpt = ++s; + decpt = (s += decp_len); if (!hexdig[*s]) goto pcheck; while(*s == '0') @@ -184,8 +181,10 @@ _DEFUN(gethex, (ptr, sp, fpi, exp, bp, sign), } while(hexdig[*s]) s++; - if (*s == decimalpoint && !decpt) { - decpt = ++s; + if (strncmp ((const char *) s, (const char *) decimalpoint, + decp_len) == 0 + && !decpt) { + decpt = (s += decp_len); while(hexdig[*s]) s++; } @@ -226,8 +225,12 @@ _DEFUN(gethex, (ptr, sp, fpi, exp, bp, sign), n = 0; L = 0; while(s1 > s0) { - if (*--s1 == decimalpoint) + if (*--s1 == decp_end && s1 - decp_len + 1 >= s0 + && strncmp ((const char *) s1 - decp_len + 1, + (const char *) decimalpoint, decp_len) == 0) { + s1 -= decp_len - 1; /* Note the --s1 above! */ continue; + } if (n == 32) { *x++ = L; L = 0; |