summaryrefslogtreecommitdiffstats
path: root/newlib/libc/stdlib/gdtoa-gethex.c
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2009-03-24 10:13:27 +0000
committerCorinna Vinschen <corinna@vinschen.de>2009-03-24 10:13:27 +0000
commit28186e81d947a830d9895cecc2d8e836a3cbccd0 (patch)
tree8ef79212f3476f0b1fbbef8fa46b97ea297c6fe3 /newlib/libc/stdlib/gdtoa-gethex.c
parent0258b687228f0d9d5191615ba0a13f7496f09d3b (diff)
downloadcygnal-28186e81d947a830d9895cecc2d8e836a3cbccd0.tar.gz
cygnal-28186e81d947a830d9895cecc2d8e836a3cbccd0.tar.bz2
cygnal-28186e81d947a830d9895cecc2d8e836a3cbccd0.zip
* libc/ctype/iswalpha.c: Handle all wchar_t as unicode on
_MB_CAPABLE systems. * libc/ctype/iswblank.c: Ditto. * libc/ctype/iswcntrl.c: Ditto. * libc/ctype/iswprint.c: Ditto. * libc/ctype/iswpunct.c: Ditto. * libc/ctype/iswspace.c: Ditto. * libc/ctype/jp2uc.c (__jp2uc): On Cygwin, just return c. Explain why. * libc/ctype/towlower.c: Ditto. * libc/ctype/towupper.c: Ditto. * libc/include/sys/config.h: Define _MB_EXTENDED_CHARSETS_ISO and _MB_EXTENDED_CHARSETS_WINDOWS if _MB_EXTENDED_CHARSETS_ALL is defined. Define _MB_EXTENDED_CHARSETS_ALL on Cygwin only for now. * libc/include/sys/reent.h (struct _reent): Mark _current_category and _current_locale as unused. * libc/locale/locale.c: Add new charset support to documentation. Include ../stdio/local.h from here. (lc_ctype_charset): Set to "ASCII" by default. (lc_message_charset): Ditto. (_setlocale_r): Don't set _current_category and _current_locale. (loadlocale): Add Cygwin codepage support. On _MB_CAPABLE systems, set __mbtowc and __wctomb function pointers to function corresponding with current charset. Don't allow non-existant ISO-8859-12 charset. Add support for Windows singlebyte codepages. On Cygwin, add support for GBK, CP949, and BIG5. On Cygwin, call __set_ctype() in case the catorgy is LC_CTYPE. Don't set _current_category and _current_locale. * libc/stdlib/Makefile.am (GENERAL_SOURCES): Add sb_charsets.c. * libc/stdlib/Makefile.in: Regenerate. * libc/stdlib/local.h: Add prototype for __locale_charset. Add prototypes for __mbtowc and __wctomb pointers. Add prototypes for charset-specific _wctomb_r and _mbtowc_r functions. Declare tables and functions from sb_charsets.c. * libc/stdlib/mbtowc_r.c (__mbtowc): Define. Set to __ascii_mbtowc by default. (_mbtowc_r): Just call __mbtowc from here. (__ascii_mbtowc): New function. (__iso_mbtowc): New function. (__cp_mbtowc): New function. (__utf8_mbtowc): New function. (__sjis_mbtowc): New function. Disable on Cygwin. (__eucjp_mbtowc): New function. Disable on Cygwin. (__jis_mbtowc): New function. Disable on Cygwin. * libc/stdlib/sb_charsets.c: New file, adding singlebyte to UTF conversion tables for all ISO and CP charsets. (__iso_8859_index): New function. (__cp_index): New function. * libc/stdlib/wctomb_r.c (__wctomb): Define. Set to __ascii_wctomb by default. (_wctomb_r): Just call __wctomb from here. (__ascii_wctomb): New function. (__utf8_wctomb): New function. (__sjis_wctomb): New function. Disable on Cygwin. (__eucjp_wctomb): New function. Disable on Cygwin. (__jis_wctomb): New function. Disable on Cygwin. (__iso_wctomb): New function. (__cp_wctomb): New function.
Diffstat (limited to 'newlib/libc/stdlib/gdtoa-gethex.c')
-rw-r--r--newlib/libc/stdlib/gdtoa-gethex.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/newlib/libc/stdlib/gdtoa-gethex.c b/newlib/libc/stdlib/gdtoa-gethex.c
index 92f30fca0..80f56959d 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()->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,9 @@ _DEFUN(gethex, (ptr, sp, fpi, exp, bp, sign),
e = 0;
if (!hexdig[*s]) {
zret = 1;
- if (*s != decimalpoint)
+ if (strcmp ((const char *) s, (const char *) decimalpoint) != 0)
goto pcheck;
- decpt = ++s;
+ decpt = (s += decp_len);
if (!hexdig[*s])
goto pcheck;
while(*s == '0')
@@ -184,8 +180,9 @@ _DEFUN(gethex, (ptr, sp, fpi, exp, bp, sign),
}
while(hexdig[*s])
s++;
- if (*s == decimalpoint && !decpt) {
- decpt = ++s;
+ if (strcmp ((const char *) s, (const char *) decimalpoint) == 0
+ && !decpt) {
+ decpt = (s += decp_len);
while(hexdig[*s])
s++;
}
@@ -226,8 +223,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
+ && strcmp ((const char *) s1 - decp_len + 1,
+ (const char *) decimalpoint) == 0) {
+ s1 -= decp_len - 1; /* Note the --s1 above! */
continue;
+ }
if (n == 32) {
*x++ = L;
L = 0;