+1999-09-12 Ulrich Drepper <drepper@cygnus.com>
+
+ * locale/programs/ld-address.c: Fix handling of non-existing
+ definitions for this category. Correctly ignore content of this
+ category is this is necessary.
+ * locale/programs/ld-collate.c: Likewise.
+ * locale/programs/ld-ctype.c: Likewise.
+ * locale/programs/ld-identification.c: Likewise.
+ * locale/programs/ld-measurement.c: Likewise.
+ * locale/programs/ld-messages.c: Likewise.
+ * locale/programs/ld-monetary.c: Likewise.
+ * locale/programs/ld-name.c: Likewise.
+ * locale/programs/ld-numeric.c: Likewise.
+ * locale/programs/ld-paper.c: Likewise.
+ * locale/programs/ld-telephone.c: Likewise.
+ * locale/programs/ld-time.c: Likewise.
+ * locale/programs/locfile.h (handle_copy): Take extra parameter
+ with result pointer. Fill in name of locale from which to copy.
+ Correctly read token after `END'.
+
+ * locale/programs/localedef.c (main): Correct handling copy.
+ (add_to_readlist): Take extra parameter which says whether we
+ are supposed to read the file or not.
+ (find_locale): Call add_to_readlist with extra parameter set to 0.
+
+ * locale/programs/localedef.h (struct localedef_t): Use __LC_LAST
+ instead of wrong number in array definitions.
+ (add_to_readlist): Update prototype.
+
+ * locale/programs/locfile.c (locfile_read): Mark categories not
+ available in source file as read.
+ (write_all_categories): Fix typo.
+
1999-09-10 Ulrich Drepper <drepper@cygnus.com>
* elf/elf.h (SHF_MASKOS): Added.
(struct locale_address_t *) xcalloc (1,
sizeof (struct locale_address_t));
- lr->translate_strings = 1;
- lr->return_widestr = 0;
+ if (lr != NULL)
+ {
+ lr->translate_strings = 1;
+ lr->return_widestr = 0;
+ }
}
struct locale_address_t *address = locale->categories[LC_ADDRESS].address;
size_t cnt;
int helper;
+ int nothing = 0;
+
+ /* Now resolve copying and also handle completely missing definitions. */
+ if (address == NULL)
+ {
+ /* First see whether we were supposed to copy. If yes, find the
+ actual definition. */
+ if (locale->copy_name[LC_ADDRESS] != NULL)
+ {
+ /* Find the copying locale. This has to happen transitively since
+ the locale we are copying from might also copying another one. */
+ struct localedef_t *from = locale;
+
+ do
+ from = find_locale (LC_ADDRESS, from->copy_name[LC_ADDRESS],
+ from->repertoire_name, charmap);
+ while (from->categories[LC_ADDRESS].address == NULL
+ && from->copy_name[LC_ADDRESS] != NULL);
+
+ address = locale->categories[LC_ADDRESS].address
+ = from->categories[LC_ADDRESS].address;
+ }
+
+ /* If there is still no definition issue an warning and create an
+ empty one. */
+ if (address == NULL)
+ {
+ error (0, 0, _("No definition for %s category found"), "LC_ADDRESS");
+ address_startup (NULL, locale, 0);
+ address = locale->categories[LC_ADDRESS].address;
+ nothing = 1;
+ }
+ }
if (address->postal_fmt == NULL)
{
- error (0, 0, _("%s: field `%s' not defined"),
- "LC_ADDRESS", "postal_fmt");
+ if (! nothing)
+ error (0, 0, _("%s: field `%s' not defined"),
+ "LC_ADDRESS", "postal_fmt");
/* Use as the default value the value of the i18n locale. */
address->postal_fmt = "%a%N%f%N%d%N%b%N%s %h %e %r%N%C-%z %T%N%c%N";
}
#define TEST_ELEM(cat) \
if (address->cat == NULL) \
{ \
- if (verbose) \
+ if (verbose && ! nothing) \
error (0, 0, _("%s: field `%s' not defined"), "LC_ADDRESS", #cat); \
address->cat = ""; \
}
helper = 1;
if (address->lang_term == NULL)
{
- if (verbose)
+ if (verbose && ! nothing)
error (0, 0, _("%s: field `%s' not defined"), "LC_ADDRESS",
"lang_term");
address->lang_term = "";
if (address->lang_ab == NULL)
{
- if (verbose)
+ if (verbose && ! nothing)
error (0, 0, _("%s: field `%s' not defined"), "LC_ADDRESS", "lang_ab");
address->lang_ab = "";
}
if (address->country_num == 0)
{
- if (verbose)
+ if (verbose && ! nothing)
error (0, 0, _("%s: field `%s' not defined"),
"LC_ADDRESS", "country_num");
cnt = sizeof (iso3166) / sizeof (iso3166[0]);
if (address->country_ab2 == NULL)
{
- if (verbose)
+ if (verbose && ! nothing)
error (0, 0, _("%s: field `%s' not defined"),
"LC_ADDRESS", "country_ab2");
address->country_ab2 = " ";
if (address->country_ab3 == NULL)
{
- if (verbose)
+ if (verbose && ! nothing)
error (0, 0, _("%s: field `%s' not defined"),
"LC_ADDRESS", "country_ab3");
address->country_ab3 = " ";
/* If we see `copy' now we are almost done. */
if (nowtok == tok_copy)
{
- handle_copy (ldfile, charmap, repertoire, tok_lc_address, LC_ADDRESS,
- "LC_ADDRESS", ignore_content);
+ handle_copy (ldfile, charmap, repertoire, result, tok_lc_address,
+ LC_ADDRESS, "LC_ADDRESS", ignore_content);
return;
}
{
#define STR_ELEM(cat) \
case tok_##cat: \
+ /* Ignore the rest of the line if we don't need the input of \
+ this line. */ \
+ if (ignore_content) \
+ { \
+ lr_ignore_rest (ldfile, 0); \
+ break; \
+ } \
+ \
arg = lr_token (ldfile, charmap, NULL); \
if (arg->tok != tok_string) \
goto err_label; \
#define INT_ELEM(cat) \
case tok_##cat: \
+ /* Ignore the rest of the line if we don't need the input of \
+ this line. */ \
+ if (ignore_content) \
+ { \
+ lr_ignore_rest (ldfile, 0); \
+ break; \
+ } \
+ \
arg = lr_token (ldfile, charmap, NULL); \
if (arg->tok != tok_number) \
goto err_label; \
switch (nowtok)
{
case tok_coll_weight_max:
+ /* Ignore the rest of the line if we don't need the input of
+ this line. */
+ if (ignore_content)
+ {
+ lr_ignore_rest (ldfile, 0);
+ break;
+ }
+
if (state != 0)
goto err_label;
break;
case tok_section_symbol:
+ /* Ignore the rest of the line if we don't need the input of
+ this line. */
+ if (ignore_content)
+ {
+ lr_ignore_rest (ldfile, 0);
+ break;
+ }
+
if (state != 0)
goto err_label;
break;
case tok_collating_element:
+ /* Ignore the rest of the line if we don't need the input of
+ this line. */
+ if (ignore_content)
+ {
+ lr_ignore_rest (ldfile, 0);
+ break;
+ }
+
if (state != 0)
goto err_label;
break;
case tok_collating_symbol:
+ /* Ignore the rest of the line if we don't need the input of
+ this line. */
+ if (ignore_content)
+ {
+ lr_ignore_rest (ldfile, 0);
+ break;
+ }
+
if (state != 0)
goto err_label;
break;
case tok_symbol_equivalence:
+ /* Ignore the rest of the line if we don't need the input of
+ this line. */
+ if (ignore_content)
+ {
+ lr_ignore_rest (ldfile, 0);
+ break;
+ }
+
if (state != 0)
goto err_label;
break;
case tok_order_start:
+ /* Ignore the rest of the line if we don't need the input of
+ this line. */
+ if (ignore_content)
+ {
+ lr_ignore_rest (ldfile, 0);
+ break;
+ }
+
if (state != 0 && state != 1)
goto err_label;
state = 1;
break;
case tok_order_end:
+ /* Ignore the rest of the line if we don't need the input of
+ this line. */
+ if (ignore_content)
+ {
+ lr_ignore_rest (ldfile, 0);
+ break;
+ }
+
if (state != 1)
goto err_label;
state = 2;
break;
case tok_reorder_after:
+ /* Ignore the rest of the line if we don't need the input of
+ this line. */
+ if (ignore_content)
+ {
+ lr_ignore_rest (ldfile, 0);
+ break;
+ }
+
if (state != 2 && state != 3)
goto err_label;
state = 3;
break;
case tok_reorder_end:
+ /* Ignore the rest of the line if we don't need the input of
+ this line. */
+ if (ignore_content)
+ break;
+
if (state != 3)
goto err_label;
state = 4;
break;
case tok_bsymbol:
+ /* Ignore the rest of the line if we don't need the input of
+ this line. */
+ if (ignore_content)
+ {
+ lr_ignore_rest (ldfile, 0);
+ break;
+ }
+
if (state != 1 && state != 3)
goto err_label;
break;
case tok_undefined:
+ /* Ignore the rest of the line if we don't need the input of
+ this line. */
+ if (ignore_content)
+ {
+ lr_ignore_rest (ldfile, 0);
+ break;
+ }
+
if (state != 1)
goto err_label;
/* XXX handle UNDEFINED weight */
break;
case tok_ellipsis3:
+ /* Ignore the rest of the line if we don't need the input of
+ this line. */
+ if (ignore_content)
+ {
+ lr_ignore_rest (ldfile, 0);
+ break;
+ }
+
if (state != 1 && state != 3)
goto err_label;
case tok_end:
/* Next we assume `LC_COLLATE'. */
- if (state == 0)
- /* We must either see a copy statement or have ordering values. */
- lr_error (ldfile, _("%s: empty category description not allowed"),
- "LC_COLLATE");
- else if (state == 1)
- lr_error (ldfile, _("%s: missing `order_end' keyword"),
- "LC_COLLATE");
- else if (state == 3)
- error (0, 0, _("%s: missing `reorder-end' keyword"),
- "LC_COLLATE");
+ if (!ignore_content)
+ {
+ if (state == 0)
+ /* We must either see a copy statement or have
+ ordering values. */
+ lr_error (ldfile,
+ _("%s: empty category description not allowed"),
+ "LC_COLLATE");
+ else if (state == 1)
+ lr_error (ldfile, _("%s: missing `order_end' keyword"),
+ "LC_COLLATE");
+ else if (state == 3)
+ error (0, 0, _("%s: missing `reorder-end' keyword"),
+ "LC_COLLATE");
+ }
arg = lr_token (ldfile, charmap, NULL);
if (arg->tok == tok_eof)
break;
/* If we see `copy' now we are almost done. */
if (nowtok == tok_copy)
{
- handle_copy (ldfile, charmap, tok_lc_collate, LC_COLLATE, "LC_COLLATE",
- ignore_content);
+ handle_copy (ldfile, charmap, repertoire, result, tok_lc_collate,
+ LC_COLLATE, "LC_COLLATE", ignore_content);
did_copy = 1;
}
struct locale_ctype_t *ctype = locale->categories[LC_CTYPE].ctype;
int warned;
+ /* Now resolve copying and also handle completely missing definitions. */
+ if (ctype == NULL)
+ {
+ /* First see whether we were supposed to copy. If yes, find the
+ actual definition. */
+ if (locale->copy_name[LC_CTYPE] != NULL)
+ {
+ /* Find the copying locale. This has to happen transitively since
+ the locale we are copying from might also copying another one. */
+ struct localedef_t *from = locale;
+
+ do
+ from = find_locale (LC_CTYPE, from->copy_name[LC_CTYPE],
+ from->repertoire_name, charmap);
+ while (from->categories[LC_CTYPE].ctype == NULL
+ && from->copy_name[LC_CTYPE] != NULL);
+
+ ctype = locale->categories[LC_CTYPE].ctype
+ = from->categories[LC_CTYPE].ctype;
+ }
+
+ /* If there is still no definition issue an warning and create an
+ empty one. */
+ if (ctype == NULL)
+ {
+ error (0, 0, _("No definition for %s category found"), "LC_CTYPE");
+ ctype_startup (NULL, locale, charmap, 0);
+ ctype = locale->categories[LC_CTYPE].ctype;
+ }
+ }
+
/* Set default value for classes not specified. */
set_class_defaults (ctype, charmap, ctype->repertoire);
/* If we see `copy' now we are almost done. */
if (nowtok == tok_copy)
{
- handle_copy (ldfile, charmap, repertoire, tok_lc_ctype, LC_CTYPE,
+ handle_copy (ldfile, charmap, repertoire, result, tok_lc_ctype, LC_CTYPE,
"LC_CTYPE", ignore_content);
return;
}
switch (nowtok)
{
case tok_class:
+ /* Ignore the rest of the line if we don't need the input of
+ this line. */
+ if (ignore_content)
+ {
+ lr_ignore_rest (ldfile, 0);
+ break;
+ }
+
/* We simply forget the `class' keyword and use the following
operand to determine the bit. */
now = lr_token (ldfile, charmap, NULL);
case tok_print:
case tok_xdigit:
case tok_blank:
+ /* Ignore the rest of the line if we don't need the input of
+ this line. */
+ if (ignore_content)
+ {
+ lr_ignore_rest (ldfile, 0);
+ break;
+ }
+
class_bit = BITw (now->tok);
class256_bit = BIT (now->tok);
handle_digits = 0;
/* We must store the digit values. */
if (ctype->mbdigits_act == ctype->mbdigits_max)
{
- ctype->mbdigits_max *= 2;
+ ctype->mbdigits_max += 10;
ctype->mbdigits = xrealloc (ctype->mbdigits,
(ctype->mbdigits_max
* sizeof (char *)));
- ctype->wcdigits_max *= 2;
+ ctype->wcdigits_max += 10;
ctype->wcdigits = xrealloc (ctype->wcdigits,
(ctype->wcdigits_max
* sizeof (uint32_t)));
break;
case tok_digit:
+ /* Ignore the rest of the line if we don't need the input of
+ this line. */
+ if (ignore_content)
+ break;
+
handle_tok_digit:
class_bit = _ISwdigit;
class256_bit = _ISdigit;
goto read_charclass;
case tok_outdigit:
+ /* Ignore the rest of the line if we don't need the input of
+ this line. */
+ if (ignore_content)
+ {
+ lr_ignore_rest (ldfile, 0);
+ break;
+ }
+
if (ctype->outdigits_act != 0)
lr_error (ldfile, _("\
%s: field `%s' declared more than once"),
goto read_charclass;
case tok_toupper:
+ /* Ignore the rest of the line if we don't need the input of
+ this line. */
+ if (ignore_content)
+ {
+ lr_ignore_rest (ldfile, 0);
+ break;
+ }
+
mapidx = 0;
goto read_mapping;
case tok_tolower:
+ /* Ignore the rest of the line if we don't need the input of
+ this line. */
+ if (ignore_content)
+ {
+ lr_ignore_rest (ldfile, 0);
+ break;
+ }
+
mapidx = 1;
goto read_mapping;
case tok_map:
+ /* Ignore the rest of the line if we don't need the input of
+ this line. */
+ if (ignore_content)
+ {
+ lr_ignore_rest (ldfile, 0);
+ break;
+ }
+
/* We simply forget the `map' keyword and use the following
operand to determine the mapping. */
now = lr_token (ldfile, charmap, NULL);
break;
case tok_translit_start:
+ /* Ignore the rest of the line if we don't need the input of
+ this line. */
+ if (ignore_content)
+ {
+ lr_ignore_rest (ldfile, 0);
+ break;
+ }
+
/* The rest of the line better should be empty. */
lr_ignore_rest (ldfile, 1);
break;
case tok_ident:
+ /* Ignore the rest of the line if we don't need the input of
+ this line. */
+ if (ignore_content)
+ {
+ lr_ignore_rest (ldfile, 0);
+ break;
+ }
+
/* This could mean one of several things. First test whether
it's a character class name. */
for (cnt = 0; cnt < ctype->nr_charclass; ++cnt)
ctype->mboutdigits[cnt]->nbytes = 1;
}
}
+
+ ctype->wcoutdigits[cnt] = repertoire_find_value (repertoire,
+ digits + cnt, 1);
+
+ if (ctype->wcoutdigits[cnt] == ILLEGAL_CHAR_VALUE)
+ {
+ ctype->wcoutdigits[cnt] = repertoire_find_value (repertoire,
+ longnames[cnt],
+ strlen (longnames[cnt]));
+
+ if (ctype->wcoutdigits[cnt] == ILLEGAL_CHAR_VALUE)
+ {
+ /* Provide a replacement. */
+ error (0, 0, _("\
+no output digits defined and none of the standard names in the repertoire"));
+
+ /* This is better than nothing. */
+ ctype->wcoutdigits[cnt] = (uint32_t) digits[cnt];
+ }
+ }
}
ctype->outdigits_act = 10;
};
+static const char *category_name[__LC_LAST] =
+{
+ [LC_CTYPE] = "LC_CTYPE",
+ [LC_NUMERIC] = "LC_NUMERIC",
+ [LC_TIME] = "LC_TIME",
+ [LC_COLLATE] = "LC_COLLATE",
+ [LC_MONETARY] = "LC_MONETARY",
+ [LC_MESSAGES] = "LC_MESSAGES",
+ [LC_ALL] = "LC_ALL",
+ [LC_PAPER] = "LC_PAPER",
+ [LC_NAME] = "LC_NAME",
+ [LC_ADDRESS] = "LC_ADDRESS",
+ [LC_TELEPHONE] = "LC_TELEPHONE",
+ [LC_MEASUREMENT] = "LC_MEASUREMENT",
+ [LC_IDENTIFICATION] = "LC_IDENTIFICATION"
+};
+
+
static void
identification_startup (struct linereader *lr, struct localedef_t *locale,
int ignore_content)
"";
}
- lr->translate_strings = 1;
- lr->return_widestr = 0;
+ if (lr != NULL)
+ {
+ lr->translate_strings = 1;
+ lr->return_widestr = 0;
+ }
}
{
struct locale_identification_t *identification
= locale->categories[LC_IDENTIFICATION].identification;
+ int nothing = 0;
+ size_t num;
+
+ /* Now resolve copying and also handle completely missing definitions. */
+ if (identification == NULL)
+ {
+ /* First see whether we were supposed to copy. If yes, find the
+ actual definition. */
+ if (locale->copy_name[LC_IDENTIFICATION] != NULL)
+ {
+ /* Find the copying locale. This has to happen transitively since
+ the locale we are copying from might also copying another one. */
+ struct localedef_t *from = locale;
+
+ do
+ from = find_locale (LC_IDENTIFICATION,
+ from->copy_name[LC_IDENTIFICATION],
+ from->repertoire_name, charmap);
+ while (from->categories[LC_IDENTIFICATION].identification == NULL
+ && from->copy_name[LC_IDENTIFICATION] != NULL);
+
+ identification = locale->categories[LC_IDENTIFICATION].identification
+ = from->categories[LC_IDENTIFICATION].identification;
+ }
+
+ /* If there is still no definition issue an warning and create an
+ empty one. */
+ if (identification == NULL)
+ {
+ error (0, 0, _("No definition for %s category found"),
+ "LC_IDENTIFICATION");
+ identification_startup (NULL, locale, 0);
+ identification
+ = locale->categories[LC_IDENTIFICATION].identification;
+ nothing = 1;
+ }
+ }
#define TEST_ELEM(cat) \
if (identification->cat == NULL) \
{ \
- if (verbose) \
+ if (verbose && ! nothing) \
error (0, 0, _("%s: field `%s' not defined"), \
"LC_IDENTIFICATION", #cat); \
identification->cat = ""; \
TEST_ELEM (abbreviation);
TEST_ELEM (revision);
TEST_ELEM (date);
+
+ for (num = 0; num < __LC_LAST; ++num)
+ if (num != LC_ALL && identification->category[num] == NULL)
+ {
+ if (verbose && ! nothing)
+ error (0, 0, _("%s: no identification for category `%s'"),
+ "LC_IDENTIFICATION", category_name[num]);
+ identification->category[num] = "";
+ }
}
struct locale_identification_t *identification
= locale->categories[LC_IDENTIFICATION].identification;
struct iovec iov[2 + _NL_ITEM_INDEX (_NL_NUM_LC_IDENTIFICATION)
- + (__LC_LAST - 1)];
+ + (__LC_LAST - 2)];
struct locale_file data;
uint32_t idx[_NL_ITEM_INDEX (_NL_NUM_LC_IDENTIFICATION)];
size_t cnt = 0;
idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
for (num = 0; num < __LC_LAST; ++num)
- {
- iov[cnt].iov_base = (void *) identification->category[num];
- iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
- ++cnt;
- }
+ if (num != LC_ALL)
+ {
+ iov[cnt].iov_base = (void *) identification->category[num];
+ iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
+ ++cnt;
+ }
assert (cnt == (2 + _NL_ITEM_INDEX (_NL_NUM_LC_IDENTIFICATION)
- + (__LC_LAST - 1)));
+ + (__LC_LAST - 2)));
write_locale_data (output_path, "LC_IDENTIFICATION",
2 + _NL_ITEM_INDEX (_NL_NUM_LC_IDENTIFICATION), iov);
/* If we see `copy' now we are almost done. */
if (nowtok == tok_copy)
{
- handle_copy (ldfile, charmap, repertoire, tok_lc_identification,
+ handle_copy (ldfile, charmap, repertoire, result, tok_lc_identification,
LC_IDENTIFICATION, "LC_IDENTIFICATION", ignore_content);
return;
}
{
#define STR_ELEM(cat) \
case tok_##cat: \
+ /* Ignore the rest of the line if we don't need the input of \
+ this line. */ \
+ if (ignore_content) \
+ { \
+ lr_ignore_rest (ldfile, 0); \
+ break; \
+ } \
+ \
arg = lr_token (ldfile, charmap, NULL); \
if (arg->tok != tok_string) \
goto err_label; \
STR_ELEM (date);
case tok_category:
+ /* Ignore the rest of the line if we don't need the input of
+ this line. */
+ if (ignore_content)
+ {
+ lr_ignore_rest (ldfile, 0);
+ break;
+ }
+
/* We expect two operands. */
arg = lr_token (ldfile, charmap, NULL);
if (arg->tok != tok_string && arg->tok != tok_ident)
(struct locale_measurement_t *)
xcalloc (1, sizeof (struct locale_measurement_t));
- lr->translate_strings = 1;
- lr->return_widestr = 0;
+ if (lr != NULL)
+ {
+ lr->translate_strings = 1;
+ lr->return_widestr = 0;
+ }
}
{
struct locale_measurement_t *measurement =
locale->categories[LC_MEASUREMENT].measurement;
+ int nothing = 0;
+
+ /* Now resolve copying and also handle completely missing definitions. */
+ if (measurement == NULL)
+ {
+ /* First see whether we were supposed to copy. If yes, find the
+ actual definition. */
+ if (locale->copy_name[LC_MEASUREMENT] != NULL)
+ {
+ /* Find the copying locale. This has to happen transitively since
+ the locale we are copying from might also copying another one. */
+ struct localedef_t *from = locale;
+
+ do
+ from = find_locale (LC_MEASUREMENT,
+ from->copy_name[LC_MEASUREMENT],
+ from->repertoire_name, charmap);
+ while (from->categories[LC_MEASUREMENT].measurement == NULL
+ && from->copy_name[LC_MEASUREMENT] != NULL);
+
+ measurement = locale->categories[LC_MEASUREMENT].measurement
+ = from->categories[LC_MEASUREMENT].measurement;
+ }
+
+ /* If there is still no definition issue an warning and create an
+ empty one. */
+ if (measurement == NULL)
+ {
+ error (0, 0, _("No definition for %s category found"),
+ "LC_MEASUREMENT");
+ measurement_startup (NULL, locale, 0);
+ measurement = locale->categories[LC_MEASUREMENT].measurement;
+ nothing = 1;
+ }
+ }
if (measurement->measurement == 0)
{
- error (0, 0, _("%s: field `%s' not defined"),
- "LC_MEASUREMENT", "measurement");
+ if (! nothing)
+ error (0, 0, _("%s: field `%s' not defined"),
+ "LC_MEASUREMENT", "measurement");
/* Use as the default value the value of the i18n locale. */
measurement->measurement = 1;
}
/* If we see `copy' now we are almost done. */
if (nowtok == tok_copy)
{
- handle_copy (ldfile, charmap, repertoire, tok_lc_measurement,
+ handle_copy (ldfile, charmap, repertoire, result, tok_lc_measurement,
LC_MEASUREMENT, "LC_MEASUREMENT", ignore_content);
return;
}
{
#define INT_ELEM(cat) \
case tok_##cat: \
+ /* Ignore the rest of the line if we don't need the input of \
+ this line. */ \
+ if (ignore_content) \
+ { \
+ lr_ignore_rest (ldfile, 0); \
+ break; \
+ } \
+ \
arg = lr_token (ldfile, charmap, NULL); \
if (arg->tok != tok_number) \
goto err_label; \
(struct locale_messages_t *) xcalloc (1,
sizeof (struct locale_messages_t));
- lr->translate_strings = 1;
- lr->return_widestr = 0;
+ if (lr != NULL)
+ {
+ lr->translate_strings = 1;
+ lr->return_widestr = 0;
+ }
}
{
struct locale_messages_t *messages
= locale->categories[LC_MESSAGES].messages;
+ int nothing = 0;
+
+ /* Now resolve copying and also handle completely missing definitions. */
+ if (messages == NULL)
+ {
+ /* First see whether we were supposed to copy. If yes, find the
+ actual definition. */
+ if (locale->copy_name[LC_MESSAGES] != NULL)
+ {
+ /* Find the copying locale. This has to happen transitively since
+ the locale we are copying from might also copying another one. */
+ struct localedef_t *from = locale;
+
+ do
+ from = find_locale (LC_MESSAGES, from->copy_name[LC_MESSAGES],
+ from->repertoire_name, charmap);
+ while (from->categories[LC_MESSAGES].messages == NULL
+ && from->copy_name[LC_MESSAGES] != NULL);
+
+ messages = locale->categories[LC_MESSAGES].messages
+ = from->categories[LC_MESSAGES].messages;
+ }
+
+ /* If there is still no definition issue an warning and create an
+ empty one. */
+ if (messages == NULL)
+ {
+ error (0, 0, _("No definition for %s category found"),
+ "LC_MESSAGES");
+ messages_startup (NULL, locale, 0);
+ messages = locale->categories[LC_MESSAGES].messages;
+ nothing = 1;
+ }
+ }
/* The fields YESSTR and NOSTR are optional. */
if (messages->yesstr == NULL)
if (messages->yesexpr == NULL)
{
- if (!be_quiet)
+ if (! be_quiet && ! nothing)
error (0, 0, _("%s: field `%s' undefined"), "LC_MESSAGES", "yesexpr");
messages->yesexpr = "";
}
if (messages->noexpr == NULL)
{
- if (!be_quiet)
+ if (! be_quiet && ! nothing)
error (0, 0, _("%s: field `%s' undefined"), "LC_MESSAGES", "noexpr");
messages->noexpr = "";
}
/* If we see `copy' now we are almost done. */
if (nowtok == tok_copy)
{
- handle_copy (ldfile, charmap, repertoire, tok_lc_messages, LC_MESSAGES,
- "LC_MESSAGES", ignore_content);
+ handle_copy (ldfile, charmap, repertoire, result, tok_lc_messages,
+ LC_MESSAGES, "LC_MESSAGES", ignore_content);
return;
}
{
#define STR_ELEM(cat) \
case tok_##cat: \
+ /* Ignore the rest of the line if we don't need the input of \
+ this line. */ \
+ if (ignore_content) \
+ { \
+ lr_ignore_rest (ldfile, 0); \
+ break; \
+ } \
+ \
if (messages->cat != NULL) \
{ \
lr_error (ldfile, _("\
monetary->duo_int_n_sign_posn = -2;
}
- lr->translate_strings = 1;
- lr->return_widestr = 0;
+ if (lr != NULL)
+ {
+ lr->translate_strings = 1;
+ lr->return_widestr = 0;
+ }
}
{
struct locale_monetary_t *monetary
= locale->categories[LC_MONETARY].monetary;
+ int nothing = 0;
+
+ /* Now resolve copying and also handle completely missing definitions. */
+ if (monetary == NULL)
+ {
+ /* First see whether we were supposed to copy. If yes, find the
+ actual definition. */
+ if (locale->copy_name[LC_MONETARY] != NULL)
+ {
+ /* Find the copying locale. This has to happen transitively since
+ the locale we are copying from might also copying another one. */
+ struct localedef_t *from = locale;
+
+ do
+ from = find_locale (LC_MONETARY, from->copy_name[LC_MONETARY],
+ from->repertoire_name, charmap);
+ while (from->categories[LC_MONETARY].monetary == NULL
+ && from->copy_name[LC_MONETARY] != NULL);
+
+ monetary = locale->categories[LC_MONETARY].monetary
+ = from->categories[LC_MONETARY].monetary;
+ }
+
+ /* If there is still no definition issue an warning and create an
+ empty one. */
+ if (monetary == NULL)
+ {
+ error (0, 0, _("No definition for %s category found"),
+ "LC_MONETARY");
+ monetary_startup (NULL, locale, 0);
+ monetary = locale->categories[LC_MONETARY].monetary;
+ nothing = 1;
+ }
+ }
#define TEST_ELEM(cat) \
if (monetary->cat == NULL && !be_quiet) \
{ \
- error (0, 0, _("%s: field `%s' not defined"), \
- "LC_MONETARY", #cat); \
+ if (! nothing) \
+ error (0, 0, _("%s: field `%s' not defined"), \
+ "LC_MONETARY", #cat); \
monetary->cat = ""; \
}
/* The decimal point must not be empty. This is not said explicitly
in POSIX but ANSI C (ISO/IEC 9899) says in 4.4.2.1 it has to be
!= "". */
- if (monetary->mon_decimal_point[0] == '\0' && !be_quiet)
+ if (monetary->mon_decimal_point[0] == '\0' && ! be_quiet && ! nothing)
{
error (0, 0, _("\
%s: value for field `%s' must not be the empty string"),
"LC_MONETARY", "mon_decimal_point");
}
- if (monetary->mon_grouping_len == 0 && !be_quiet)
+ if (monetary->mon_grouping_len == 0 && ! be_quiet && ! nothing)
error (0, 0, _("%s: field `%s' not defined"),
"LC_MONETARY", "mon_grouping");
#undef TEST_ELEM
#define TEST_ELEM(cat, min, max) \
- if (monetary->cat == -2 && !be_quiet) \
+ if (monetary->cat == -2 && ! be_quiet && ! nothing) \
error (0, 0, _("%s: field `%s' not defined"), \
"LC_MONETARY", #cat); \
else if ((monetary->cat < min || monetary->cat > max) && !be_quiet) \
#undef TEST_ELEM
#define TEST_ELEM(cat, alt, min, max) \
- if (monetary->cat == -2 && !be_quiet) \
+ if (monetary->cat == -2) \
monetary->cat = monetary->alt; \
- else if ((monetary->cat < min || monetary->cat > max) && !be_quiet) \
+ else if ((monetary->cat < min || monetary->cat > max) && !be_quiet \
+ && ! nothing) \
error (0, 0, _("\
%s: value for field `%s' must be in range %d...%d"), \
"LC_MONETARY", #cat, min, max)
/* If we see `copy' now we are almost done. */
if (nowtok == tok_copy)
{
- handle_copy (ldfile, charmap, repertoire, tok_lc_monetary, LC_MONETARY,
- "LC_MONETARY", ignore_content);
+ handle_copy (ldfile, charmap, repertoire, result, tok_lc_monetary,
+ LC_MONETARY, "LC_MONETARY", ignore_content);
return;
}
{
#define STR_ELEM(cat) \
case tok_##cat: \
+ /* Ignore the rest of the line if we don't need the input of \
+ this line. */ \
+ if (ignore_content) \
+ { \
+ lr_ignore_rest (ldfile, 0); \
+ break; \
+ } \
+ \
now = lr_token (ldfile, charmap, NULL); \
if (now->tok != tok_string) \
goto err_label; \
#define INT_ELEM(cat) \
case tok_##cat: \
+ /* Ignore the rest of the line if we don't need the input of \
+ this line. */ \
+ if (ignore_content) \
+ { \
+ lr_ignore_rest (ldfile, 0); \
+ break; \
+ } \
+ \
now = lr_token (ldfile, charmap, NULL); \
if (now->tok != tok_minus1 && now->tok != tok_number) \
goto err_label; \
INT_ELEM (duo_valid_to);
case tok_mon_grouping:
+ /* Ignore the rest of the line if we don't need the input of
+ this line. */
+ if (ignore_content)
+ {
+ lr_ignore_rest (ldfile, 0);
+ break;
+ }
+
now = lr_token (ldfile, charmap, NULL);
if (now->tok != tok_minus1 && now->tok != tok_number)
goto err_label;
break;
case tok_conversion_rate:
+ /* Ignore the rest of the line if we don't need the input of
+ this line. */
+ if (ignore_content)
+ {
+ lr_ignore_rest (ldfile, 0);
+ break;
+ }
+
now = lr_token (ldfile, charmap, NULL);
if (now->tok != tok_number)
goto err_label;
locale->categories[LC_NAME].name =
(struct locale_name_t *) xcalloc (1, sizeof (struct locale_name_t));
- lr->translate_strings = 1;
- lr->return_widestr = 0;
+ if (lr != NULL)
+ {
+ lr->translate_strings = 1;
+ lr->return_widestr = 0;
+ }
}
name_finish (struct localedef_t *locale, struct charmap_t *charmap)
{
struct locale_name_t *name = locale->categories[LC_NAME].name;
+ int nothing = 0;
+
+ /* Now resolve copying and also handle completely missing definitions. */
+ if (name == NULL)
+ {
+ /* First see whether we were supposed to copy. If yes, find the
+ actual definition. */
+ if (locale->copy_name[LC_NAME] != NULL)
+ {
+ /* Find the copying locale. This has to happen transitively since
+ the locale we are copying from might also copying another one. */
+ struct localedef_t *from = locale;
+
+ do
+ from = find_locale (LC_NAME, from->copy_name[LC_NAME],
+ from->repertoire_name, charmap);
+ while (from->categories[LC_NAME].name == NULL
+ && from->copy_name[LC_NAME] != NULL);
+
+ name = locale->categories[LC_NAME].name
+ = from->categories[LC_NAME].name;
+ }
+
+ /* If there is still no definition issue an warning and create an
+ empty one. */
+ if (name == NULL)
+ {
+ error (0, 0, _("No definition for %s category found"), "LC_NAME");
+ name_startup (NULL, locale, 0);
+ name = locale->categories[LC_NAME].name;
+ nothing = 1;
+ }
+ }
if (name->name_fmt == NULL)
{
- error (0, 0, _("%s: field `%s' not defined"), "LC_NAME", "name_fmt");
+ if (! nothing)
+ error (0, 0, _("%s: field `%s' not defined"), "LC_NAME", "name_fmt");
/* Use as the default value the value of the i18n locale. */
name->name_fmt = "%p%t%g%t%m%t%f";
}
#define TEST_ELEM(cat) \
if (name->cat == NULL) \
{ \
- if (verbose) \
+ if (verbose && ! nothing) \
error (0, 0, _("%s: field `%s' not defined"), "LC_NAME", #cat); \
name->cat = ""; \
}
/* If we see `copy' now we are almost done. */
if (nowtok == tok_copy)
{
- handle_copy (ldfile, charmap, repertoire, tok_lc_name, LC_NAME,
+ handle_copy (ldfile, charmap, repertoire, result, tok_lc_name, LC_NAME,
"LC_NAME", ignore_content);
return;
}
{
#define STR_ELEM(cat) \
case tok_##cat: \
+ /* Ignore the rest of the line if we don't need the input of \
+ this line. */ \
+ if (ignore_content) \
+ { \
+ lr_ignore_rest (ldfile, 0); \
+ break; \
+ } \
+ \
arg = lr_token (ldfile, charmap, NULL); \
if (arg->tok != tok_string) \
goto err_label; \
numeric->grouping_len = 0;
}
- lr->translate_strings = 1;
- lr->return_widestr = 0;
+ if (lr != NULL)
+ {
+ lr->translate_strings = 1;
+ lr->return_widestr = 0;
+ }
}
numeric_finish (struct localedef_t *locale, struct charmap_t *charmap)
{
struct locale_numeric_t *numeric = locale->categories[LC_NUMERIC].numeric;
+ int nothing = 0;
+
+ /* Now resolve copying and also handle completely missing definitions. */
+ if (numeric == NULL)
+ {
+ /* First see whether we were supposed to copy. If yes, find the
+ actual definition. */
+ if (locale->copy_name[LC_NUMERIC] != NULL)
+ {
+ /* Find the copying locale. This has to happen transitively since
+ the locale we are copying from might also copying another one. */
+ struct localedef_t *from = locale;
+
+ do
+ from = find_locale (LC_NUMERIC, from->copy_name[LC_NUMERIC],
+ from->repertoire_name, charmap);
+ while (from->categories[LC_NUMERIC].numeric == NULL
+ && from->copy_name[LC_NUMERIC] != NULL);
+
+ numeric = locale->categories[LC_NUMERIC].numeric
+ = from->categories[LC_NUMERIC].numeric;
+ }
+
+ /* If there is still no definition issue an warning and create an
+ empty one. */
+ if (numeric == NULL)
+ {
+ error (0, 0, _("No definition for %s category found"), "LC_NUMERIC");
+ numeric_startup (NULL, locale, 0);
+ numeric = locale->categories[LC_NUMERIC].numeric;
+ nothing = 1;
+ }
+ }
#define TEST_ELEM(cat) \
- if (numeric->cat == NULL && !be_quiet) \
+ if (numeric->cat == NULL && ! be_quiet && ! nothing) \
error (0, 0, _("%s: field `%s' not defined"), "LC_NUMERIC", #cat)
TEST_ELEM (decimal_point);
/* The decimal point must not be empty. This is not said explicitly
in POSIX but ANSI C (ISO/IEC 9899) says in 4.4.2.1 it has to be
!= "". */
- if (numeric->decimal_point[0] == '\0' && !be_quiet)
+ if (numeric->decimal_point[0] == '\0' && ! be_quiet && ! nothing)
{
error (0, 0, _("\
%s: value for field `%s' must not be the empty string"),
"LC_NUMERIC", "decimal_point");
}
- if (numeric->grouping_len == 0 && !be_quiet)
+ if (numeric->grouping_len == 0 && ! be_quiet && ! nothing)
error (0, 0, _("%s: field `%s' not defined"), "LC_NUMERIC", "grouping");
}
/* If we see `copy' now we are almost done. */
if (nowtok == tok_copy)
{
- handle_copy (ldfile, charmap, repertoire, tok_lc_numeric, LC_NUMERIC,
- "LC_NUMERIC", ignore_content);
+ handle_copy (ldfile, charmap, repertoire, result, tok_lc_numeric,
+ LC_NUMERIC, "LC_NUMERIC", ignore_content);
return;
}
{
#define STR_ELEM(cat) \
case tok_##cat: \
+ /* Ignore the rest of the line if we don't need the input of \
+ this line. */ \
+ if (ignore_content) \
+ { \
+ lr_ignore_rest (ldfile, 0); \
+ break; \
+ } \
+ \
now = lr_token (ldfile, charmap, NULL); \
if (now->tok != tok_string) \
goto err_label; \
STR_ELEM (thousands_sep);
case tok_grouping:
+ /* Ignore the rest of the line if we don't need the input of
+ this line. */
+ if (ignore_content)
+ {
+ lr_ignore_rest (ldfile, 0);
+ break;
+ }
+
now = lr_token (ldfile, charmap, NULL);
if (now->tok != tok_minus1 && now->tok != tok_number)
goto err_label;
locale->categories[LC_PAPER].paper =
(struct locale_paper_t *) xcalloc (1, sizeof (struct locale_paper_t));
- lr->translate_strings = 1;
- lr->return_widestr = 0;
+ if (lr != NULL)
+ {
+ lr->translate_strings = 1;
+ lr->return_widestr = 0;
+ }
}
paper_finish (struct localedef_t *locale, struct charmap_t *charmap)
{
struct locale_paper_t *paper = locale->categories[LC_PAPER].paper;
+ int nothing = 0;
+
+ /* Now resolve copying and also handle completely missing definitions. */
+ if (paper == NULL)
+ {
+ /* First see whether we were supposed to copy. If yes, find the
+ actual definition. */
+ if (locale->copy_name[LC_PAPER] != NULL)
+ {
+ /* Find the copying locale. This has to happen transitively since
+ the locale we are copying from might also copying another one. */
+ struct localedef_t *from = locale;
+
+ do
+ from = find_locale (LC_PAPER, from->copy_name[LC_PAPER],
+ from->repertoire_name, charmap);
+ while (from->categories[LC_PAPER].paper == NULL
+ && from->copy_name[LC_PAPER] != NULL);
+
+ paper = locale->categories[LC_PAPER].paper
+ = from->categories[LC_PAPER].paper;
+ }
+
+ /* If there is still no definition issue an warning and create an
+ empty one. */
+ if (paper == NULL)
+ {
+ error (0, 0, _("No definition for %s category found"), "LC_PAPER");
+ paper_startup (NULL, locale, 0);
+ paper = locale->categories[LC_PAPER].paper;
+ nothing = 1;
+ }
+ }
if (paper->height == 0)
{
- error (0, 0, _("%s: field `%s' not defined"), "LC_PAPER", "height");
+ if (! nothing)
+ error (0, 0, _("%s: field `%s' not defined"), "LC_PAPER", "height");
/* Use as default values the values from the i18n locale. */
paper->height = 297;
}
if (paper->width == 0)
{
- error (0, 0, _("%s: field `%s' not defined"), "LC_PAPER", "width");
+ if (! nothing)
+ error (0, 0, _("%s: field `%s' not defined"), "LC_PAPER", "width");
/* Use as default values the values from the i18n locale. */
paper->width = 210;
}
/* If we see `copy' now we are almost done. */
if (nowtok == tok_copy)
{
- handle_copy (ldfile, charmap, repertoire, tok_lc_paper, LC_PAPER,
- "LC_PAPER", ignore_content);
+ handle_copy (ldfile, charmap, repertoire, result, tok_lc_paper,
+ LC_PAPER, "LC_PAPER", ignore_content);
return;
}
{
#define INT_ELEM(cat) \
case tok_##cat: \
+ /* Ignore the rest of the line if we don't need the input of \
+ this line. */ \
+ if (ignore_content) \
+ { \
+ lr_ignore_rest (ldfile, 0); \
+ break; \
+ } \
+ \
arg = lr_token (ldfile, charmap, NULL); \
if (arg->tok != tok_number) \
goto err_label; \
locale->categories[LC_TELEPHONE].telephone = (struct locale_telephone_t *)
xcalloc (1, sizeof (struct locale_telephone_t));
- lr->translate_strings = 1;
- lr->return_widestr = 0;
+ if (lr != NULL)
+ {
+ lr->translate_strings = 1;
+ lr->return_widestr = 0;
+ }
}
{
struct locale_telephone_t *telephone =
locale->categories[LC_TELEPHONE].telephone;
+ int nothing = 0;
+
+ /* Now resolve copying and also handle completely missing definitions. */
+ if (telephone == NULL)
+ {
+ /* First see whether we were supposed to copy. If yes, find the
+ actual definition. */
+ if (locale->copy_name[LC_TELEPHONE] != NULL)
+ {
+ /* Find the copying locale. This has to happen transitively since
+ the locale we are copying from might also copying another one. */
+ struct localedef_t *from = locale;
+
+ do
+ from = find_locale (LC_TELEPHONE, from->copy_name[LC_TELEPHONE],
+ from->repertoire_name, charmap);
+ while (from->categories[LC_TELEPHONE].telephone == NULL
+ && from->copy_name[LC_TELEPHONE] != NULL);
+
+ telephone = locale->categories[LC_TELEPHONE].telephone
+ = from->categories[LC_TELEPHONE].telephone;
+ }
+
+ /* If there is still no definition issue an warning and create an
+ empty one. */
+ if (telephone == NULL)
+ {
+ error (0, 0, _("No definition for %s category found"),
+ "LC_TELEPHONE");
+ telephone_startup (NULL, locale, 0);
+ telephone = locale->categories[LC_TELEPHONE].telephone;
+ nothing = 1;
+ }
+ }
if (telephone->tel_int_fmt == NULL)
{
- error (0, 0, _("%s: field `%s' not defined"),
- "LC_TELEPHONE", "tel_int_fmt");
+ if (! nothing)
+ error (0, 0, _("%s: field `%s' not defined"),
+ "LC_TELEPHONE", "tel_int_fmt");
/* Use as the default value the value of the i18n locale. */
telephone->tel_int_fmt = "+%c %a %l";
}
#define TEST_ELEM(cat) \
if (telephone->cat == NULL) \
{ \
- if (verbose) \
+ if (verbose && ! nothing) \
error (0, 0, _("%s: field `%s' not defined"), "LC_TELEPHONE", #cat); \
telephone->cat = ""; \
}
/* If we see `copy' now we are almost done. */
if (nowtok == tok_copy)
{
- handle_copy (ldfile, charmap, repertoire, tok_lc_telephone, LC_TELEPHONE,
- "LC_TELEPHONE", ignore_content);
+ handle_copy (ldfile, charmap, repertoire, result, tok_lc_telephone,
+ LC_TELEPHONE, "LC_TELEPHONE", ignore_content);
return;
}
{
#define STR_ELEM(cat) \
case tok_##cat: \
+ /* Ignore the rest of the line if we don't need the input of \
+ this line. */ \
+ if (ignore_content) \
+ { \
+ lr_ignore_rest (ldfile, 0); \
+ break; \
+ } \
+ \
arg = lr_token (ldfile, charmap, NULL); \
if (arg->tok != tok_string) \
goto err_label; \
locale->categories[LC_TIME].time =
(struct locale_time_t *) xcalloc (1, sizeof (struct locale_time_t));
- lr->translate_strings = 1;
- lr->return_widestr = 0;
+ if (time != NULL)
+ {
+ lr->translate_strings = 1;
+ lr->return_widestr = 0;
+ }
}
{
struct locale_time_t *time = locale->categories[LC_TIME].time;
size_t cnt;
+ int nothing = 0;
+
+ /* Now resolve copying and also handle completely missing definitions. */
+ if (time == NULL)
+ {
+ /* First see whether we were supposed to copy. If yes, find the
+ actual definition. */
+ if (locale->copy_name[LC_TIME] != NULL)
+ {
+ /* Find the copying locale. This has to happen transitively since
+ the locale we are copying from might also copying another one. */
+ struct localedef_t *from = locale;
+
+ do
+ from = find_locale (LC_TIME, from->copy_name[LC_TIME],
+ from->repertoire_name, charmap);
+ while (from->categories[LC_TIME].time == NULL
+ && from->copy_name[LC_TIME] != NULL);
+
+ time = locale->categories[LC_TIME].time
+ = from->categories[LC_TIME].time;
+ }
+
+ /* If there is still no definition issue an warning and create an
+ empty one. */
+ if (time == NULL)
+ {
+ error (0, 0, _("No definition for %s category found"), "LC_TIME");
+ time_startup (NULL, locale, 0);
+ time = locale->categories[LC_TIME].time;
+ nothing = 1;
+ }
+ }
#define TESTARR_ELEM(cat) \
- if (!time->cat##_defined && !be_quiet) \
- error (0, 0, _("%s: field `%s' not defined"), "LC_TIME", #cat); \
+ if (!time->cat##_defined) \
+ { \
+ if(! be_quiet && ! nothing) \
+ error (0, 0, _("%s: field `%s' not defined"), "LC_TIME", #cat); \
+ } \
else if (time->w##cat != NULL) \
{ \
size_t n; \
TESTARR_ELEM (am_pm);
#define TEST_ELEM(cat) \
- if (time->cat == NULL && !be_quiet) \
- error (0, 0, _("%s: field `%s' not defined"), "LC_TIME", #cat); \
+ if (time->cat == NULL) \
+ { \
+ if (! be_quiet && ! nothing) \
+ error (0, 0, _("%s: field `%s' not defined"), "LC_TIME", #cat); \
+ } \
else if (time->w##cat != NULL) \
{ \
size_t len = wcslen ((wchar_t *) time->w##cat) + 1; \
iov[2 + cnt].iov_base = (void *) time->timezone;
iov[2 + cnt].iov_len = strlen (time->timezone) + 1;
- idx[1 + last_idx] = idx[last_idx] + iov[2 + cnt].iov_len;
++cnt;
++last_idx;
/* If we see `copy' now we are almost done. */
if (nowtok == tok_copy)
{
- handle_copy (ldfile, charmap, repertoire, tok_lc_time, LC_TIME,
- "LC_TIME", ignore_content);
+ handle_copy (ldfile, charmap, repertoire, result, tok_lc_time,
+ LC_TIME, "LC_TIME", ignore_content);
return;
}
{
#define STRARR_ELEM(cat, min, max) \
case tok_##cat: \
+ /* Ignore the rest of the line if we don't need the input of \
+ this line. */ \
+ if (ignore_content) \
+ { \
+ lr_ignore_rest (ldfile, 0); \
+ break; \
+ } \
+ \
for (cnt = 0; cnt < max; ++cnt) \
{ \
now = lr_token (ldfile, charmap, repertoire); \
STRARR_ELEM (alt_digits, 0, 100);
case tok_era:
+ /* Ignore the rest of the line if we don't need the input of
+ this line. */
+ if (ignore_content)
+ {
+ lr_ignore_rest (ldfile, 0);
+ break;
+ }
+
do
{
now = lr_token (ldfile, charmap, NULL);
#define STR_ELEM(cat) \
case tok_##cat: \
+ /* Ignore the rest of the line if we don't need the input of \
+ this line. */ \
+ if (ignore_content) \
+ { \
+ lr_ignore_rest (ldfile, 0); \
+ break; \
+ } \
+ \
now = lr_token (ldfile, charmap, NULL); \
if (now->tok != tok_string) \
goto err_label; \
#define INT_ELEM(cat) \
case tok_##cat: \
+ /* Ignore the rest of the line if we don't need the input of \
+ this line. */ \
+ if (ignore_content) \
+ { \
+ lr_ignore_rest (ldfile, 0); \
+ break; \
+ } \
+ \
now = lr_token (ldfile, charmap, NULL); \
if (now->tok != tok_number) \
goto err_label; \
INT_ELEM (cal_direction);
case tok_week:
+ /* Ignore the rest of the line if we don't need the input of
+ this line. */
+ if (ignore_content)
+ {
+ lr_ignore_rest (ldfile, 0);
+ break;
+ }
+
now = lr_token (ldfile, charmap, NULL);
if (now->tok != tok_number)
goto err_label;
#include <fcntl.h>
#include <libintl.h>
#include <locale.h>
+#include <mcheck.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct localedef_t global;
int remaining;
+ /* Enable `malloc' debugging. */
+ mcheck (NULL);
+
/* Set initial values for global variables. */
copy_list = NULL;
posix_conformance = getenv ("POSIXLY_CORRECT") != NULL;
{
struct localedef_t *runp = locales;
- while (runp != NULL && runp->needed == runp->avail)
+ while (runp != NULL && (runp->needed & runp->avail) == runp->needed)
runp = runp->next;
if (runp == NULL)
struct localedef_t *
-add_to_readlist (int locale, const char *name, const char *repertoire_name)
+add_to_readlist (int locale, const char *name, const char *repertoire_name,
+ int generate)
{
struct localedef_t *runp = locales;
if (runp == NULL)
{
/* Add a new entry at the end. */
- struct localedef_t *newp = xcalloc (1, sizeof (struct localedef_t));
+ struct localedef_t *newp;
+
+ assert (generate == 1);
+
+ newp = xcalloc (1, sizeof (struct localedef_t));
newp->name = name;
newp->repertoire_name = repertoire_name;
}
}
- if ((runp->needed & (1 << locale)) != 0)
+ if (generate && (runp->needed & (1 << locale)) != 0)
error (5, 0, _("circular dependencies between locale definitions"));
runp->needed |= 1 << locale;
find_locale (int locale, const char *name, const char *repertoire_name,
struct charmap_t *charmap)
{
- struct localedef_t *result = add_to_readlist (locale, name, repertoire_name);
+ struct localedef_t *result;
+
+ /* Find the locale, but do not generate it since this would be a bug. */
+ result = add_to_readlist (locale, name, repertoire_name, 0);
+
+ assert (result != NULL);
- if (locfile_read (result, charmap) != 0)
+ if ((result->avail & (1 << locale)) == 0
+ && locfile_read (result, charmap) != 0)
error (4, errno, _("cannot open locale definition file `%s'"),
result->name);
struct locale_telephone_t *telephone;
struct locale_measurement_t *measurement;
struct locale_identification_t *identification;
- } categories[12];
+ } categories[__LC_LAST];
- size_t len[12];
+ size_t len[__LC_LAST];
+
+ const char *copy_name[__LC_LAST];
const char *repertoire_name;
};
/* Mark given locale as to be read. */
extern struct localedef_t *add_to_readlist (int locale, const char *name,
- const char *repertoire_name);
+ const char *repertoire_name,
+ int generate);
/* Find the information for the locale NAME. */
extern struct localedef_t *find_locale (int locale, const char *name,
+++ /dev/null
-/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-#ifndef _LOCALES_H
-#define _LOCALES_H
-
-#include <ctype.h>
-
-/* Undefine following line in production version. */
-/* #define NDEBUG 1 */
-#include <assert.h>
-
-#include "linereader.h"
-#include "locfile-token.h"
-#include "charset.h"
-#include "locfile.h"
-#include "localeinfo.h"
-
-
-/* List of locale definition files which are used in `copy' instructions. */
-struct copy_def_list_t
-{
- struct copy_def_list_t *next;
-
- const char *name;
- int mask;
-
- struct localedef_t *locale;
-
- struct
- {
- void *data;
- size_t len;
- } binary[6];
-};
-
-extern struct copy_def_list_t copy_posix;
-
-
-/* Header of the locale data files. */
-struct locale_file
-{
- int magic;
- int n;
-};
-
-
-/* Handle LC_CTYPE category. */
-
-static inline unsigned int
-charclass_to_bit (enum token_t tok)
-{
- static unsigned int lastbit = _ISalnum;
-
- switch (tok)
- {
-#define CLASS(name) case tok_##name: return _IS##name
- CLASS (upper);
- CLASS (lower);
- CLASS (alpha);
- CLASS (digit);
- CLASS (alnum);
- CLASS (space);
- CLASS (cntrl);
- CLASS (punct);
- CLASS (graph);
- CLASS (print);
- CLASS (xdigit);
- CLASS (blank);
-#undef CLASS
- case tok_string:
- lastbit <<= 1;
- if (lastbit == 0ul)
- /* Exit status 2 means a limitation in the implementation is
- exceeded. */
- error (2, 0, _("too many character classes defined"));
- return lastbit;
- default:
- assert (1 == 0);
- }
- return 0;
-}
-
-/* Remember name of newly created charclass. */
-void ctype_startup (struct linereader *lr, struct localedef_t *locale,
- struct charset_t *charset);
-void ctype_finish (struct localedef_t *locale, struct charset_t *charset);
-
-void ctype_output (struct localedef_t *locale, struct charset_t *charset,
- const char *output_path);
-
-int ctype_is_charclass (struct linereader *lr, struct localedef_t *locale,
- const char *name);
-void ctype_class_new (struct linereader *lr, struct localedef_t *locale,
- enum token_t tok, struct token *code,
- struct charset_t *charset);
-void ctype_class_start (struct linereader *lr, struct localedef_t *locale,
- enum token_t tok, const char *name,
- struct charset_t *charset);
-void ctype_class_from (struct linereader *lr, struct localedef_t *locale,
- struct token *code, struct charset_t *charset);
-void ctype_class_to (struct linereader *lr, struct localedef_t *locale,
- struct token *code, struct charset_t *charset);
-void ctype_class_end (struct linereader *lr, struct localedef_t *locale);
-
-int ctype_is_charconv (struct linereader *lr, struct localedef_t *locale,
- const char *name);
-void ctype_map_new (struct linereader *lr, struct localedef_t *locale,
- enum token_t tok, struct token *code,
- struct charset_t *charset);
-void ctype_map_start (struct linereader *lr, struct localedef_t *locale,
- enum token_t tok, const char *name,
- struct charset_t *charset);
-void ctype_map_from (struct linereader *lr, struct localedef_t *locale,
- struct token *code, struct charset_t *charset);
-void ctype_map_to (struct linereader *lr, struct localedef_t *locale,
- struct token *code, struct charset_t *charset);
-void ctype_map_end (struct linereader *lr, struct localedef_t *locale);
-
-
-/* Handle LC_COLLATE category. */
-
-void collate_startup (struct linereader *lr, struct localedef_t *locale,
- struct charset_t *charset);
-
-void collate_finish (struct localedef_t *locale,
- struct charset_t *charset);
-
-void collate_output (struct localedef_t *locale, struct charset_t *charset,
- const char *output_path);
-
-void collate_element_to (struct linereader *lr, struct localedef_t *locale,
- struct token *code, struct charset_t *charset);
-void collate_element_from (struct linereader *lr,
- struct localedef_t *locale, struct token *code,
- struct charset_t *charset);
-void collate_symbol (struct linereader *lr, struct localedef_t *locale,
- struct token *code, struct charset_t *charset);
-void collate_new_order (struct linereader *lr, struct localedef_t *locale,
- enum coll_sort_rule sort_rule);
-void collate_build_arrays (struct linereader *lr,
- struct localedef_t *locale);
-int collate_order_elem (struct linereader *lr, struct localedef_t *locale,
- struct token *code, struct charset_t *charset);
-int collate_weight_bsymbol (struct linereader *lr,
- struct localedef_t *locale,
- struct token *code, struct charset_t *charset);
-int collate_next_weight (struct linereader *lr,
- struct localedef_t *locale);
-int collate_simple_weight (struct linereader *lr,
- struct localedef_t *locale,
- struct token *code, struct charset_t *charset);
-void collate_end_weight (struct linereader *lr,
- struct localedef_t *locale);
-
-
-/* Handle LC_MONETARY category. */
-
-void monetary_startup (struct linereader *lr, struct localedef_t *locale,
- struct charset_t *charset);
-
-void monetary_finish (struct localedef_t *locale);
-
-void monetary_output (struct localedef_t *locale, const char *output_path);
-
-void monetary_add (struct linereader *lr, struct localedef_t *locale,
- enum token_t tok, struct token *code,
- struct charset_t *charset);
-
-
-/* Handle LC_NUMERIC category. */
-
-void numeric_startup (struct linereader *lr, struct localedef_t *locale,
- struct charset_t *charset);
-
-void numeric_finish (struct localedef_t *locale);
-
-void numeric_output (struct localedef_t *locale, const char *output_path);
-
-void numeric_add (struct linereader *lr, struct localedef_t *locale,
- enum token_t tok, struct token *code,
- struct charset_t *charset);
-
-
-/* Handle LC_TIME category. */
-
-void time_startup (struct linereader *lr, struct localedef_t *locale,
- struct charset_t *charset);
-
-void time_finish (struct localedef_t *locale);
-
-void time_output (struct localedef_t *locale, const char *output_path);
-
-void time_add (struct linereader *lr, struct localedef_t *locale,
- enum token_t tok, struct token *code,
- struct charset_t *charset);
-
-
-/* Handle LC_MESSAGES category. */
-
-void messages_startup (struct linereader *lr, struct localedef_t *locale,
- struct charset_t *charset);
-
-void messages_finish (struct localedef_t *locale);
-
-void messages_output (struct localedef_t *locale, const char *output_path);
-
-void messages_add (struct linereader *lr, struct localedef_t *locale,
- enum token_t tok, struct token *code,
- struct charset_t *charset);
-
-
-#endif /* locales.h */
const char *repertoire_name = result->repertoire_name;
int locale_mask = result->needed ^ result->avail;
struct linereader *ldfile;
+ int not_here = ALL_LOCALES;
/* If no repertoire name was specified use the global one. */
if (repertoire_name == NULL)
ctype_read (ldfile, result, charmap, repertoire_name,
(locale_mask & CTYPE_LOCALE) == 0);
result->avail |= locale_mask & CTYPE_LOCALE;
+ not_here ^= CTYPE_LOCALE;
continue;
case tok_lc_collate:
collate_read (ldfile, result, charmap, repertoire_name,
(locale_mask & COLLATE_LOCALE) == 0);
result->avail |= locale_mask & COLLATE_LOCALE;
+ not_here ^= COLLATE_LOCALE;
continue;
case tok_lc_monetary:
monetary_read (ldfile, result, charmap, repertoire_name,
(locale_mask & MONETARY_LOCALE) == 0);
result->avail |= locale_mask & MONETARY_LOCALE;
+ not_here ^= MONETARY_LOCALE;
continue;
case tok_lc_numeric:
numeric_read (ldfile, result, charmap, repertoire_name,
(locale_mask & NUMERIC_LOCALE) == 0);
result->avail |= locale_mask & NUMERIC_LOCALE;
+ not_here ^= NUMERIC_LOCALE;
continue;
case tok_lc_time:
time_read (ldfile, result, charmap, repertoire_name,
(locale_mask & TIME_LOCALE) == 0);
result->avail |= locale_mask & TIME_LOCALE;
+ not_here ^= TIME_LOCALE;
continue;
case tok_lc_messages:
messages_read (ldfile, result, charmap, repertoire_name,
(locale_mask & MESSAGES_LOCALE) == 0);
result->avail |= locale_mask & MESSAGES_LOCALE;
+ not_here ^= MESSAGES_LOCALE;
continue;
case tok_lc_paper:
paper_read (ldfile, result, charmap, repertoire_name,
(locale_mask & PAPER_LOCALE) == 0);
result->avail |= locale_mask & PAPER_LOCALE;
+ not_here ^= PAPER_LOCALE;
continue;
case tok_lc_name:
name_read (ldfile, result, charmap, repertoire_name,
(locale_mask & NAME_LOCALE) == 0);
result->avail |= locale_mask & NAME_LOCALE;
+ not_here ^= NAME_LOCALE;
continue;
case tok_lc_address:
address_read (ldfile, result, charmap, repertoire_name,
(locale_mask & ADDRESS_LOCALE) == 0);
result->avail |= locale_mask & ADDRESS_LOCALE;
+ not_here ^= ADDRESS_LOCALE;
continue;
case tok_lc_telephone:
telephone_read (ldfile, result, charmap, repertoire_name,
(locale_mask & TELEPHONE_LOCALE) == 0);
result->avail |= locale_mask & TELEPHONE_LOCALE;
+ not_here ^= TELEPHONE_LOCALE;
continue;
case tok_lc_measurement:
measurement_read (ldfile, result, charmap, repertoire_name,
(locale_mask & MEASUREMENT_LOCALE) == 0);
result->avail |= locale_mask & MEASUREMENT_LOCALE;
+ not_here ^= MEASUREMENT_LOCALE;
continue;
case tok_lc_identification:
identification_read (ldfile, result, charmap, repertoire_name,
(locale_mask & IDENTIFICATION_LOCALE) == 0);
result->avail |= locale_mask & IDENTIFICATION_LOCALE;
+ not_here ^= IDENTIFICATION_LOCALE;
continue;
default:
/* We read all of the file. */
lr_close (ldfile);
+ /* Mark the categories which are not contained in the file. We assume
+ them to be available and the default data will be used. */
+ result->avail |= not_here;
+
return 0;
}
int cnt;
for (cnt = 0; cnt < sizeof (write_funcs) / sizeof (write_funcs[0]); ++cnt)
- if (check_funcs[cnt] != NULL)
+ if (write_funcs[cnt] != NULL)
write_funcs[cnt] (definitions, charmap, output_path);
}
/* General handling of `copy'. */
static inline void
handle_copy (struct linereader *ldfile, struct charmap_t *charmap,
- struct repertoire_t *repertoire, enum token_t token, int locale,
- const char *locale_name, int ignore_content)
+ struct repertoire_t *repertoire, struct localedef_t *result,
+ enum token_t token, int locale, const char *locale_name,
+ int ignore_content)
{
struct token *now;
int warned = 0;
lr_error (ldfile, _("\
locale name should consist only of portable characters"));
else
- (void) add_to_readlist (locale, now->val.str.startmb,
- repertoire->name);
+ {
+ (void) add_to_readlist (locale, now->val.str.startmb,
+ repertoire->name, 1);
+ result->copy_name[locale] = now->val.str.startmb;
+ }
}
lr_ignore_rest (ldfile, now->tok == tok_string);
/* The rest of the line must be empty and the next keyword must be
`END xxx'. */
- while (lr_token (ldfile, charmap, NULL)->tok != tok_end)
+ while ((now = lr_token (ldfile, charmap, NULL))->tok != tok_end
+ && now->tok != tok_eof)
{
if (warned == 0)
{
lr_ignore_rest (ldfile, 0);
}
- /* Handle `END xxx'. */
- if (now->tok != token)
- lr_error (ldfile, _("\
+ if (now->tok != tok_eof)
+ {
+ /* Handle `END xxx'. */
+ now = lr_token (ldfile, charmap, NULL);
+
+ if (now->tok != token)
+ lr_error (ldfile, _("\
`%1$s' definition does not end with `END %1$s'"), locale_name);
- lr_ignore_rest (ldfile, now->tok == token);
+ lr_ignore_rest (ldfile, now->tok == token);
+ }
+ else
+ /* When we come here we reached the end of the file. */
+ lr_error (ldfile, _("%s: premature end of file"), locale_name);
}