summaryrefslogtreecommitdiffstats
path: root/lib/libc/locale/fix_grouping.c
diff options
context:
space:
mode:
authorphantom <phantom@FreeBSD.org>2001-02-10 20:22:45 +0000
committerphantom <phantom@FreeBSD.org>2001-02-10 20:22:45 +0000
commit9e607edc06ad379cb082195f6e93d8e11a760727 (patch)
tree5a399d0dc763f52802f5b8cb4020ceaf847886a7 /lib/libc/locale/fix_grouping.c
parent7ada9af3f7a73ff39d4e98d26ff61a3521f03b7f (diff)
downloadFreeBSD-src-9e607edc06ad379cb082195f6e93d8e11a760727.zip
FreeBSD-src-9e607edc06ad379cb082195f6e93d8e11a760727.tar.gz
make it possible to specify grouping number from range 0..CHAR_MAX,
not only one-digit number
Diffstat (limited to 'lib/libc/locale/fix_grouping.c')
-rw-r--r--lib/libc/locale/fix_grouping.c12
1 files changed, 9 insertions, 3 deletions
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 <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;
OpenPOWER on IntegriCloud