Back to index

tetex-bin  3.0
Classes | Defines | Functions
loadinfo.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  loaded_l10nfile

Defines

#define internal_function
#define __builtin_expect(expr, val)   (expr)
#define PATH_SEPARATOR   ':'
#define CEN_REVISION   1
#define CEN_SPONSOR   2
#define CEN_SPECIAL   4
#define XPG_NORM_CODESET   8
#define XPG_CODESET   16
#define TERRITORY   32
#define CEN_AUDIENCE   64
#define XPG_MODIFIER   128
#define CEN_SPECIFIC   (CEN_REVISION|CEN_SPONSOR|CEN_SPECIAL|CEN_AUDIENCE)
#define XPG_SPECIFIC   (XPG_CODESET|XPG_NORM_CODESET|XPG_MODIFIER)

Functions

const char * _nl_normalize_codeset (const char *codeset, size_t name_len)
struct loaded_l10nfile_nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list, const char *dirlist, size_t dirlist_len, int mask, const char *language, const char *territory, const char *codeset, const char *normalized_codeset, const char *modifier, const char *special, const char *sponsor, const char *revision, const char *filename, int do_allocate)
const char * _nl_expand_alias (const char *name)
int _nl_explode_name (char *name, const char **language, const char **modifier, const char **territory, const char **codeset, const char **normalized_codeset, const char **special, const char **sponsor, const char **revision)
char * _nl_find_language (const char *name)

Class Documentation

struct loaded_l10nfile

Definition at line 68 of file loadinfo.h.

Collaboration diagram for loaded_l10nfile:
Class Members
const void * data
int decided
const char * filename
struct loaded_l10nfile * next
struct loaded_l10nfile * successor

Define Documentation

#define __builtin_expect (   expr,
  val 
)    (expr)

Definition at line 42 of file loadinfo.h.

#define CEN_AUDIENCE   64

Definition at line 61 of file loadinfo.h.

#define CEN_REVISION   1

Definition at line 55 of file loadinfo.h.

#define CEN_SPECIAL   4

Definition at line 57 of file loadinfo.h.

Definition at line 64 of file loadinfo.h.

#define CEN_SPONSOR   2

Definition at line 56 of file loadinfo.h.

Definition at line 36 of file loadinfo.h.

#define PATH_SEPARATOR   ':'

Definition at line 51 of file loadinfo.h.

#define TERRITORY   32

Definition at line 60 of file loadinfo.h.

#define XPG_CODESET   16

Definition at line 59 of file loadinfo.h.

#define XPG_MODIFIER   128

Definition at line 62 of file loadinfo.h.

#define XPG_NORM_CODESET   8

Definition at line 58 of file loadinfo.h.

Definition at line 65 of file loadinfo.h.


Function Documentation

const char* _nl_expand_alias ( const char *  name)

Definition at line 151 of file localealias.c.

{
  static const char *locale_alias_path;
  struct alias_map *retval;
  const char *result = NULL;
  size_t added;

#ifdef _LIBC
  __libc_lock_lock (lock);
#endif

  if (locale_alias_path == NULL)
    locale_alias_path = LOCALE_ALIAS_PATH;

  do
    {
      struct alias_map item;

      item.alias = name;

      if (nmap > 0)
       retval = (struct alias_map *) bsearch (&item, map, nmap,
                                          sizeof (struct alias_map),
                                          (int (*) (const void *,
                                                  const void *)
                                          ) alias_compare);
      else
       retval = NULL;

      /* We really found an alias.  Return the value.  */
      if (retval != NULL)
       {
         result = retval->value;
         break;
       }

      /* Perhaps we can find another alias file.  */
      added = 0;
      while (added == 0 && locale_alias_path[0] != '\0')
       {
         const char *start;

         while (locale_alias_path[0] == PATH_SEPARATOR)
           ++locale_alias_path;
         start = locale_alias_path;

         while (locale_alias_path[0] != '\0'
               && locale_alias_path[0] != PATH_SEPARATOR)
           ++locale_alias_path;

         if (start < locale_alias_path)
           added = read_alias_file (start, locale_alias_path - start);
       }
    }
  while (added != 0);

#ifdef _LIBC
  __libc_lock_unlock (lock);
#endif

  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int _nl_explode_name ( char *  name,
const char **  language,
const char **  modifier,
const char **  territory,
const char **  codeset,
const char **  normalized_codeset,
const char **  special,
const char **  sponsor,
const char **  revision 
)

Definition at line 52 of file explodename.c.

{
  enum { undecided, xpg, cen } syntax;
  char *cp;
  int mask;

  *modifier = NULL;
  *territory = NULL;
  *codeset = NULL;
  *normalized_codeset = NULL;
  *special = NULL;
  *sponsor = NULL;
  *revision = NULL;

  /* Now we determine the single parts of the locale name.  First
     look for the language.  Termination symbols are `_' and `@' if
     we use XPG4 style, and `_', `+', and `,' if we use CEN syntax.  */
  mask = 0;
  syntax = undecided;
  *language = cp = name;
  cp = _nl_find_language (*language);

  if (*language == cp)
    /* This does not make sense: language has to be specified.  Use
       this entry as it is without exploding.  Perhaps it is an alias.  */
    cp = strchr (*language, '\0');
  else if (cp[0] == '_')
    {
      /* Next is the territory.  */
      cp[0] = '\0';
      *territory = ++cp;

      while (cp[0] != '\0' && cp[0] != '.' && cp[0] != '@'
            && cp[0] != '+' && cp[0] != ',' && cp[0] != '_')
       ++cp;

      mask |= TERRITORY;

      if (cp[0] == '.')
       {
         /* Next is the codeset.  */
         syntax = xpg;
         cp[0] = '\0';
         *codeset = ++cp;

         while (cp[0] != '\0' && cp[0] != '@')
           ++cp;

         mask |= XPG_CODESET;

         if (*codeset != cp && (*codeset)[0] != '\0')
           {
             *normalized_codeset = _nl_normalize_codeset (*codeset,
                                                    cp - *codeset);
             if (strcmp (*codeset, *normalized_codeset) == 0)
              free ((char *) *normalized_codeset);
             else
              mask |= XPG_NORM_CODESET;
           }
       }
    }

  if (cp[0] == '@' || (syntax != xpg && cp[0] == '+'))
    {
      /* Next is the modifier.  */
      syntax = cp[0] == '@' ? xpg : cen;
      cp[0] = '\0';
      *modifier = ++cp;

      while (syntax == cen && cp[0] != '\0' && cp[0] != '+'
            && cp[0] != ',' && cp[0] != '_')
       ++cp;

      mask |= XPG_MODIFIER | CEN_AUDIENCE;
    }

  if (syntax != xpg && (cp[0] == '+' || cp[0] == ',' || cp[0] == '_'))
    {
      syntax = cen;

      if (cp[0] == '+')
       {
         /* Next is special application (CEN syntax).  */
         cp[0] = '\0';
         *special = ++cp;

         while (cp[0] != '\0' && cp[0] != ',' && cp[0] != '_')
           ++cp;

         mask |= CEN_SPECIAL;
       }

      if (cp[0] == ',')
       {
         /* Next is sponsor (CEN syntax).  */
         cp[0] = '\0';
         *sponsor = ++cp;

         while (cp[0] != '\0' && cp[0] != '_')
           ++cp;

         mask |= CEN_SPONSOR;
       }

      if (cp[0] == '_')
       {
         /* Next is revision (CEN syntax).  */
         cp[0] = '\0';
         *revision = ++cp;

         mask |= CEN_REVISION;
       }
    }

  /* For CEN syntax values it might be important to have the
     separator character in the file name, not for XPG syntax.  */
  if (syntax == xpg)
    {
      if (*territory != NULL && (*territory)[0] == '\0')
       mask &= ~TERRITORY;

      if (*codeset != NULL && (*codeset)[0] == '\0')
       mask &= ~XPG_CODESET;

      if (*modifier != NULL && (*modifier)[0] == '\0')
       mask &= ~XPG_MODIFIER;
    }

  return mask;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* _nl_find_language ( const char *  name)

Definition at line 41 of file explodename.c.

{
  while (name[0] != '\0' && name[0] != '_' && name[0] != '@'
        && name[0] != '+' && name[0] != ',')
    ++name;

  return (char *) name;
}

Here is the caller graph for this function:

struct loaded_l10nfile* _nl_make_l10nflist ( struct loaded_l10nfile **  l10nfile_list,
const char *  dirlist,
size_t  dirlist_len,
int  mask,
const char *  language,
const char *  territory,
const char *  codeset,
const char *  normalized_codeset,
const char *  modifier,
const char *  special,
const char *  sponsor,
const char *  revision,
const char *  filename,
int  do_allocate 
) [read]

Definition at line 169 of file l10nflist.c.

{
  char *abs_filename;
  struct loaded_l10nfile **lastp;
  struct loaded_l10nfile *retval;
  char *cp;
  size_t dirlist_count;
  size_t entries;
  int cnt;

  /* If LANGUAGE contains an absolute directory specification, we ignore
     DIRLIST.  */
  if (IS_ABSOLUTE_PATH (language))
    dirlist_len = 0;

  /* Allocate room for the full file name.  */
  abs_filename = (char *) malloc (dirlist_len
                              + strlen (language)
                              + ((mask & TERRITORY) != 0
                                 ? strlen (territory) + 1 : 0)
                              + ((mask & XPG_CODESET) != 0
                                 ? strlen (codeset) + 1 : 0)
                              + ((mask & XPG_NORM_CODESET) != 0
                                 ? strlen (normalized_codeset) + 1 : 0)
                              + (((mask & XPG_MODIFIER) != 0
                                  || (mask & CEN_AUDIENCE) != 0)
                                 ? strlen (modifier) + 1 : 0)
                              + ((mask & CEN_SPECIAL) != 0
                                 ? strlen (special) + 1 : 0)
                              + (((mask & CEN_SPONSOR) != 0
                                  || (mask & CEN_REVISION) != 0)
                                 ? (1 + ((mask & CEN_SPONSOR) != 0
                                        ? strlen (sponsor) : 0)
                                   + ((mask & CEN_REVISION) != 0
                                      ? strlen (revision) + 1 : 0)) : 0)
                              + 1 + strlen (filename) + 1);

  if (abs_filename == NULL)
    return NULL;

  /* Construct file name.  */
  cp = abs_filename;
  if (dirlist_len > 0)
    {
      memcpy (cp, dirlist, dirlist_len);
      __argz_stringify (cp, dirlist_len, PATH_SEPARATOR);
      cp += dirlist_len;
      cp[-1] = '/';
    }

  cp = stpcpy (cp, language);

  if ((mask & TERRITORY) != 0)
    {
      *cp++ = '_';
      cp = stpcpy (cp, territory);
    }
  if ((mask & XPG_CODESET) != 0)
    {
      *cp++ = '.';
      cp = stpcpy (cp, codeset);
    }
  if ((mask & XPG_NORM_CODESET) != 0)
    {
      *cp++ = '.';
      cp = stpcpy (cp, normalized_codeset);
    }
  if ((mask & (XPG_MODIFIER | CEN_AUDIENCE)) != 0)
    {
      /* This component can be part of both syntaces but has different
        leading characters.  For CEN we use `+', else `@'.  */
      *cp++ = (mask & CEN_AUDIENCE) != 0 ? '+' : '@';
      cp = stpcpy (cp, modifier);
    }
  if ((mask & CEN_SPECIAL) != 0)
    {
      *cp++ = '+';
      cp = stpcpy (cp, special);
    }
  if ((mask & (CEN_SPONSOR | CEN_REVISION)) != 0)
    {
      *cp++ = ',';
      if ((mask & CEN_SPONSOR) != 0)
       cp = stpcpy (cp, sponsor);
      if ((mask & CEN_REVISION) != 0)
       {
         *cp++ = '_';
         cp = stpcpy (cp, revision);
       }
    }

  *cp++ = '/';
  stpcpy (cp, filename);

  /* Look in list of already loaded domains whether it is already
     available.  */
  lastp = l10nfile_list;
  for (retval = *l10nfile_list; retval != NULL; retval = retval->next)
    if (retval->filename != NULL)
      {
       int compare = strcmp (retval->filename, abs_filename);
       if (compare == 0)
         /* We found it!  */
         break;
       if (compare < 0)
         {
           /* It's not in the list.  */
           retval = NULL;
           break;
         }

       lastp = &retval->next;
      }

  if (retval != NULL || do_allocate == 0)
    {
      free (abs_filename);
      return retval;
    }

  dirlist_count = (dirlist_len > 0 ? __argz_count (dirlist, dirlist_len) : 1);

  /* Allocate a new loaded_l10nfile.  */
  retval =
    (struct loaded_l10nfile *)
    malloc (sizeof (*retval)
           + (((dirlist_count << pop (mask)) + (dirlist_count > 1 ? 1 : 0))
              * sizeof (struct loaded_l10nfile *)));
  if (retval == NULL)
    return NULL;

  retval->filename = abs_filename;

  /* We set retval->data to NULL here; it is filled in later.
     Setting retval->decided to 1 here means that retval does not
     correspond to a real file (dirlist_count > 1) or is not worth
     looking up (if an unnormalized codeset was specified).  */
  retval->decided = (dirlist_count > 1
                   || ((mask & XPG_CODESET) != 0
                      && (mask & XPG_NORM_CODESET) != 0));
  retval->data = NULL;

  retval->next = *lastp;
  *lastp = retval;

  entries = 0;
  /* Recurse to fill the inheritance list of RETVAL.
     If the DIRLIST is a real list (i.e. DIRLIST_COUNT > 1), the RETVAL
     entry does not correspond to a real file; retval->filename contains
     colons.  In this case we loop across all elements of DIRLIST and
     across all bit patterns dominated by MASK.
     If the DIRLIST is a single directory or entirely redundant (i.e.
     DIRLIST_COUNT == 1), we loop across all bit patterns dominated by
     MASK, excluding MASK itself.
     In either case, we loop down from MASK to 0.  This has the effect
     that the extra bits in the locale name are dropped in this order:
     first the modifier, then the territory, then the codeset, then the
     normalized_codeset.  */
  for (cnt = dirlist_count > 1 ? mask : mask - 1; cnt >= 0; --cnt)
    if ((cnt & ~mask) == 0
       && ((cnt & CEN_SPECIFIC) == 0 || (cnt & XPG_SPECIFIC) == 0)
       && ((cnt & XPG_CODESET) == 0 || (cnt & XPG_NORM_CODESET) == 0))
      {
       if (dirlist_count > 1)
         {
           /* Iterate over all elements of the DIRLIST.  */
           char *dir = NULL;

           while ((dir = __argz_next ((char *) dirlist, dirlist_len, dir))
                 != NULL)
             retval->successor[entries++]
              = _nl_make_l10nflist (l10nfile_list, dir, strlen (dir) + 1,
                                  cnt, language, territory, codeset,
                                  normalized_codeset, modifier, special,
                                  sponsor, revision, filename, 1);
         }
       else
         retval->successor[entries++]
           = _nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len,
                              cnt, language, territory, codeset,
                              normalized_codeset, modifier, special,
                              sponsor, revision, filename, 1);
      }
  retval->successor[entries] = NULL;

  return retval;
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* _nl_normalize_codeset ( const char *  codeset,
size_t  name_len 
)

Definition at line 368 of file l10nflist.c.

{
  int len = 0;
  int only_digit = 1;
  char *retval;
  char *wp;
  size_t cnt;

  for (cnt = 0; cnt < name_len; ++cnt)
    if (isalnum ((unsigned char) codeset[cnt]))
      {
       ++len;

       if (isalpha ((unsigned char) codeset[cnt]))
         only_digit = 0;
      }

  retval = (char *) malloc ((only_digit ? 3 : 0) + len + 1);

  if (retval != NULL)
    {
      if (only_digit)
       wp = stpcpy (retval, "iso");
      else
       wp = retval;

      for (cnt = 0; cnt < name_len; ++cnt)
       if (isalpha ((unsigned char) codeset[cnt]))
         *wp++ = tolower ((unsigned char) codeset[cnt]);
       else if (isdigit ((unsigned char) codeset[cnt]))
         *wp++ = codeset[cnt];

      *wp = '\0';
    }

  return (const char *) retval;
}

Here is the call graph for this function:

Here is the caller graph for this function: