2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
13 * Copyright 2010 Nexenta Systems, Inc. All rights reserved.
14 * Copyright 2015 John Marino <draco@marino.st>
18 * LC_NUMERIC database generation routines for localedef.
24 #include <sys/types.h>
27 #include "localedef.h"
31 static struct lc_numeric_T numeric;
36 (void) memset(&numeric, 0, sizeof (numeric));
40 add_numeric_str(wchar_t *wcs)
44 if ((str = to_mb_string(wcs)) == NULL) {
52 numeric.decimal_point = str;
55 numeric.thousands_sep = str;
64 #pragma GCC diagnostic push
65 #pragma GCC diagnostic ignored "-Wcast-qual"
68 reset_numeric_group(void)
70 free((char *)numeric.grouping);
71 numeric.grouping = NULL;
75 add_numeric_group(int n)
79 if (numeric.grouping == NULL) {
80 (void) asprintf(&s, "%d", n);
82 (void) asprintf(&s, "%s;%d", numeric.grouping, n);
85 fprintf(stderr, "out of memory");
87 free((char *)numeric.grouping);
91 #pragma GCC diagnostic pop
98 if ((f = open_category()) == NULL) {
102 if ((putl_category(numeric.decimal_point, f) == EOF) ||
103 (putl_category(numeric.thousands_sep, f) == EOF) ||
104 (putl_category(numeric.grouping, f) == EOF)) {