From 576b7804d63caaae29b7a6ae007f10c0d2c0e58a Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Wed, 18 Dec 2013 19:23:33 +0000 Subject: * vfscanf.c (BUF): Change definition to take multibyte decimal point into account. (__SVFSCANF_R): Handle radix char language-dependent per POSIX. (__SVFWSCANF_R): Ditto. --- newlib/libc/stdio/vfwscanf.c | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) (limited to 'newlib/libc/stdio/vfwscanf.c') diff --git a/newlib/libc/stdio/vfwscanf.c b/newlib/libc/stdio/vfwscanf.c index d86594ef6..731197a1c 100644 --- a/newlib/libc/stdio/vfwscanf.c +++ b/newlib/libc/stdio/vfwscanf.c @@ -161,6 +161,9 @@ C99, POSIX-1.2008 #ifdef FLOATING_POINT #include #include +#ifdef __HAVE_LOCALE_INFO_EXTENDED__ +#include "../locale/lnumeric.h" +#endif /* Currently a test is made to see if long double processing is warranted. This could be changed in the future should the _ldtoa_r code be @@ -414,6 +417,7 @@ _DEFUN(__SVFWSCANF_R, (rptr, fp, fmt0, ap), float *flp; _LONG_DOUBLE *ldp; double *dp; + wchar_t decpt; #endif long *lp; #ifndef _NO_LONGLONG @@ -440,6 +444,27 @@ _DEFUN(__SVFWSCANF_R, (rptr, fp, fmt0, ap), # define GET_ARG(n, ap, type) (va_arg (ap, type)) #endif +#ifdef FLOATING_POINT +#ifdef _MB_CAPABLE +#ifdef __HAVE_LOCALE_INFO_EXTENDED__ + decpt = *__get_current_numeric_locale ()->wdecimal_point; +#else + { + size_t nconv; + + memset (&state, '\0', sizeof (state)); + nconv = _mbrtowc_r (data, &decpt, + _localeconv_r (data)->decimal_point, + MB_CUR_MAX, &state); + if (nconv == (size_t) -1 || nconv == (size_t) -2) + decpt = L'.'; + } +#endif /* !__HAVE_LOCALE_INFO_EXTENDED__ */ +#else + decpt = (wchar_t) *_localeconv_r (data)->decimal_point; +#endif /* !_MB_CAPABLE */ +#endif /* FLOATING_POINT */ + _newlib_flockfile_start (fp); ORIENT (fp, 1); @@ -1271,14 +1296,6 @@ _DEFUN(__SVFWSCANF_R, (rptr, fp, fmt0, ap), goto fok; } break; - case L'.': - if (flags & DPTOK) - { - flags &= ~(SIGNOK | DPTOK); - leading_zeroes = zeroes; - goto fok; - } - break; case L'e': case L'E': /* no exponent without some digits */ @@ -1297,6 +1314,14 @@ _DEFUN(__SVFWSCANF_R, (rptr, fp, fmt0, ap), goto fok; } break; + default: + if ((wchar_t) c == decpt && (flags & DPTOK)) + { + flags &= ~(SIGNOK | DPTOK); + leading_zeroes = zeroes; + goto fok; + } + break; } if (c != WEOF) _ungetwc_r (rptr, c, fp); -- cgit v1.2.3