diff options
author | Alexey Zelkin <phantom@FreeBSD.org> | 2001-02-10 20:22:45 +0000 |
---|---|---|
committer | Alexey Zelkin <phantom@FreeBSD.org> | 2001-02-10 20:22:45 +0000 |
commit | cb03ae3061835a849f9466a4047aa9787f8e99f0 (patch) | |
tree | 49ef35fbfb7487f4ed3c90d141c6058d6fa5a697 /lib/libc | |
parent | 208058ad79336bfbcf57b68e10e90a1db1c0285f (diff) | |
download | src-cb03ae3061835a849f9466a4047aa9787f8e99f0.tar.gz src-cb03ae3061835a849f9466a4047aa9787f8e99f0.zip |
make it possible to specify grouping number from range 0..CHAR_MAX,
not only one-digit number
Notes
Notes:
svn path=/head/; revision=72333
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/locale/fix_grouping.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/libc/locale/fix_grouping.c b/lib/libc/locale/fix_grouping.c index ab11655b2e91..49211b7c7e39 100644 --- a/lib/libc/locale/fix_grouping.c +++ b/lib/libc/locale/fix_grouping.c @@ -26,19 +26,20 @@ * $FreeBSD$ */ +#include <ctype.h> #include <limits.h> static const char nogrouping[] = { CHAR_MAX, '\0' }; /* * "3;3;-1" -> "\003\003\177" - * NOTE: one digit numbers assumed! */ const char * __fix_locale_grouping_str(const char *str) { char *src, *dst; + char n; if (str == 0) { return nogrouping; @@ -56,12 +57,17 @@ __fix_locale_grouping_str(const char *str) { continue; } - if (!isdigit(*src)) { + if (!isdigit((unsigned char)*src)) { /* broken grouping string */ return nogrouping; } - *dst++ = *src - '0'; + for (n = 0; isdigit((unsigned char)*src); src++) { + n *= 10; + n += *src - '0'; + } + + *dst++ = n; } *dst = '\0'; return str; |