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/messages.c
+++ new/usr/src/cmd/localedef/messages.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_MESSAGES 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 <alloca.h>
27 28 #include "localedef.h"
28 29 #include "parser.tab.h"
29 30 #include "lmessages.h"
30 31
31 -static struct lc_messages_T msgs;
32 +static struct lc_messages msgs;
32 33
33 34 void
34 35 init_messages(void)
35 36 {
36 37 (void) memset(&msgs, 0, sizeof (msgs));
37 38 }
38 39
39 40 void
40 41 add_message(wchar_t *wcs)
41 42 {
42 43 char *str;
43 44
44 45 if ((str = to_mb_string(wcs)) == NULL) {
45 46 INTERR;
46 47 return;
47 48 }
48 49 free(wcs);
49 50
50 51 switch (last_kw) {
51 52 case T_YESSTR:
52 53 msgs.yesstr = str;
53 54 break;
54 55 case T_NOSTR:
55 56 msgs.nostr = str;
56 57 break;
57 58 case T_YESEXPR:
58 59 msgs.yesexpr = str;
59 60 break;
60 61 case T_NOEXPR:
61 62 msgs.noexpr = str;
62 63 break;
63 64 default:
64 65 free(str);
65 66 INTERR;
66 67 break;
67 68 }
68 69 }
69 70
70 71 void
71 72 dump_messages(void)
72 73 {
73 74 FILE *f;
74 75 char *ptr;
75 76
76 77 if (msgs.yesstr == NULL) {
77 78 warn(_("missing field 'yesstr'"));
78 79 msgs.yesstr = "";
79 80 }
80 81 if (msgs.nostr == NULL) {
81 82 warn(_("missing field 'nostr'"));
82 83 msgs.nostr = "";
83 84 }
84 85
85 86 /*
86 87 * CLDR likes to add : separated lists for yesstr and nostr.
87 88 * Legacy Solaris code does not seem to grok this. Fix it.
88 89 */
89 90 if ((ptr = strchr(msgs.yesstr, ':')) != NULL)
90 91 *ptr = 0;
91 92 if ((ptr = strchr(msgs.nostr, ':')) != NULL)
92 93 *ptr = 0;
93 94
94 95 if ((f = open_category()) == NULL) {
95 96 return;
96 97 }
97 98
98 99 if ((putl_category(msgs.yesexpr, f) == EOF) ||
99 100 (putl_category(msgs.noexpr, f) == EOF) ||
100 101 (putl_category(msgs.yesstr, f) == EOF) ||
101 102 (putl_category(msgs.nostr, f) == EOF)) {
102 103 return;
103 104 }
104 105 close_category(f);
105 106 }
↓ open down ↓ |
64 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX