diff options
author | ache <ache@FreeBSD.org> | 2001-02-10 05:46:05 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2001-02-10 05:46:05 +0000 |
commit | 29f5f24614e7411d94cf24cd437b38a2802ec939 (patch) | |
tree | d8203a845e38a561e470d02474df0e57b0056c5f | |
parent | 2cb0d2861191404a692eeddf6d94808d0b9e64b7 (diff) | |
download | FreeBSD-src-29f5f24614e7411d94cf24cd437b38a2802ec939.zip FreeBSD-src-29f5f24614e7411d94cf24cd437b38a2802ec939.tar.gz |
Use decimal point from localeconv() instead of hardcoded '.' (SUSv2)
-rw-r--r-- | lib/libc/stdio/vfscanf.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/libc/stdio/vfscanf.c b/lib/libc/stdio/vfscanf.c index 04ce95c..5181a4e 100644 --- a/lib/libc/stdio/vfscanf.c +++ b/lib/libc/stdio/vfscanf.c @@ -60,7 +60,11 @@ static const char rcsid[] = #define FLOATING_POINT +#ifdef FLOATING_POINT +#include <locale.h> #include "floatio.h" +#endif + #define BUF 513 /* Maximum length of numeric string. */ /* @@ -140,6 +144,9 @@ __svfscanf(FILE *fp, char const *fmt0, va_list ap) /* `basefix' is used to avoid `if' tests in the integer scanner */ static short basefix[17] = { 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; +#ifdef FLOATING_POINT + char decimal_point = localeconv()->decimal_point[0]; +#endif nassigned = 0; nconversions = 0; @@ -616,12 +623,6 @@ literal: goto fok; } break; - case '.': - if (flags & DPTOK) { - flags &= ~(SIGNOK | DPTOK); - goto fok; - } - break; case 'e': case 'E': /* no exponent without some digits */ if ((flags&(NDIGITS|EXPOK)) == EXPOK) { @@ -631,6 +632,13 @@ literal: goto fok; } break; + default: + if ((char)c == decimal_point && + (flags & DPTOK)) { + flags &= ~(SIGNOK | DPTOK); + goto fok; + } + break; } break; fok: |