1 /* Copyright (c) 2004 Google Inc.; see LICENSE */
10 * Fill in the internationalization stuff in the State structure.
11 * For nil arguments, provide the sensible defaults:
13 * thousands separator is a comma
14 * thousands are marked every three digits
17 fmtlocaleinit(Fmt *f, char *decimal, char *thousands, char *grouping)
19 if(decimal == nil || decimal[0] == '\0')
26 f->thousands = thousands;
27 f->grouping = grouping;
31 * We are about to emit a digit in e.g. %'d. If that digit would
32 * overflow a thousands (e.g.) grouping, tell the caller to emit
33 * the thousands separator. Always advance the digit counter
34 * and pointer into the grouping descriptor.
37 __needsep(int *ndig, char **grouping)
42 group = *(unsigned char*)*grouping;
43 /* CHAR_MAX means no further grouping. \0 means we got the empty string */
44 if(group == 0xFF || group == 0x7f || group == 0x00)
47 /* if we're at end of string, continue with this grouping; else advance */
48 if((*grouping)[1] != '\0')