From 9e607edc06ad379cb082195f6e93d8e11a760727 Mon Sep 17 00:00:00 2001 From: phantom Date: Sat, 10 Feb 2001 20:22:45 +0000 Subject: make it possible to specify grouping number from range 0..CHAR_MAX, not only one-digit number --- lib/libc/locale/fix_grouping.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/libc/locale/fix_grouping.c b/lib/libc/locale/fix_grouping.c index ab11655..49211b7 100644 --- a/lib/libc/locale/fix_grouping.c +++ b/lib/libc/locale/fix_grouping.c @@ -26,19 +26,20 @@ * $FreeBSD$ */ +#include #include 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; -- cgit v1.1