Back to index

glibc  2.9
Classes | Defines | Functions
locfile.h File Reference
#include <sys/uio.h>
#include "linereader.h"
#include "localedef.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  locale_file

Defines

#define SYNTAX_ERROR(string, args...)

Functions

void handle_copy (struct linereader *ldfile, const struct charmap_t *charmap, const char *repertoire_name, struct localedef_t *result, enum token_t token, int locale, const char *locale_name, int ignore_content)
int locfile_read (struct localedef_t *result, const struct charmap_t *charmap)
void check_all_categories (struct localedef_t *definitions, const struct charmap_t *charmap)
void write_all_categories (struct localedef_t *definitions, const struct charmap_t *charmap, const char *locname, const char *output_path)
void write_locale_data (const char *output_path, int catidx, const char *category, size_t n_elem, struct iovec *vec)
void ctype_read (struct linereader *ldfile, struct localedef_t *result, const struct charmap_t *charmap, const char *repertoire_name, int ignore_content)
void ctype_finish (struct localedef_t *locale, const struct charmap_t *charmap)
void ctype_output (struct localedef_t *locale, const struct charmap_t *charmap, const char *output_path)
uint32_tfind_translit (struct localedef_t *locale, const struct charmap_t *charmap, uint32_t wch)
void collate_read (struct linereader *ldfile, struct localedef_t *result, const struct charmap_t *charmap, const char *repertoire_name, int ignore_content)
void collate_finish (struct localedef_t *locale, const struct charmap_t *charmap)
void collate_output (struct localedef_t *locale, const struct charmap_t *charmap, const char *output_path)
void monetary_read (struct linereader *ldfile, struct localedef_t *result, const struct charmap_t *charmap, const char *repertoire_name, int ignore_content)
void monetary_finish (struct localedef_t *locale, const struct charmap_t *charmap)
void monetary_output (struct localedef_t *locale, const struct charmap_t *charmap, const char *output_path)
void numeric_read (struct linereader *ldfile, struct localedef_t *result, const struct charmap_t *charmap, const char *repertoire_name, int ignore_content)
void numeric_finish (struct localedef_t *locale, const struct charmap_t *charmap)
void numeric_output (struct localedef_t *locale, const struct charmap_t *charmap, const char *output_path)
void messages_read (struct linereader *ldfile, struct localedef_t *result, const struct charmap_t *charmap, const char *repertoire_name, int ignore_content)
void messages_finish (struct localedef_t *locale, const struct charmap_t *charmap)
void messages_output (struct localedef_t *locale, const struct charmap_t *charmap, const char *output_path)
void time_read (struct linereader *ldfile, struct localedef_t *result, const struct charmap_t *charmap, const char *repertoire_name, int ignore_content)
void time_finish (struct localedef_t *locale, const struct charmap_t *charmap)
void time_output (struct localedef_t *locale, const struct charmap_t *charmap, const char *output_path)
void paper_read (struct linereader *ldfile, struct localedef_t *result, const struct charmap_t *charmap, const char *repertoire_name, int ignore_content)
void paper_finish (struct localedef_t *locale, const struct charmap_t *charmap)
void paper_output (struct localedef_t *locale, const struct charmap_t *charmap, const char *output_path)
void name_read (struct linereader *ldfile, struct localedef_t *result, const struct charmap_t *charmap, const char *repertoire_name, int ignore_content)
void name_finish (struct localedef_t *locale, const struct charmap_t *charmap)
void name_output (struct localedef_t *locale, const struct charmap_t *charmap, const char *output_path)
void address_read (struct linereader *ldfile, struct localedef_t *result, const struct charmap_t *charmap, const char *repertoire_name, int ignore_content)
void address_finish (struct localedef_t *locale, const struct charmap_t *charmap)
void address_output (struct localedef_t *locale, const struct charmap_t *charmap, const char *output_path)
void telephone_read (struct linereader *ldfile, struct localedef_t *result, const struct charmap_t *charmap, const char *repertoire_name, int ignore_content)
void telephone_finish (struct localedef_t *locale, const struct charmap_t *charmap)
void telephone_output (struct localedef_t *locale, const struct charmap_t *charmap, const char *output_path)
void measurement_read (struct linereader *ldfile, struct localedef_t *result, const struct charmap_t *charmap, const char *repertoire_name, int ignore_content)
void measurement_finish (struct localedef_t *locale, const struct charmap_t *charmap)
void measurement_output (struct localedef_t *locale, const struct charmap_t *charmap, const char *output_path)
void identification_read (struct linereader *ldfile, struct localedef_t *result, const struct charmap_t *charmap, const char *repertoire_name, int ignore_content)
void identification_finish (struct localedef_t *locale, const struct charmap_t *charmap)
void identification_output (struct localedef_t *locale, const struct charmap_t *charmap, const char *output_path)

Class Documentation

struct locale_file

Definition at line 29 of file locfile.h.

Class Members
int magic
int n

Define Documentation

#define SYNTAX_ERROR (   string,
  args... 
)
Value:
do                                                                   \
    {                                                                \
      lr_error (ldfile, string, ## args);                            \
      lr_ignore_rest (ldfile, 0);                                    \
    }                                                                \
  while (0)

Definition at line 37 of file locfile.h.


Function Documentation

void address_finish ( struct localedef_t locale,
const struct charmap_t charmap 
)

Definition at line 100 of file ld-address.c.

{
  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)
       {
         if (! be_quiet)
           WITH_CUR_LOCALE (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)
    {
      if (! nothing)
       WITH_CUR_LOCALE (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";
    }
  else
    {
      /* We must check whether the format string contains only the
        allowed escape sequences.  */
      const char *cp = address->postal_fmt;

      if (*cp == '\0')
       WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' must not be empty"),
                            "LC_ADDRESS", "postal_fmt"));
      else
       while (*cp != '\0')
         {
           if (*cp == '%')
             {
              if (*++cp == 'R')
                /* Romanize-flag.  */
                ++cp;
              if (strchr ("afdbshNtreCzTSc%", *cp) == NULL)
                {
                  WITH_CUR_LOCALE (error (0, 0, _("\
%s: invalid escape `%%%c' sequence in field `%s'"),
                                       "LC_ADDRESS", *cp, "postal_fmt"));
                  break;
                }
             }
           ++cp;
         }
    }

#define TEST_ELEM(cat) \
  if (address->cat == NULL)                                          \
    {                                                                \
      if (verbose && ! nothing)                                             \
       WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"),       \
                            "LC_ADDRESS", #cat));                           \
      address->cat = "";                                             \
    }

  TEST_ELEM (country_name);
  /* XXX Test against list of defined codes.  */
  TEST_ELEM (country_post);
  /* XXX Test against list of defined codes.  */
  TEST_ELEM (country_car);
  /* XXX Test against list of defined codes.  */
  TEST_ELEM (country_isbn);
  TEST_ELEM (lang_name);

  helper = 1;
  if (address->lang_term == NULL)
    {
      if (verbose && ! nothing)
       WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"),
                            "LC_ADDRESS", "lang_term"));
      address->lang_term = "";
      cnt = sizeof (iso639) / sizeof (iso639[0]);
    }
  else if (address->lang_term[0] == '\0')
    {
      if (verbose)
       WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' must not be empty"),
                            "LC_ADDRESS", "lang_term"));
      cnt = sizeof (iso639) / sizeof (iso639[0]);
    }
  else
    {
      /* Look for this language in the table.  */
      for (cnt = 0; cnt < sizeof (iso639) / sizeof (iso639[0]); ++cnt)
       if (strcmp (address->lang_term, iso639[cnt].term) == 0)
         break;
      if (cnt == sizeof (iso639) / sizeof (iso639[0]))
       WITH_CUR_LOCALE (error (0, 0, _("\
%s: terminology language code `%s' not defined"),
                            "LC_ADDRESS", address->lang_term));
    }

  if (address->lang_ab == NULL)
    {
      if ((cnt == sizeof (iso639) / sizeof (iso639[0])
          || iso639[cnt].ab[0] != '\0')
         && verbose && ! nothing)
       WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"),
                            "LC_ADDRESS", "lang_ab"));
      address->lang_ab = "";
    }
  else if (address->lang_ab[0] == '\0')
    {
      if ((cnt == sizeof (iso639) / sizeof (iso639[0])
          || iso639[cnt].ab[0] != '\0')
         && verbose)
       WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' must not be empty"),
                            "LC_ADDRESS", "lang_ab"));
    }
  else if (cnt < sizeof (iso639) / sizeof (iso639[0])
          && iso639[cnt].ab[0] == '\0')
    {
      WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' must not be defined"),
                           "LC_ADDRESS", "lang_ab"));

      address->lang_ab = "";
    }
  else
    {
      if (cnt == sizeof (iso639) / sizeof (iso639[0]))
       {
         helper = 2;
         for (cnt = 0; cnt < sizeof (iso639) / sizeof (iso639[0]); ++cnt)
           if (strcmp (address->lang_ab, iso639[cnt].ab) == 0)
             break;
         if (cnt == sizeof (iso639) / sizeof (iso639[0]))
           WITH_CUR_LOCALE (error (0, 0, _("\
%s: language abbreviation `%s' not defined"),
                                "LC_ADDRESS", address->lang_ab));
       }
      else
       if (strcmp (iso639[cnt].ab, address->lang_ab) != 0
           && iso639[cnt].ab[0] != '\0')
         WITH_CUR_LOCALE (error (0, 0, _("\
%s: `%s' value does not match `%s' value"),
                              "LC_ADDRESS", "lang_ab", "lang_term"));
    }

  if (address->lang_lib == NULL)
    /* This is no error.  */
    address->lang_lib = address->lang_term;
  else if (address->lang_lib[0] == '\0')
    {
      if (verbose)
       WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' must not be empty"),
                            "LC_ADDRESS", "lang_lib"));
    }
  else
    {
      if (cnt == sizeof (iso639) / sizeof (iso639[0]))
       {
         for (cnt = 0; cnt < sizeof (iso639) / sizeof (iso639[0]); ++cnt)
           if (strcmp (address->lang_lib, iso639[cnt].lib) == 0)
             break;
         if (cnt == sizeof (iso639) / sizeof (iso639[0]))
           WITH_CUR_LOCALE (error (0, 0, _("\
%s: language abbreviation `%s' not defined"),
                                "LC_ADDRESS", address->lang_lib));
       }
      else
       if (strcmp (iso639[cnt].ab, address->lang_ab) != 0)
         WITH_CUR_LOCALE (error (0, 0, _("\
%s: `%s' value does not match `%s' value"), "LC_ADDRESS", "lang_lib",
                              helper == 1 ? "lang_term" : "lang_ab"));
    }

  if (address->country_num == 0)
    {
      if (verbose && ! nothing)
       WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"),
                            "LC_ADDRESS", "country_num"));
      cnt = sizeof (iso3166) / sizeof (iso3166[0]);
    }
  else
    {
      for (cnt = 0; cnt < sizeof (iso3166) / sizeof (iso3166[0]); ++cnt)
       if (address->country_num == iso3166[cnt].num)
         break;

      if (cnt == sizeof (iso3166) / sizeof (iso3166[0]))
       WITH_CUR_LOCALE (error (0, 0, _("\
%s: numeric country code `%d' not valid"),
                            "LC_ADDRESS", address->country_num));
    }

  if (address->country_ab2 == NULL)
    {
      if (verbose && ! nothing)
       WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"),
                            "LC_ADDRESS", "country_ab2"));
      address->country_ab2 = "  ";
    }
  else if (cnt != sizeof (iso3166) / sizeof (iso3166[0])
          && strcmp (address->country_ab2, iso3166[cnt].ab2) != 0)
    WITH_CUR_LOCALE (error (0, 0,
                         _("%s: `%s' value does not match `%s' value"),
                         "LC_ADDRESS", "country_ab2", "country_num"));

  if (address->country_ab3 == NULL)
    {
      if (verbose && ! nothing)
       WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"),
                            "LC_ADDRESS", "country_ab3"));
      address->country_ab3 = "   ";
    }
  else if (cnt != sizeof (iso3166) / sizeof (iso3166[0])
          && strcmp (address->country_ab3, iso3166[cnt].ab3) != 0)
    WITH_CUR_LOCALE (error (0, 0, _("\
%s: `%s' value does not match `%s' value"),
                         "LC_ADDRESS", "country_ab3", "country_num"));
}

Here is the call graph for this function:

void address_output ( struct localedef_t locale,
const struct charmap_t charmap,
const char *  output_path 
)

Definition at line 346 of file ld-address.c.

{
  struct locale_address_t *address = locale->categories[LC_ADDRESS].address;
  struct iovec iov[3 + _NL_ITEM_INDEX (_NL_NUM_LC_ADDRESS)];
  struct locale_file data;
  uint32_t idx[_NL_ITEM_INDEX (_NL_NUM_LC_ADDRESS)];
  size_t cnt = 0;

  data.magic = LIMAGIC (LC_ADDRESS);
  data.n = _NL_ITEM_INDEX (_NL_NUM_LC_ADDRESS);
  iov[cnt].iov_base = (void *) &data;
  iov[cnt].iov_len = sizeof (data);
  ++cnt;

  iov[cnt].iov_base = (void *) idx;
  iov[cnt].iov_len = sizeof (idx);
  ++cnt;

  idx[cnt - 2] = iov[0].iov_len + iov[1].iov_len;
  iov[cnt].iov_base = (void *) address->postal_fmt;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) address->country_name;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) address->country_post;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) address->country_ab2;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) address->country_ab3;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) address->country_car;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;

  /* Align following data */
  iov[cnt].iov_base = (void *) "\0\0";
  iov[cnt].iov_len = ((idx[cnt - 2] + 3) & ~3) - idx[cnt - 2];
  idx[cnt - 2] = (idx[cnt - 2] + 3) & ~3;
  ++cnt;

  iov[cnt].iov_base = (void *) &address->country_num;
  iov[cnt].iov_len = sizeof (uint32_t);
  ++cnt;

  idx[cnt - 3] = idx[cnt - 4] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) address->country_isbn;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 3] = idx[cnt - 4] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) address->lang_name;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 3] = idx[cnt - 4] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) address->lang_ab;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 3] = idx[cnt - 4] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) address->lang_term;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 3] = idx[cnt - 4] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) address->lang_lib;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 3] = idx[cnt - 4] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) charmap->code_set_name;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  assert (cnt == 3 + _NL_ITEM_INDEX (_NL_NUM_LC_ADDRESS));

  write_locale_data (output_path, LC_ADDRESS, "LC_ADDRESS",
                   3 + _NL_ITEM_INDEX (_NL_NUM_LC_ADDRESS), iov);
}

Here is the call graph for this function:

void address_read ( struct linereader ldfile,
struct localedef_t result,
const struct charmap_t charmap,
const char *  repertoire_name,
int  ignore_content 
)

Definition at line 446 of file ld-address.c.

{
  struct locale_address_t *address;
  struct token *now;
  struct token *arg;
  enum token_t nowtok;

  /* The rest of the line containing `LC_ADDRESS' must be free.  */
  lr_ignore_rest (ldfile, 1);


  do
    {
      now = lr_token (ldfile, charmap, result, NULL, verbose);
      nowtok = now->tok;
    }
  while (nowtok == tok_eol);

  /* If we see `copy' now we are almost done.  */
  if (nowtok == tok_copy)
    {
      handle_copy (ldfile, charmap, repertoire_name, result, tok_lc_address,
                 LC_ADDRESS, "LC_ADDRESS", ignore_content);
      return;
    }

  /* Prepare the data structures.  */
  address_startup (ldfile, result, ignore_content);
  address = result->categories[LC_ADDRESS].address;

  while (1)
    {
      /* Of course we don't proceed beyond the end of file.  */
      if (nowtok == tok_eof)
       break;

      /* Ignore empty lines.  */
      if (nowtok == tok_eol)
       {
         now = lr_token (ldfile, charmap, result, NULL, verbose);
         nowtok = now->tok;
         continue;
       }

      switch (nowtok)
       {
#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, result, NULL, verbose);           \
         if (arg->tok != tok_string)                                        \
           goto err_label;                                           \
         if (address->cat != NULL)                                   \
           lr_error (ldfile, _("\
%s: field `%s' declared more than once"), "LC_ADDRESS", #cat);              \
         else if (!ignore_content && arg->val.str.startmb == NULL)          \
           {                                                         \
             lr_error (ldfile, _("\
%s: unknown character in field `%s'"), "LC_ADDRESS", #cat);                 \
             address->cat = "";                                      \
           }                                                         \
         else if (!ignore_content)                                   \
           address->cat = arg->val.str.startmb;                      \
         break

         STR_ELEM (postal_fmt);
         STR_ELEM (country_name);
         STR_ELEM (country_post);
         STR_ELEM (country_ab2);
         STR_ELEM (country_ab3);
         STR_ELEM (country_car);
         STR_ELEM (lang_name);
         STR_ELEM (lang_ab);
         STR_ELEM (lang_term);
         STR_ELEM (lang_lib);

#define INT_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, result, NULL, verbose);           \
         if (arg->tok != tok_string && arg->tok != tok_number)              \
           goto err_label;                                           \
         if (address->cat != NULL)                                   \
           lr_error (ldfile, _("\
%s: field `%s' declared more than once"), "LC_ADDRESS", #cat);              \
         else if (!ignore_content && arg->tok == tok_string                 \
                 && arg->val.str.startmb == NULL)                           \
           {                                                         \
             lr_error (ldfile, _("\
%s: unknown character in field `%s'"), "LC_ADDRESS", #cat);                 \
             address->cat = "";                                      \
           }                                                         \
         else if (!ignore_content)                                   \
           {                                                         \
             if (arg->tok == tok_string)                             \
              address->cat = arg->val.str.startmb;                          \
             else                                                    \
              {                                                      \
                char *numbuf = (char *) xmalloc (11);                       \
                snprintf (numbuf, 11, "%ld", arg->val.num);                 \
                address->cat = numbuf;                               \
              }                                                      \
           }                                                         \
         break

         INT_STR_ELEM (country_isbn);

#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, result, NULL, verbose);           \
         if (arg->tok != tok_number)                                        \
           goto err_label;                                           \
         else if (address->cat != 0)                                        \
           lr_error (ldfile, _("\
%s: field `%s' declared more than once"), "LC_ADDRESS", #cat);              \
         else if (!ignore_content)                                   \
           address->cat = arg->val.num;                              \
         break

         INT_ELEM (country_num);

       case tok_end:
         /* Next we assume `LC_ADDRESS'.  */
         arg = lr_token (ldfile, charmap, result, NULL, verbose);
         if (arg->tok == tok_eof)
           break;
         if (arg->tok == tok_eol)
           lr_error (ldfile, _("%s: incomplete `END' line"),
                    "LC_ADDRESS");
         else if (arg->tok != tok_lc_address)
           lr_error (ldfile, _("\
%1$s: definition does not end with `END %1$s'"), "LC_ADDRESS");
         lr_ignore_rest (ldfile, arg->tok == tok_lc_address);
         return;

       default:
       err_label:
         SYNTAX_ERROR (_("%s: syntax error"), "LC_ADDRESS");
       }

      /* Prepare for the next round.  */
      now = lr_token (ldfile, charmap, result, NULL, verbose);
      nowtok = now->tok;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void check_all_categories ( struct localedef_t definitions,
const struct charmap_t charmap 
)

Definition at line 292 of file locfile.c.

{
  int cnt;

  for (cnt = 0; cnt < sizeof (check_funcs) / sizeof (check_funcs[0]); ++cnt)
    if (check_funcs[cnt] != NULL)
      check_funcs[cnt] (definitions, charmap);
}

Here is the caller graph for this function:

void collate_finish ( struct localedef_t locale,
const struct charmap_t charmap 
)

Definition at line 1515 of file ld-collate.c.

{
  /* Now is the time when we can assign the individual collation
     values for all the symbols.  We have possibly different values
     for the wide- and the multibyte-character symbols.  This is done
     since it might make a difference in the encoding if there is in
     some cases no multibyte-character but there are wide-characters.
     (The other way around it is not important since theencoded
     collation value in the wide-character case is 32 bits wide and
     therefore requires no encoding).

     The lowest collation value assigned is 2.  Zero is reserved for
     the NUL byte terminating the strings in the `strxfrm'/`wcsxfrm'
     functions and 1 is used to separate the individual passes for the
     different rules.

     We also have to construct is list with all the bytes/words which
     can come first in a sequence, followed by all the elements which
     also start with this byte/word.  The order is reverse which has
     among others the important effect that longer strings are located
     first in the list.  This is required for the output data since
     the algorithm used in `strcoll' etc depends on this.

     The multibyte case is easy.  We simply sort into an array with
     256 elements.  */
  struct locale_collate_t *collate = locale->categories[LC_COLLATE].collate;
  int mbact[nrules];
  int wcact;
  int mbseqact;
  int wcseqact;
  struct element_t *runp;
  int i;
  int need_undefined = 0;
  struct section_list *sect;
  int ruleidx;
  int nr_wide_elems = 0;

  if (collate == NULL)
    {
      /* No data, no check.  */
      if (! be_quiet)
       WITH_CUR_LOCALE (error (0, 0, _("No definition for %s category found"),
                            "LC_COLLATE"));
      return;
    }

  /* If this assertion is hit change the type in `element_t'.  */
  assert (nrules <= sizeof (runp->used_in_level) * 8);

  /* Make sure that the `position' rule is used either in all sections
     or in none.  */
  for (i = 0; i < nrules; ++i)
    for (sect = collate->sections; sect != NULL; sect = sect->next)
      if (sect != collate->current_section
         && sect->rules != NULL
         && ((sect->rules[i] & sort_position)
             != (collate->current_section->rules[i] & sort_position)))
       {
         WITH_CUR_LOCALE (error (0, 0, _("\
%s: `position' must be used for a specific level in all sections or none"),
                              "LC_COLLATE"));
         break;
       }

  /* Find out which elements are used at which level.  At the same
     time we find out whether we have any undefined symbols.  */
  runp = collate->start;
  while (runp != NULL)
    {
      if (runp->mbs != NULL)
       {
         for (i = 0; i < nrules; ++i)
           {
             int j;

             for (j = 0; j < runp->weights[i].cnt; ++j)
              /* A NULL pointer as the weight means IGNORE.  */
              if (runp->weights[i].w[j] != NULL)
                {
                  if (runp->weights[i].w[j]->weights == NULL)
                    {
                     WITH_CUR_LOCALE (error_at_line (0, 0, runp->file,
                                                 runp->line,
                                                 _("symbol `%s' not defined"),
                                                 runp->weights[i].w[j]->name));

                     need_undefined = 1;
                     runp->weights[i].w[j] = &collate->undefined;
                    }
                  else
                    /* Set the bit for the level.  */
                    runp->weights[i].w[j]->used_in_level |= 1 << i;
                }
           }
       }

      /* Up to the next entry.  */
      runp = runp->next;
    }

  /* Walk through the list of defined sequences and assign weights.  Also
     create the data structure which will allow generating the single byte
     character based tables.

     Since at each time only the weights for each of the rules are
     only compared to other weights for this rule it is possible to
     assign more compact weight values than simply counting all
     weights in sequence.  We can assign weights from 3, one for each
     rule individually and only for those elements, which are actually
     used for this rule.

     Why is this important?  It is not for the wide char table.  But
     it is for the singlebyte output since here larger numbers have to
     be encoded to make it possible to emit the value as a byte
     string.  */
  for (i = 0; i < nrules; ++i)
    mbact[i] = 2;
  wcact = 2;
  mbseqact = 0;
  wcseqact = 0;
  runp = collate->start;
  while (runp != NULL)
    {
      /* Determine the order.  */
      if (runp->used_in_level != 0)
       {
         runp->mborder = (int *) obstack_alloc (&collate->mempool,
                                           nrules * sizeof (int));

         for (i = 0; i < nrules; ++i)
           if ((runp->used_in_level & (1 << i)) != 0)
             runp->mborder[i] = mbact[i]++;
           else
             runp->mborder[i] = 0;
       }

      if (runp->mbs != NULL)
       {
         struct element_t **eptr;
         struct element_t *lastp = NULL;

         /* Find the point where to insert in the list.  */
         eptr = &collate->mbheads[((unsigned char *) runp->mbs)[0]];
         while (*eptr != NULL)
           {
             if ((*eptr)->nmbs < runp->nmbs)
              break;

             if ((*eptr)->nmbs == runp->nmbs)
              {
                int c = memcmp ((*eptr)->mbs, runp->mbs, runp->nmbs);

                if (c == 0)
                  {
                    /* This should not happen.  It means that we have
                      to symbols with the same byte sequence.  It is
                      of course an error.  */
                    WITH_CUR_LOCALE (error_at_line (0, 0, (*eptr)->file,
                                                (*eptr)->line,
                                                _("\
symbol `%s' has the same encoding as"), (*eptr)->name);
                                   error_at_line (0, 0, runp->file,
                                                runp->line,
                                                _("symbol `%s'"),
                                                runp->name));
                    goto dont_insert;
                  }
                else if (c < 0)
                  /* Insert it here.  */
                  break;
              }

             /* To the next entry.  */
             lastp = *eptr;
             eptr = &(*eptr)->mbnext;
           }

         /* Set the pointers.  */
         runp->mbnext = *eptr;
         runp->mblast = lastp;
         if (*eptr != NULL)
           (*eptr)->mblast = runp;
         *eptr = runp;
       dont_insert:
         ;
       }

      if (runp->used_in_level)
       {
         runp->wcorder = wcact++;

         /* We take the opportunity to count the elements which have
            wide characters.  */
         ++nr_wide_elems;
       }

      if (runp->is_character)
       {
         if (runp->nmbs == 1)
           collate->mbseqorder[((unsigned char *) runp->mbs)[0]] = mbseqact++;

         runp->wcseqorder = wcseqact++;
       }
      else if (runp->mbs != NULL && runp->weights != NULL)
       /* This is for collation elements.  */
       runp->wcseqorder = wcseqact++;

      /* Up to the next entry.  */
      runp = runp->next;
    }

  /* Find out whether any of the `mbheads' entries is unset.  In this
     case we use the UNDEFINED entry.  */
  for (i = 1; i < 256; ++i)
    if (collate->mbheads[i] == NULL)
      {
       need_undefined = 1;
       collate->mbheads[i] = &collate->undefined;
      }

  /* Now to the wide character case.  */
  collate->wcheads.p = 6;
  collate->wcheads.q = 10;
  wchead_table_init (&collate->wcheads);

  collate->wcseqorder.p = 6;
  collate->wcseqorder.q = 10;
  collseq_table_init (&collate->wcseqorder);

  /* Start adding.  */
  runp = collate->start;
  while (runp != NULL)
    {
      if (runp->wcs != NULL)
       {
         struct element_t *e;
         struct element_t **eptr;
         struct element_t *lastp;

         /* Insert the collation sequence value.  */
         if (runp->is_character)
           collseq_table_add (&collate->wcseqorder, runp->wcs[0],
                            runp->wcseqorder);

         /* Find the point where to insert in the list.  */
         e = wchead_table_get (&collate->wcheads, runp->wcs[0]);
         eptr = &e;
         lastp = NULL;
         while (*eptr != NULL)
           {
             if ((*eptr)->nwcs < runp->nwcs)
              break;

             if ((*eptr)->nwcs == runp->nwcs)
              {
                int c = wmemcmp ((wchar_t *) (*eptr)->wcs,
                               (wchar_t *) runp->wcs, runp->nwcs);

                if (c == 0)
                  {
                    /* This should not happen.  It means that we have
                      two symbols with the same byte sequence.  It is
                      of course an error.  */
                    WITH_CUR_LOCALE (error_at_line (0, 0, (*eptr)->file,
                                                (*eptr)->line,
                                                _("\
symbol `%s' has the same encoding as"), (*eptr)->name);
                                   error_at_line (0, 0, runp->file,
                                                runp->line,
                                                _("symbol `%s'"),
                                                runp->name));
                    goto dont_insertwc;
                  }
                else if (c < 0)
                  /* Insert it here.  */
                  break;
              }

             /* To the next entry.  */
             lastp = *eptr;
             eptr = &(*eptr)->wcnext;
           }

         /* Set the pointers.  */
         runp->wcnext = *eptr;
         runp->wclast = lastp;
         if (*eptr != NULL)
           (*eptr)->wclast = runp;
         *eptr = runp;
         if (eptr == &e)
           wchead_table_add (&collate->wcheads, runp->wcs[0], e);
       dont_insertwc:
         ;
       }

      /* Up to the next entry.  */
      runp = runp->next;
    }

  collseq_table_finalize (&collate->wcseqorder);

  /* Now determine whether the UNDEFINED entry is needed and if yes,
     whether it was defined.  */
  collate->undefined.used_in_level = need_undefined ? ~0ul : 0;
  if (collate->undefined.file == NULL)
    {
      if (need_undefined)
       {
         /* This seems not to be enforced by recent standards.  Don't
            emit an error, simply append UNDEFINED at the end.  */
         if (0)
           WITH_CUR_LOCALE (error (0, 0, _("no definition of `UNDEFINED'")));

         /* Add UNDEFINED at the end.  */
         collate->undefined.mborder =
           (int *) obstack_alloc (&collate->mempool, nrules * sizeof (int));

         for (i = 0; i < nrules; ++i)
           collate->undefined.mborder[i] = mbact[i]++;
       }

      /* In any case we will need the definition for the wide character
        case.  But we will not complain that it is missing since the
        specification strangely enough does not seem to account for
        this.  */
      collate->undefined.wcorder = wcact++;
    }

  /* Finally, try to unify the rules for the sections.  Whenever the rules
     for a section are the same as those for another section give the
     ruleset the same index.  Since there are never many section we can
     use an O(n^2) algorithm here.  */
  sect = collate->sections;
  while (sect != NULL && sect->rules == NULL)
    sect = sect->next;

  /* Bail out if we have no sections because of earlier errors.  */
  if (sect == NULL)
    {
      WITH_CUR_LOCALE (error (EXIT_FAILURE, 0,
                           _("too many errors; giving up")));
      return;
    }

  ruleidx = 0;
  do
    {
      struct section_list *osect = collate->sections;

      while (osect != sect)
       if (osect->rules != NULL
           && memcmp (osect->rules, sect->rules,
                     nrules * sizeof (osect->rules[0])) == 0)
         break;
       else
         osect = osect->next;

      if (osect == sect)
       sect->ruleidx = ruleidx++;
      else
       sect->ruleidx = osect->ruleidx;

      /* Next section.  */
      do
       sect = sect->next;
      while (sect != NULL && sect->rules == NULL);
    }
  while (sect != NULL);
  /* We are currently not prepared for more than 128 rulesets.  But this
     should never really be a problem.  */
  assert (ruleidx <= 128);
}

Here is the call graph for this function:

void collate_output ( struct localedef_t locale,
const struct charmap_t charmap,
const char *  output_path 
)

Definition at line 2096 of file ld-collate.c.

{
  struct locale_collate_t *collate = locale->categories[LC_COLLATE].collate;
  const size_t nelems = _NL_ITEM_INDEX (_NL_NUM_LC_COLLATE);
  struct iovec iov[2 + nelems];
  struct locale_file data;
  uint32_t idx[nelems];
  size_t cnt;
  size_t ch;
  int32_t tablemb[256];
  struct obstack weightpool;
  struct obstack extrapool;
  struct obstack indirectpool;
  struct section_list *sect;
  struct collidx_table tablewc;
  uint32_t elem_size;
  uint32_t *elem_table;
  int i;
  struct element_t *runp;

  data.magic = LIMAGIC (LC_COLLATE);
  data.n = nelems;
  iov[0].iov_base = (void *) &data;
  iov[0].iov_len = sizeof (data);

  iov[1].iov_base = (void *) idx;
  iov[1].iov_len = sizeof (idx);

  idx[0] = iov[0].iov_len + iov[1].iov_len;
  cnt = 0;

  assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_NRULES));
  iov[2 + cnt].iov_base = &nrules;
  iov[2 + cnt].iov_len = sizeof (uint32_t);
  idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
  ++cnt;

  /* If we have no LC_COLLATE data emit only the number of rules as zero.  */
  if (collate == NULL)
    {
      int32_t dummy = 0;

      while (cnt < _NL_ITEM_INDEX (_NL_NUM_LC_COLLATE))
       {
         /* The words have to be handled specially.  */
         if (cnt == _NL_ITEM_INDEX (_NL_COLLATE_SYMB_HASH_SIZEMB))
           {
             iov[2 + cnt].iov_base = &dummy;
             iov[2 + cnt].iov_len = sizeof (int32_t);
           }
         else
           {
             iov[2 + cnt].iov_base = NULL;
             iov[2 + cnt].iov_len = 0;
           }

         if (cnt + 1 < _NL_ITEM_INDEX (_NL_NUM_LC_COLLATE))
           idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
         ++cnt;
       }

      assert (cnt == _NL_ITEM_INDEX (_NL_NUM_LC_COLLATE));

      write_locale_data (output_path, LC_COLLATE, "LC_COLLATE", 2 + cnt, iov);

      return;
    }

  obstack_init (&weightpool);
  obstack_init (&extrapool);
  obstack_init (&indirectpool);

  /* Since we are using the sign of an integer to mark indirection the
     offsets in the arrays we are indirectly referring to must not be
     zero since -0 == 0.  Therefore we add a bit of dummy content.  */
  obstack_int32_grow (&extrapool, 0);
  obstack_int32_grow (&indirectpool, 0);

  /* Prepare the ruleset table.  */
  for (sect = collate->sections, i = 0; sect != NULL; sect = sect->next)
    if (sect->rules != NULL && sect->ruleidx == i)
      {
       int j;

       obstack_make_room (&weightpool, nrules);

       for (j = 0; j < nrules; ++j)
         obstack_1grow_fast (&weightpool, sect->rules[j]);
       ++i;
      }
  /* And align the output.  */
  i = (nrules * i) % __alignof__ (int32_t);
  if (i > 0)
    do
      obstack_1grow (&weightpool, '\0');
    while (++i < __alignof__ (int32_t));

  assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_RULESETS));
  iov[2 + cnt].iov_len = obstack_object_size (&weightpool);
  iov[2 + cnt].iov_base = obstack_finish (&weightpool);
  idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
  ++cnt;

  /* Generate the 8-bit table.  Walk through the lists of sequences
     starting with the same byte and add them one after the other to
     the table.  In case we have more than one sequence starting with
     the same byte we have to use extra indirection.

     First add a record for the NUL byte.  This entry will never be used
     so it does not matter.  */
  tablemb[0] = 0;

  /* Now insert the `UNDEFINED' value if it is used.  Since this value
     will probably be used more than once it is good to store the
     weights only once.  */
  if (collate->undefined.used_in_level != 0)
    output_weight (&weightpool, collate, &collate->undefined);

  for (ch = 1; ch < 256; ++ch)
    if (collate->mbheads[ch]->mbnext == NULL
       && collate->mbheads[ch]->nmbs <= 1)
      {
       tablemb[ch] = output_weight (&weightpool, collate,
                                 collate->mbheads[ch]);
      }
    else
      {
       /* The entries in the list are sorted by length and then
           alphabetically.  This is the order in which we will add the
           elements to the collation table.  This allows simply walking
          the table in sequence and stopping at the first matching
           entry.  Since the longer sequences are coming first in the
           list they have the possibility to match first, just as it
           has to be.  In the worst case we are walking to the end of
           the list where we put, if no singlebyte sequence is defined
           in the locale definition, the weights for UNDEFINED.

          To reduce the length of the search list we compress them a bit.
          This happens by collecting sequences of consecutive byte
          sequences in one entry (having and begin and end byte sequence)
          and add only one index into the weight table.  We can find the
          consecutive entries since they are also consecutive in the list.  */
       struct element_t *runp = collate->mbheads[ch];
       struct element_t *lastp;

       assert ((obstack_object_size (&extrapool)
               & (__alignof__ (int32_t) - 1)) == 0);

       tablemb[ch] = -obstack_object_size (&extrapool);

       do
         {
           /* Store the current index in the weight table.  We know that
              the current position in the `extrapool' is aligned on a
              32-bit address.  */
           int32_t weightidx;
           int added;

           /* Find out wether this is a single entry or we have more than
              one consecutive entry.  */
           if (runp->mbnext != NULL
              && runp->nmbs == runp->mbnext->nmbs
              && memcmp (runp->mbs, runp->mbnext->mbs, runp->nmbs - 1) == 0
              && (runp->mbs[runp->nmbs - 1]
                  == runp->mbnext->mbs[runp->nmbs - 1] + 1))
             {
              int i;
              struct element_t *series_startp = runp;
              struct element_t *curp;

              /* Compute how much space we will need.  */
              added = ((sizeof (int32_t) + 1 + 2 * (runp->nmbs - 1)
                       + __alignof__ (int32_t) - 1)
                      & ~(__alignof__ (int32_t) - 1));
              assert ((obstack_object_size (&extrapool)
                      & (__alignof__ (int32_t) - 1)) == 0);
              obstack_make_room (&extrapool, added);

              /* More than one consecutive entry.  We mark this by having
                 a negative index into the indirect table.  */
              obstack_int32_grow_fast (&extrapool,
                                    -(obstack_object_size (&indirectpool)
                                      / sizeof (int32_t)));

              /* Now search first the end of the series.  */
              do
                runp = runp->mbnext;
              while (runp->mbnext != NULL
                     && runp->nmbs == runp->mbnext->nmbs
                     && memcmp (runp->mbs, runp->mbnext->mbs,
                              runp->nmbs - 1) == 0
                     && (runp->mbs[runp->nmbs - 1]
                        == runp->mbnext->mbs[runp->nmbs - 1] + 1));

              /* Now walk backward from here to the beginning.  */
              curp = runp;

              assert (runp->nmbs <= 256);
              obstack_1grow_fast (&extrapool, curp->nmbs - 1);
              for (i = 1; i < curp->nmbs; ++i)
                obstack_1grow_fast (&extrapool, curp->mbs[i]);

              /* Now find the end of the consecutive sequence and
                   add all the indeces in the indirect pool.  */
              do
                {
                  weightidx = output_weight (&weightpool, collate, curp);
                  obstack_int32_grow (&indirectpool, weightidx);

                  curp = curp->mblast;
                }
              while (curp != series_startp);

              /* Add the final weight.  */
              weightidx = output_weight (&weightpool, collate, curp);
              obstack_int32_grow (&indirectpool, weightidx);

              /* And add the end byte sequence.  Without length this
                   time.  */
              for (i = 1; i < curp->nmbs; ++i)
                obstack_1grow_fast (&extrapool, curp->mbs[i]);
             }
           else
             {
              /* A single entry.  Simply add the index and the length and
                 string (except for the first character which is already
                 tested for).  */
              int i;

              /* Output the weight info.  */
              weightidx = output_weight (&weightpool, collate, runp);

              added = ((sizeof (int32_t) + 1 + runp->nmbs - 1
                       + __alignof__ (int32_t) - 1)
                      & ~(__alignof__ (int32_t) - 1));
              assert ((obstack_object_size (&extrapool)
                      & (__alignof__ (int32_t) - 1)) == 0);
              obstack_make_room (&extrapool, added);

              obstack_int32_grow_fast (&extrapool, weightidx);
              assert (runp->nmbs <= 256);
              obstack_1grow_fast (&extrapool, runp->nmbs - 1);

              for (i = 1; i < runp->nmbs; ++i)
                obstack_1grow_fast (&extrapool, runp->mbs[i]);
             }

           /* Add alignment bytes if necessary.  */
           while ((obstack_object_size (&extrapool)
                  & (__alignof__ (int32_t) - 1)) != 0)
             obstack_1grow_fast (&extrapool, '\0');

           /* Next entry.  */
           lastp = runp;
           runp = runp->mbnext;
         }
       while (runp != NULL);

       assert ((obstack_object_size (&extrapool)
               & (__alignof__ (int32_t) - 1)) == 0);

       /* If the final entry in the list is not a single character we
           add an UNDEFINED entry here.  */
       if (lastp->nmbs != 1)
         {
           int added = ((sizeof (int32_t) + 1 + 1 + __alignof__ (int32_t) - 1)
                      & ~(__alignof__ (int32_t) - 1));
           obstack_make_room (&extrapool, added);

           obstack_int32_grow_fast (&extrapool, 0);
           /* XXX What rule? We just pick the first.  */
           obstack_1grow_fast (&extrapool, 0);
           /* Length is zero.  */
           obstack_1grow_fast (&extrapool, 0);

           /* Add alignment bytes if necessary.  */
           while ((obstack_object_size (&extrapool)
                  & (__alignof__ (int32_t) - 1)) != 0)
             obstack_1grow_fast (&extrapool, '\0');
         }
      }

  /* Add padding to the tables if necessary.  */
  while ((obstack_object_size (&weightpool) & (__alignof__ (int32_t) - 1))
        != 0)
    obstack_1grow (&weightpool, 0);

  /* Now add the four tables.  */
  assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_TABLEMB));
  iov[2 + cnt].iov_base = tablemb;
  iov[2 + cnt].iov_len = sizeof (tablemb);
  idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
  assert ((iov[2 + cnt].iov_len & (__alignof__ (int32_t) - 1)) == 0);
  ++cnt;

  assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_WEIGHTMB));
  iov[2 + cnt].iov_len = obstack_object_size (&weightpool);
  iov[2 + cnt].iov_base = obstack_finish (&weightpool);
  idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
  ++cnt;

  assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_EXTRAMB));
  iov[2 + cnt].iov_len = obstack_object_size (&extrapool);
  iov[2 + cnt].iov_base = obstack_finish (&extrapool);
  idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
  ++cnt;

  assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_INDIRECTMB));
  iov[2 + cnt].iov_len = obstack_object_size (&indirectpool);
  iov[2 + cnt].iov_base = obstack_finish (&indirectpool);
  idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
  assert ((iov[2 + cnt].iov_len & (__alignof__ (int32_t) - 1)) == 0);
  ++cnt;


  /* Now the same for the wide character table.  We need to store some
     more information here.  */
  assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_GAP1));
  iov[2 + cnt].iov_base = NULL;
  iov[2 + cnt].iov_len = 0;
  idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
  assert (idx[cnt] % __alignof__ (int32_t) == 0);
  ++cnt;

  assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_GAP2));
  iov[2 + cnt].iov_base = NULL;
  iov[2 + cnt].iov_len = 0;
  idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
  assert (idx[cnt] % __alignof__ (int32_t) == 0);
  ++cnt;

  assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_GAP3));
  iov[2 + cnt].iov_base = NULL;
  iov[2 + cnt].iov_len = 0;
  idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
  assert (idx[cnt] % __alignof__ (int32_t) == 0);
  ++cnt;

  /* Since we are using the sign of an integer to mark indirection the
     offsets in the arrays we are indirectly referring to must not be
     zero since -0 == 0.  Therefore we add a bit of dummy content.  */
  obstack_int32_grow (&extrapool, 0);
  obstack_int32_grow (&indirectpool, 0);

  /* Now insert the `UNDEFINED' value if it is used.  Since this value
     will probably be used more than once it is good to store the
     weights only once.  */
  if (output_weightwc (&weightpool, collate, &collate->undefined) != 0)
    abort ();

  /* Generate the table.  Walk through the lists of sequences starting
     with the same wide character and add them one after the other to
     the table.  In case we have more than one sequence starting with
     the same byte we have to use extra indirection.  */
  tablewc.p = 6;
  tablewc.q = 10;
  collidx_table_init (&tablewc);

  atwc.weightpool = &weightpool;
  atwc.extrapool = &extrapool;
  atwc.indpool = &indirectpool;
  atwc.collate = collate;
  atwc.tablewc = &tablewc;

  wchead_table_iterate (&collate->wcheads, add_to_tablewc);

  memset (&atwc, 0, sizeof (atwc));

  collidx_table_finalize (&tablewc);

  /* Now add the four tables.  */
  assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_TABLEWC));
  iov[2 + cnt].iov_base = tablewc.result;
  iov[2 + cnt].iov_len = tablewc.result_size;
  idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
  assert (iov[2 + cnt].iov_len % sizeof (int32_t) == 0);
  assert (idx[cnt] % __alignof__ (int32_t) == 0);
  ++cnt;

  assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_WEIGHTWC));
  iov[2 + cnt].iov_len = obstack_object_size (&weightpool);
  iov[2 + cnt].iov_base = obstack_finish (&weightpool);
  idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
  assert (iov[2 + cnt].iov_len % sizeof (int32_t) == 0);
  assert (idx[cnt] % __alignof__ (int32_t) == 0);
  ++cnt;

  assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_EXTRAWC));
  iov[2 + cnt].iov_len = obstack_object_size (&extrapool);
  iov[2 + cnt].iov_base = obstack_finish (&extrapool);
  idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
  assert (iov[2 + cnt].iov_len % sizeof (int32_t) == 0);
  assert (idx[cnt] % __alignof__ (int32_t) == 0);
  ++cnt;

  assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_INDIRECTWC));
  iov[2 + cnt].iov_len = obstack_object_size (&indirectpool);
  iov[2 + cnt].iov_base = obstack_finish (&indirectpool);
  idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
  assert (iov[2 + cnt].iov_len % sizeof (int32_t) == 0);
  assert (idx[cnt] % __alignof__ (int32_t) == 0);
  ++cnt;


  /* Finally write the table with collation element names out.  It is
     a hash table with a simple function which gets the name of the
     character as the input.  One character might have many names.  The
     value associated with the name is an index into the weight table
     where we are then interested in the first-level weight value.

     To determine how large the table should be we are counting the
     elements have to put in.  Since we are using internal chaining
     using a secondary hash function we have to make the table a bit
     larger to avoid extremely long search times.  We can achieve
     good results with a 40% larger table than there are entries.  */
  elem_size = 0;
  runp = collate->start;
  while (runp != NULL)
    {
      if (runp->mbs != NULL && runp->weights != NULL && !runp->is_character)
       /* Yep, the element really counts.  */
       ++elem_size;

      runp = runp->next;
    }
  /* Add 40% and find the next prime number.  */
  elem_size = next_prime (elem_size * 1.4);

  /* Allocate the table.  Each entry consists of two words: the hash
     value and an index in a secondary table which provides the index
     into the weight table and the string itself (so that a match can
     be determined).  */
  elem_table = (uint32_t *) obstack_alloc (&extrapool,
                                      elem_size * 2 * sizeof (uint32_t));
  memset (elem_table, '\0', elem_size * 2 * sizeof (uint32_t));

  /* Now add the elements.  */
  runp = collate->start;
  while (runp != NULL)
    {
      if (runp->mbs != NULL && runp->weights != NULL && !runp->is_character)
       {
         /* Compute the hash value of the name.  */
         uint32_t namelen = strlen (runp->name);
         uint32_t hash = elem_hash (runp->name, namelen);
         size_t idx = hash % elem_size;
#ifndef NDEBUG
         size_t start_idx = idx;
#endif

         if (elem_table[idx * 2] != 0)
           {
             /* The spot is already taken.  Try iterating using the value
               from the secondary hashing function.  */
             size_t iter = hash % (elem_size - 2) + 1;

             do
              {
                idx += iter;
                if (idx >= elem_size)
                  idx -= elem_size;
                assert (idx != start_idx);
              }
             while (elem_table[idx * 2] != 0);
           }
         /* This is the spot where we will insert the value.  */
         elem_table[idx * 2] = hash;
         elem_table[idx * 2 + 1] = obstack_object_size (&extrapool);

         /* The the string itself including length.  */
         obstack_1grow (&extrapool, namelen);
         obstack_grow (&extrapool, runp->name, namelen);

         /* And the multibyte representation.  */
         obstack_1grow (&extrapool, runp->nmbs);
         obstack_grow (&extrapool, runp->mbs, runp->nmbs);

         /* And align again to 32 bits.  */
         if ((1 + namelen + 1 + runp->nmbs) % sizeof (int32_t) != 0)
           obstack_grow (&extrapool, "\0\0",
                       (sizeof (int32_t)
                        - ((1 + namelen + 1 + runp->nmbs)
                           % sizeof (int32_t))));

         /* Now some 32-bit values: multibyte collation sequence,
            wide char string (including length), and wide char
            collation sequence.  */
         obstack_int32_grow (&extrapool, runp->mbseqorder);

         obstack_int32_grow (&extrapool, runp->nwcs);
         obstack_grow (&extrapool, runp->wcs,
                     runp->nwcs * sizeof (uint32_t));

         obstack_int32_grow (&extrapool, runp->wcseqorder);
       }

      runp = runp->next;
    }

  /* Prepare to write out this data.  */
  assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_SYMB_HASH_SIZEMB));
  iov[2 + cnt].iov_base = &elem_size;
  iov[2 + cnt].iov_len = sizeof (int32_t);
  idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
  assert (idx[cnt] % __alignof__ (int32_t) == 0);
  ++cnt;

  assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_SYMB_TABLEMB));
  iov[2 + cnt].iov_base = elem_table;
  iov[2 + cnt].iov_len = elem_size * 2 * sizeof (int32_t);
  idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
  assert (idx[cnt] % __alignof__ (int32_t) == 0);
  ++cnt;

  assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_SYMB_EXTRAMB));
  iov[2 + cnt].iov_len = obstack_object_size (&extrapool);
  iov[2 + cnt].iov_base = obstack_finish (&extrapool);
  idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
  ++cnt;

  assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_COLLSEQMB));
  iov[2 + cnt].iov_base = collate->mbseqorder;
  iov[2 + cnt].iov_len = 256;
  idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
  ++cnt;

  assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_COLLSEQWC));
  iov[2 + cnt].iov_base = collate->wcseqorder.result;
  iov[2 + cnt].iov_len = collate->wcseqorder.result_size;
  idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
  assert (idx[cnt] % __alignof__ (int32_t) == 0);
  ++cnt;

  assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_CODESET));
  iov[2 + cnt].iov_base = (void *) charmap->code_set_name;
  iov[2 + cnt].iov_len = strlen (iov[2 + cnt].iov_base) + 1;
  ++cnt;

  assert (cnt == _NL_ITEM_INDEX (_NL_NUM_LC_COLLATE));

  write_locale_data (output_path, LC_COLLATE, "LC_COLLATE", 2 + cnt, iov);

  obstack_free (&weightpool, NULL);
  obstack_free (&extrapool, NULL);
  obstack_free (&indirectpool, NULL);
}

Here is the call graph for this function:

void collate_read ( struct linereader ldfile,
struct localedef_t result,
const struct charmap_t charmap,
const char *  repertoire_name,
int  ignore_content 
)

Definition at line 2686 of file ld-collate.c.

{
  struct repertoire_t *repertoire = NULL;
  struct locale_collate_t *collate;
  struct token *now;
  struct token *arg = NULL;
  enum token_t nowtok;
  enum token_t was_ellipsis = tok_none;
  struct localedef_t *copy_locale = NULL;
  /* Parsing state:
     0 - start
     1 - between `order-start' and `order-end'
     2 - after `order-end'
     3 - after `reorder-after', waiting for `reorder-end'
     4 - after `reorder-end'
     5 - after `reorder-sections-after', waiting for `reorder-sections-end'
     6 - after `reorder-sections-end'
  */
  int state = 0;

  /* Get the repertoire we have to use.  */
  if (repertoire_name != NULL)
    repertoire = repertoire_read (repertoire_name);

  /* The rest of the line containing `LC_COLLATE' must be free.  */
  lr_ignore_rest (ldfile, 1);

  while (1)
    {
      do
       {
         now = lr_token (ldfile, charmap, result, NULL, verbose);
         nowtok = now->tok;
       }
      while (nowtok == tok_eol);

      if (nowtok != tok_define)
       break;

      if (ignore_content)
       lr_ignore_rest (ldfile, 0);
      else
       {
         arg = lr_token (ldfile, charmap, result, NULL, verbose);
         if (arg->tok != tok_ident)
           SYNTAX_ERROR (_("%s: syntax error"), "LC_COLLATE");
         else
           {
             /* Simply add the new symbol.  */
             struct name_list *newsym = xmalloc (sizeof (*newsym)
                                            + arg->val.str.lenmb + 1);
             memcpy (newsym->str, arg->val.str.startmb, arg->val.str.lenmb);
             newsym->str[arg->val.str.lenmb] = '\0';
             newsym->next = defined;
             defined = newsym;

             lr_ignore_rest (ldfile, 1);
           }
       }
    }

  if (nowtok == tok_copy)
    {
      now = lr_token (ldfile, charmap, result, NULL, verbose);
      if (now->tok != tok_string)
       {
         SYNTAX_ERROR (_("%s: syntax error"), "LC_COLLATE");

       skip_category:
         do
           now = lr_token (ldfile, charmap, result, NULL, verbose);
         while (now->tok != tok_eof && now->tok != tok_end);

         if (now->tok != tok_eof
             || (now = lr_token (ldfile, charmap, result, NULL, verbose),
                now->tok == tok_eof))
           lr_error (ldfile, _("%s: premature end of file"), "LC_COLLATE");
         else if (now->tok != tok_lc_collate)
           {
             lr_error (ldfile, _("\
%1$s: definition does not end with `END %1$s'"), "LC_COLLATE");
             lr_ignore_rest (ldfile, 0);
           }
         else
           lr_ignore_rest (ldfile, 1);

         return;
       }

      if (! ignore_content)
       {
         /* Get the locale definition.  */
         copy_locale = load_locale (LC_COLLATE, now->val.str.startmb,
                                 repertoire_name, charmap, NULL);
         if ((copy_locale->avail & COLLATE_LOCALE) == 0)
           {
             /* Not yet loaded.  So do it now.  */
             if (locfile_read (copy_locale, charmap) != 0)
              goto skip_category;
           }

         if (copy_locale->categories[LC_COLLATE].collate == NULL)
           return;
       }

      lr_ignore_rest (ldfile, 1);

      now = lr_token (ldfile, charmap, result, NULL, verbose);
      nowtok = now->tok;
    }

  /* Prepare the data structures.  */
  collate_startup (ldfile, result, copy_locale, ignore_content);
  collate = result->categories[LC_COLLATE].collate;

  while (1)
    {
      char ucs4buf[10];
      char *symstr;
      size_t symlen;

      /* Of course we don't proceed beyond the end of file.  */
      if (nowtok == tok_eof)
       break;

      /* Ingore empty lines.  */
      if (nowtok == tok_eol)
       {
         now = lr_token (ldfile, charmap, result, NULL, verbose);
         nowtok = now->tok;
         continue;
       }

      switch (nowtok)
       {
       case tok_copy:
         /* Allow copying other locales.  */
         now = lr_token (ldfile, charmap, result, NULL, verbose);
         if (now->tok != tok_string)
           goto err_label;

         if (! ignore_content)
           load_locale (LC_COLLATE, now->val.str.startmb, repertoire_name,
                      charmap, result);

         lr_ignore_rest (ldfile, 1);
         break;

       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;

         arg = lr_token (ldfile, charmap, result, NULL, verbose);
         if (arg->tok != tok_number)
           goto err_label;
         if (collate->col_weight_max != -1)
           lr_error (ldfile, _("%s: duplicate definition of `%s'"),
                    "LC_COLLATE", "col_weight_max");
         else
           collate->col_weight_max = arg->val.num;
         lr_ignore_rest (ldfile, 1);
         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;

         arg = lr_token (ldfile, charmap, result, repertoire, verbose);
         if (arg->tok != tok_bsymbol)
           goto err_label;
         else if (!ignore_content)
           {
             /* Check whether this section is already known.  */
             struct section_list *known = collate->sections;
             while (known != NULL)
              {
                if (strcmp (known->name, arg->val.str.startmb) == 0)
                  break;
                known = known->next;
              }

             if (known != NULL)
              {
                lr_error (ldfile,
                         _("%s: duplicate declaration of section `%s'"),
                         "LC_COLLATE", arg->val.str.startmb);
                free (arg->val.str.startmb);
              }
             else
              collate->sections = make_seclist_elem (collate,
                                                 arg->val.str.startmb,
                                                 collate->sections);

             lr_ignore_rest (ldfile, known == NULL);
           }
         else
           {
             free (arg->val.str.startmb);
             lr_ignore_rest (ldfile, 0);
           }
         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 && state != 2)
           goto err_label;

         arg = lr_token (ldfile, charmap, result, repertoire, verbose);
         if (arg->tok != tok_bsymbol)
           goto err_label;
         else
           {
             const char *symbol = arg->val.str.startmb;
             size_t symbol_len = arg->val.str.lenmb;

             /* Next the `from' keyword.  */
             arg = lr_token (ldfile, charmap, result, repertoire, verbose);
             if (arg->tok != tok_from)
              {
                free ((char *) symbol);
                goto err_label;
              }

             ldfile->return_widestr = 1;
             ldfile->translate_strings = 1;

             /* Finally the string with the replacement.  */
             arg = lr_token (ldfile, charmap, result, repertoire, verbose);

             ldfile->return_widestr = 0;
             ldfile->translate_strings = 0;

             if (arg->tok != tok_string)
              goto err_label;

             if (!ignore_content && symbol != NULL)
              {
                /* The name is already defined.  */
                if (check_duplicate (ldfile, collate, charmap,
                                   repertoire, symbol, symbol_len))
                  goto col_elem_free;

                if (arg->val.str.startmb != NULL)
                  insert_entry (&collate->elem_table, symbol, symbol_len,
                              new_element (collate,
                                          arg->val.str.startmb,
                                          arg->val.str.lenmb - 1,
                                          arg->val.str.startwc,
                                          symbol, symbol_len, 0));
              }
             else
              {
              col_elem_free:
                free ((char *) symbol);
                free (arg->val.str.startmb);
                free (arg->val.str.startwc);
              }
             lr_ignore_rest (ldfile, 1);
           }
         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 && state != 2)
           goto err_label;

         arg = lr_token (ldfile, charmap, result, repertoire, verbose);
         if (arg->tok != tok_bsymbol)
           goto err_label;
         else
           {
             char *symbol = arg->val.str.startmb;
             size_t symbol_len = arg->val.str.lenmb;
             char *endsymbol = NULL;
             size_t endsymbol_len = 0;
             enum token_t ellipsis = tok_none;

             arg = lr_token (ldfile, charmap, result, repertoire, verbose);
             if (arg->tok == tok_ellipsis2 || arg->tok == tok_ellipsis4)
              {
                ellipsis = arg->tok;

                arg = lr_token (ldfile, charmap, result, repertoire,
                              verbose);
                if (arg->tok != tok_bsymbol)
                  {
                    free (symbol);
                    goto err_label;
                  }

                endsymbol = arg->val.str.startmb;
                endsymbol_len = arg->val.str.lenmb;

                lr_ignore_rest (ldfile, 1);
              }
             else if (arg->tok != tok_eol)
              {
                free (symbol);
                goto err_label;
              }

             if (!ignore_content)
              {
                if (symbol == NULL
                    || (ellipsis != tok_none && endsymbol == NULL))
                  {
                    lr_error (ldfile, _("\
%s: unknown character in collating symbol name"),
                            "LC_COLLATE");
                    goto col_sym_free;
                  }
                else if (ellipsis == tok_none)
                  {
                    /* A single symbol, no ellipsis.  */
                    if (check_duplicate (ldfile, collate, charmap,
                                      repertoire, symbol, symbol_len))
                     /* The name is already defined.  */
                     goto col_sym_free;

                    insert_entry (&collate->sym_table, symbol, symbol_len,
                                new_symbol (collate, symbol, symbol_len));
                  }
                else if (symbol_len != endsymbol_len)
                  {
                  col_sym_inv_range:
                    lr_error (ldfile,
                            _("invalid names for character range"));
                    goto col_sym_free;
                  }
                else
                  {
                    /* Oh my, we have to handle an ellipsis.  First, as
                      usual, determine the common prefix and then
                      convert the rest into a range.  */
                    size_t prefixlen;
                    unsigned long int from;
                    unsigned long int to;
                    char *endp;

                    for (prefixlen = 0; prefixlen < symbol_len; ++prefixlen)
                     if (symbol[prefixlen] != endsymbol[prefixlen])
                       break;

                    /* Convert the rest into numbers.  */
                    symbol[symbol_len] = '\0';
                    from = strtoul (&symbol[prefixlen], &endp,
                                  ellipsis == tok_ellipsis2 ? 16 : 10);
                    if (*endp != '\0')
                     goto col_sym_inv_range;

                    endsymbol[symbol_len] = '\0';
                    to = strtoul (&endsymbol[prefixlen], &endp,
                                ellipsis == tok_ellipsis2 ? 16 : 10);
                    if (*endp != '\0')
                     goto col_sym_inv_range;

                    if (from > to)
                     goto col_sym_inv_range;

                    /* Now loop over all entries.  */
                    while (from <= to)
                     {
                       char *symbuf;

                       symbuf = (char *) obstack_alloc (&collate->mempool,
                                                    symbol_len + 1);

                       /* Create the name.  */
                       sprintf (symbuf,
                               ellipsis == tok_ellipsis2
                               ? "%.*s%.*lX" : "%.*s%.*lu",
                               (int) prefixlen, symbol,
                               (int) (symbol_len - prefixlen), from);

                       if (check_duplicate (ldfile, collate, charmap,
                                          repertoire, symbuf, symbol_len))
                         /* The name is already defined.  */
                         goto col_sym_free;

                       insert_entry (&collate->sym_table, symbuf,
                                   symbol_len,
                                   new_symbol (collate, symbuf,
                                              symbol_len));

                       /* Increment the counter.  */
                       ++from;
                     }

                    goto col_sym_free;
                  }
              }
             else
              {
              col_sym_free:
                free (symbol);
                free (endsymbol);
              }
           }
         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;

         arg = lr_token (ldfile, charmap, result, repertoire, verbose);
         if (arg->tok != tok_bsymbol)
           goto err_label;
         else
           {
             const char *newname = arg->val.str.startmb;
             size_t newname_len = arg->val.str.lenmb;
             const char *symname;
             size_t symname_len;
             void *symval;  /* Actually struct symbol_t*  */

             arg = lr_token (ldfile, charmap, result, repertoire, verbose);
             if (arg->tok != tok_bsymbol)
              {
                free ((char *) newname);
                goto err_label;
              }

             symname = arg->val.str.startmb;
             symname_len = arg->val.str.lenmb;

             if (newname == NULL)
              {
                lr_error (ldfile, _("\
%s: unknown character in equivalent definition name"),
                         "LC_COLLATE");

              sym_equiv_free:
                free ((char *) newname);
                free ((char *) symname);
                break;
              }
             if (symname == NULL)
              {
                lr_error (ldfile, _("\
%s: unknown character in equivalent definition value"),
                         "LC_COLLATE");
                goto sym_equiv_free;
              }

             /* See whether the symbol name is already defined.  */
             if (find_entry (&collate->sym_table, symname, symname_len,
                           &symval) != 0)
              {
                lr_error (ldfile, _("\
%s: unknown symbol `%s' in equivalent definition"),
                         "LC_COLLATE", symname);
                goto sym_equiv_free;
              }

             if (insert_entry (&collate->sym_table,
                            newname, newname_len, symval) < 0)
              {
                lr_error (ldfile, _("\
error while adding equivalent collating symbol"));
                goto sym_equiv_free;
              }

             free ((char *) symname);
           }
         lr_ignore_rest (ldfile, 1);
         break;

       case tok_script:
         /* 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 get told about the scripts we know.  */
         arg = lr_token (ldfile, charmap, result, repertoire, verbose);
         if (arg->tok != tok_bsymbol)
           goto err_label;
         else
           {
             struct section_list *runp = collate->known_sections;
             char *name;

             while (runp != NULL)
              if (strncmp (runp->name, arg->val.str.startmb,
                          arg->val.str.lenmb) == 0
                  && runp->name[arg->val.str.lenmb] == '\0')
                break;
              else
                runp = runp->def_next;

             if (runp != NULL)
              {
                lr_error (ldfile, _("duplicate definition of script `%s'"),
                         runp->name);
                lr_ignore_rest (ldfile, 0);
                break;
              }

             runp = (struct section_list *) xcalloc (1, sizeof (*runp));
             name = (char *) xmalloc (arg->val.str.lenmb + 1);
             memcpy (name, arg->val.str.startmb, arg->val.str.lenmb);
             name[arg->val.str.lenmb] = '\0';
             runp->name = name;

             runp->def_next = collate->known_sections;
             collate->known_sections = runp;
           }
         lr_ignore_rest (ldfile, 1);
         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 && state != 2)
           goto err_label;
         state = 1;

         /* The 14652 draft does not specify whether all `order_start' lines
            must contain the same number of sort-rules, but 14651 does.  So
            we require this here as well.  */
         arg = lr_token (ldfile, charmap, result, repertoire, verbose);
         if (arg->tok == tok_bsymbol)
           {
             /* This better should be a section name.  */
             struct section_list *sp = collate->known_sections;
             while (sp != NULL
                   && (sp->name == NULL
                      || strncmp (sp->name, arg->val.str.startmb,
                                 arg->val.str.lenmb) != 0
                      || sp->name[arg->val.str.lenmb] != '\0'))
              sp = sp->def_next;

             if (sp == NULL)
              {
                lr_error (ldfile, _("\
%s: unknown section name `%.*s'"),
                         "LC_COLLATE", (int) arg->val.str.lenmb,
                         arg->val.str.startmb);
                /* We use the error section.  */
                collate->current_section = &collate->error_section;

                if (collate->error_section.first == NULL)
                  {
                    /* Insert &collate->error_section at the end of
                      the collate->sections list.  */
                    if (collate->sections == NULL)
                     collate->sections = &collate->error_section;
                    else
                     {
                       sp = collate->sections;
                       while (sp->next != NULL)
                         sp = sp->next;

                       sp->next = &collate->error_section;
                     }
                    collate->error_section.next = NULL;
                  }
              }
             else
              {
                /* One should not be allowed to open the same
                     section twice.  */
                if (sp->first != NULL)
                  lr_error (ldfile, _("\
%s: multiple order definitions for section `%s'"),
                           "LC_COLLATE", sp->name);
                else
                  {
                    /* Insert sp in the collate->sections list,
                      right after collate->current_section.  */
                    if (collate->current_section != NULL)
                     {
                       sp->next = collate->current_section->next;
                       collate->current_section->next = sp;
                     }
                    else if (collate->sections == NULL)
                     /* This is the first section to be defined.  */
                     collate->sections = sp;

                    collate->current_section = sp;
                  }

                /* Next should come the end of the line or a semicolon.  */
                arg = lr_token (ldfile, charmap, result, repertoire,
                              verbose);
                if (arg->tok == tok_eol)
                  {
                    uint32_t cnt;

                    /* This means we have exactly one rule: `forward'.  */
                    if (nrules > 1)
                     lr_error (ldfile, _("\
%s: invalid number of sorting rules"),
                              "LC_COLLATE");
                    else
                     nrules = 1;
                    sp->rules = obstack_alloc (&collate->mempool,
                                           (sizeof (enum coll_sort_rule)
                                            * nrules));
                    for (cnt = 0; cnt < nrules; ++cnt)
                     sp->rules[cnt] = sort_forward;

                    /* Next line.  */
                    break;
                  }

                /* Get the next token.  */
                arg = lr_token (ldfile, charmap, result, repertoire,
                              verbose);
              }
           }
         else
           {
             /* There is no section symbol.  Therefore we use the unnamed
               section.  */
             collate->current_section = &collate->unnamed_section;

             if (collate->unnamed_section.first != NULL)
              lr_error (ldfile, _("\
%s: multiple order definitions for unnamed section"),
                       "LC_COLLATE");
             else
              {
                /* Insert &collate->unnamed_section at the beginning of
                   the collate->sections list.  */
                collate->unnamed_section.next = collate->sections;
                collate->sections = &collate->unnamed_section;
              }
           }

         /* Now read the direction names.  */
         read_directions (ldfile, arg, charmap, repertoire, result);

         /* From now we need the strings untranslated.  */
         ldfile->translate_strings = 0;
         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;

         /* Handle ellipsis at end of list.  */
         if (was_ellipsis != tok_none)
           {
             handle_ellipsis (ldfile, NULL, 0, was_ellipsis, charmap,
                            repertoire, result);
             was_ellipsis = tok_none;
           }

         state = 2;
         lr_ignore_rest (ldfile, 1);
         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 == 1)
           {
             lr_error (ldfile, _("%s: missing `order_end' keyword"),
                     "LC_COLLATE");
             state = 2;

             /* Handle ellipsis at end of list.  */
             if (was_ellipsis != tok_none)
              {
                handle_ellipsis (ldfile, arg->val.str.startmb,
                               arg->val.str.lenmb, was_ellipsis, charmap,
                               repertoire, result);
                was_ellipsis = tok_none;
              }
           }
         else if (state == 0 && copy_locale == NULL)
           goto err_label;
         else if (state != 0 && state != 2 && state != 3)
           goto err_label;
         state = 3;

         arg = lr_token (ldfile, charmap, result, repertoire, verbose);
         if (arg->tok == tok_bsymbol || arg->tok == tok_ucs4)
           {
             /* Find this symbol in the sequence table.  */
             char ucsbuf[10];
             char *startmb;
             size_t lenmb;
             struct element_t *insp;
             int no_error = 1;
             void *ptr;

             if (arg->tok == tok_bsymbol)
              {
                startmb = arg->val.str.startmb;
                lenmb = arg->val.str.lenmb;
              }
             else
              {
                sprintf (ucsbuf, "U%08X", arg->val.ucs4);
                startmb = ucsbuf;
                lenmb = 9;
              }

             if (find_entry (&collate->seq_table, startmb, lenmb, &ptr) == 0)
              /* Yes, the symbol exists.  Simply point the cursor
                 to it.  */
              collate->cursor = (struct element_t *) ptr;
             else
              {
                struct symbol_t *symbp;
                void *ptr;

                if (find_entry (&collate->sym_table, startmb, lenmb,
                              &ptr) == 0)
                  {
                    symbp = ptr;

                    if (symbp->order->last != NULL
                       || symbp->order->next != NULL)
                     collate->cursor = symbp->order;
                    else
                     {
                       /* This is a collating symbol but its position
                          is not yet defined.  */
                       lr_error (ldfile, _("\
%s: order for collating symbol %.*s not yet defined"),
                                "LC_COLLATE", (int) lenmb, startmb);
                       collate->cursor = NULL;
                       no_error = 0;
                     }
                  }
                else if (find_entry (&collate->elem_table, startmb, lenmb,
                                   &ptr) == 0)
                  {
                    insp = (struct element_t *) ptr;

                    if (insp->last != NULL || insp->next != NULL)
                     collate->cursor = insp;
                    else
                     {
                       /* This is a collating element but its position
                          is not yet defined.  */
                       lr_error (ldfile, _("\
%s: order for collating element %.*s not yet defined"),
                                "LC_COLLATE", (int) lenmb, startmb);
                       collate->cursor = NULL;
                       no_error = 0;
                     }
                  }
                else
                  {
                    /* This is bad.  The symbol after which we have to
                      insert does not exist.  */
                    lr_error (ldfile, _("\
%s: cannot reorder after %.*s: symbol not known"),
                            "LC_COLLATE", (int) lenmb, startmb);
                    collate->cursor = NULL;
                    no_error = 0;
                  }
              }

             lr_ignore_rest (ldfile, no_error);
           }
         else
           /* This must not happen.  */
           goto err_label;
         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;
         lr_ignore_rest (ldfile, 1);
         break;

       case tok_reorder_sections_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 == 1)
           {
             lr_error (ldfile, _("%s: missing `order_end' keyword"),
                     "LC_COLLATE");
             state = 2;

             /* Handle ellipsis at end of list.  */
             if (was_ellipsis != tok_none)
              {
                handle_ellipsis (ldfile, NULL, 0, was_ellipsis, charmap,
                               repertoire, result);
                was_ellipsis = tok_none;
              }
           }
         else if (state == 3)
           {
             WITH_CUR_LOCALE (error (0, 0, _("\
%s: missing `reorder-end' keyword"), "LC_COLLATE"));
             state = 4;
           }
         else if (state != 2 && state != 4)
           goto err_label;
         state = 5;

         /* Get the name of the sections we are adding after.  */
         arg = lr_token (ldfile, charmap, result, repertoire, verbose);
         if (arg->tok == tok_bsymbol)
           {
             /* Now find a section with this name.  */
             struct section_list *runp = collate->sections;

             while (runp != NULL)
              {
                if (runp->name != NULL
                    && strlen (runp->name) == arg->val.str.lenmb
                    && memcmp (runp->name, arg->val.str.startmb,
                             arg->val.str.lenmb) == 0)
                  break;

                runp = runp->next;
              }

             if (runp != NULL)
              collate->current_section = runp;
             else
              {
                /* This is bad.  The section after which we have to
                     reorder does not exist.  Therefore we cannot
                     process the whole rest of this reorder
                     specification.  */
                lr_error (ldfile, _("%s: section `%.*s' not known"),
                         "LC_COLLATE", (int) arg->val.str.lenmb,
                         arg->val.str.startmb);

                do
                  {
                    lr_ignore_rest (ldfile, 0);

                    now = lr_token (ldfile, charmap, result, NULL, verbose);
                  }
                while (now->tok == tok_reorder_sections_after
                      || now->tok == tok_reorder_sections_end
                      || now->tok == tok_end);

                /* Process the token we just saw.  */
                nowtok = now->tok;
                continue;
              }
           }
         else
           /* This must not happen.  */
           goto err_label;
         break;

       case tok_reorder_sections_end:
         /* Ignore the rest of the line if we don't need the input of
            this line.  */
         if (ignore_content)
           break;

         if (state != 5)
           goto err_label;
         state = 6;
         lr_ignore_rest (ldfile, 1);
         break;

       case tok_bsymbol:
       case tok_ucs4:
         /* 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 && state != 3 && state != 5)
           goto err_label;

         if ((state == 0 || state == 5) && nowtok == tok_ucs4)
           goto err_label;

         if (nowtok == tok_ucs4)
           {
             snprintf (ucs4buf, sizeof (ucs4buf), "U%08X", now->val.ucs4);
             symstr = ucs4buf;
             symlen = 9;
           }
         else if (arg != NULL)
           {
             symstr = arg->val.str.startmb;
             symlen = arg->val.str.lenmb;
           }
         else
           {
             lr_error (ldfile, _("%s: bad symbol <%.*s>"), "LC_COLLATE",
                     (int) ldfile->token.val.str.lenmb,
                     ldfile->token.val.str.startmb);
             break;
           }

         struct element_t *seqp;
         if (state == 0)
           {
             /* We are outside an `order_start' region.  This means
                 we must only accept definitions of values for
                 collation symbols since these are purely abstract
                 values and don't need directions associated.  */
             void *ptr;

             if (find_entry (&collate->seq_table, symstr, symlen, &ptr) == 0)
              {
                seqp = ptr;

                /* It's already defined.  First check whether this
                   is really a collating symbol.  */
                if (seqp->is_character)
                  goto err_label;

                goto move_entry;
              }
             else
              {
                void *result;

                if (find_entry (&collate->sym_table, symstr, symlen,
                              &result) != 0)
                  /* No collating symbol, it's an error.  */
                  goto err_label;

                /* Maybe this is the first time we define a symbol
                   value and it is before the first actual section.  */
                if (collate->sections == NULL)
                  collate->sections = collate->current_section =
                    &collate->symbol_section;
              }

             if (was_ellipsis != tok_none)
              {
                handle_ellipsis (ldfile, symstr, symlen, was_ellipsis,
                               charmap, repertoire, result);

                /* Remember that we processed the ellipsis.  */
                was_ellipsis = tok_none;

                /* And don't add the value a second time.  */
                break;
              }
           }
         else if (state == 3)
           {
             /* It is possible that we already have this collation sequence.
               In this case we move the entry.  */
             void *sym;
             void *ptr;

             /* If the symbol after which we have to insert was not found
               ignore all entries.  */
             if (collate->cursor == NULL)
              {
                lr_ignore_rest (ldfile, 0);
                break;
              }

             if (find_entry (&collate->seq_table, symstr, symlen, &ptr) == 0)
              {
                seqp = (struct element_t *) ptr;
                goto move_entry;
              }

             if (find_entry (&collate->sym_table, symstr, symlen, &sym) == 0
                && (seqp = ((struct symbol_t *) sym)->order) != NULL)
              goto move_entry;

             if (find_entry (&collate->elem_table, symstr, symlen, &ptr) == 0
                && (seqp = (struct element_t *) ptr,
                    seqp->last != NULL || seqp->next != NULL
                    || (collate->start != NULL && seqp == collate->start)))
              {
              move_entry:
                /* Remove the entry from the old position.  */
                if (seqp->last == NULL)
                  collate->start = seqp->next;
                else
                  seqp->last->next = seqp->next;
                if (seqp->next != NULL)
                  seqp->next->last = seqp->last;

                /* We also have to check whether this entry is the
                     first or last of a section.  */
                if (seqp->section->first == seqp)
                  {
                    if (seqp->section->first == seqp->section->last)
                     /* This section has no content anymore.  */
                     seqp->section->first = seqp->section->last = NULL;
                    else
                     seqp->section->first = seqp->next;
                  }
                else if (seqp->section->last == seqp)
                  seqp->section->last = seqp->last;

                /* Now insert it in the new place.  */
                insert_weights (ldfile, seqp, charmap, repertoire, result,
                              tok_none);
                break;
              }

             /* Otherwise we just add a new entry.  */
           }
         else if (state == 5)
           {
             /* We are reordering sections.  Find the named section.  */
             struct section_list *runp = collate->sections;
             struct section_list *prevp = NULL;

             while (runp != NULL)
              {
                if (runp->name != NULL
                    && strlen (runp->name) == symlen
                    && memcmp (runp->name, symstr, symlen) == 0)
                  break;

                prevp = runp;
                runp = runp->next;
              }

             if (runp == NULL)
              {
                lr_error (ldfile, _("%s: section `%.*s' not known"),
                         "LC_COLLATE", (int) symlen, symstr);
                lr_ignore_rest (ldfile, 0);
              }
             else
              {
                if (runp != collate->current_section)
                  {
                    /* Remove the named section from the old place and
                      insert it in the new one.  */
                    prevp->next = runp->next;

                    runp->next = collate->current_section->next;
                    collate->current_section->next = runp;
                    collate->current_section = runp;
                  }

                /* Process the rest of the line which might change
                     the collation rules.  */
                arg = lr_token (ldfile, charmap, result, repertoire,
                              verbose);
                if (arg->tok != tok_eof && arg->tok != tok_eol)
                  read_directions (ldfile, arg, charmap, repertoire,
                                 result);
              }
             break;
           }
         else if (was_ellipsis != tok_none)
           {
             /* Using the information in the `ellipsis_weight'
                 element and this and the last value we have to handle
                 the ellipsis now.  */
             assert (state == 1);

             handle_ellipsis (ldfile, symstr, symlen, was_ellipsis, charmap,
                            repertoire, result);

             /* Remember that we processed the ellipsis.  */
             was_ellipsis = tok_none;

             /* And don't add the value a second time.  */
             break;
           }

         /* Now insert in the new place.  */
         insert_value (ldfile, symstr, symlen, charmap, repertoire, result);
         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;

         if (was_ellipsis != tok_none)
           {
             lr_error (ldfile,
                     _("%s: cannot have `%s' as end of ellipsis range"),
                     "LC_COLLATE", "UNDEFINED");

             unlink_element (collate);
             was_ellipsis = tok_none;
           }

         /* See whether UNDEFINED already appeared somewhere.  */
         if (collate->undefined.next != NULL
             || &collate->undefined == collate->cursor)
           {
             lr_error (ldfile,
                     _("%s: order for `%.*s' already defined at %s:%Zu"),
                     "LC_COLLATE", 9, "UNDEFINED",
                     collate->undefined.file,
                     collate->undefined.line);
             lr_ignore_rest (ldfile, 0);
           }
         else
           /* Parse the weights.  */
            insert_weights (ldfile, &collate->undefined, charmap,
                          repertoire, result, tok_none);
         break;

       case tok_ellipsis2: /* symbolic hexadecimal ellipsis */
       case tok_ellipsis3: /* absolute ellipsis */
       case tok_ellipsis4: /* symbolic decimal ellipsis */
         /* This is the symbolic (decimal or hexadecimal) or absolute
             ellipsis.  */
         if (was_ellipsis != tok_none)
           goto err_label;

         if (state != 0 && state != 1 && state != 3)
           goto err_label;

         was_ellipsis = nowtok;

         insert_weights (ldfile, &collate->ellipsis_weight, charmap,
                       repertoire, result, nowtok);
         break;

       case tok_end:
       seen_end:
         /* Next we assume `LC_COLLATE'.  */
         if (!ignore_content)
           {
             if (state == 0 && copy_locale == NULL)
              /* 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");

                /* Handle ellipsis at end of list.  */
                if (was_ellipsis != tok_none)
                  {
                    handle_ellipsis (ldfile, NULL, 0, was_ellipsis, charmap,
                                   repertoire, result);
                    was_ellipsis = tok_none;
                  }
              }
             else if (state == 3)
              WITH_CUR_LOCALE (error (0, 0, _("\
%s: missing `reorder-end' keyword"), "LC_COLLATE"));
             else if (state == 5)
              WITH_CUR_LOCALE (error (0, 0, _("\
%s: missing `reorder-sections-end' keyword"), "LC_COLLATE"));
           }
         arg = lr_token (ldfile, charmap, result, NULL, verbose);
         if (arg->tok == tok_eof)
           break;
         if (arg->tok == tok_eol)
           lr_error (ldfile, _("%s: incomplete `END' line"), "LC_COLLATE");
         else if (arg->tok != tok_lc_collate)
           lr_error (ldfile, _("\
%1$s: definition does not end with `END %1$s'"), "LC_COLLATE");
         lr_ignore_rest (ldfile, arg->tok == tok_lc_collate);
         return;

       case tok_define:
         if (ignore_content)
           {
             lr_ignore_rest (ldfile, 0);
             break;
           }

         arg = lr_token (ldfile, charmap, result, NULL, verbose);
         if (arg->tok != tok_ident)
           goto err_label;

         /* Simply add the new symbol.  */
         struct name_list *newsym = xmalloc (sizeof (*newsym)
                                         + arg->val.str.lenmb + 1);
         memcpy (newsym->str, arg->val.str.startmb, arg->val.str.lenmb);
         newsym->str[arg->val.str.lenmb] = '\0';
         newsym->next = defined;
         defined = newsym;

         lr_ignore_rest (ldfile, 1);
         break;

       case tok_undef:
         if (ignore_content)
           {
             lr_ignore_rest (ldfile, 0);
             break;
           }

         arg = lr_token (ldfile, charmap, result, NULL, verbose);
         if (arg->tok != tok_ident)
           goto err_label;

         /* Remove _all_ occurrences of the symbol from the list.  */
         struct name_list *prevdef = NULL;
         struct name_list *curdef = defined;
         while (curdef != NULL)
           if (strncmp (arg->val.str.startmb, curdef->str,
                      arg->val.str.lenmb) == 0
              && curdef->str[arg->val.str.lenmb] == '\0')
             {
              if (prevdef == NULL)
                defined = curdef->next;
              else
                prevdef->next = curdef->next;

              struct name_list *olddef = curdef;
              curdef = curdef->next;

              free (olddef);
             }
           else
             {
              prevdef = curdef;
              curdef = curdef->next;
             }

         lr_ignore_rest (ldfile, 1);
         break;

       case tok_ifdef:
       case tok_ifndef:
         if (ignore_content)
           {
             lr_ignore_rest (ldfile, 0);
             break;
           }

       found_ifdef:
         arg = lr_token (ldfile, charmap, result, NULL, verbose);
         if (arg->tok != tok_ident)
           goto err_label;
         lr_ignore_rest (ldfile, 1);

         if (collate->else_action == else_none)
           {
             curdef = defined;
             while (curdef != NULL)
              if (strncmp (arg->val.str.startmb, curdef->str,
                          arg->val.str.lenmb) == 0
                  && curdef->str[arg->val.str.lenmb] == '\0')
                break;
              else
                curdef = curdef->next;

             if ((nowtok == tok_ifdef && curdef != NULL)
                || (nowtok == tok_ifndef && curdef == NULL))
              {
                /* We have to use the if-branch.  */
                collate->else_action = else_ignore;
              }
             else
              {
                /* We have to use the else-branch, if there is one.  */
                nowtok = skip_to (ldfile, collate, charmap, 0);
                if (nowtok == tok_else)
                  collate->else_action = else_seen;
                else if (nowtok == tok_elifdef)
                  {
                    nowtok = tok_ifdef;
                    goto found_ifdef;
                  }
                else if (nowtok == tok_elifndef)
                  {
                    nowtok = tok_ifndef;
                    goto found_ifdef;
                  }
                else if (nowtok == tok_eof)
                  goto seen_eof;
                else if (nowtok == tok_end)
                  goto seen_end;
              }
           }
         else
           {
             /* XXX Should it really become necessary to support nested
               preprocessor handling we will push the state here.  */
             lr_error (ldfile, _("%s: nested conditionals not supported"),
                     "LC_COLLATE");
             nowtok = skip_to (ldfile, collate, charmap, 1);
             if (nowtok == tok_eof)
              goto seen_eof;
             else if (nowtok == tok_end)
              goto seen_end;
           }
         break;

       case tok_elifdef:
       case tok_elifndef:
       case tok_else:
         if (ignore_content)
           {
             lr_ignore_rest (ldfile, 0);
             break;
           }

         lr_ignore_rest (ldfile, 1);

         if (collate->else_action == else_ignore)
           {
             /* Ignore everything until the endif.  */
             nowtok = skip_to (ldfile, collate, charmap, 1);
             if (nowtok == tok_eof)
              goto seen_eof;
             else if (nowtok == tok_end)
              goto seen_end;
           }
         else
           {
             assert (collate->else_action == else_none);
             lr_error (ldfile, _("\
%s: '%s' without matching 'ifdef' or 'ifndef'"), "LC_COLLATE",
                     nowtok == tok_else ? "else"
                     : nowtok == tok_elifdef ? "elifdef" : "elifndef");
           }
         break;

       case tok_endif:
         if (ignore_content)
           {
             lr_ignore_rest (ldfile, 0);
             break;
           }

         lr_ignore_rest (ldfile, 1);

         if (collate->else_action != else_ignore
             && collate->else_action != else_seen)
           lr_error (ldfile, _("\
%s: 'endif' without matching 'ifdef' or 'ifndef'"), "LC_COLLATE");

         /* XXX If we support nested preprocessor directives we pop
            the state here.  */
         collate->else_action = else_none;
         break;

       default:
       err_label:
         SYNTAX_ERROR (_("%s: syntax error"), "LC_COLLATE");
       }

      /* Prepare for the next round.  */
      now = lr_token (ldfile, charmap, result, NULL, verbose);
      nowtok = now->tok;
    }

 seen_eof:
  /* When we come here we reached the end of the file.  */
  lr_error (ldfile, _("%s: premature end of file"), "LC_COLLATE");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ctype_finish ( struct localedef_t locale,
const struct charmap_t charmap 
)

Definition at line 355 of file ld-ctype.c.

{
  /* See POSIX.2, table 2-6 for the meaning of the following table.  */
#define NCLASS 12
  static const struct
  {
    const char *name;
    const char allow[NCLASS];
  }
  valid_table[NCLASS] =
  {
    /* The order is important.  See token.h for more information.
       M = Always, D = Default, - = Permitted, X = Mutually exclusive  */
    { "upper",  "--MX-XDDXXX-" },
    { "lower",  "--MX-XDDXXX-" },
    { "alpha",  "---X-XDDXXX-" },
    { "digit",  "XXX--XDDXXX-" },
    { "xdigit", "-----XDDXXX-" },
    { "space",  "XXXXX------X" },
    { "print",  "---------X--" },
    { "graph",  "---------X--" },
    { "blank",  "XXXXXM-----X" },
    { "cntrl",  "XXXXX-XX--XX" },
    { "punct",  "XXXXX-DD-X-X" },
    { "alnum",  "-----XDDXXX-" }
  };
  size_t cnt;
  int cls1, cls2;
  uint32_t space_value;
  struct charseq *space_seq;
  struct locale_ctype_t *ctype = locale->categories[LC_CTYPE].ctype;
  int warned;
  const void *key;
  size_t len;
  void *vdata;
  void *curs;

  /* Now resolve copying and also handle completely missing definitions.  */
  if (ctype == NULL)
    {
      const char *repertoire_name;

      /* 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)
       {
         if (! be_quiet)
           WITH_CUR_LOCALE (error (0, 0, _("\
No definition for %s category found"), "LC_CTYPE"));
         ctype_startup (NULL, locale, charmap, NULL, 0);
         ctype = locale->categories[LC_CTYPE].ctype;
       }

      /* Get the repertoire we have to use.  */
      repertoire_name = locale->repertoire_name ?: repertoire_global;
      if (repertoire_name != NULL)
       ctype->repertoire = repertoire_read (repertoire_name);
    }

  /* We need the name of the currently used 8-bit character set to
     make correct conversion between this 8-bit representation and the
     ISO 10646 character set used internally for wide characters.  */
  ctype->codeset_name = charmap->code_set_name;
  if (ctype->codeset_name == NULL)
    {
      if (! be_quiet)
       WITH_CUR_LOCALE (error (0, 0, _("\
No character set name specified in charmap")));
      ctype->codeset_name = "//UNKNOWN//";
    }

  /* Set default value for classes not specified.  */
  set_class_defaults (ctype, charmap, ctype->repertoire);

  /* Check according to table.  */
  for (cnt = 0; cnt < ctype->class_collection_act; ++cnt)
    {
      uint32_t tmp = ctype->class_collection[cnt];

      if (tmp != 0)
       {
         for (cls1 = 0; cls1 < NCLASS; ++cls1)
           if ((tmp & _ISwbit (cls1)) != 0)
             for (cls2 = 0; cls2 < NCLASS; ++cls2)
              if (valid_table[cls1].allow[cls2] != '-')
                {
                  int eq = (tmp & _ISwbit (cls2)) != 0;
                  switch (valid_table[cls1].allow[cls2])
                    {
                    case 'M':
                     if (!eq)
                       {
                         uint32_t value = ctype->charnames[cnt];

                         if (!be_quiet)
                           WITH_CUR_LOCALE (error (0, 0, _("\
character L'\\u%0*x' in class `%s' must be in class `%s'"),
                                                value > 0xffff ? 8 : 4,
                                                value,
                                                valid_table[cls1].name,
                                                valid_table[cls2].name));
                       }
                     break;

                    case 'X':
                     if (eq)
                       {
                         uint32_t value = ctype->charnames[cnt];

                         if (!be_quiet)
                           WITH_CUR_LOCALE (error (0, 0, _("\
character L'\\u%0*x' in class `%s' must not be in class `%s'"),
                                                value > 0xffff ? 8 : 4,
                                                value,
                                                valid_table[cls1].name,
                                                valid_table[cls2].name));
                       }
                     break;

                    case 'D':
                     ctype->class_collection[cnt] |= _ISwbit (cls2);
                     break;

                    default:
                     WITH_CUR_LOCALE (error (5, 0, _("\
internal error in %s, line %u"), __FUNCTION__, __LINE__));
                    }
                }
       }
    }

  for (cnt = 0; cnt < 256; ++cnt)
    {
      uint32_t tmp = ctype->class256_collection[cnt];

      if (tmp != 0)
       {
         for (cls1 = 0; cls1 < NCLASS; ++cls1)
           if ((tmp & _ISbit (cls1)) != 0)
             for (cls2 = 0; cls2 < NCLASS; ++cls2)
              if (valid_table[cls1].allow[cls2] != '-')
                {
                  int eq = (tmp & _ISbit (cls2)) != 0;
                  switch (valid_table[cls1].allow[cls2])
                    {
                    case 'M':
                     if (!eq)
                       {
                         char buf[17];

                         snprintf (buf, sizeof buf, "\\%Zo", cnt);

                         if (!be_quiet)
                           WITH_CUR_LOCALE (error (0, 0, _("\
character '%s' in class `%s' must be in class `%s'"),
                                                buf,
                                                valid_table[cls1].name,
                                                valid_table[cls2].name));
                       }
                     break;

                    case 'X':
                     if (eq)
                       {
                         char buf[17];

                         snprintf (buf, sizeof buf, "\\%Zo", cnt);

                         if (!be_quiet)
                           WITH_CUR_LOCALE (error (0, 0, _("\
character '%s' in class `%s' must not be in class `%s'"),
                                                buf,
                                                valid_table[cls1].name,
                                                valid_table[cls2].name));
                       }
                     break;

                    case 'D':
                     ctype->class256_collection[cnt] |= _ISbit (cls2);
                     break;

                    default:
                     WITH_CUR_LOCALE (error (5, 0, _("\
internal error in %s, line %u"), __FUNCTION__, __LINE__));
                    }
                }
       }
    }

  /* ... and now test <SP> as a special case.  */
  space_value = 32;
  if (((cnt = BITPOS (tok_space),
       (ELEM (ctype, class_collection, , space_value)
        & BITw (tok_space)) == 0)
       || (cnt = BITPOS (tok_blank),
          (ELEM (ctype, class_collection, , space_value)
           & BITw (tok_blank)) == 0)))
    {
      if (!be_quiet)
       WITH_CUR_LOCALE (error (0, 0, _("<SP> character not in class `%s'"),
                            valid_table[cnt].name));
    }
  else if (((cnt = BITPOS (tok_punct),
            (ELEM (ctype, class_collection, , space_value)
             & BITw (tok_punct)) != 0)
           || (cnt = BITPOS (tok_graph),
              (ELEM (ctype, class_collection, , space_value)
               & BITw (tok_graph))
              != 0)))
    {
      if (!be_quiet)
       WITH_CUR_LOCALE (error (0, 0, _("\
<SP> character must not be in class `%s'"),
                            valid_table[cnt].name));
    }
  else
    ELEM (ctype, class_collection, , space_value) |= BITw (tok_print);

  space_seq = charmap_find_value (charmap, "SP", 2);
  if (space_seq == NULL)
    space_seq = charmap_find_value (charmap, "space", 5);
  if (space_seq == NULL)
    space_seq = charmap_find_value (charmap, "U00000020", 9);
  if (space_seq == NULL || space_seq->nbytes != 1)
    {
      if (!be_quiet)
       WITH_CUR_LOCALE (error (0, 0, _("\
character <SP> not defined in character map")));
    }
  else if (((cnt = BITPOS (tok_space),
            (ctype->class256_collection[space_seq->bytes[0]]
             & BIT (tok_space)) == 0)
           || (cnt = BITPOS (tok_blank),
              (ctype->class256_collection[space_seq->bytes[0]]
               & BIT (tok_blank)) == 0)))
    {
      if (!be_quiet)
       WITH_CUR_LOCALE (error (0, 0, _("<SP> character not in class `%s'"),
                            valid_table[cnt].name));
    }
  else if (((cnt = BITPOS (tok_punct),
            (ctype->class256_collection[space_seq->bytes[0]]
             & BIT (tok_punct)) != 0)
           || (cnt = BITPOS (tok_graph),
              (ctype->class256_collection[space_seq->bytes[0]]
               & BIT (tok_graph)) != 0)))
    {
      if (!be_quiet)
       WITH_CUR_LOCALE (error (0, 0, _("\
<SP> character must not be in class `%s'"),
                            valid_table[cnt].name));
    }
  else
    ctype->class256_collection[space_seq->bytes[0]] |= BIT (tok_print);

  /* Now that the tests are done make sure the name array contains all
     characters which are handled in the WIDTH section of the
     character set definition file.  */
  if (charmap->width_rules != NULL)
    for (cnt = 0; cnt < charmap->nwidth_rules; ++cnt)
      {
       unsigned char bytes[charmap->mb_cur_max];
       int nbytes = charmap->width_rules[cnt].from->nbytes;

       /* We have the range of character for which the width is
           specified described using byte sequences of the multibyte
           charset.  We have to convert this to UCS4 now.  And we
           cannot simply convert the beginning and the end of the
           sequence, we have to iterate over the byte sequence and
           convert it for every single character.  */
       memcpy (bytes, charmap->width_rules[cnt].from->bytes, nbytes);

       while (nbytes < charmap->width_rules[cnt].to->nbytes
              || memcmp (bytes, charmap->width_rules[cnt].to->bytes,
                       nbytes) <= 0)
         {
           /* Find the UCS value for `bytes'.  */
           int inner;
           uint32_t wch;
           struct charseq *seq
             = charmap_find_symbol (charmap, (char *) bytes, nbytes);

           if (seq == NULL)
             wch = ILLEGAL_CHAR_VALUE;
           else if (seq->ucs4 != UNINITIALIZED_CHAR_VALUE)
             wch = seq->ucs4;
           else
             wch = repertoire_find_value (ctype->repertoire, seq->name,
                                      strlen (seq->name));

           if (wch != ILLEGAL_CHAR_VALUE)
             /* We are only interested in the side-effects of the
               `find_idx' call.  It will add appropriate entries in
               the name array if this is necessary.  */
             (void) find_idx (ctype, NULL, NULL, NULL, wch);

           /* "Increment" the bytes sequence.  */
           inner = nbytes - 1;
           while (inner >= 0 && bytes[inner] == 0xff)
             --inner;

           if (inner < 0)
             {
              /* We have to extend the byte sequence.  */
              if (nbytes >= charmap->width_rules[cnt].to->nbytes)
                break;

              bytes[0] = 1;
              memset (&bytes[1], 0, nbytes);
              ++nbytes;
             }
           else
             {
              ++bytes[inner];
              while (++inner < nbytes)
                bytes[inner] = 0;
             }
         }
      }

  /* Now set all the other characters of the character set to the
     default width.  */
  curs = NULL;
  while (iterate_table (&charmap->char_table, &curs, &key, &len, &vdata) == 0)
    {
      struct charseq *data = (struct charseq *) vdata;

      if (data->ucs4 == UNINITIALIZED_CHAR_VALUE)
       data->ucs4 = repertoire_find_value (ctype->repertoire,
                                       data->name, len);

      if (data->ucs4 != ILLEGAL_CHAR_VALUE)
       (void) find_idx (ctype, NULL, NULL, NULL, data->ucs4);
    }

  /* There must be a multiple of 10 digits.  */
  if (ctype->mbdigits_act % 10 != 0)
    {
      assert (ctype->mbdigits_act == ctype->wcdigits_act);
      ctype->wcdigits_act -= ctype->mbdigits_act % 10;
      ctype->mbdigits_act -= ctype->mbdigits_act % 10;
      WITH_CUR_LOCALE (error (0, 0, _("\
`digit' category has not entries in groups of ten")));
    }

  /* Check the input digits.  There must be a multiple of ten available.
     In each group it could be that one or the other character is missing.
     In this case the whole group must be removed.  */
  cnt = 0;
  while (cnt < ctype->mbdigits_act)
    {
      size_t inner;
      for (inner = 0; inner < 10; ++inner)
       if (ctype->mbdigits[cnt + inner] == NULL)
         break;

      if (inner == 10)
       cnt += 10;
      else
       {
         /* Remove the group.  */
         memmove (&ctype->mbdigits[cnt], &ctype->mbdigits[cnt + 10],
                 ((ctype->wcdigits_act - cnt - 10)
                  * sizeof (ctype->mbdigits[0])));
         ctype->mbdigits_act -= 10;
       }
    }

  /* If no input digits are given use the default.  */
  if (ctype->mbdigits_act == 0)
    {
      if (ctype->mbdigits_max == 0)
       {
         ctype->mbdigits = obstack_alloc (&((struct charmap_t *) charmap)->mem_pool,
                                      10 * sizeof (struct charseq *));
         ctype->mbdigits_max = 10;
       }

      for (cnt = 0; cnt < 10; ++cnt)
       {
         ctype->mbdigits[cnt] = charmap_find_symbol (charmap,
                                                (char *) digits + cnt, 1);
         if (ctype->mbdigits[cnt] == NULL)
           {
             ctype->mbdigits[cnt] = charmap_find_symbol (charmap,
                                                   longnames[cnt],
                                                   strlen (longnames[cnt]));
             if (ctype->mbdigits[cnt] == NULL)
              {
                /* Hum, this ain't good.  */
                WITH_CUR_LOCALE (error (0, 0, _("\
no input digits defined and none of the standard names in the charmap")));

                ctype->mbdigits[cnt] = obstack_alloc (&((struct charmap_t *) charmap)->mem_pool,
                                                 sizeof (struct charseq) + 1);

                /* This is better than nothing.  */
                ctype->mbdigits[cnt]->bytes[0] = digits[cnt];
                ctype->mbdigits[cnt]->nbytes = 1;
              }
           }
       }

      ctype->mbdigits_act = 10;
    }

  /* Check the wide character input digits.  There must be a multiple
     of ten available.  In each group it could be that one or the other
     character is missing.  In this case the whole group must be
     removed.  */
  cnt = 0;
  while (cnt < ctype->wcdigits_act)
    {
      size_t inner;
      for (inner = 0; inner < 10; ++inner)
       if (ctype->wcdigits[cnt + inner] == ILLEGAL_CHAR_VALUE)
         break;

      if (inner == 10)
       cnt += 10;
      else
       {
         /* Remove the group.  */
         memmove (&ctype->wcdigits[cnt], &ctype->wcdigits[cnt + 10],
                 ((ctype->wcdigits_act - cnt - 10)
                  * sizeof (ctype->wcdigits[0])));
         ctype->wcdigits_act -= 10;
       }
    }

  /* If no input digits are given use the default.  */
  if (ctype->wcdigits_act == 0)
    {
      if (ctype->wcdigits_max == 0)
       {
         ctype->wcdigits = obstack_alloc (&((struct charmap_t *) charmap)->mem_pool,
                                      10 * sizeof (uint32_t));
         ctype->wcdigits_max = 10;
       }

      for (cnt = 0; cnt < 10; ++cnt)
       ctype->wcdigits[cnt] = L'0' + cnt;

      ctype->mbdigits_act = 10;
    }

  /* Check the outdigits.  */
  warned = 0;
  for (cnt = 0; cnt < 10; ++cnt)
    if (ctype->mboutdigits[cnt] == NULL)
      {
       static struct charseq replace[2];

       if (!warned)
         {
           WITH_CUR_LOCALE (error (0, 0, _("\
not all characters used in `outdigit' are available in the charmap")));
           warned = 1;
         }

       replace[0].nbytes = 1;
       replace[0].bytes[0] = '?';
       replace[0].bytes[1] = '\0';
       ctype->mboutdigits[cnt] = &replace[0];
      }

  warned = 0;
  for (cnt = 0; cnt < 10; ++cnt)
    if (ctype->wcoutdigits[cnt] == 0)
      {
       if (!warned)
         {
           WITH_CUR_LOCALE (error (0, 0, _("\
not all characters used in `outdigit' are available in the repertoire")));
           warned = 1;
         }

       ctype->wcoutdigits[cnt] = L'?';
      }

  /* Sort the entries in the translit_ignore list.  */
  if (ctype->translit_ignore != NULL)
    {
      struct translit_ignore_t *firstp = ctype->translit_ignore;
      struct translit_ignore_t *runp;

      ctype->ntranslit_ignore = 1;

      for (runp = firstp->next; runp != NULL; runp = runp->next)
       {
         struct translit_ignore_t *lastp = NULL;
         struct translit_ignore_t *cmpp;

         ++ctype->ntranslit_ignore;

         for (cmpp = firstp; cmpp != NULL; lastp = cmpp, cmpp = cmpp->next)
           if (runp->from < cmpp->from)
             break;

         runp->next = lastp;
         if (lastp == NULL)
           firstp = runp;
       }

      ctype->translit_ignore = firstp;
    }
}

Here is the call graph for this function:

void ctype_output ( struct localedef_t locale,
const struct charmap_t charmap,
const char *  output_path 
)

Definition at line 883 of file ld-ctype.c.

{
  static const char nulbytes[4] = { 0, 0, 0, 0 };
  struct locale_ctype_t *ctype = locale->categories[LC_CTYPE].ctype;
  const size_t nelems = (_NL_ITEM_INDEX (_NL_CTYPE_EXTRA_MAP_1)
                      + ctype->nr_charclass + ctype->map_collection_nr);
  struct iovec *iov = alloca (sizeof *iov
                           * (2 + nelems + 2 * ctype->nr_charclass
                             + ctype->map_collection_nr + 4));
  struct locale_file data;
  uint32_t *idx = alloca (sizeof *idx * (nelems + 1));
  uint32_t default_missing_len;
  size_t elem, cnt, offset, total;
  char *cp;

  /* Now prepare the output: Find the sizes of the table we can use.  */
  allocate_arrays (ctype, charmap, ctype->repertoire);

  data.magic = LIMAGIC (LC_CTYPE);
  data.n = nelems;
  iov[0].iov_base = (void *) &data;
  iov[0].iov_len = sizeof (data);

  iov[1].iov_base = (void *) idx;
  iov[1].iov_len = nelems * sizeof (uint32_t);

  idx[0] = iov[0].iov_len + iov[1].iov_len;
  offset = 0;

  for (elem = 0; elem < nelems; ++elem)
    {
      if (elem < _NL_ITEM_INDEX (_NL_CTYPE_EXTRA_MAP_1))
       switch (elem)
         {
#define CTYPE_EMPTY(name) \
         case name:                                                  \
           iov[2 + elem + offset].iov_base = NULL;                          \
           iov[2 + elem + offset].iov_len = 0;                              \
           idx[elem + 1] = idx[elem];                                       \
           break

         CTYPE_EMPTY(_NL_CTYPE_GAP1);
         CTYPE_EMPTY(_NL_CTYPE_GAP2);
         CTYPE_EMPTY(_NL_CTYPE_GAP3);
         CTYPE_EMPTY(_NL_CTYPE_GAP4);
         CTYPE_EMPTY(_NL_CTYPE_GAP5);
         CTYPE_EMPTY(_NL_CTYPE_GAP6);

#define CTYPE_DATA(name, base, len)                                         \
         case _NL_ITEM_INDEX (name):                                        \
           iov[2 + elem + offset].iov_base = (base);                        \
           iov[2 + elem + offset].iov_len = (len);                          \
           idx[elem + 1] = idx[elem] + iov[2 + elem + offset].iov_len;             \
           break

         CTYPE_DATA (_NL_CTYPE_CLASS,
                    ctype->ctype_b,
                    (256 + 128) * sizeof (char_class_t));

         CTYPE_DATA (_NL_CTYPE_TOUPPER,
                    ctype->map_b[0],
                    (256 + 128) * sizeof (uint32_t));
         CTYPE_DATA (_NL_CTYPE_TOLOWER,
                    ctype->map_b[1],
                    (256 + 128) * sizeof (uint32_t));

         CTYPE_DATA (_NL_CTYPE_TOUPPER32,
                    ctype->map32_b[0],
                    256 * sizeof (uint32_t));
         CTYPE_DATA (_NL_CTYPE_TOLOWER32,
                    ctype->map32_b[1],
                    256 * sizeof (uint32_t));

         CTYPE_DATA (_NL_CTYPE_CLASS32,
                    ctype->ctype32_b,
                    256 * sizeof (char_class32_t));

         CTYPE_DATA (_NL_CTYPE_CLASS_OFFSET,
                    &ctype->class_offset, sizeof (uint32_t));

         CTYPE_DATA (_NL_CTYPE_MAP_OFFSET,
                    &ctype->map_offset, sizeof (uint32_t));

         CTYPE_DATA (_NL_CTYPE_TRANSLIT_TAB_SIZE,
                    &ctype->translit_idx_size, sizeof (uint32_t));

         CTYPE_DATA (_NL_CTYPE_TRANSLIT_FROM_IDX,
                    ctype->translit_from_idx,
                    ctype->translit_idx_size * sizeof (uint32_t));

         CTYPE_DATA (_NL_CTYPE_TRANSLIT_FROM_TBL,
                    ctype->translit_from_tbl,
                    ctype->translit_from_tbl_size);

         CTYPE_DATA (_NL_CTYPE_TRANSLIT_TO_IDX,
                    ctype->translit_to_idx,
                    ctype->translit_idx_size * sizeof (uint32_t));

         CTYPE_DATA (_NL_CTYPE_TRANSLIT_TO_TBL,
                    ctype->translit_to_tbl, ctype->translit_to_tbl_size);

         case _NL_ITEM_INDEX (_NL_CTYPE_CLASS_NAMES):
           /* The class name array.  */
           total = 0;
           for (cnt = 0; cnt < ctype->nr_charclass; ++cnt, ++offset)
             {
              iov[2 + elem + offset].iov_base
                = (void *) ctype->classnames[cnt];
              iov[2 + elem + offset].iov_len
                = strlen (ctype->classnames[cnt]) + 1;
              total += iov[2 + elem + offset].iov_len;
             }
           iov[2 + elem + offset].iov_base = (void *) nulbytes;
           iov[2 + elem + offset].iov_len = 4 - (total % 4);
           total += 4 - (total % 4);

           idx[elem + 1] = idx[elem] + total;
           break;

         case _NL_ITEM_INDEX (_NL_CTYPE_MAP_NAMES):
           /* The class name array.  */
           total = 0;
           for (cnt = 0; cnt < ctype->map_collection_nr; ++cnt, ++offset)
             {
              iov[2 + elem + offset].iov_base
                = (void *) ctype->mapnames[cnt];
              iov[2 + elem + offset].iov_len
                = strlen (ctype->mapnames[cnt]) + 1;
              total += iov[2 + elem + offset].iov_len;
             }
           iov[2 + elem + offset].iov_base = (void *) nulbytes;
           iov[2 + elem + offset].iov_len = 4 - (total % 4);
           total += 4 - (total % 4);

           idx[elem + 1] = idx[elem] + total;
           break;

         CTYPE_DATA (_NL_CTYPE_WIDTH,
                    ctype->width.iov_base,
                    ctype->width.iov_len);

         CTYPE_DATA (_NL_CTYPE_MB_CUR_MAX,
                    &ctype->mb_cur_max, sizeof (uint32_t));

         case _NL_ITEM_INDEX (_NL_CTYPE_CODESET_NAME):
           total = strlen (ctype->codeset_name) + 1;
           if (total % 4 == 0)
             iov[2 + elem + offset].iov_base = (char *) ctype->codeset_name;
           else
             {
              iov[2 + elem + offset].iov_base = alloca ((total + 3) & ~3);
              memset (mempcpy (iov[2 + elem + offset].iov_base,
                             ctype->codeset_name, total),
                     '\0', 4 - (total & 3));
              total = (total + 3) & ~3;
             }
           iov[2 + elem + offset].iov_len = total;
           idx[elem + 1] = idx[elem] + iov[2 + elem + offset].iov_len;
           break;


         CTYPE_DATA (_NL_CTYPE_MAP_TO_NONASCII,
                    &ctype->to_nonascii, sizeof (uint32_t));

         case _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS_MB_LEN):
           iov[2 + elem + offset].iov_base = alloca (sizeof (uint32_t));
           iov[2 + elem + offset].iov_len = sizeof (uint32_t);
           *(uint32_t *) iov[2 + elem + offset].iov_base =
             ctype->mbdigits_act / 10;
           idx[elem + 1] = idx[elem] + sizeof (uint32_t);
           break;

         case _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS_WC_LEN):
           /* Align entries.  */
           iov[2 + elem + offset].iov_base = (void *) nulbytes;
           iov[2 + elem + offset].iov_len = (4 - idx[elem] % 4) % 4;
           idx[elem] += iov[2 + elem + offset].iov_len;
           ++offset;

           iov[2 + elem + offset].iov_base = alloca (sizeof (uint32_t));
           iov[2 + elem + offset].iov_len = sizeof (uint32_t);
           *(uint32_t *) iov[2 + elem + offset].iov_base =
             ctype->wcdigits_act / 10;
           idx[elem + 1] = idx[elem] + sizeof (uint32_t);
           break;

         case _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS0_MB) ... _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS9_MB):
           /* Compute the length of all possible characters.  For INDIGITS
              there might be more than one.  We simply concatenate all of
              them with a NUL byte following.  The NUL byte wouldn't be
              necessary but it makes it easier for the user.  */
           total = 0;

           for (cnt = elem - _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS0_MB);
               cnt < ctype->mbdigits_act; cnt += 10)
             total += ctype->mbdigits[cnt]->nbytes + 1;
           iov[2 + elem + offset].iov_base = (char *) alloca (total);
           iov[2 + elem + offset].iov_len = total;

           cp = iov[2 + elem + offset].iov_base;
           for (cnt = elem - _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS0_MB);
               cnt < ctype->mbdigits_act; cnt += 10)
             {
              cp = mempcpy (cp, ctype->mbdigits[cnt]->bytes,
                           ctype->mbdigits[cnt]->nbytes);
              *cp++ = '\0';
             }
           idx[elem + 1] = idx[elem] + iov[2 + elem + offset].iov_len;
           break;

         case _NL_ITEM_INDEX (_NL_CTYPE_OUTDIGIT0_MB) ... _NL_ITEM_INDEX (_NL_CTYPE_OUTDIGIT9_MB):
           /* Compute the length of all possible characters.  For INDIGITS
              there might be more than one.  We simply concatenate all of
              them with a NUL byte following.  The NUL byte wouldn't be
              necessary but it makes it easier for the user.  */
           cnt = elem - _NL_ITEM_INDEX (_NL_CTYPE_OUTDIGIT0_MB);
           total = ctype->mboutdigits[cnt]->nbytes + 1;
           iov[2 + elem + offset].iov_base = (char *) alloca (total);
           iov[2 + elem + offset].iov_len = total;

           *(char *) mempcpy (iov[2 + elem + offset].iov_base,
                            ctype->mboutdigits[cnt]->bytes,
                            ctype->mboutdigits[cnt]->nbytes) = '\0';
           idx[elem + 1] = idx[elem] + iov[2 + elem + offset].iov_len;
           break;

         case _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS0_WC) ... _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS9_WC):
           total = ctype->wcdigits_act / 10;

           iov[2 + elem + offset].iov_base =
             (uint32_t *) alloca (total * sizeof (uint32_t));
           iov[2 + elem + offset].iov_len = total * sizeof (uint32_t);

           for (cnt = elem - _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS0_WC);
               cnt < ctype->wcdigits_act; cnt += 10)
             ((uint32_t *) iov[2 + elem + offset].iov_base)[cnt / 10]
              = ctype->wcdigits[cnt];
           idx[elem + 1] = idx[elem] + iov[2 + elem + offset].iov_len;
           break;

         case _NL_ITEM_INDEX (_NL_CTYPE_OUTDIGIT0_WC):
           /* Align entries.  */
           iov[2 + elem + offset].iov_base = (void *) nulbytes;
           iov[2 + elem + offset].iov_len = (4 - idx[elem] % 4) % 4;
           idx[elem] += iov[2 + elem + offset].iov_len;
           ++offset;
           /* FALLTRHOUGH */

         case _NL_ITEM_INDEX (_NL_CTYPE_OUTDIGIT1_WC) ... _NL_ITEM_INDEX (_NL_CTYPE_OUTDIGIT9_WC):
           cnt = elem - _NL_ITEM_INDEX (_NL_CTYPE_OUTDIGIT0_WC);
           iov[2 + elem + offset].iov_base = &ctype->wcoutdigits[cnt];
           iov[2 + elem + offset].iov_len = sizeof (uint32_t);
           idx[elem + 1] = idx[elem] + iov[2 + elem + offset].iov_len;
           break;

         case _NL_ITEM_INDEX(_NL_CTYPE_TRANSLIT_DEFAULT_MISSING_LEN):
           /* Align entries.  */
           iov[2 + elem + offset].iov_base = (void *) nulbytes;
           iov[2 + elem + offset].iov_len = (4 - idx[elem] % 4) % 4;
           idx[elem] += iov[2 + elem + offset].iov_len;
           ++offset;

           default_missing_len = (ctype->default_missing
                               ? wcslen ((wchar_t *)ctype->default_missing)
                               : 0);
           iov[2 + elem + offset].iov_base = &default_missing_len;
           iov[2 + elem + offset].iov_len = sizeof (uint32_t);
           idx[elem + 1] = idx[elem] + iov[2 + elem + offset].iov_len;
           break;

         case _NL_ITEM_INDEX(_NL_CTYPE_TRANSLIT_DEFAULT_MISSING):
           iov[2 + elem + offset].iov_base =
             ctype->default_missing ?: (uint32_t *) L"";
           iov[2 + elem + offset].iov_len =
             wcslen (iov[2 + elem + offset].iov_base) * sizeof (uint32_t);
           idx[elem + 1] = idx[elem] + iov[2 + elem + offset].iov_len;
           break;

         case _NL_ITEM_INDEX(_NL_CTYPE_TRANSLIT_IGNORE_LEN):
           /* Align entries.  */
           iov[2 + elem + offset].iov_base = (void *) nulbytes;
           iov[2 + elem + offset].iov_len = (4 - idx[elem] % 4) % 4;
           idx[elem] += iov[2 + elem + offset].iov_len;
           ++offset;

           iov[2 + elem + offset].iov_base = &ctype->ntranslit_ignore;
           iov[2 + elem + offset].iov_len = sizeof (uint32_t);
           idx[elem + 1] = idx[elem] + iov[2 + elem + offset].iov_len;
           break;

         case _NL_ITEM_INDEX(_NL_CTYPE_TRANSLIT_IGNORE):
           {
             uint32_t *ranges = (uint32_t *) alloca (ctype->ntranslit_ignore
                                                * 3 * sizeof (uint32_t));
             struct translit_ignore_t *runp;

             iov[2 + elem + offset].iov_base = ranges;
             iov[2 + elem + offset].iov_len = (ctype->ntranslit_ignore
                                          * 3 * sizeof (uint32_t));

             for (runp = ctype->translit_ignore; runp != NULL;
                 runp = runp->next)
              {
                *ranges++ = runp->from;
                *ranges++ = runp->to;
                *ranges++ = runp->step;
              }
           }
           /* Remove the following line in case a new entry is added
              after _NL_CTYPE_TRANSLIT_DEFAULT_MISSING_LEN.  */
           if (elem < nelems)
             idx[elem + 1] = idx[elem] + iov[2 + elem + offset].iov_len;
           break;

         default:
           assert (! "unknown CTYPE element");
         }
      else
       {
         /* Handle extra maps.  */
         size_t nr = elem - _NL_ITEM_INDEX (_NL_CTYPE_EXTRA_MAP_1);
         if (nr < ctype->nr_charclass)
           {
             iov[2 + elem + offset].iov_base = ctype->class_b[nr];
             iov[2 + elem + offset].iov_len = 256 / 32 * sizeof (uint32_t);
             idx[elem] += iov[2 + elem + offset].iov_len;
             ++offset;

             iov[2 + elem + offset] = ctype->class_3level[nr];
           }
         else
           {
             nr -= ctype->nr_charclass;
             assert (nr < ctype->map_collection_nr);
             iov[2 + elem + offset] = ctype->map_3level[nr];
           }
         idx[elem + 1] = idx[elem] + iov[2 + elem + offset].iov_len;
       }
    }

  assert (2 + elem + offset == (nelems + 2 * ctype->nr_charclass
                            + ctype->map_collection_nr + 4 + 2));

  write_locale_data (output_path, LC_CTYPE, "LC_CTYPE", 2 + elem + offset,
                   iov);
}

Here is the call graph for this function:

void ctype_read ( struct linereader ldfile,
struct localedef_t result,
const struct charmap_t charmap,
const char *  repertoire_name,
int  ignore_content 
)

Definition at line 2178 of file ld-ctype.c.

{
  struct repertoire_t *repertoire = NULL;
  struct locale_ctype_t *ctype;
  struct token *now;
  enum token_t nowtok;
  size_t cnt;
  struct charseq *last_seq;
  uint32_t last_wch = 0;
  enum token_t last_token;
  enum token_t ellipsis_token;
  int step;
  char last_charcode[16];
  size_t last_charcode_len = 0;
  const char *last_str = NULL;
  int mapidx;
  struct localedef_t *copy_locale = NULL;

  /* Get the repertoire we have to use.  */
  if (repertoire_name != NULL)
    repertoire = repertoire_read (repertoire_name);

  /* The rest of the line containing `LC_CTYPE' must be free.  */
  lr_ignore_rest (ldfile, 1);


  do
    {
      now = lr_token (ldfile, charmap, NULL, NULL, verbose);
      nowtok = now->tok;
    }
  while (nowtok == tok_eol);

  /* If we see `copy' now we are almost done.  */
  if (nowtok == tok_copy)
    {
      now = lr_token (ldfile, charmap, NULL, NULL, verbose);
      if (now->tok != tok_string)
       {
         SYNTAX_ERROR (_("%s: syntax error"), "LC_CTYPE");

       skip_category:
         do
           now = lr_token (ldfile, charmap, NULL, NULL, verbose);
         while (now->tok != tok_eof && now->tok != tok_end);

         if (now->tok != tok_eof
             || (now = lr_token (ldfile, charmap, NULL, NULL, verbose),
                now->tok == tok_eof))
           lr_error (ldfile, _("%s: premature end of file"), "LC_CTYPE");
         else if (now->tok != tok_lc_ctype)
           {
             lr_error (ldfile, _("\
%1$s: definition does not end with `END %1$s'"), "LC_CTYPE");
             lr_ignore_rest (ldfile, 0);
           }
         else
           lr_ignore_rest (ldfile, 1);

         return;
       }

      if (! ignore_content)
       {
         /* Get the locale definition.  */
         copy_locale = load_locale (LC_CTYPE, now->val.str.startmb,
                                 repertoire_name, charmap, NULL);
         if ((copy_locale->avail & CTYPE_LOCALE) == 0)
           {
             /* Not yet loaded.  So do it now.  */
             if (locfile_read (copy_locale, charmap) != 0)
              goto skip_category;
           }

         if (copy_locale->categories[LC_CTYPE].ctype == NULL)
           return;
       }

      lr_ignore_rest (ldfile, 1);

      now = lr_token (ldfile, charmap, NULL, NULL, verbose);
      nowtok = now->tok;
    }

  /* Prepare the data structures.  */
  ctype_startup (ldfile, result, charmap, copy_locale, ignore_content);
  ctype = result->categories[LC_CTYPE].ctype;

  /* Remember the repertoire we use.  */
  if (!ignore_content)
    ctype->repertoire = repertoire;

  while (1)
    {
      unsigned long int class_bit = 0;
      unsigned long int class256_bit = 0;
      int handle_digits = 0;

      /* Of course we don't proceed beyond the end of file.  */
      if (nowtok == tok_eof)
       break;

      /* Ingore empty lines.  */
      if (nowtok == tok_eol)
       {
         now = lr_token (ldfile, charmap, NULL, NULL, verbose);
         nowtok = now->tok;
         continue;
       }

      switch (nowtok)
       {
       case tok_charclass:
         now = lr_token (ldfile, charmap, NULL, NULL, verbose);
         while (now->tok == tok_ident || now->tok == tok_string)
           {
             ctype_class_new (ldfile, ctype, now->val.str.startmb);
             now = lr_token (ldfile, charmap, NULL, NULL, verbose);
             if (now->tok != tok_semicolon)
              break;
             now = lr_token (ldfile, charmap, NULL, NULL, verbose);
           }
         if (now->tok != tok_eol)
           SYNTAX_ERROR (_("\
%s: syntax error in definition of new character class"), "LC_CTYPE");
         break;

       case tok_charconv:
         now = lr_token (ldfile, charmap, NULL, NULL, verbose);
         while (now->tok == tok_ident || now->tok == tok_string)
           {
             ctype_map_new (ldfile, ctype, now->val.str.startmb, charmap);
             now = lr_token (ldfile, charmap, NULL, NULL, verbose);
             if (now->tok != tok_semicolon)
              break;
             now = lr_token (ldfile, charmap, NULL, NULL, verbose);
           }
         if (now->tok != tok_eol)
           SYNTAX_ERROR (_("\
%s: syntax error in definition of new character map"), "LC_CTYPE");
         break;

       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, NULL, verbose);
         if (now->tok == tok_ident || now->tok == tok_string)
           {
             /* Must can be one of the predefined class names.  */
             for (cnt = 0; cnt < ctype->nr_charclass; ++cnt)
              if (strcmp (ctype->classnames[cnt], now->val.str.startmb) == 0)
                break;
             if (cnt >= ctype->nr_charclass)
              {
#ifdef PREDEFINED_CLASSES
                if (now->val.str.lenmb == 8
                    && memcmp ("special1", now->val.str.startmb, 8) == 0)
                  class_bit = _ISwspecial1;
                else if (now->val.str.lenmb == 8
                    && memcmp ("special2", now->val.str.startmb, 8) == 0)
                  class_bit = _ISwspecial2;
                else if (now->val.str.lenmb == 8
                    && memcmp ("special3", now->val.str.startmb, 8) == 0)
                  class_bit = _ISwspecial3;
                else
#endif
                  {
                    /* OK, it's a new class.  */
                    ctype_class_new (ldfile, ctype, now->val.str.startmb);

                    class_bit = _ISwbit (ctype->nr_charclass - 1);
                  }
              }
             else
              {
                class_bit = _ISwbit (cnt);

                free (now->val.str.startmb);
              }
           }
         else if (now->tok == tok_digit)
           goto handle_tok_digit;
         else if (now->tok < tok_upper || now->tok > tok_blank)
           goto err_label;
         else
           {
             class_bit = BITw (now->tok);
             class256_bit = BIT (now->tok);
           }

         /* The next character must be a semicolon.  */
         now = lr_token (ldfile, charmap, NULL, NULL, verbose);
         if (now->tok != tok_semicolon)
           goto err_label;
         goto read_charclass;

       case tok_upper:
       case tok_lower:
       case tok_alpha:
       case tok_alnum:
       case tok_space:
       case tok_cntrl:
       case tok_punct:
       case tok_graph:
       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;
       read_charclass:
         ctype->class_done |= class_bit;
         last_token = tok_none;
         ellipsis_token = tok_none;
         step = 1;
         now = lr_token (ldfile, charmap, NULL, NULL, verbose);
         while (now->tok != tok_eol && now->tok != tok_eof)
           {
             uint32_t wch;
             struct charseq *seq;

             if (ellipsis_token == tok_none)
              {
                if (get_character (now, charmap, repertoire, &seq, &wch))
                  goto err_label;

                if (!ignore_content && seq != NULL && seq->nbytes == 1)
                  /* Yep, we can store information about this byte
                     sequence.  */
                  ctype->class256_collection[seq->bytes[0]] |= class256_bit;

                if (!ignore_content && wch != ILLEGAL_CHAR_VALUE
                    && class_bit != 0)
                  /* We have the UCS4 position.  */
                  *find_idx (ctype, &ctype->class_collection,
                            &ctype->class_collection_max,
                            &ctype->class_collection_act, wch) |= class_bit;

                last_token = now->tok;
                /* Terminate the string.  */
                if (last_token == tok_bsymbol)
                  {
                    now->val.str.startmb[now->val.str.lenmb] = '\0';
                    last_str = now->val.str.startmb;
                  }
                else
                  last_str = NULL;
                last_seq = seq;
                last_wch = wch;
                memcpy (last_charcode, now->val.charcode.bytes, 16);
                last_charcode_len = now->val.charcode.nbytes;

                if (!ignore_content && handle_digits == 1)
                  {
                    /* We must store the digit values.  */
                    if (ctype->mbdigits_act == ctype->mbdigits_max)
                     {
                       ctype->mbdigits_max += 10;
                       ctype->mbdigits = xrealloc (ctype->mbdigits,
                                                (ctype->mbdigits_max
                                                 * sizeof (char *)));
                       ctype->wcdigits_max += 10;
                       ctype->wcdigits = xrealloc (ctype->wcdigits,
                                                (ctype->wcdigits_max
                                                 * sizeof (uint32_t)));
                     }

                    ctype->mbdigits[ctype->mbdigits_act++] = seq;
                    ctype->wcdigits[ctype->wcdigits_act++] = wch;
                  }
                else if (!ignore_content && handle_digits == 2)
                  {
                    /* We must store the digit values.  */
                    if (ctype->outdigits_act >= 10)
                     {
                       lr_error (ldfile, _("\
%s: field `%s' does not contain exactly ten entries"),
                         "LC_CTYPE", "outdigit");
                       lr_ignore_rest (ldfile, 0);
                       break;
                     }

                    ctype->mboutdigits[ctype->outdigits_act] = seq;
                    ctype->wcoutdigits[ctype->outdigits_act] = wch;
                    ++ctype->outdigits_act;
                  }
              }
             else
              {
                /* Now it gets complicated.  We have to resolve the
                   ellipsis problem.  First we must distinguish between
                   the different kind of ellipsis and this must match the
                   tokens we have seen.  */
                assert (last_token != tok_none);

                if (last_token != now->tok)
                  {
                    lr_error (ldfile, _("\
ellipsis range must be marked by two operands of same type"));
                    lr_ignore_rest (ldfile, 0);
                    break;
                  }

                if (last_token == tok_bsymbol)
                  {
                    if (ellipsis_token == tok_ellipsis3)
                     lr_error (ldfile, _("with symbolic name range values \
the absolute ellipsis `...' must not be used"));

                    charclass_symbolic_ellipsis (ldfile, ctype, charmap,
                                             repertoire, now, last_str,
                                             class256_bit, class_bit,
                                             (ellipsis_token
                                              == tok_ellipsis4
                                              ? 10 : 16),
                                             ignore_content,
                                             handle_digits, step);
                  }
                else if (last_token == tok_ucs4)
                  {
                    if (ellipsis_token != tok_ellipsis2)
                     lr_error (ldfile, _("\
with UCS range values one must use the hexadecimal symbolic ellipsis `..'"));

                    charclass_ucs4_ellipsis (ldfile, ctype, charmap,
                                          repertoire, now, last_wch,
                                          class256_bit, class_bit,
                                          ignore_content, handle_digits,
                                          step);
                  }
                else
                  {
                    assert (last_token == tok_charcode);

                    if (ellipsis_token != tok_ellipsis3)
                     lr_error (ldfile, _("\
with character code range values one must use the absolute ellipsis `...'"));

                    charclass_charcode_ellipsis (ldfile, ctype, charmap,
                                             repertoire, now,
                                             last_charcode,
                                             last_charcode_len,
                                             class256_bit, class_bit,
                                             ignore_content,
                                             handle_digits);
                  }

                /* Now we have used the last value.  */
                last_token = tok_none;
              }

             /* Next we expect a semicolon or the end of the line.  */
             now = lr_token (ldfile, charmap, NULL, NULL, verbose);
             if (now->tok == tok_eol || now->tok == tok_eof)
              break;

             if (last_token != tok_none
                && now->tok >= tok_ellipsis2 && now->tok <= tok_ellipsis4_2)
              {
                if (now->tok == tok_ellipsis2_2)
                  {
                    now->tok = tok_ellipsis2;
                    step = 2;
                  }
                else if (now->tok == tok_ellipsis4_2)
                  {
                    now->tok = tok_ellipsis4;
                    step = 2;
                  }

                ellipsis_token = now->tok;

                now = lr_token (ldfile, charmap, NULL, NULL, verbose);
                continue;
              }

             if (now->tok != tok_semicolon)
              goto err_label;

             /* And get the next character.  */
             now = lr_token (ldfile, charmap, NULL, NULL, verbose);

             ellipsis_token = tok_none;
             step = 1;
           }
         break;

       case tok_digit:
         /* 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;
           }

       handle_tok_digit:
         class_bit = _ISwdigit;
         class256_bit = _ISdigit;
         handle_digits = 1;
         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"),
                    "LC_CTYPE", "outdigit");
         class_bit = 0;
         class256_bit = 0;
         handle_digits = 2;
         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, NULL, verbose);
         if (now->tok == tok_ident || now->tok == tok_string)
           {
             size_t cnt;

             for (cnt = 2; cnt < ctype->map_collection_nr; ++cnt)
              if (strcmp (now->val.str.startmb, ctype->mapnames[cnt]) == 0)
                break;

             if (cnt < ctype->map_collection_nr)
              free (now->val.str.startmb);
             else
              /* OK, it's a new map.  */
              ctype_map_new (ldfile, ctype, now->val.str.startmb, charmap);

             mapidx = cnt;
           }
         else if (now->tok < tok_toupper || now->tok > tok_tolower)
           goto err_label;
         else
           mapidx = now->tok - tok_toupper;

         now = lr_token (ldfile, charmap, NULL, NULL, verbose);
         /* This better should be a semicolon.  */
         if (now->tok != tok_semicolon)
           goto err_label;

       read_mapping:
         /* Test whether this mapping was already defined.  */
         if (ctype->tomap_done[mapidx])
           {
             lr_error (ldfile, _("duplicated definition for mapping `%s'"),
                     ctype->mapnames[mapidx]);
             lr_ignore_rest (ldfile, 0);
             break;
           }
         ctype->tomap_done[mapidx] = 1;

         now = lr_token (ldfile, charmap, NULL, NULL, verbose);
         while (now->tok != tok_eol && now->tok != tok_eof)
           {
             struct charseq *from_seq;
             uint32_t from_wch;
             struct charseq *to_seq;
             uint32_t to_wch;

             /* Every pair starts with an opening brace.  */
             if (now->tok != tok_open_brace)
              goto err_label;

             /* Next comes the from-value.  */
             now = lr_token (ldfile, charmap, NULL, NULL, verbose);
             if (get_character (now, charmap, repertoire, &from_seq,
                             &from_wch) != 0)
              goto err_label;

             /* The next is a comma.  */
             now = lr_token (ldfile, charmap, NULL, NULL, verbose);
             if (now->tok != tok_comma)
              goto err_label;

             /* And the other value.  */
             now = lr_token (ldfile, charmap, NULL, NULL, verbose);
             if (get_character (now, charmap, repertoire, &to_seq,
                             &to_wch) != 0)
              goto err_label;

             /* And the last thing is the closing brace.  */
             now = lr_token (ldfile, charmap, NULL, NULL, verbose);
             if (now->tok != tok_close_brace)
              goto err_label;

             if (!ignore_content)
              {
                /* Check whether the mapping converts from an ASCII value
                   to a non-ASCII value.  */
                if (from_seq != NULL && from_seq->nbytes == 1
                    && isascii (from_seq->bytes[0])
                    && to_seq != NULL && (to_seq->nbytes != 1
                                       || !isascii (to_seq->bytes[0])))
                  ctype->to_nonascii = 1;

                if (mapidx < 2 && from_seq != NULL && to_seq != NULL
                    && from_seq->nbytes == 1 && to_seq->nbytes == 1)
                  /* We can use this value.  */
                  ctype->map256_collection[mapidx][from_seq->bytes[0]]
                    = to_seq->bytes[0];

                if (from_wch != ILLEGAL_CHAR_VALUE
                    && to_wch != ILLEGAL_CHAR_VALUE)
                  /* Both correct values.  */
                  *find_idx (ctype, &ctype->map_collection[mapidx],
                            &ctype->map_collection_max[mapidx],
                            &ctype->map_collection_act[mapidx],
                            from_wch) = to_wch;
              }

             /* Now comes a semicolon or the end of the line/file.  */
             now = lr_token (ldfile, charmap, NULL, NULL, verbose);
             if (now->tok == tok_semicolon)
              now = lr_token (ldfile, charmap, NULL, NULL, verbose);
           }
         break;

       case tok_translit_start:
         /* Ignore the entire translit section with its peculiar syntax
            if we don't need the input.  */
         if (ignore_content)
           {
             do
              {
                lr_ignore_rest (ldfile, 0);
                now = lr_token (ldfile, charmap, NULL, NULL, verbose);
              }
             while (now->tok != tok_translit_end && now->tok != tok_eof);

             if (now->tok == tok_eof)
              lr_error (ldfile, _(\
"%s: `translit_start' section does not end with `translit_end'"),
                       "LC_CTYPE");

             break;
           }

         /* The rest of the line better should be empty.  */
         lr_ignore_rest (ldfile, 1);

         /* We count here the number of allocated entries in the `translit'
            array.  */
         cnt = 0;

         ldfile->translate_strings = 1;
         ldfile->return_widestr = 1;

         /* We proceed until we see the `translit_end' token.  */
         while (now = lr_token (ldfile, charmap, NULL, repertoire, verbose),
               now->tok != tok_translit_end && now->tok != tok_eof)
           {
             if (now->tok == tok_eol)
              /* Ignore empty lines.  */
              continue;

             if (now->tok == tok_include)
              {
                /* We have to include locale.  */
                const char *locale_name;
                const char *repertoire_name;
                struct translit_include_t *include_stmt, **include_ptr;

                now = lr_token (ldfile, charmap, NULL, NULL, verbose);
                /* This should be a string or an identifier.  In any
                   case something to name a locale.  */
                if (now->tok != tok_string && now->tok != tok_ident)
                  {
                  translit_syntax:
                    lr_error (ldfile, _("%s: syntax error"), "LC_CTYPE");
                    lr_ignore_rest (ldfile, 0);
                    continue;
                  }
                locale_name = now->val.str.startmb;

                /* Next should be a semicolon.  */
                now = lr_token (ldfile, charmap, NULL, NULL, verbose);
                if (now->tok != tok_semicolon)
                  goto translit_syntax;

                /* Now the repertoire name.  */
                now = lr_token (ldfile, charmap, NULL, NULL, verbose);
                if ((now->tok != tok_string && now->tok != tok_ident)
                    || now->val.str.startmb == NULL)
                  goto translit_syntax;
                repertoire_name = now->val.str.startmb;
                if (repertoire_name[0] == '\0')
                  /* Ignore the empty string.  */
                  repertoire_name = NULL;

                /* Save the include statement for later processing.  */
                include_stmt = (struct translit_include_t *)
                  xmalloc (sizeof (struct translit_include_t));
                include_stmt->copy_locale = locale_name;
                include_stmt->copy_repertoire = repertoire_name;
                include_stmt->next = NULL;

                include_ptr = &ctype->translit_include;
                while (*include_ptr != NULL)
                  include_ptr = &(*include_ptr)->next;
                *include_ptr = include_stmt;

                /* The rest of the line must be empty.  */
                lr_ignore_rest (ldfile, 1);

                /* Make sure the locale is read.  */
                add_to_readlist (LC_CTYPE, locale_name, repertoire_name,
                               1, NULL);
                continue;
              }
             else if (now->tok == tok_default_missing)
              {
                uint32_t *wstr;

                while (1)
                  {
                    /* We expect a single character or string as the
                      argument.  */
                    now = lr_token (ldfile, charmap, NULL, NULL, verbose);
                    wstr = read_widestring (ldfile, now, charmap,
                                         repertoire);

                    if (wstr != NULL)
                     {
                       if (ctype->default_missing != NULL)
                         {
                           lr_error (ldfile, _("\
%s: duplicate `default_missing' definition"), "LC_CTYPE");
                           WITH_CUR_LOCALE (error_at_line (0, 0,
                                                       ctype->default_missing_file,
                                                       ctype->default_missing_lineno,
                                                       _("\
previous definition was here")));
                         }
                       else
                         {
                           ctype->default_missing = wstr;
                           ctype->default_missing_file = ldfile->fname;
                           ctype->default_missing_lineno = ldfile->lineno;
                         }
                       /* We can have more entries, ignore them.  */
                       lr_ignore_rest (ldfile, 0);
                       break;
                     }
                    else if (wstr == (uint32_t *) -1l)
                     /* This was an syntax error.  */
                     break;

                    /* Maybe there is another replacement we can use.  */
                    now = lr_token (ldfile, charmap, NULL, NULL, verbose);
                    if (now->tok == tok_eol || now->tok == tok_eof)
                     {
                       /* Nothing found.  We tell the user.  */
                       lr_error (ldfile, _("\
%s: no representable `default_missing' definition found"), "LC_CTYPE");
                       break;
                     }
                    if (now->tok != tok_semicolon)
                     goto translit_syntax;
                  }

                continue;
              }
             else if (now->tok == tok_translit_ignore)
              {
                read_translit_ignore_entry (ldfile, ctype, charmap,
                                         repertoire);
                continue;
              }

             read_translit_entry (ldfile, ctype, now, charmap, repertoire);
           }
         ldfile->return_widestr = 0;

         if (now->tok == tok_eof)
           lr_error (ldfile, _(\
"%s: `translit_start' section does not end with `translit_end'"),
                    "LC_CTYPE");

         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)
           if (strcmp (now->val.str.startmb, ctype->classnames[cnt]) == 0)
             break;
         if (cnt < ctype->nr_charclass)
           {
             class_bit = _ISwbit (cnt);
             class256_bit = cnt <= 11 ? _ISbit (cnt) : 0;
             free (now->val.str.startmb);
             goto read_charclass;
           }
         for (cnt = 0; cnt < ctype->map_collection_nr; ++cnt)
           if (strcmp (now->val.str.startmb, ctype->mapnames[cnt]) == 0)
             break;
         if (cnt < ctype->map_collection_nr)
           {
             mapidx = cnt;
             free (now->val.str.startmb);
             goto read_mapping;
            }
#ifdef PREDEFINED_CLASSES
         if (strcmp (now->val.str.startmb, "special1") == 0)
           {
             class_bit = _ISwspecial1;
             free (now->val.str.startmb);
             goto read_charclass;
           }
         if (strcmp (now->val.str.startmb, "special2") == 0)
           {
             class_bit = _ISwspecial2;
             free (now->val.str.startmb);
             goto read_charclass;
           }
         if (strcmp (now->val.str.startmb, "special3") == 0)
           {
             class_bit = _ISwspecial3;
             free (now->val.str.startmb);
             goto read_charclass;
           }
         if (strcmp (now->val.str.startmb, "tosymmetric") == 0)
           {
             mapidx = 2;
             goto read_mapping;
           }
#endif
         break;

       case tok_end:
         /* Next we assume `LC_CTYPE'.  */
         now = lr_token (ldfile, charmap, NULL, NULL, verbose);
         if (now->tok == tok_eof)
           break;
         if (now->tok == tok_eol)
           lr_error (ldfile, _("%s: incomplete `END' line"),
                    "LC_CTYPE");
         else if (now->tok != tok_lc_ctype)
           lr_error (ldfile, _("\
%1$s: definition does not end with `END %1$s'"), "LC_CTYPE");
         lr_ignore_rest (ldfile, now->tok == tok_lc_ctype);
         return;

       default:
       err_label:
         if (now->tok != tok_eof)
           SYNTAX_ERROR (_("%s: syntax error"), "LC_CTYPE");
       }

      /* Prepare for the next round.  */
      now = lr_token (ldfile, charmap, NULL, NULL, verbose);
      nowtok = now->tok;
    }

  /* When we come here we reached the end of the file.  */
  lr_error (ldfile, _("%s: premature end of file"), "LC_CTYPE");
}

Here is the call graph for this function:

Here is the caller graph for this function:

uint32_t* find_translit ( struct localedef_t locale,
const struct charmap_t charmap,
uint32_t  wch 
)

Definition at line 1862 of file ld-ctype.c.

{
  struct locale_ctype_t *ctype;
  uint32_t *result = NULL;

  assert (locale != NULL);
  ctype = locale->categories[LC_CTYPE].ctype;

  if (ctype == NULL)
    return NULL;

  if (ctype->translit != NULL)
    result = find_translit2 (ctype, charmap, wch);

  if (result == NULL)
    {
      struct translit_include_t *irunp = ctype->translit_include;

      while (irunp != NULL && result == NULL)
       {
         result = find_translit (find_locale (CTYPE_LOCALE,
                                          irunp->copy_locale,
                                          irunp->copy_repertoire,
                                          charmap),
                              charmap, wch);
         irunp = irunp->next;
       }
    }

  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void handle_copy ( struct linereader ldfile,
const struct charmap_t charmap,
const char *  repertoire_name,
struct localedef_t result,
enum token_t  token,
int  locale,
const char *  locale_name,
int  ignore_content 
)

Definition at line 772 of file locfile.c.

{
  struct token *now;
  int warned = 0;

  now = lr_token (ldfile, charmap, result, NULL, verbose);
  if (now->tok != tok_string)
    lr_error (ldfile, _("expecting string argument for `copy'"));
  else if (!ignore_content)
    {
      if (now->val.str.startmb == NULL)
       lr_error (ldfile, _("\
locale name should consist only of portable characters"));
      else
       {
         (void) add_to_readlist (locale, now->val.str.startmb,
                              repertoire_name, 1, NULL);
         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 ((now = lr_token (ldfile, charmap, result, NULL, verbose))->tok
        != tok_end && now->tok != tok_eof)
    {
      if (warned == 0)
       {
         lr_error (ldfile, _("\
no other keyword shall be specified when `copy' is used"));
         warned = 1;
       }

      lr_ignore_rest (ldfile, 0);
    }

  if (now->tok != tok_eof)
    {
      /* Handle `END xxx'.  */
      now = lr_token (ldfile, charmap, result, NULL, verbose);

      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);
    }
  else
    /* When we come here we reached the end of the file.  */
    lr_error (ldfile, _("%s: premature end of file"), locale_name);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void identification_finish ( struct localedef_t locale,
const struct charmap_t charmap 
)

Definition at line 98 of file ld-identification.c.

{
  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)
       {
         if (! be_quiet)
           WITH_CUR_LOCALE (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 && ! nothing)                                             \
       WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"),       \
                                   "LC_IDENTIFICATION", #cat));                    \
      identification->cat = "";                                             \
    }

  TEST_ELEM (title);
  TEST_ELEM (source);
  TEST_ELEM (address);
  TEST_ELEM (contact);
  TEST_ELEM (email);
  TEST_ELEM (tel);
  TEST_ELEM (fax);
  TEST_ELEM (language);
  TEST_ELEM (territory);
  TEST_ELEM (audience);
  TEST_ELEM (application);
  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)
         WITH_CUR_LOCALE (error (0, 0, _("\
%s: no identification for category `%s'"),
                              "LC_IDENTIFICATION", category_name[num]));
       identification->category[num] = "";
      }
}

Here is the call graph for this function:

void identification_output ( struct localedef_t locale,
const struct charmap_t charmap,
const char *  output_path 
)

Definition at line 179 of file ld-identification.c.

{
  struct locale_identification_t *identification
    = locale->categories[LC_IDENTIFICATION].identification;
  struct iovec iov[2 + _NL_ITEM_INDEX (_NL_NUM_LC_IDENTIFICATION)
                + (__LC_LAST - 2)];
  struct locale_file data;
  uint32_t idx[_NL_ITEM_INDEX (_NL_NUM_LC_IDENTIFICATION)];
  size_t cnt = 0;
  size_t num;
  size_t last_idx;

  data.magic = LIMAGIC (LC_IDENTIFICATION);
  data.n = _NL_ITEM_INDEX (_NL_NUM_LC_IDENTIFICATION);
  iov[cnt].iov_base = (void *) &data;
  iov[cnt].iov_len = sizeof (data);
  ++cnt;

  iov[cnt].iov_base = (void *) idx;
  iov[cnt].iov_len = sizeof (idx);
  ++cnt;

  idx[cnt - 2] = iov[0].iov_len + iov[1].iov_len;
  iov[cnt].iov_base = (void *) identification->title;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) identification->source;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) identification->address;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) identification->contact;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) identification->email;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) identification->tel;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) identification->fax;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) identification->language;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) identification->territory;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) identification->audience;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) identification->application;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) identification->abbreviation;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) identification->revision;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) identification->date;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  last_idx = cnt - 1;
  idx[last_idx] = idx[cnt - 2];
  for (num = 0; num < __LC_LAST; ++num)
    if (num != LC_ALL)
      {
       iov[cnt].iov_base = (void *) identification->category[num];
       iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
       idx[last_idx] += iov[cnt].iov_len;
       ++cnt;
      }

  assert (last_idx == _NL_ITEM_INDEX (_NL_NUM_LC_IDENTIFICATION) - 1);
  iov[cnt].iov_base = (void *) charmap->code_set_name;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  assert (cnt == (2 + _NL_ITEM_INDEX (_NL_NUM_LC_IDENTIFICATION)
                + (__LC_LAST - 2)));

  write_locale_data (output_path, LC_IDENTIFICATION, "LC_IDENTIFICATION", cnt,
                   iov);
}

Here is the call graph for this function:

void identification_read ( struct linereader ldfile,
struct localedef_t result,
const struct charmap_t charmap,
const char *  repertoire_name,
int  ignore_content 
)

Definition at line 300 of file ld-identification.c.

{
  struct locale_identification_t *identification;
  struct token *now;
  struct token *arg;
  struct token *cattok;
  int category;
  enum token_t nowtok;

  /* The rest of the line containing `LC_IDENTIFICATION' must be free.  */
  lr_ignore_rest (ldfile, 1);

  do
    {
      now = lr_token (ldfile, charmap, result, NULL, verbose);
      nowtok = now->tok;
    }
  while (nowtok == tok_eol);

  /* If we see `copy' now we are almost done.  */
  if (nowtok == tok_copy)
    {
      handle_copy (ldfile, charmap, repertoire_name, result,
                 tok_lc_identification, LC_IDENTIFICATION,
                 "LC_IDENTIFICATION", ignore_content);
      return;
    }

  /* Prepare the data structures.  */
  identification_startup (ldfile, result, ignore_content);
  identification = result->categories[LC_IDENTIFICATION].identification;

  while (1)
    {
      /* Of course we don't proceed beyond the end of file.  */
      if (nowtok == tok_eof)
       break;

      /* Ignore empty lines.  */
      if (nowtok == tok_eol)
       {
         now = lr_token (ldfile, charmap, result, NULL, verbose);
         nowtok = now->tok;
         continue;
       }

      switch (nowtok)
       {
#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, result, NULL, verbose);           \
         if (arg->tok != tok_string)                                        \
           goto err_label;                                           \
         if (identification->cat != NULL)                            \
           lr_error (ldfile, _("\
%s: field `%s' declared more than once"), "LC_IDENTIFICATION", #cat);       \
         else if (!ignore_content && arg->val.str.startmb == NULL)          \
           {                                                         \
             lr_error (ldfile, _("\
%s: unknown character in field `%s'"), "LC_IDENTIFICATION", #cat);          \
             identification->cat = "";                                      \
           }                                                         \
         else if (!ignore_content)                                   \
           identification->cat = arg->val.str.startmb;                      \
         break

         STR_ELEM (title);
         STR_ELEM (source);
         STR_ELEM (address);
         STR_ELEM (contact);
         STR_ELEM (email);
         STR_ELEM (tel);
         STR_ELEM (fax);
         STR_ELEM (language);
         STR_ELEM (territory);
         STR_ELEM (audience);
         STR_ELEM (application);
         STR_ELEM (abbreviation);
         STR_ELEM (revision);
         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, result, NULL, verbose);
         if (arg->tok != tok_string && arg->tok != tok_ident)
           goto err_label;
         /* Next is a semicolon.  */
         cattok = lr_token (ldfile, charmap, result, NULL, verbose);
         if (cattok->tok != tok_semicolon)
           goto err_label;
         /* Now a LC_xxx identifier.  */
         cattok = lr_token (ldfile, charmap, result, NULL, verbose);
         switch (cattok->tok)
           {
#define CATEGORY(lname, uname) \
           case tok_lc_##lname:                                      \
             category = LC_##uname;                                         \
             break

             CATEGORY (identification, IDENTIFICATION);
             CATEGORY (ctype, CTYPE);
             CATEGORY (collate, COLLATE);
             CATEGORY (time, TIME);
             CATEGORY (numeric, NUMERIC);
             CATEGORY (monetary, MONETARY);
             CATEGORY (messages, MESSAGES);
             CATEGORY (paper, PAPER);
             CATEGORY (name, NAME);
             CATEGORY (address, ADDRESS);
             CATEGORY (telephone, TELEPHONE);
             CATEGORY (measurement, MEASUREMENT);

           default:
             goto err_label;
           }
         if (identification->category[category] != NULL)
           {
             lr_error (ldfile, _("\
%s: duplicate category version definition"), "LC_IDENTIFICATION");
             free (arg->val.str.startmb);
           }
         else
           identification->category[category] = arg->val.str.startmb;
         break;

       case tok_end:
         /* Next we assume `LC_IDENTIFICATION'.  */
         arg = lr_token (ldfile, charmap, result, NULL, verbose);
         if (arg->tok == tok_eof)
           break;
         if (arg->tok == tok_eol)
           lr_error (ldfile, _("%s: incomplete `END' line"),
                    "LC_IDENTIFICATION");
         else if (arg->tok != tok_lc_identification)
           lr_error (ldfile, _("\
%1$s: definition does not end with `END %1$s'"), "LC_IDENTIFICATION");
         lr_ignore_rest (ldfile, arg->tok == tok_lc_identification);
         return;

       default:
       err_label:
         SYNTAX_ERROR (_("%s: syntax error"), "LC_IDENTIFICATION");
       }

      /* Prepare for the next round.  */
      now = lr_token (ldfile, charmap, result, NULL, verbose);
      nowtok = now->tok;
    }

  /* When we come here we reached the end of the file.  */
  lr_error (ldfile, _("%s: premature end of file"), "LC_IDENTIFICATION");

Here is the call graph for this function:

Here is the caller graph for this function:

int locfile_read ( struct localedef_t result,
const struct charmap_t charmap 
)

Definition at line 45 of file locfile.c.

{
  const char *filename = result->name;
  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)
    repertoire_name = repertoire_global;

  /* Open the locale definition file.  */
  ldfile = lr_open (filename, locfile_hash);
  if (ldfile == NULL)
    {
      if (filename != NULL && filename[0] != '/')
       {
         char *i18npath = getenv ("I18NPATH");
         if (i18npath != NULL && *i18npath != '\0')
           {
             const size_t pathlen = strlen (i18npath);
             char i18npathbuf[pathlen + 1];
             char path[strlen (filename) + 1 + pathlen
                     + sizeof ("/locales/") - 1];
             char *next;
             i18npath = memcpy (i18npathbuf, i18npath, pathlen + 1);

             while (ldfile == NULL
                   && (next = strsep (&i18npath, ":")) != NULL)
              {
                stpcpy (stpcpy (stpcpy (path, next), "/locales/"), filename);

                ldfile = lr_open (path, locfile_hash);

                if (ldfile == NULL)
                  {
                    stpcpy (stpcpy (path, next), filename);

                    ldfile = lr_open (path, locfile_hash);
                  }
              }
           }

         /* Test in the default directory.  */
         if (ldfile == NULL)
           {
             char path[strlen (filename) + 1 + sizeof (LOCSRCDIR)];

             stpcpy (stpcpy (stpcpy (path, LOCSRCDIR), "/"), filename);
             ldfile = lr_open (path, locfile_hash);
           }
       }

      if (ldfile == NULL)
       return 1;
    }

    /* Parse locale definition file and store result in RESULT.  */
  while (1)
    {
      struct token *now = lr_token (ldfile, charmap, NULL, NULL, verbose);
      enum token_t nowtok = now->tok;
      struct token *arg;

      if (nowtok == tok_eof)
       break;

      if (nowtok == tok_eol)
       /* Ignore empty lines.  */
       continue;

      switch (nowtok)
       {
       case tok_escape_char:
       case tok_comment_char:
         /* We need an argument.  */
         arg = lr_token (ldfile, charmap, NULL, NULL, verbose);

         if (arg->tok != tok_ident)
           {
             SYNTAX_ERROR (_("bad argument"));
             continue;
           }

         if (arg->val.str.lenmb != 1)
           {
             lr_error (ldfile, _("\
argument to `%s' must be a single character"),
                     nowtok == tok_escape_char
                     ? "escape_char" : "comment_char");

             lr_ignore_rest (ldfile, 0);
             continue;
           }

         if (nowtok == tok_escape_char)
           ldfile->escape_char = *arg->val.str.startmb;
         else
           ldfile->comment_char = *arg->val.str.startmb;
         break;

       case tok_repertoiremap:
         /* We need an argument.  */
         arg = lr_token (ldfile, charmap, NULL, NULL, verbose);

         if (arg->tok != tok_ident)
           {
             SYNTAX_ERROR (_("bad argument"));
             continue;
           }

         if (repertoire_name == NULL)
           {
             char *newp = alloca (arg->val.str.lenmb + 1);

             *((char *) mempcpy (newp, arg->val.str.startmb,
                              arg->val.str.lenmb)) = '\0';
             repertoire_name = newp;
           }
         break;

       case tok_lc_ctype:
         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:
         SYNTAX_ERROR (_("\
syntax error: not inside a locale definition section"));
         continue;
       }

      /* The rest of the line must be empty.  */
      lr_ignore_rest (ldfile, 1);
    }

  /* 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;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void measurement_finish ( struct localedef_t locale,
const struct charmap_t charmap 
)

Definition at line 60 of file ld-measurement.c.

{
  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)
       {
         if (! be_quiet)
           WITH_CUR_LOCALE (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)
    {
      if (! nothing)
       WITH_CUR_LOCALE (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;
    }
  else
    {
      if (measurement->measurement > 3)
       WITH_CUR_LOCALE (error (0, 0, _("%s: invalid value for field `%s'"),
                            "LC_MEASUREMENT", "measurement"));
    }
}

Here is the call graph for this function:

void measurement_output ( struct localedef_t locale,
const struct charmap_t charmap,
const char *  output_path 
)

Definition at line 120 of file ld-measurement.c.

{
  struct locale_measurement_t *measurement =
    locale->categories[LC_MEASUREMENT].measurement;
  struct iovec iov[2 + _NL_ITEM_INDEX (_NL_NUM_LC_MEASUREMENT)];
  struct locale_file data;
  uint32_t idx[_NL_ITEM_INDEX (_NL_NUM_LC_MEASUREMENT)];
  size_t cnt = 0;

  data.magic = LIMAGIC (LC_MEASUREMENT);
  data.n = _NL_ITEM_INDEX (_NL_NUM_LC_MEASUREMENT);
  iov[cnt].iov_base = (void *) &data;
  iov[cnt].iov_len = sizeof (data);
  ++cnt;

  iov[cnt].iov_base = (void *) idx;
  iov[cnt].iov_len = sizeof (idx);
  ++cnt;

  idx[cnt - 2] = iov[0].iov_len + iov[1].iov_len;
  iov[cnt].iov_base = &measurement->measurement;
  iov[cnt].iov_len = 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) charmap->code_set_name;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  assert (cnt == 2 + _NL_ITEM_INDEX (_NL_NUM_LC_MEASUREMENT));

  write_locale_data (output_path, LC_MEASUREMENT, "LC_MEASUREMENT",
                   2 + _NL_ITEM_INDEX (_NL_NUM_LC_MEASUREMENT), iov);
}

Here is the call graph for this function:

void measurement_read ( struct linereader ldfile,
struct localedef_t result,
const struct charmap_t charmap,
const char *  repertoire_name,
int  ignore_content 
)

Definition at line 159 of file ld-measurement.c.

{
  struct locale_measurement_t *measurement;
  struct token *now;
  struct token *arg;
  enum token_t nowtok;

  /* The rest of the line containing `LC_MEASUREMENT' must be free.  */
  lr_ignore_rest (ldfile, 1);

  do
    {
      now = lr_token (ldfile, charmap, result, NULL, verbose);
      nowtok = now->tok;
    }
  while (nowtok == tok_eol);

  /* If we see `copy' now we are almost done.  */
  if (nowtok == tok_copy)
    {
      handle_copy (ldfile, charmap, repertoire_name, result,
                 tok_lc_measurement, LC_MEASUREMENT, "LC_MEASUREMENT",
                 ignore_content);
      return;
    }

  /* Prepare the data structures.  */
  measurement_startup (ldfile, result, ignore_content);
  measurement = result->categories[LC_MEASUREMENT].measurement;

  while (1)
    {
      /* Of course we don't proceed beyond the end of file.  */
      if (nowtok == tok_eof)
       break;

      /* Ingore empty lines.  */
      if (nowtok == tok_eol)
       {
         now = lr_token (ldfile, charmap, result, NULL, verbose);
         nowtok = now->tok;
         continue;
       }

      switch (nowtok)
       {
#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, result, NULL, verbose);           \
         if (arg->tok != tok_number)                                        \
           goto err_label;                                           \
         else if (measurement->cat != 0)                             \
           lr_error (ldfile, _("%s: field `%s' declared more than once"),    \
                    "LC_MEASUREMENT", #cat);                                \
         else if (!ignore_content)                                   \
           measurement->cat = arg->val.num;                                 \
         break

         INT_ELEM (measurement);

       case tok_end:
         /* Next we assume `LC_MEASUREMENT'.  */
         arg = lr_token (ldfile, charmap, result, NULL, verbose);
         if (arg->tok == tok_eof)
           break;
         if (arg->tok == tok_eol)
           lr_error (ldfile, _("%s: incomplete `END' line"),
                    "LC_MEASUREMENT");
         else if (arg->tok != tok_lc_measurement)
           lr_error (ldfile, _("\
%1$s: definition does not end with `END %1$s'"), "LC_MEASUREMENT");
         lr_ignore_rest (ldfile, arg->tok == tok_lc_measurement);
         return;

       default:
       err_label:
         SYNTAX_ERROR (_("%s: syntax error"), "LC_MEASUREMENT");
       }

      /* Prepare for the next round.  */
      now = lr_token (ldfile, charmap, result, NULL, verbose);
      nowtok = now->tok;
    }

  /* When we come here we reached the end of the file.  */
  lr_error (ldfile, _("%s: premature end of file"),
           "LC_MEASUREMENT");

Here is the call graph for this function:

Here is the caller graph for this function:

void messages_finish ( struct localedef_t locale,
const struct charmap_t charmap 
)

Definition at line 65 of file ld-messages.c.

{
  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)
       {
         if (! be_quiet)
           WITH_CUR_LOCALE (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)
    messages->yesstr = "";
  if (messages->nostr == NULL)
    messages->nostr = "";

  if (messages->yesexpr == NULL)
    {
      if (! be_quiet && ! nothing)
       WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' undefined"),
                            "LC_MESSAGES", "yesexpr"));
      messages->yesexpr = "^[yY]";
    }
  else if (messages->yesexpr[0] == '\0')
    {
      if (!be_quiet)
       WITH_CUR_LOCALE (error (0, 0, _("\
%s: value for field `%s' must not be an empty string"),
                            "LC_MESSAGES", "yesexpr"));
    }
  else
    {
      int result;
      regex_t re;

      /* Test whether it are correct regular expressions.  */
      result = regcomp (&re, messages->yesexpr, REG_EXTENDED);
      if (result != 0 && !be_quiet)
       {
         char errbuf[BUFSIZ];

         (void) regerror (result, &re, errbuf, BUFSIZ);
         WITH_CUR_LOCALE (error (0, 0, _("\
%s: no correct regular expression for field `%s': %s"),
                              "LC_MESSAGES", "yesexpr", errbuf));
       }
      else if (result != 0)
       regfree (&re);
    }

  if (messages->noexpr == NULL)
    {
      if (! be_quiet && ! nothing)
       WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' undefined"),
                            "LC_MESSAGES", "noexpr"));
      messages->noexpr = "^[nN]";
    }
  else if (messages->noexpr[0] == '\0')
    {
      if (!be_quiet)
       WITH_CUR_LOCALE (error (0, 0, _("\
%s: value for field `%s' must not be an empty string"),
                            "LC_MESSAGES", "noexpr"));
    }
  else
    {
      int result;
      regex_t re;

      /* Test whether it are correct regular expressions.  */
      result = regcomp (&re, messages->noexpr, REG_EXTENDED);
      if (result != 0 && !be_quiet)
       {
         char errbuf[BUFSIZ];

         (void) regerror (result, &re, errbuf, BUFSIZ);
         WITH_CUR_LOCALE (error (0, 0, _("\
%s: no correct regular expression for field `%s': %s"),
                              "LC_MESSAGES", "noexpr", errbuf));
       }
      else if (result != 0)
       regfree (&re);
    }
}

Here is the call graph for this function:

void messages_output ( struct localedef_t locale,
const struct charmap_t charmap,
const char *  output_path 
)

Definition at line 182 of file ld-messages.c.

{
  struct locale_messages_t *messages
    = locale->categories[LC_MESSAGES].messages;
  struct iovec iov[2 + _NL_ITEM_INDEX (_NL_NUM_LC_MESSAGES)];
  struct locale_file data;
  uint32_t idx[_NL_ITEM_INDEX (_NL_NUM_LC_MESSAGES)];
  size_t cnt = 0;

  data.magic = LIMAGIC (LC_MESSAGES);
  data.n = _NL_ITEM_INDEX (_NL_NUM_LC_MESSAGES);
  iov[cnt].iov_base = (void *) &data;
  iov[cnt].iov_len = sizeof (data);
  ++cnt;

  iov[cnt].iov_base = (void *) idx;
  iov[cnt].iov_len = sizeof (idx);
  ++cnt;

  idx[cnt - 2] = iov[0].iov_len + iov[1].iov_len;
  iov[cnt].iov_base = (char *) messages->yesexpr;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (char *) messages->noexpr;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (char *) messages->yesstr;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (char *) messages->nostr;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (char *) charmap->code_set_name;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;

  assert (cnt + 1 == 2 + _NL_ITEM_INDEX (_NL_NUM_LC_MESSAGES));

  write_locale_data (output_path, LC_MESSAGES, "LC_MESSAGES",
                   2 + _NL_ITEM_INDEX (_NL_NUM_LC_MESSAGES), iov);
}

Here is the call graph for this function:

void messages_read ( struct linereader ldfile,
struct localedef_t result,
const struct charmap_t charmap,
const char *  repertoire_name,
int  ignore_content 
)

Definition at line 235 of file ld-messages.c.

{
  struct repertoire_t *repertoire = NULL;
  struct locale_messages_t *messages;
  struct token *now;
  enum token_t nowtok;

  /* Get the repertoire we have to use.  */
  if (repertoire_name != NULL)
    repertoire = repertoire_read (repertoire_name);

  /* The rest of the line containing `LC_MESSAGES' must be free.  */
  lr_ignore_rest (ldfile, 1);


  do
    {
      now = lr_token (ldfile, charmap, result, NULL, verbose);
      nowtok = now->tok;
    }
  while (nowtok == tok_eol);

  /* If we see `copy' now we are almost done.  */
  if (nowtok == tok_copy)
    {
      handle_copy (ldfile, charmap, repertoire_name, result, tok_lc_messages,
                 LC_MESSAGES, "LC_MESSAGES", ignore_content);
      return;
    }

  /* Prepare the data structures.  */
  messages_startup (ldfile, result, ignore_content);
  messages = result->categories[LC_MESSAGES].messages;

  while (1)
    {
      struct token *arg;

      /* Of course we don't proceed beyond the end of file.  */
      if (nowtok == tok_eof)
       break;

      /* Ignore empty lines.  */
      if (nowtok == tok_eol)
       {
         now = lr_token (ldfile, charmap, result, NULL, verbose);
         nowtok = now->tok;
         continue;
       }

      switch (nowtok)
       {
#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, _("\
%s: field `%s' declared more than once"), "LC_MESSAGES", #cat);                    \
             lr_ignore_rest (ldfile, 0);                             \
             break;                                                  \
           }                                                         \
         now = lr_token (ldfile, charmap, result, repertoire, verbose);      \
         if (now->tok != tok_string)                                        \
           goto syntax_error;                                               \
         else if (!ignore_content && now->val.str.startmb == NULL)          \
           {                                                         \
             lr_error (ldfile, _("\
%s: unknown character in field `%s'"), "LC_MESSAGES", #cat);                \
             messages->cat = "";                                     \
           }                                                         \
         else if (!ignore_content)                                   \
           messages->cat = now->val.str.startmb;                     \
         break

         STR_ELEM (yesexpr);
         STR_ELEM (noexpr);
         STR_ELEM (yesstr);
         STR_ELEM (nostr);

       case tok_end:
         /* Next we assume `LC_MESSAGES'.  */
         arg = lr_token (ldfile, charmap, result, NULL, verbose);
         if (arg->tok == tok_eof)
           break;
         if (arg->tok == tok_eol)
           lr_error (ldfile, _("%s: incomplete `END' line"), "LC_MESSAGES");
         else if (arg->tok != tok_lc_messages)
           lr_error (ldfile, _("\
%1$s: definition does not end with `END %1$s'"), "LC_MESSAGES");
         lr_ignore_rest (ldfile, arg->tok == tok_lc_messages);
         return;

       default:
       syntax_error:
         SYNTAX_ERROR (_("%s: syntax error"), "LC_MESSAGES");
       }

      /* Prepare for the next round.  */
      now = lr_token (ldfile, charmap, result, NULL, verbose);
      nowtok = now->tok;
    }

  /* When we come here we reached the end of the file.  */
  lr_error (ldfile, _("%s: premature end of file"), "LC_MESSAGES");

Here is the call graph for this function:

Here is the caller graph for this function:

void monetary_finish ( struct localedef_t locale,
const struct charmap_t charmap 
)

Definition at line 162 of file ld-monetary.c.

{
  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)
       {
         if (! be_quiet)
           WITH_CUR_LOCALE (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, initval) \
  if (monetary->cat == NULL)                                                \
    {                                                                \
      if (! be_quiet && ! nothing)                                   \
       WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"),       \
                            "LC_MONETARY", #cat));                          \
      monetary->cat = initval;                                              \
    }

  TEST_ELEM (int_curr_symbol, "");
  TEST_ELEM (currency_symbol, "");
  TEST_ELEM (mon_decimal_point, ".");
  TEST_ELEM (mon_thousands_sep, "");
  TEST_ELEM (positive_sign, "");
  TEST_ELEM (negative_sign, "");

  /* The international currency symbol must come from ISO 4217.  */
  if (monetary->int_curr_symbol != NULL)
    {
      if (strlen (monetary->int_curr_symbol) != 4)
       {
         if (! be_quiet && ! nothing)
           WITH_CUR_LOCALE (error (0, 0, _("\
%s: value of field `int_curr_symbol' has wrong length"),
                                "LC_MONETARY"));
       }
      else
       { /* Check the first three characters against ISO 4217 */
         char symbol[4];
         strncpy (symbol, monetary->int_curr_symbol, 3);
         symbol[3] = '\0';
         if (bsearch (symbol, valid_int_curr, NR_VALID_INT_CURR,
                     sizeof (const char *),
                     (comparison_fn_t) curr_strcmp) == NULL
              && !be_quiet)
           WITH_CUR_LOCALE (error (0, 0, _("\
%s: value of field `int_curr_symbol' does \
not correspond to a valid name in ISO 4217"),
                            "LC_MONETARY"));
       }
    }

  /* 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 == NULL)
    {
      if (! be_quiet && ! nothing)
       WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"),
                            "LC_MONETARY", "mon_decimal_point"));
      monetary->mon_decimal_point = ".";
    }
  else if (monetary->mon_decimal_point[0] == '\0' && ! be_quiet && ! nothing)
    {
      WITH_CUR_LOCALE (error (0, 0, _("\
%s: value for field `%s' must not be an empty string"),
                           "LC_MONETARY", "mon_decimal_point"));
    }
  if (monetary->mon_decimal_point_wc == L'\0')
    monetary->mon_decimal_point_wc = L'.';

  if (monetary->mon_grouping_len == 0)
    {
      if (! be_quiet && ! nothing)
       WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"),
                            "LC_MONETARY", "mon_grouping"));

      monetary->mon_grouping = (char *) "\177";
      monetary->mon_grouping_len = 1;
    }

#undef TEST_ELEM
#define TEST_ELEM(cat, min, max, initval) \
  if (monetary->cat == -2)                                           \
    {                                                                \
       if (! be_quiet && ! nothing)                                         \
        WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"),             \
                             "LC_MONETARY", #cat));                         \
       monetary->cat = initval;                                             \
    }                                                                \
  else if ((monetary->cat < min || monetary->cat > max)                     \
          && min < max                                                      \
          && !be_quiet && !nothing)                                         \
    WITH_CUR_LOCALE (error (0, 0, _("\
%s: value for field `%s' must be in range %d...%d"),                        \
                         "LC_MONETARY", #cat, min, max))

  TEST_ELEM (int_frac_digits, 1, 0, -1);
  TEST_ELEM (frac_digits, 1, 0, -1);
  TEST_ELEM (p_cs_precedes, -1, 1, -1);
  TEST_ELEM (p_sep_by_space, -1, 2, -1);
  TEST_ELEM (n_cs_precedes, -1, 1, -1);
  TEST_ELEM (n_sep_by_space, -1, 2, -1);
  TEST_ELEM (p_sign_posn, -1, 4, -1);
  TEST_ELEM (n_sign_posn, -1, 4, -1);

  /* The non-POSIX.2 extensions are optional.  */
  if (monetary->duo_int_curr_symbol == NULL)
    monetary->duo_int_curr_symbol = monetary->int_curr_symbol;
  if (monetary->duo_currency_symbol == NULL)
    monetary->duo_currency_symbol = monetary->currency_symbol;

  if (monetary->duo_int_frac_digits == -2)
    monetary->duo_int_frac_digits = monetary->int_frac_digits;
  if (monetary->duo_frac_digits == -2)
    monetary->duo_frac_digits = monetary->frac_digits;

#undef TEST_ELEM
#define TEST_ELEM(cat, alt, min, max) \
  if (monetary->cat == -2)                                           \
    monetary->cat = monetary->alt;                                   \
  else if ((monetary->cat < min || monetary->cat > max) && !be_quiet        \
          && ! nothing)                                              \
    WITH_CUR_LOCALE (error (0, 0, _("\
%s: value for field `%s' must be in range %d...%d"),                        \
                         "LC_MONETARY", #cat, min, max))

  TEST_ELEM (int_p_cs_precedes, p_cs_precedes, -1, 1);
  TEST_ELEM (int_p_sep_by_space, p_sep_by_space, -1, 2);
  TEST_ELEM (int_n_cs_precedes, n_cs_precedes, -1, 1);
  TEST_ELEM (int_n_sep_by_space, n_sep_by_space, -1, 2);
  TEST_ELEM (int_p_sign_posn, p_sign_posn, -1, 4);
  TEST_ELEM (int_n_sign_posn, n_sign_posn, -1, 4);

  TEST_ELEM (duo_p_cs_precedes, p_cs_precedes, -1, 1);
  TEST_ELEM (duo_p_sep_by_space, p_sep_by_space, -1, 2);
  TEST_ELEM (duo_n_cs_precedes, n_cs_precedes, -1, 1);
  TEST_ELEM (duo_n_sep_by_space, n_sep_by_space, -1, 2);
  TEST_ELEM (duo_int_p_cs_precedes, int_p_cs_precedes, -1, 1);
  TEST_ELEM (duo_int_p_sep_by_space, int_p_sep_by_space, -1, 2);
  TEST_ELEM (duo_int_n_cs_precedes, int_n_cs_precedes, -1, 1);
  TEST_ELEM (duo_int_n_sep_by_space, int_n_sep_by_space, -1, 2);
  TEST_ELEM (duo_p_sign_posn, p_sign_posn, -1, 4);
  TEST_ELEM (duo_n_sign_posn, n_sign_posn, -1, 4);
  TEST_ELEM (duo_int_p_sign_posn, int_p_sign_posn, -1, 4);
  TEST_ELEM (duo_int_n_sign_posn, int_n_sign_posn, -1, 4);

  if (monetary->uno_valid_from == 0)
    monetary->uno_valid_from = 10101;
  if (monetary->uno_valid_to == 0)
    monetary->uno_valid_to = 99991231;
  if (monetary->duo_valid_from == 0)
    monetary->duo_valid_from = 10101;
  if (monetary->duo_valid_to == 0)
    monetary->duo_valid_to = 99991231;

  if (monetary->conversion_rate[0] == 0)
    {
      monetary->conversion_rate[0] = 1;
      monetary->conversion_rate[1] = 1;
    }

  /* Create the crncystr entry.  */
  monetary->crncystr = (char *) xmalloc (strlen (monetary->currency_symbol)
                                    + 2);
  monetary->crncystr[0] = monetary->p_cs_precedes ? '-' : '+';
  strcpy (&monetary->crncystr[1], monetary->currency_symbol);
}

Here is the call graph for this function:

void monetary_output ( struct localedef_t locale,
const struct charmap_t charmap,
const char *  output_path 
)

Definition at line 363 of file ld-monetary.c.

{
  struct locale_monetary_t *monetary
    = locale->categories[LC_MONETARY].monetary;
  struct iovec iov[3 + _NL_ITEM_INDEX (_NL_NUM_LC_MONETARY)];
  struct locale_file data;
  uint32_t idx[_NL_ITEM_INDEX (_NL_NUM_LC_MONETARY)];
  size_t cnt = 0;

  data.magic = LIMAGIC (LC_MONETARY);
  data.n = _NL_ITEM_INDEX (_NL_NUM_LC_MONETARY);
  iov[cnt].iov_base = (void *) &data;
  iov[cnt].iov_len = sizeof (data);
  ++cnt;

  iov[cnt].iov_base = (void *) idx;
  iov[cnt].iov_len = sizeof (idx);
  ++cnt;

  idx[cnt - 2] = iov[0].iov_len + iov[1].iov_len;
  iov[cnt].iov_base = (void *) monetary->int_curr_symbol;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) monetary->currency_symbol;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) monetary->mon_decimal_point;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) monetary->mon_thousands_sep;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = monetary->mon_grouping;
  iov[cnt].iov_len = monetary->mon_grouping_len;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) monetary->positive_sign;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) monetary->negative_sign;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) &monetary->int_frac_digits;
  iov[cnt].iov_len = 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) &monetary->frac_digits;
  iov[cnt].iov_len = 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) &monetary->p_cs_precedes;
  iov[cnt].iov_len = 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) &monetary->p_sep_by_space;
  iov[cnt].iov_len = 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) &monetary->n_cs_precedes;
  iov[cnt].iov_len = 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) &monetary->n_sep_by_space;
  iov[cnt].iov_len = 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) &monetary->p_sign_posn;
  iov[cnt].iov_len = 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) &monetary->n_sign_posn;
  iov[cnt].iov_len = 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) monetary->crncystr;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) &monetary->int_p_cs_precedes;
  iov[cnt].iov_len = 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) &monetary->int_p_sep_by_space;
  iov[cnt].iov_len = 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) &monetary->int_n_cs_precedes;
  iov[cnt].iov_len = 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) &monetary->int_n_sep_by_space;
  iov[cnt].iov_len = 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) &monetary->int_p_sign_posn;
  iov[cnt].iov_len = 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) &monetary->int_n_sign_posn;
  iov[cnt].iov_len = 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) monetary->duo_int_curr_symbol;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) monetary->duo_currency_symbol;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) &monetary->duo_int_frac_digits;
  iov[cnt].iov_len = 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) &monetary->duo_frac_digits;
  iov[cnt].iov_len = 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) &monetary->duo_p_cs_precedes;
  iov[cnt].iov_len = 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) &monetary->duo_p_sep_by_space;
  iov[cnt].iov_len = 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) &monetary->duo_n_cs_precedes;
  iov[cnt].iov_len = 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) &monetary->duo_n_sep_by_space;
  iov[cnt].iov_len = 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) &monetary->duo_int_p_cs_precedes;
  iov[cnt].iov_len = 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) &monetary->duo_int_p_sep_by_space;
  iov[cnt].iov_len = 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) &monetary->duo_int_n_cs_precedes;
  iov[cnt].iov_len = 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) &monetary->duo_int_n_sep_by_space;
  iov[cnt].iov_len = 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) &monetary->duo_p_sign_posn;
  iov[cnt].iov_len = 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) &monetary->duo_n_sign_posn;
  iov[cnt].iov_len = 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) &monetary->duo_int_p_sign_posn;
  iov[cnt].iov_len = 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) &monetary->duo_int_n_sign_posn;
  iov[cnt].iov_len = 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;

  /* Align following data */
  iov[cnt].iov_base = (void *) "\0\0";
  iov[cnt].iov_len = ((idx[cnt - 2] + 3) & ~3) - idx[cnt - 2];
  idx[cnt - 2] = (idx[cnt - 2] + 3) & ~3;
  ++cnt;

  iov[cnt].iov_base = (void *) &monetary->uno_valid_from;
  iov[cnt].iov_len = sizeof(uint32_t);
  ++cnt;

  idx[cnt - 3] = idx[cnt - 4] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) &monetary->uno_valid_to;
  iov[cnt].iov_len = sizeof(uint32_t);
  ++cnt;

  idx[cnt - 3] = idx[cnt - 4] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) &monetary->duo_valid_from;
  iov[cnt].iov_len = sizeof(uint32_t);
  ++cnt;

  idx[cnt - 3] = idx[cnt - 4] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) &monetary->duo_valid_to;
  iov[cnt].iov_len = sizeof(uint32_t);
  ++cnt;

  idx[cnt - 3] = idx[cnt - 4] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) monetary->conversion_rate;
  iov[cnt].iov_len = 2 * sizeof(uint32_t);
  ++cnt;

  idx[cnt - 3] = idx[cnt - 4] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) &monetary->mon_decimal_point_wc;
  iov[cnt].iov_len = sizeof (uint32_t);
  ++cnt;

  idx[cnt - 3] = idx[cnt - 4] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) &monetary->mon_thousands_sep_wc;
  iov[cnt].iov_len = sizeof (uint32_t);
  ++cnt;

  idx[cnt - 3] = idx[cnt - 4] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) charmap->code_set_name;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  assert (cnt == 3 + _NL_ITEM_INDEX (_NL_NUM_LC_MONETARY));

  write_locale_data (output_path, LC_MONETARY, "LC_MONETARY",
                   3 + _NL_ITEM_INDEX (_NL_NUM_LC_MONETARY), iov);
}

Here is the call graph for this function:

void monetary_read ( struct linereader ldfile,
struct localedef_t result,
const struct charmap_t charmap,
const char *  repertoire_name,
int  ignore_content 
)

Definition at line 636 of file ld-monetary.c.

{
  struct repertoire_t *repertoire = NULL;
  struct locale_monetary_t *monetary;
  struct token *now;
  enum token_t nowtok;

  /* Get the repertoire we have to use.  */
  if (repertoire_name != NULL)
    repertoire = repertoire_read (repertoire_name);

  /* The rest of the line containing `LC_MONETARY' must be free.  */
  lr_ignore_rest (ldfile, 1);

  do
    {
      now = lr_token (ldfile, charmap, result, NULL, verbose);
      nowtok = now->tok;
    }
  while (nowtok == tok_eol);

  /* If we see `copy' now we are almost done.  */
  if (nowtok == tok_copy)
    {
      handle_copy (ldfile, charmap, repertoire_name, result, tok_lc_monetary,
                 LC_MONETARY, "LC_MONETARY", ignore_content);
      return;
    }

  /* Prepare the data structures.  */
  monetary_startup (ldfile, result, ignore_content);
  monetary = result->categories[LC_MONETARY].monetary;

  while (1)
    {
      /* Of course we don't proceed beyond the end of file.  */
      if (nowtok == tok_eof)
       break;

      /* Ignore empty lines.  */
      if (nowtok == tok_eol)
       {
         now = lr_token (ldfile, charmap, result, NULL, verbose);
         nowtok = now->tok;
         continue;
       }

      switch (nowtok)
       {
#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, result, NULL, verbose);           \
         if (now->tok != tok_string)                                        \
           goto err_label;                                           \
         else if (monetary->cat != NULL)                             \
           lr_error (ldfile, _("%s: field `%s' declared more than once"),    \
                    "LC_MONETARY", #cat);                            \
         else if (!ignore_content && now->val.str.startmb == NULL)          \
           {                                                         \
             lr_error (ldfile, _("\
%s: unknown character in field `%s'"), "LC_MONETARY", #cat);                \
             monetary->cat = "";                                     \
           }                                                         \
         else if (!ignore_content)                                   \
           monetary->cat = now->val.str.startmb;                     \
         lr_ignore_rest (ldfile, 1);                                        \
         break

         STR_ELEM (int_curr_symbol);
         STR_ELEM (currency_symbol);
         STR_ELEM (positive_sign);
         STR_ELEM (negative_sign);
         STR_ELEM (duo_int_curr_symbol);
         STR_ELEM (duo_currency_symbol);

#define STR_ELEM_WC(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;                                                  \
           }                                                         \
                                                                     \
         ldfile->return_widestr = 1;                                        \
         now = lr_token (ldfile, charmap, result, repertoire, verbose);      \
         if (now->tok != tok_string)                                        \
           goto err_label;                                           \
         if (monetary->cat != NULL)                                         \
           lr_error (ldfile, _("\
%s: field `%s' declared more than once"), "LC_MONETARY", #cat);                    \
         else if (!ignore_content && now->val.str.startmb == NULL)          \
           {                                                         \
             lr_error (ldfile, _("\
%s: unknown character in field `%s'"), "LC_MONETARY", #cat);                \
             monetary->cat = "";                                     \
             monetary->cat##_wc = L'\0';                             \
           }                                                         \
         else if (now->val.str.startwc != NULL && now->val.str.lenwc > 2)    \
           {                                                         \
             lr_error (ldfile, _("\
%s: value for field `%s' must be a single character"), "LC_MONETARY", #cat);  \
           }                                                         \
         else if (!ignore_content)                                   \
           {                                                         \
             monetary->cat = now->val.str.startmb;                          \
                                                                     \
             if (now->val.str.startwc != NULL)                              \
              monetary->cat##_wc = *now->val.str.startwc;                   \
           }                                                         \
         ldfile->return_widestr = 0;                                        \
         break

         STR_ELEM_WC (mon_decimal_point);
         STR_ELEM_WC (mon_thousands_sep);

#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, result, NULL, verbose);           \
         if (now->tok != tok_minus1 && now->tok != tok_number)              \
           goto err_label;                                           \
         else if (monetary->cat != -2)                                      \
           lr_error (ldfile, _("%s: field `%s' declared more than once"),    \
                    "LC_MONETARY", #cat);                            \
         else if (!ignore_content)                                   \
           monetary->cat = now->tok == tok_minus1 ? -1 : now->val.num;             \
         break

         INT_ELEM (int_frac_digits);
         INT_ELEM (frac_digits);
         INT_ELEM (p_cs_precedes);
         INT_ELEM (p_sep_by_space);
         INT_ELEM (n_cs_precedes);
         INT_ELEM (n_sep_by_space);
         INT_ELEM (p_sign_posn);
         INT_ELEM (n_sign_posn);
         INT_ELEM (int_p_cs_precedes);
         INT_ELEM (int_p_sep_by_space);
         INT_ELEM (int_n_cs_precedes);
         INT_ELEM (int_n_sep_by_space);
         INT_ELEM (int_p_sign_posn);
         INT_ELEM (int_n_sign_posn);
         INT_ELEM (duo_int_frac_digits);
         INT_ELEM (duo_frac_digits);
         INT_ELEM (duo_p_cs_precedes);
         INT_ELEM (duo_p_sep_by_space);
         INT_ELEM (duo_n_cs_precedes);
         INT_ELEM (duo_n_sep_by_space);
         INT_ELEM (duo_p_sign_posn);
         INT_ELEM (duo_n_sign_posn);
         INT_ELEM (duo_int_p_cs_precedes);
         INT_ELEM (duo_int_p_sep_by_space);
         INT_ELEM (duo_int_n_cs_precedes);
         INT_ELEM (duo_int_n_sep_by_space);
         INT_ELEM (duo_int_p_sign_posn);
         INT_ELEM (duo_int_n_sign_posn);
         INT_ELEM (uno_valid_from);
         INT_ELEM (uno_valid_to);
         INT_ELEM (duo_valid_from);
         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, result, NULL, verbose);
         if (now->tok != tok_minus1 && now->tok != tok_number)
           goto err_label;
         else
           {
             size_t act = 0;
             size_t max = 10;
             char *grouping = ignore_content ? NULL : xmalloc (max);

             do
              {
                if (act + 1 >= max)
                  {
                    max *= 2;
                    grouping = xrealloc (grouping, max);
                  }

                if (act > 0 && grouping[act - 1] == '\177')
                  {
                    lr_error (ldfile, _("\
%s: `-1' must be last entry in `%s' field"),
                            "LC_MONETARY", "mon_grouping");
                    lr_ignore_rest (ldfile, 0);
                    break;
                  }

                if (now->tok == tok_minus1)
                  {
                    if (!ignore_content)
                     grouping[act++] = '\177';
                  }
                else if (now->val.num == 0)
                  {
                    /* A value of 0 disables grouping from here on but
                      we must not store a NUL character since this
                      terminates the string.  Use something different
                      which must not be used otherwise.  */
                    if (!ignore_content)
                     grouping[act++] = '\377';
                  }
                else if (now->val.num > 126)
                  lr_error (ldfile, _("\
%s: values for field `%s' must be smaller than 127"),
                           "LC_MONETARY", "mon_grouping");
                else if (!ignore_content)
                  grouping[act++] = now->val.num;

                /* Next must be semicolon.  */
                now = lr_token (ldfile, charmap, result, NULL, verbose);
                if (now->tok != tok_semicolon)
                  break;

                now = lr_token (ldfile, charmap, result, NULL, verbose);
              }
             while (now->tok == tok_minus1 || now->tok == tok_number);

             if (now->tok != tok_eol)
              goto err_label;

             if (!ignore_content)
              {
                grouping[act++] = '\0';

                monetary->mon_grouping = xrealloc (grouping, act);
                monetary->mon_grouping_len = act;
              }
           }
         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, result, NULL, verbose);
         if (now->tok != tok_number)
           goto err_label;
         if (now->val.num == 0)
           {
           invalid_conversion_rate:
             lr_error (ldfile, _("conversion rate value cannot be zero"));
             if (!ignore_content)
              {
                monetary->conversion_rate[0] = 1;
                monetary->conversion_rate[1] = 1;
              }
             break;
           }
         if (!ignore_content)
           monetary->conversion_rate[0] = now->val.num;
         /* Next must be a semicolon.  */
         now = lr_token (ldfile, charmap, result, NULL, verbose);
         if (now->tok != tok_semicolon)
           goto err_label;
         /* And another number.  */
         now = lr_token (ldfile, charmap, result, NULL, verbose);
         if (now->tok != tok_number)
           goto err_label;
         if (now->val.num == 0)
           goto invalid_conversion_rate;
         if (!ignore_content)
           monetary->conversion_rate[1] = now->val.num;
         /* The rest of the line must be empty.  */
         lr_ignore_rest (ldfile, 1);
         break;

       case tok_end:
         /* Next we assume `LC_MONETARY'.  */
         now = lr_token (ldfile, charmap, result, NULL, verbose);
         if (now->tok == tok_eof)
           break;
         if (now->tok == tok_eol)
           lr_error (ldfile, _("%s: incomplete `END' line"), "LC_MONETARY");
         else if (now->tok != tok_lc_monetary)
           lr_error (ldfile, _("\
%1$s: definition does not end with `END %1$s'"), "LC_MONETARY");
         lr_ignore_rest (ldfile, now->tok == tok_lc_monetary);
         return;

       default:
       err_label:
         SYNTAX_ERROR (_("%s: syntax error"), "LC_MONETARY");
       }

      /* Prepare for the next round.  */
      now = lr_token (ldfile, charmap, result, NULL, verbose);
      nowtok = now->tok;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void name_finish ( struct localedef_t locale,
const struct charmap_t charmap 
)

Definition at line 63 of file ld-name.c.

{
  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)
       {
         if (! be_quiet)
           WITH_CUR_LOCALE (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)
    {
      if (! nothing)
       WITH_CUR_LOCALE (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";
    }
  else
    {
      /* We must check whether the format string contains only the
        allowed escape sequences.  */
      const char *cp = name->name_fmt;

      if (*cp == '\0')
       WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' must not be empty"),
                            "LC_NAME", "name_fmt"));
      else
       while (*cp != '\0')
         {
           if (*cp == '%')
             {
              if (*++cp == 'R')
                /* Romanize-flag.  */
                ++cp;
              if (strchr ("dfFgGlomMpsSt", *cp) == NULL)
                {
                  WITH_CUR_LOCALE (error (0, 0, _("\
%s: invalid escape sequence in field `%s'"), "LC_NAME", "name_fmt"));
                  break;
                }
             }
           ++cp;
         }
    }

#define TEST_ELEM(cat) \
  if (name->cat == NULL)                                             \
    {                                                                \
      if (verbose && ! nothing)                                             \
       WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"),       \
                            "LC_NAME", #cat));                              \
      name->cat = "";                                                       \
    }

  TEST_ELEM (name_gen);
  TEST_ELEM (name_mr);
  TEST_ELEM (name_mrs);
  TEST_ELEM (name_miss);
  TEST_ELEM (name_ms);
}

Here is the call graph for this function:

void name_output ( struct localedef_t locale,
const struct charmap_t charmap,
const char *  output_path 
)

Definition at line 156 of file ld-name.c.

{
  struct locale_name_t *name = locale->categories[LC_NAME].name;
  struct iovec iov[2 + _NL_ITEM_INDEX (_NL_NUM_LC_NAME)];
  struct locale_file data;
  uint32_t idx[_NL_ITEM_INDEX (_NL_NUM_LC_NAME)];
  size_t cnt = 0;

  data.magic = LIMAGIC (LC_NAME);
  data.n = _NL_ITEM_INDEX (_NL_NUM_LC_NAME);
  iov[cnt].iov_base = (void *) &data;
  iov[cnt].iov_len = sizeof (data);
  ++cnt;

  iov[cnt].iov_base = (void *) idx;
  iov[cnt].iov_len = sizeof (idx);
  ++cnt;

  idx[cnt - 2] = iov[0].iov_len + iov[1].iov_len;
  iov[cnt].iov_base = (void *) name->name_fmt;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) name->name_gen;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) name->name_mr;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) name->name_mrs;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) name->name_miss;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) name->name_ms;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) charmap->code_set_name;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  assert (cnt == 2 + _NL_ITEM_INDEX (_NL_NUM_LC_NAME));

  write_locale_data (output_path, LC_NAME, "LC_NAME",
                   2 + _NL_ITEM_INDEX (_NL_NUM_LC_NAME), iov);
}

Here is the call graph for this function:

void name_read ( struct linereader ldfile,
struct localedef_t result,
const struct charmap_t charmap,
const char *  repertoire_name,
int  ignore_content 
)

Definition at line 219 of file ld-name.c.

{
  struct locale_name_t *name;
  struct token *now;
  struct token *arg;
  enum token_t nowtok;

  /* The rest of the line containing `LC_NAME' must be empty.  */
  lr_ignore_rest (ldfile, 1);

  do
    {
      now = lr_token (ldfile, charmap, result, NULL, verbose);
      nowtok = now->tok;
    }
  while (nowtok == tok_eol);

  /* If we see `copy' now we are almost done.  */
  if (nowtok == tok_copy)
    {
      handle_copy (ldfile, charmap, repertoire_name, result, tok_lc_name,
                 LC_NAME, "LC_NAME", ignore_content);
      return;
    }

  /* Prepare the data structures.  */
  name_startup (ldfile, result, ignore_content);
  name = result->categories[LC_NAME].name;

  while (1)
    {
      /* Of course we don't proceed beyond the end of file.  */
      if (nowtok == tok_eof)
       break;

      /* Ignore empty lines.  */
      if (nowtok == tok_eol)
       {
         now = lr_token (ldfile, charmap, result, NULL, verbose);
         nowtok = now->tok;
         continue;
       }

      switch (nowtok)
       {
#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, result, NULL, verbose);           \
         if (arg->tok != tok_string)                                        \
           goto err_label;                                           \
         if (name->cat != NULL)                                      \
           lr_error (ldfile, _("%s: field `%s' declared more than once"),    \
                    "LC_NAME", #cat);                                       \
         else if (!ignore_content && arg->val.str.startmb == NULL)          \
           {                                                         \
             lr_error (ldfile, _("%s: unknown character in field `%s'"),     \
                     "LC_NAME", #cat);                               \
             name->cat = "";                                                \
           }                                                         \
         else if (!ignore_content)                                   \
           name->cat = arg->val.str.startmb;                                \
         break

         STR_ELEM (name_fmt);
         STR_ELEM (name_gen);
         STR_ELEM (name_mr);
         STR_ELEM (name_mrs);
         STR_ELEM (name_miss);
         STR_ELEM (name_ms);

       case tok_end:
         /* Next we assume `LC_NAME'.  */
         arg = lr_token (ldfile, charmap, result, NULL, verbose);
         if (arg->tok == tok_eof)
           break;
         if (arg->tok == tok_eol)
           lr_error (ldfile, _("%s: incomplete `END' line"), "LC_NAME");
         else if (arg->tok != tok_lc_name)
           lr_error (ldfile, _("\
%1$s: definition does not end with `END %1$s'"), "LC_NAME");
         lr_ignore_rest (ldfile, arg->tok == tok_lc_name);
         return;

       default:
       err_label:
         SYNTAX_ERROR (_("%s: syntax error"), "LC_NAME");
       }

      /* Prepare for the next round.  */
      now = lr_token (ldfile, charmap, result, NULL, verbose);
      nowtok = now->tok;
    }

  /* When we come here we reached the end of the file.  */
  lr_error (ldfile, _("%s: premature end of file"), "LC_NAME");

Here is the call graph for this function:

Here is the caller graph for this function:

void numeric_finish ( struct localedef_t locale,
const struct charmap_t charmap 
)

Definition at line 67 of file ld-numeric.c.

{
  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)
       {
         if (! be_quiet)
           WITH_CUR_LOCALE (error (0, 0, _("\
No definition for %s category found"), "LC_NUMERIC"));
         numeric_startup (NULL, locale, 0);
         numeric = locale->categories[LC_NUMERIC].numeric;
         nothing = 1;
       }
    }

  /* 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 == NULL)
    {
      if (! be_quiet && ! nothing)
       WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"),
                            "LC_NUMERIC", "decimal_point"));
      numeric->decimal_point = ".";
    }
  else if (numeric->decimal_point[0] == '\0' && ! be_quiet && ! nothing)
    {
      WITH_CUR_LOCALE (error (0, 0, _("\
%s: value for field `%s' must not be an empty string"),
                           "LC_NUMERIC", "decimal_point"));
    }
  if (numeric->decimal_point_wc == L'\0')
    numeric->decimal_point_wc = L'.';

  if (numeric->grouping_len == 0 && ! be_quiet && ! nothing)
    WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"),
                         "LC_NUMERIC", "grouping"));
}

Here is the call graph for this function:

void numeric_output ( struct localedef_t locale,
const struct charmap_t charmap,
const char *  output_path 
)

Definition at line 132 of file ld-numeric.c.

{
  struct locale_numeric_t *numeric = locale->categories[LC_NUMERIC].numeric;
  struct iovec iov[3 + _NL_ITEM_INDEX (_NL_NUM_LC_NUMERIC)];
  struct locale_file data;
  uint32_t idx[_NL_ITEM_INDEX (_NL_NUM_LC_NUMERIC)];
  size_t cnt = 0;

  data.magic = LIMAGIC (LC_NUMERIC);
  data.n = _NL_ITEM_INDEX (_NL_NUM_LC_NUMERIC);
  iov[cnt].iov_base = (void *) &data;
  iov[cnt].iov_len = sizeof (data);
  ++cnt;

  iov[cnt].iov_base = (void *) idx;
  iov[cnt].iov_len = sizeof (idx);
  ++cnt;

  idx[cnt - 2] = iov[0].iov_len + iov[1].iov_len;
  iov[cnt].iov_base = (void *) (numeric->decimal_point ?: "");
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) (numeric->thousands_sep ?: "");
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = numeric->grouping;
  iov[cnt].iov_len = numeric->grouping_len;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;

  /* Align following data */
  iov[cnt].iov_base = (void *) "\0\0";
  iov[cnt].iov_len = ((idx[cnt - 2] + 3) & ~3) - idx[cnt - 2];
  idx[cnt - 2] = (idx[cnt - 2] + 3) & ~3;
  ++cnt;

  iov[cnt].iov_base = (void *) &numeric->decimal_point_wc;
  iov[cnt].iov_len = sizeof (uint32_t);
  ++cnt;

  idx[cnt - 3] = idx[cnt - 4] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) &numeric->thousands_sep_wc;
  iov[cnt].iov_len = sizeof (uint32_t);
  ++cnt;

  idx[cnt - 3] = idx[cnt - 4] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) charmap->code_set_name;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;

  assert (cnt + 1 == 3 + _NL_ITEM_INDEX (_NL_NUM_LC_NUMERIC));

  write_locale_data (output_path, LC_NUMERIC, "LC_NUMERIC",
                   3 + _NL_ITEM_INDEX (_NL_NUM_LC_NUMERIC), iov);
}

Here is the call graph for this function:

void numeric_read ( struct linereader ldfile,
struct localedef_t result,
const struct charmap_t charmap,
const char *  repertoire_name,
int  ignore_content 
)

Definition at line 196 of file ld-numeric.c.

{
  struct repertoire_t *repertoire = NULL;
  struct locale_numeric_t *numeric;
  struct token *now;
  enum token_t nowtok;

  /* Get the repertoire we have to use.  */
  if (repertoire_name != NULL)
    repertoire = repertoire_read (repertoire_name);

  /* The rest of the line containing `LC_NUMERIC' must be free.  */
  lr_ignore_rest (ldfile, 1);


  do
    {
      now = lr_token (ldfile, charmap, result, NULL, verbose);
      nowtok = now->tok;
    }
  while (nowtok == tok_eol);

  /* If we see `copy' now we are almost done.  */
  if (nowtok == tok_copy)
    {
      handle_copy (ldfile, charmap, repertoire_name, result, tok_lc_numeric,
                 LC_NUMERIC, "LC_NUMERIC", ignore_content);
      return;
    }

  /* Prepare the data structures.  */
  numeric_startup (ldfile, result, ignore_content);
  numeric = result->categories[LC_NUMERIC].numeric;

  while (1)
    {
      /* Of course we don't proceed beyond the end of file.  */
      if (nowtok == tok_eof)
       break;

      /* Ingore empty lines.  */
      if (nowtok == tok_eol)
       {
         now = lr_token (ldfile, charmap, result, NULL, verbose);
         nowtok = now->tok;
         continue;
       }

      switch (nowtok)
       {
#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;                                                  \
           }                                                         \
                                                                     \
         ldfile->return_widestr = 1;                                        \
         now = lr_token (ldfile, charmap, result, repertoire, verbose);            \
         if (now->tok != tok_string)                                        \
           goto err_label;                                           \
         if (numeric->cat != NULL)                                   \
           lr_error (ldfile, _("\
%s: field `%s' declared more than once"), "LC_NUMERIC", #cat);              \
         else if (!ignore_content && now->val.str.startmb == NULL)          \
           {                                                         \
             lr_error (ldfile, _("\
%s: unknown character in field `%s'"), "LC_NUMERIC", #cat);                 \
             numeric->cat = "";                                      \
             numeric->cat##_wc = L'\0';                              \
           }                                                         \
         else if (now->val.str.startwc != NULL && now->val.str.lenwc > 2)    \
           {                                                         \
             lr_error (ldfile, _("\
%s: value for field `%s' must be a single character"), "LC_NUMERIC", #cat);   \
           }                                                         \
         else if (!ignore_content)                                   \
           {                                                         \
             numeric->cat = now->val.str.startmb;                           \
                                                                     \
             if (now->val.str.startwc != NULL)                              \
              numeric->cat##_wc = *now->val.str.startwc;                    \
           }                                                         \
         ldfile->return_widestr = 0;                                        \
         break

         STR_ELEM (decimal_point);
         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, result, NULL, verbose);
         if (now->tok != tok_minus1 && now->tok != tok_number)
           goto err_label;
         else
           {
             size_t act = 0;
             size_t max = 10;
             char *grouping = xmalloc (max);

             do
              {
                if (act + 1 >= max)
                  {
                    max *= 2;
                    grouping = xrealloc (grouping, max);
                  }

                if (act > 0 && grouping[act - 1] == '\177')
                  {
                    lr_error (ldfile, _("\
%s: `-1' must be last entry in `%s' field"), "LC_NUMERIC", "grouping");
                    lr_ignore_rest (ldfile, 0);
                    break;
                  }

                if (now->tok == tok_minus1)
                  grouping[act++] = '\177';
                else if (now->val.num == 0)
                  {
                    /* A value of 0 disables grouping from here on but
                      we must not store a NUL character since this
                      terminates the string.  Use something different
                      which must not be used otherwise.  */
                    grouping[act++] = '\377';
                  }
                else if (now->val.num > 126)
                  lr_error (ldfile, _("\
%s: values for field `%s' must be smaller than 127"),
                           "LC_NUMERIC", "grouping");
                else
                  grouping[act++] = now->val.num;

                /* Next must be semicolon.  */
                now = lr_token (ldfile, charmap, result, NULL, verbose);
                if (now->tok != tok_semicolon)
                  break;

                now = lr_token (ldfile, charmap, result, NULL, verbose);
              }
             while (now->tok == tok_minus1 || now->tok == tok_number);

             if (now->tok != tok_eol)
              goto err_label;

             grouping[act++] = '\0';

             numeric->grouping = xrealloc (grouping, act);
             numeric->grouping_len = act;
           }
         break;

       case tok_end:
         /* Next we assume `LC_NUMERIC'.  */
         now = lr_token (ldfile, charmap, result, NULL, verbose);
         if (now->tok == tok_eof)
           break;
         if (now->tok == tok_eol)
           lr_error (ldfile, _("%s: incomplete `END' line"), "LC_NUMERIC");
         else if (now->tok != tok_lc_numeric)
           lr_error (ldfile, _("\
%1$s: definition does not end with `END %1$s'"), "LC_NUMERIC");
         lr_ignore_rest (ldfile, now->tok == tok_lc_numeric);
         return;

       default:
       err_label:
         SYNTAX_ERROR (_("%s: syntax error"), "LC_NUMERIC");
       }

      /* Prepare for the next round.  */
      now = lr_token (ldfile, charmap, result, NULL, verbose);
      nowtok = now->tok;
    }

  /* When we come here we reached the end of the file.  */
  lr_error (ldfile, _("%s: premature end of file"), "LC_NUMERIC");

Here is the call graph for this function:

Here is the caller graph for this function:

void paper_finish ( struct localedef_t locale,
const struct charmap_t charmap 
)

Definition at line 60 of file ld-paper.c.

{
  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)
       {
         if (! be_quiet)
           WITH_CUR_LOCALE (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)
    {
      if (! nothing)
       WITH_CUR_LOCALE (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)
    {
      if (! nothing)
       WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"),
                            "LC_PAPER", "width"));
      /* Use as default values the values from the i18n locale.  */
      paper->width = 210;
    }
}

Here is the call graph for this function:

void paper_output ( struct localedef_t locale,
const struct charmap_t charmap,
const char *  output_path 
)

Definition at line 120 of file ld-paper.c.

{
  struct locale_paper_t *paper = locale->categories[LC_PAPER].paper;
  struct iovec iov[2 + _NL_ITEM_INDEX (_NL_NUM_LC_PAPER)];
  struct locale_file data;
  uint32_t idx[_NL_ITEM_INDEX (_NL_NUM_LC_PAPER)];
  size_t cnt = 0;

  data.magic = LIMAGIC (LC_PAPER);
  data.n = _NL_ITEM_INDEX (_NL_NUM_LC_PAPER);
  iov[cnt].iov_base = (void *) &data;
  iov[cnt].iov_len = sizeof (data);
  ++cnt;

  iov[cnt].iov_base = (void *) idx;
  iov[cnt].iov_len = sizeof (idx);
  ++cnt;

  idx[cnt - 2] = iov[cnt - 2].iov_len + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = &paper->height;
  iov[cnt].iov_len = 4;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = &paper->width;
  iov[cnt].iov_len = 4;
  ++cnt;

  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
  iov[cnt].iov_base = (void *) charmap->code_set_name;
  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
  ++cnt;

  assert (cnt == 2 + _NL_ITEM_INDEX (_NL_NUM_LC_PAPER));

  write_locale_data (output_path, LC_PAPER, "LC_PAPER",
                   2 + _NL_ITEM_INDEX (_NL_NUM_LC_PAPER), iov);
}

Here is the call graph for this function: