1 /* Copyright (C) 1996,1997,1998,1999,2000,2001 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@gnu.org>, 1996.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
25 #include "linereader.h"
26 #include "localedef.h"
29 /* Header of the locale data files. */
37 /* Macros used in the parser. */
38 #define SYNTAX_ERROR(string, args...) \
41 lr_error (ldfile, string, ## args); \
42 lr_ignore_rest (ldfile, 0); \
47 /* General handling of `copy'. */
49 handle_copy (struct linereader
*ldfile
, const struct charmap_t
*charmap
,
50 const char *repertoire_name
, struct localedef_t
*result
,
51 enum token_t token
, int locale
, const char *locale_name
,
57 now
= lr_token (ldfile
, charmap
, result
, NULL
, verbose
);
58 if (now
->tok
!= tok_string
)
59 lr_error (ldfile
, _("expect string argument for `copy'"));
60 else if (!ignore_content
)
62 if (now
->val
.str
.startmb
== NULL
)
63 lr_error (ldfile
, _("\
64 locale name should consist only of portable characters"));
67 (void) add_to_readlist (locale
, now
->val
.str
.startmb
,
68 repertoire_name
, 1, NULL
);
69 result
->copy_name
[locale
] = now
->val
.str
.startmb
;
73 lr_ignore_rest (ldfile
, now
->tok
== tok_string
);
75 /* The rest of the line must be empty and the next keyword must be
77 while ((now
= lr_token (ldfile
, charmap
, result
, NULL
, verbose
))->tok
78 != tok_end
&& now
->tok
!= tok_eof
)
82 lr_error (ldfile
, _("\
83 no other keyword shall be specified when `copy' is used"));
87 lr_ignore_rest (ldfile
, 0);
90 if (now
->tok
!= tok_eof
)
92 /* Handle `END xxx'. */
93 now
= lr_token (ldfile
, charmap
, result
, NULL
, verbose
);
95 if (now
->tok
!= token
)
96 lr_error (ldfile
, _("\
97 `%1$s' definition does not end with `END %1$s'"), locale_name
);
99 lr_ignore_rest (ldfile
, now
->tok
== token
);
102 /* When we come here we reached the end of the file. */
103 lr_error (ldfile
, _("%s: premature end of file"), locale_name
);
107 /* Found in locfile.c. */
108 extern int locfile_read (struct localedef_t
*result
,
109 const struct charmap_t
*charmap
);
111 /* Check validity of all the locale data. */
112 extern void check_all_categories (struct localedef_t
*definitions
,
113 const struct charmap_t
*charmap
);
115 /* Write out all locale categories. */
116 extern void write_all_categories (struct localedef_t
*definitions
,
117 const struct charmap_t
*charmap
,
118 const char *output_path
);
120 /* Write out the data. */
121 extern void write_locale_data (const char *output_path
, const char *category
,
122 size_t n_elem
, struct iovec
*vec
);
125 /* Entrypoints for the parsers of the individual categories. */
127 /* Handle LC_CTYPE category. */
128 extern void ctype_read (struct linereader
*ldfile
,
129 struct localedef_t
*result
,
130 const struct charmap_t
*charmap
,
131 const char *repertoire_name
,
133 extern void ctype_finish (struct localedef_t
*locale
,
134 const struct charmap_t
*charmap
);
135 extern void ctype_output (struct localedef_t
*locale
,
136 const struct charmap_t
*charmap
,
137 const char *output_path
);
138 extern uint32_t *find_translit (struct localedef_t
*locale
,
139 const struct charmap_t
*charmap
, uint32_t wch
);
141 /* Handle LC_COLLATE category. */
142 extern void collate_read (struct linereader
*ldfile
,
143 struct localedef_t
*result
,
144 const struct charmap_t
*charmap
,
145 const char *repertoire_name
,
147 extern void collate_finish (struct localedef_t
*locale
,
148 const struct charmap_t
*charmap
);
149 extern void collate_output (struct localedef_t
*locale
,
150 const struct charmap_t
*charmap
,
151 const char *output_path
);
153 /* Handle LC_MONETARY category. */
154 extern void monetary_read (struct linereader
*ldfile
,
155 struct localedef_t
*result
,
156 const struct charmap_t
*charmap
,
157 const char *repertoire_name
,
159 extern void monetary_finish (struct localedef_t
*locale
,
160 const struct charmap_t
*charmap
);
161 extern void monetary_output (struct localedef_t
*locale
,
162 const struct charmap_t
*charmap
,
163 const char *output_path
);
165 /* Handle LC_NUMERIC category. */
166 extern void numeric_read (struct linereader
*ldfile
,
167 struct localedef_t
*result
,
168 const struct charmap_t
*charmap
,
169 const char *repertoire_name
,
171 extern void numeric_finish (struct localedef_t
*locale
,
172 const struct charmap_t
*charmap
);
173 extern void numeric_output (struct localedef_t
*locale
,
174 const struct charmap_t
*charmap
,
175 const char *output_path
);
177 /* Handle LC_MESSAGES category. */
178 extern void messages_read (struct linereader
*ldfile
,
179 struct localedef_t
*result
,
180 const struct charmap_t
*charmap
,
181 const char *repertoire_name
,
183 extern void messages_finish (struct localedef_t
*locale
,
184 const struct charmap_t
*charmap
);
185 extern void messages_output (struct localedef_t
*locale
,
186 const struct charmap_t
*charmap
,
187 const char *output_path
);
189 /* Handle LC_TIME category. */
190 extern void time_read (struct linereader
*ldfile
,
191 struct localedef_t
*result
,
192 const struct charmap_t
*charmap
,
193 const char *repertoire_name
,
195 extern void time_finish (struct localedef_t
*locale
,
196 const struct charmap_t
*charmap
);
197 extern void time_output (struct localedef_t
*locale
,
198 const struct charmap_t
*charmap
,
199 const char *output_path
);
201 /* Handle LC_PAPER category. */
202 extern void paper_read (struct linereader
*ldfile
,
203 struct localedef_t
*result
,
204 const struct charmap_t
*charmap
,
205 const char *repertoire_name
,
207 extern void paper_finish (struct localedef_t
*locale
,
208 const struct charmap_t
*charmap
);
209 extern void paper_output (struct localedef_t
*locale
,
210 const struct charmap_t
*charmap
,
211 const char *output_path
);
213 /* Handle LC_NAME category. */
214 extern void name_read (struct linereader
*ldfile
,
215 struct localedef_t
*result
,
216 const struct charmap_t
*charmap
,
217 const char *repertoire_name
,
219 extern void name_finish (struct localedef_t
*locale
,
220 const struct charmap_t
*charmap
);
221 extern void name_output (struct localedef_t
*locale
,
222 const struct charmap_t
*charmap
,
223 const char *output_path
);
225 /* Handle LC_ADDRESS category. */
226 extern void address_read (struct linereader
*ldfile
,
227 struct localedef_t
*result
,
228 const struct charmap_t
*charmap
,
229 const char *repertoire_name
,
231 extern void address_finish (struct localedef_t
*locale
,
232 const struct charmap_t
*charmap
);
233 extern void address_output (struct localedef_t
*locale
,
234 const struct charmap_t
*charmap
,
235 const char *output_path
);
237 /* Handle LC_TELEPHONE category. */
238 extern void telephone_read (struct linereader
*ldfile
,
239 struct localedef_t
*result
,
240 const struct charmap_t
*charmap
,
241 const char *repertoire_name
,
243 extern void telephone_finish (struct localedef_t
*locale
,
244 const struct charmap_t
*charmap
);
245 extern void telephone_output (struct localedef_t
*locale
,
246 const struct charmap_t
*charmap
,
247 const char *output_path
);
249 /* Handle LC_MEASUREMENT category. */
250 extern void measurement_read (struct linereader
*ldfile
,
251 struct localedef_t
*result
,
252 const struct charmap_t
*charmap
,
253 const char *repertoire_name
,
255 extern void measurement_finish (struct localedef_t
*locale
,
256 const struct charmap_t
*charmap
);
257 extern void measurement_output (struct localedef_t
*locale
,
258 const struct charmap_t
*charmap
,
259 const char *output_path
);
261 /* Handle LC_IDENTIFICATION category. */
262 extern void identification_read (struct linereader
*ldfile
,
263 struct localedef_t
*result
,
264 const struct charmap_t
*charmap
,
265 const char *repertoire_name
,
267 extern void identification_finish (struct localedef_t
*locale
,
268 const struct charmap_t
*charmap
);
269 extern void identification_output (struct localedef_t
*locale
,
270 const struct charmap_t
*charmap
,
271 const char *output_path
);
273 #endif /* locfile.h */