Print this page
2964 need POSIX 2008 locale object support
Reviewed by: Robert Mustacchi <rm@joyent.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/localedef/numeric.c
+++ new/usr/src/cmd/localedef/numeric.c
1 1 /*
2 2 * This file and its contents are supplied under the terms of the
↓ open down ↓ |
2 lines elided |
↑ open up ↑ |
3 3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 4 * You may only use this file in accordance with the terms of version
5 5 * 1.0 of the CDDL.
6 6 *
7 7 * A full copy of the text of the CDDL should have accompanied this
8 8 * source. A copy of the CDDL is also available via the Internet at
9 9 * http://www.illumos.org/license/CDDL.
10 10 */
11 11
12 12 /*
13 + * Copyright 2013 Garrett D'Amore <garrett@damore.org>
13 14 * Copyright 2010 Nexenta Systems, Inc. All rights reserved.
14 15 */
15 16
16 17 /*
17 18 * LC_NUMERIC database generation routines for localedef.
18 19 */
19 20
20 21 #include <stdio.h>
21 22 #include <stdlib.h>
22 23 #include <errno.h>
23 24 #include <sys/types.h>
24 25 #include <string.h>
25 26 #include <unistd.h>
26 27 #include "localedef.h"
27 28 #include "parser.tab.h"
28 29 #include "lnumeric.h"
29 30
30 -static struct lc_numeric_T numeric;
31 +static struct lc_numeric numeric;
31 32
32 33 void
33 34 init_numeric(void)
34 35 {
35 36 (void) memset(&numeric, 0, sizeof (numeric));
36 37 }
37 38
38 39 void
39 40 add_numeric_str(wchar_t *wcs)
40 41 {
41 42 char *str;
42 43
43 44 if ((str = to_mb_string(wcs)) == NULL) {
44 45 INTERR;
45 46 return;
46 47 }
47 48 free(wcs);
48 49
49 50 switch (last_kw) {
50 51 case T_DECIMAL_POINT:
51 52 numeric.decimal_point = str;
52 53 break;
53 54 case T_THOUSANDS_SEP:
54 55 numeric.thousands_sep = str;
55 56 break;
56 57 default:
57 58 free(str);
58 59 INTERR;
59 60 break;
60 61 }
61 62 }
62 63
63 64 void
64 65 reset_numeric_group(void)
65 66 {
66 67 free((char *)numeric.grouping);
67 68 numeric.grouping = NULL;
68 69 }
69 70
70 71 void
71 72 add_numeric_group(int n)
72 73 {
73 74 char *s;
74 75
75 76 if (numeric.grouping == NULL) {
76 77 (void) asprintf(&s, "%d", n);
77 78 } else {
78 79 (void) asprintf(&s, "%s;%d", numeric.grouping, n);
79 80 }
80 81 if (s == NULL)
81 82 errf(_("out of memory"));
82 83
83 84 free((char *)numeric.grouping);
84 85 numeric.grouping = s;
85 86 }
86 87
87 88 void
88 89 dump_numeric(void)
89 90 {
90 91 FILE *f;
91 92
92 93 if ((f = open_category()) == NULL) {
93 94 return;
94 95 }
95 96
96 97 if ((putl_category(numeric.decimal_point, f) == EOF) ||
97 98 (putl_category(numeric.thousands_sep, f) == EOF) ||
98 99 (putl_category(numeric.grouping, f) == EOF)) {
99 100 return;
100 101 }
101 102 close_category(f);
102 103 }
↓ open down ↓ |
62 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX