OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [intl/] [l10nflist.c] - Diff between revs 227 and 816

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 227 Rev 816
/* Copyright (C) 1995-1999, 2000, 2001, 2002 Free Software Foundation, Inc.
/* Copyright (C) 1995-1999, 2000, 2001, 2002 Free Software Foundation, Inc.
   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
 
 
   This program is free software; you can redistribute it and/or modify it
   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU Library General Public License as published
   under the terms of the GNU Library General Public License as published
   by the Free Software Foundation; either version 2, or (at your option)
   by the Free Software Foundation; either version 2, or (at your option)
   any later version.
   any later version.
 
 
   This program is distributed in the hope that it will be useful,
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.
   Library General Public License for more details.
 
 
   You should have received a copy of the GNU Library General Public
   You should have received a copy of the GNU Library General Public
   License along with this program; if not, write to the Free Software
   License along with this program; if not, write to the Free Software
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301,
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301,
   USA.  */
   USA.  */
 
 
/* Tell glibc's <string.h> to provide a prototype for stpcpy().
/* Tell glibc's <string.h> to provide a prototype for stpcpy().
   This must come before <config.h> because <config.h> may include
   This must come before <config.h> because <config.h> may include
   <features.h>, and once <features.h> has been included, it's too late.  */
   <features.h>, and once <features.h> has been included, it's too late.  */
#ifndef _GNU_SOURCE
#ifndef _GNU_SOURCE
# define _GNU_SOURCE    1
# define _GNU_SOURCE    1
#endif
#endif
 
 
#ifdef HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
# include <config.h>
#endif
#endif
 
 
#include <string.h>
#include <string.h>
 
 
#if defined _LIBC || defined HAVE_ARGZ_H
#if defined _LIBC || defined HAVE_ARGZ_H
# include <argz.h>
# include <argz.h>
#endif
#endif
#include <ctype.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/types.h>
#include <stdlib.h>
#include <stdlib.h>
 
 
#include "loadinfo.h"
#include "loadinfo.h"
 
 
/* On some strange systems still no definition of NULL is found.  Sigh!  */
/* On some strange systems still no definition of NULL is found.  Sigh!  */
#ifndef NULL
#ifndef NULL
# if defined __STDC__ && __STDC__
# if defined __STDC__ && __STDC__
#  define NULL ((void *) 0)
#  define NULL ((void *) 0)
# else
# else
#  define NULL 0
#  define NULL 0
# endif
# endif
#endif
#endif
 
 
/* @@ end of prolog @@ */
/* @@ end of prolog @@ */
 
 
#ifdef _LIBC
#ifdef _LIBC
/* Rename the non ANSI C functions.  This is required by the standard
/* Rename the non ANSI C functions.  This is required by the standard
   because some ANSI C functions will require linking with this object
   because some ANSI C functions will require linking with this object
   file and the name space must not be polluted.  */
   file and the name space must not be polluted.  */
# ifndef stpcpy
# ifndef stpcpy
#  define stpcpy(dest, src) __stpcpy(dest, src)
#  define stpcpy(dest, src) __stpcpy(dest, src)
# endif
# endif
#else
#else
# ifndef HAVE_STPCPY
# ifndef HAVE_STPCPY
static char *stpcpy PARAMS ((char *dest, const char *src));
static char *stpcpy PARAMS ((char *dest, const char *src));
# endif
# endif
#endif
#endif
 
 
/* Pathname support.
/* Pathname support.
   ISSLASH(C)           tests whether C is a directory separator character.
   ISSLASH(C)           tests whether C is a directory separator character.
   IS_ABSOLUTE_PATH(P)  tests whether P is an absolute path.  If it is not,
   IS_ABSOLUTE_PATH(P)  tests whether P is an absolute path.  If it is not,
                        it may be concatenated to a directory pathname.
                        it may be concatenated to a directory pathname.
 */
 */
#if defined _WIN32 || defined __WIN32__ || defined __EMX__ || defined __DJGPP__
#if defined _WIN32 || defined __WIN32__ || defined __EMX__ || defined __DJGPP__
  /* Win32, OS/2, DOS */
  /* Win32, OS/2, DOS */
# define ISSLASH(C) ((C) == '/' || (C) == '\\')
# define ISSLASH(C) ((C) == '/' || (C) == '\\')
# define HAS_DEVICE(P) \
# define HAS_DEVICE(P) \
    ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \
    ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \
     && (P)[1] == ':')
     && (P)[1] == ':')
# define IS_ABSOLUTE_PATH(P) (ISSLASH ((P)[0]) || HAS_DEVICE (P))
# define IS_ABSOLUTE_PATH(P) (ISSLASH ((P)[0]) || HAS_DEVICE (P))
#else
#else
  /* Unix */
  /* Unix */
# define ISSLASH(C) ((C) == '/')
# define ISSLASH(C) ((C) == '/')
# define IS_ABSOLUTE_PATH(P) ISSLASH ((P)[0])
# define IS_ABSOLUTE_PATH(P) ISSLASH ((P)[0])
#endif
#endif
 
 
/* Define function which are usually not available.  */
/* Define function which are usually not available.  */
 
 
#if !defined _LIBC && !defined HAVE___ARGZ_COUNT
#if !defined _LIBC && !defined HAVE___ARGZ_COUNT
/* Returns the number of strings in ARGZ.  */
/* Returns the number of strings in ARGZ.  */
static size_t argz_count__ PARAMS ((const char *argz, size_t len));
static size_t argz_count__ PARAMS ((const char *argz, size_t len));
 
 
static size_t
static size_t
argz_count__ (argz, len)
argz_count__ (argz, len)
     const char *argz;
     const char *argz;
     size_t len;
     size_t len;
{
{
  size_t count = 0;
  size_t count = 0;
  while (len > 0)
  while (len > 0)
    {
    {
      size_t part_len = strlen (argz);
      size_t part_len = strlen (argz);
      argz += part_len + 1;
      argz += part_len + 1;
      len -= part_len + 1;
      len -= part_len + 1;
      count++;
      count++;
    }
    }
  return count;
  return count;
}
}
# undef __argz_count
# undef __argz_count
# define __argz_count(argz, len) argz_count__ (argz, len)
# define __argz_count(argz, len) argz_count__ (argz, len)
#else
#else
# ifdef _LIBC
# ifdef _LIBC
#  define __argz_count(argz, len) INTUSE(__argz_count) (argz, len)
#  define __argz_count(argz, len) INTUSE(__argz_count) (argz, len)
# endif
# endif
#endif  /* !_LIBC && !HAVE___ARGZ_COUNT */
#endif  /* !_LIBC && !HAVE___ARGZ_COUNT */
 
 
#if !defined _LIBC && !defined HAVE___ARGZ_STRINGIFY
#if !defined _LIBC && !defined HAVE___ARGZ_STRINGIFY
/* Make '\0' separated arg vector ARGZ printable by converting all the '\0's
/* Make '\0' separated arg vector ARGZ printable by converting all the '\0's
   except the last into the character SEP.  */
   except the last into the character SEP.  */
static void argz_stringify__ PARAMS ((char *argz, size_t len, int sep));
static void argz_stringify__ PARAMS ((char *argz, size_t len, int sep));
 
 
static void
static void
argz_stringify__ (argz, len, sep)
argz_stringify__ (argz, len, sep)
     char *argz;
     char *argz;
     size_t len;
     size_t len;
     int sep;
     int sep;
{
{
  while (len > 0)
  while (len > 0)
    {
    {
      size_t part_len = strlen (argz);
      size_t part_len = strlen (argz);
      argz += part_len;
      argz += part_len;
      len -= part_len + 1;
      len -= part_len + 1;
      if (len > 0)
      if (len > 0)
        *argz++ = sep;
        *argz++ = sep;
    }
    }
}
}
# undef __argz_stringify
# undef __argz_stringify
# define __argz_stringify(argz, len, sep) argz_stringify__ (argz, len, sep)
# define __argz_stringify(argz, len, sep) argz_stringify__ (argz, len, sep)
#else
#else
# ifdef _LIBC
# ifdef _LIBC
#  define __argz_stringify(argz, len, sep) \
#  define __argz_stringify(argz, len, sep) \
  INTUSE(__argz_stringify) (argz, len, sep)
  INTUSE(__argz_stringify) (argz, len, sep)
# endif
# endif
#endif  /* !_LIBC && !HAVE___ARGZ_STRINGIFY */
#endif  /* !_LIBC && !HAVE___ARGZ_STRINGIFY */
 
 
#if !defined _LIBC && !defined HAVE___ARGZ_NEXT
#if !defined _LIBC && !defined HAVE___ARGZ_NEXT
static char *argz_next__ PARAMS ((char *argz, size_t argz_len,
static char *argz_next__ PARAMS ((char *argz, size_t argz_len,
                                  const char *entry));
                                  const char *entry));
 
 
static char *
static char *
argz_next__ (argz, argz_len, entry)
argz_next__ (argz, argz_len, entry)
     char *argz;
     char *argz;
     size_t argz_len;
     size_t argz_len;
     const char *entry;
     const char *entry;
{
{
  if (entry)
  if (entry)
    {
    {
      if (entry < argz + argz_len)
      if (entry < argz + argz_len)
        entry = strchr (entry, '\0') + 1;
        entry = strchr (entry, '\0') + 1;
 
 
      return entry >= argz + argz_len ? NULL : (char *) entry;
      return entry >= argz + argz_len ? NULL : (char *) entry;
    }
    }
  else
  else
    if (argz_len > 0)
    if (argz_len > 0)
      return argz;
      return argz;
    else
    else
      return 0;
      return 0;
}
}
# undef __argz_next
# undef __argz_next
# define __argz_next(argz, len, entry) argz_next__ (argz, len, entry)
# define __argz_next(argz, len, entry) argz_next__ (argz, len, entry)
#endif  /* !_LIBC && !HAVE___ARGZ_NEXT */
#endif  /* !_LIBC && !HAVE___ARGZ_NEXT */
 
 
 
 
/* Return number of bits set in X.  */
/* Return number of bits set in X.  */
static int pop PARAMS ((int x));
static int pop PARAMS ((int x));
 
 
static inline int
static inline int
pop (x)
pop (x)
     int x;
     int x;
{
{
  /* We assume that no more than 16 bits are used.  */
  /* We assume that no more than 16 bits are used.  */
  x = ((x & ~0x5555) >> 1) + (x & 0x5555);
  x = ((x & ~0x5555) >> 1) + (x & 0x5555);
  x = ((x & ~0x3333) >> 2) + (x & 0x3333);
  x = ((x & ~0x3333) >> 2) + (x & 0x3333);
  x = ((x >> 4) + x) & 0x0f0f;
  x = ((x >> 4) + x) & 0x0f0f;
  x = ((x >> 8) + x) & 0xff;
  x = ((x >> 8) + x) & 0xff;
 
 
  return x;
  return x;
}
}
 
 


struct loaded_l10nfile *
struct loaded_l10nfile *
_nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len, mask, language,
_nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len, mask, language,
                    territory, codeset, normalized_codeset, modifier, special,
                    territory, codeset, normalized_codeset, modifier, special,
                    sponsor, revision, filename, do_allocate)
                    sponsor, revision, filename, do_allocate)
     struct loaded_l10nfile **l10nfile_list;
     struct loaded_l10nfile **l10nfile_list;
     const char *dirlist;
     const char *dirlist;
     size_t dirlist_len;
     size_t dirlist_len;
     int mask;
     int mask;
     const char *language;
     const char *language;
     const char *territory;
     const char *territory;
     const char *codeset;
     const char *codeset;
     const char *normalized_codeset;
     const char *normalized_codeset;
     const char *modifier;
     const char *modifier;
     const char *special;
     const char *special;
     const char *sponsor;
     const char *sponsor;
     const char *revision;
     const char *revision;
     const char *filename;
     const char *filename;
     int do_allocate;
     int do_allocate;
{
{
  char *abs_filename;
  char *abs_filename;
  struct loaded_l10nfile **lastp;
  struct loaded_l10nfile **lastp;
  struct loaded_l10nfile *retval;
  struct loaded_l10nfile *retval;
  char *cp;
  char *cp;
  size_t dirlist_count;
  size_t dirlist_count;
  size_t entries;
  size_t entries;
  int cnt;
  int cnt;
 
 
  /* If LANGUAGE contains an absolute directory specification, we ignore
  /* If LANGUAGE contains an absolute directory specification, we ignore
     DIRLIST.  */
     DIRLIST.  */
  if (IS_ABSOLUTE_PATH (language))
  if (IS_ABSOLUTE_PATH (language))
    dirlist_len = 0;
    dirlist_len = 0;
 
 
  /* Allocate room for the full file name.  */
  /* Allocate room for the full file name.  */
  abs_filename = (char *) malloc (dirlist_len
  abs_filename = (char *) malloc (dirlist_len
                                  + strlen (language)
                                  + strlen (language)
                                  + ((mask & TERRITORY) != 0
                                  + ((mask & TERRITORY) != 0
                                     ? strlen (territory) + 1 : 0)
                                     ? strlen (territory) + 1 : 0)
                                  + ((mask & XPG_CODESET) != 0
                                  + ((mask & XPG_CODESET) != 0
                                     ? strlen (codeset) + 1 : 0)
                                     ? strlen (codeset) + 1 : 0)
                                  + ((mask & XPG_NORM_CODESET) != 0
                                  + ((mask & XPG_NORM_CODESET) != 0
                                     ? strlen (normalized_codeset) + 1 : 0)
                                     ? strlen (normalized_codeset) + 1 : 0)
                                  + (((mask & XPG_MODIFIER) != 0
                                  + (((mask & XPG_MODIFIER) != 0
                                      || (mask & CEN_AUDIENCE) != 0)
                                      || (mask & CEN_AUDIENCE) != 0)
                                     ? strlen (modifier) + 1 : 0)
                                     ? strlen (modifier) + 1 : 0)
                                  + ((mask & CEN_SPECIAL) != 0
                                  + ((mask & CEN_SPECIAL) != 0
                                     ? strlen (special) + 1 : 0)
                                     ? strlen (special) + 1 : 0)
                                  + (((mask & CEN_SPONSOR) != 0
                                  + (((mask & CEN_SPONSOR) != 0
                                      || (mask & CEN_REVISION) != 0)
                                      || (mask & CEN_REVISION) != 0)
                                     ? (1 + ((mask & CEN_SPONSOR) != 0
                                     ? (1 + ((mask & CEN_SPONSOR) != 0
                                             ? strlen (sponsor) : 0)
                                             ? strlen (sponsor) : 0)
                                        + ((mask & CEN_REVISION) != 0
                                        + ((mask & CEN_REVISION) != 0
                                           ? strlen (revision) + 1 : 0)) : 0)
                                           ? strlen (revision) + 1 : 0)) : 0)
                                  + 1 + strlen (filename) + 1);
                                  + 1 + strlen (filename) + 1);
 
 
  if (abs_filename == NULL)
  if (abs_filename == NULL)
    return NULL;
    return NULL;
 
 
  /* Construct file name.  */
  /* Construct file name.  */
  cp = abs_filename;
  cp = abs_filename;
  if (dirlist_len > 0)
  if (dirlist_len > 0)
    {
    {
      memcpy (cp, dirlist, dirlist_len);
      memcpy (cp, dirlist, dirlist_len);
      __argz_stringify (cp, dirlist_len, PATH_SEPARATOR);
      __argz_stringify (cp, dirlist_len, PATH_SEPARATOR);
      cp += dirlist_len;
      cp += dirlist_len;
      cp[-1] = '/';
      cp[-1] = '/';
    }
    }
 
 
  cp = stpcpy (cp, language);
  cp = stpcpy (cp, language);
 
 
  if ((mask & TERRITORY) != 0)
  if ((mask & TERRITORY) != 0)
    {
    {
      *cp++ = '_';
      *cp++ = '_';
      cp = stpcpy (cp, territory);
      cp = stpcpy (cp, territory);
    }
    }
  if ((mask & XPG_CODESET) != 0)
  if ((mask & XPG_CODESET) != 0)
    {
    {
      *cp++ = '.';
      *cp++ = '.';
      cp = stpcpy (cp, codeset);
      cp = stpcpy (cp, codeset);
    }
    }
  if ((mask & XPG_NORM_CODESET) != 0)
  if ((mask & XPG_NORM_CODESET) != 0)
    {
    {
      *cp++ = '.';
      *cp++ = '.';
      cp = stpcpy (cp, normalized_codeset);
      cp = stpcpy (cp, normalized_codeset);
    }
    }
  if ((mask & (XPG_MODIFIER | CEN_AUDIENCE)) != 0)
  if ((mask & (XPG_MODIFIER | CEN_AUDIENCE)) != 0)
    {
    {
      /* This component can be part of both syntaces but has different
      /* This component can be part of both syntaces but has different
         leading characters.  For CEN we use `+', else `@'.  */
         leading characters.  For CEN we use `+', else `@'.  */
      *cp++ = (mask & CEN_AUDIENCE) != 0 ? '+' : '@';
      *cp++ = (mask & CEN_AUDIENCE) != 0 ? '+' : '@';
      cp = stpcpy (cp, modifier);
      cp = stpcpy (cp, modifier);
    }
    }
  if ((mask & CEN_SPECIAL) != 0)
  if ((mask & CEN_SPECIAL) != 0)
    {
    {
      *cp++ = '+';
      *cp++ = '+';
      cp = stpcpy (cp, special);
      cp = stpcpy (cp, special);
    }
    }
  if ((mask & (CEN_SPONSOR | CEN_REVISION)) != 0)
  if ((mask & (CEN_SPONSOR | CEN_REVISION)) != 0)
    {
    {
      *cp++ = ',';
      *cp++ = ',';
      if ((mask & CEN_SPONSOR) != 0)
      if ((mask & CEN_SPONSOR) != 0)
        cp = stpcpy (cp, sponsor);
        cp = stpcpy (cp, sponsor);
      if ((mask & CEN_REVISION) != 0)
      if ((mask & CEN_REVISION) != 0)
        {
        {
          *cp++ = '_';
          *cp++ = '_';
          cp = stpcpy (cp, revision);
          cp = stpcpy (cp, revision);
        }
        }
    }
    }
 
 
  *cp++ = '/';
  *cp++ = '/';
  stpcpy (cp, filename);
  stpcpy (cp, filename);
 
 
  /* Look in list of already loaded domains whether it is already
  /* Look in list of already loaded domains whether it is already
     available.  */
     available.  */
  lastp = l10nfile_list;
  lastp = l10nfile_list;
  for (retval = *l10nfile_list; retval != NULL; retval = retval->next)
  for (retval = *l10nfile_list; retval != NULL; retval = retval->next)
    if (retval->filename != NULL)
    if (retval->filename != NULL)
      {
      {
        int compare = strcmp (retval->filename, abs_filename);
        int compare = strcmp (retval->filename, abs_filename);
        if (compare == 0)
        if (compare == 0)
          /* We found it!  */
          /* We found it!  */
          break;
          break;
        if (compare < 0)
        if (compare < 0)
          {
          {
            /* It's not in the list.  */
            /* It's not in the list.  */
            retval = NULL;
            retval = NULL;
            break;
            break;
          }
          }
 
 
        lastp = &retval->next;
        lastp = &retval->next;
      }
      }
 
 
  if (retval != NULL || do_allocate == 0)
  if (retval != NULL || do_allocate == 0)
    {
    {
      free (abs_filename);
      free (abs_filename);
      return retval;
      return retval;
    }
    }
 
 
  dirlist_count = (dirlist_len > 0 ? __argz_count (dirlist, dirlist_len) : 1);
  dirlist_count = (dirlist_len > 0 ? __argz_count (dirlist, dirlist_len) : 1);
 
 
  /* Allocate a new loaded_l10nfile.  */
  /* Allocate a new loaded_l10nfile.  */
  retval =
  retval =
    (struct loaded_l10nfile *)
    (struct loaded_l10nfile *)
    malloc (sizeof (*retval)
    malloc (sizeof (*retval)
            + (((dirlist_count << pop (mask)) + (dirlist_count > 1 ? 1 : 0))
            + (((dirlist_count << pop (mask)) + (dirlist_count > 1 ? 1 : 0))
               * sizeof (struct loaded_l10nfile *)));
               * sizeof (struct loaded_l10nfile *)));
  if (retval == NULL)
  if (retval == NULL)
    return NULL;
    return NULL;
 
 
  retval->filename = abs_filename;
  retval->filename = abs_filename;
 
 
  /* We set retval->data to NULL here; it is filled in later.
  /* We set retval->data to NULL here; it is filled in later.
     Setting retval->decided to 1 here means that retval does not
     Setting retval->decided to 1 here means that retval does not
     correspond to a real file (dirlist_count > 1) or is not worth
     correspond to a real file (dirlist_count > 1) or is not worth
     looking up (if an unnormalized codeset was specified).  */
     looking up (if an unnormalized codeset was specified).  */
  retval->decided = (dirlist_count > 1
  retval->decided = (dirlist_count > 1
                     || ((mask & XPG_CODESET) != 0
                     || ((mask & XPG_CODESET) != 0
                         && (mask & XPG_NORM_CODESET) != 0));
                         && (mask & XPG_NORM_CODESET) != 0));
  retval->data = NULL;
  retval->data = NULL;
 
 
  retval->next = *lastp;
  retval->next = *lastp;
  *lastp = retval;
  *lastp = retval;
 
 
  entries = 0;
  entries = 0;
  /* Recurse to fill the inheritance list of RETVAL.
  /* Recurse to fill the inheritance list of RETVAL.
     If the DIRLIST is a real list (i.e. DIRLIST_COUNT > 1), the 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
     entry does not correspond to a real file; retval->filename contains
     colons.  In this case we loop across all elements of DIRLIST and
     colons.  In this case we loop across all elements of DIRLIST and
     across all bit patterns dominated by MASK.
     across all bit patterns dominated by MASK.
     If the DIRLIST is a single directory or entirely redundant (i.e.
     If the DIRLIST is a single directory or entirely redundant (i.e.
     DIRLIST_COUNT == 1), we loop across all bit patterns dominated by
     DIRLIST_COUNT == 1), we loop across all bit patterns dominated by
     MASK, excluding MASK itself.
     MASK, excluding MASK itself.
     In either case, we loop down from MASK to 0.  This has the effect
     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:
     that the extra bits in the locale name are dropped in this order:
     first the modifier, then the territory, then the codeset, then the
     first the modifier, then the territory, then the codeset, then the
     normalized_codeset.  */
     normalized_codeset.  */
  for (cnt = dirlist_count > 1 ? mask : mask - 1; cnt >= 0; --cnt)
  for (cnt = dirlist_count > 1 ? mask : mask - 1; cnt >= 0; --cnt)
    if ((cnt & ~mask) == 0
    if ((cnt & ~mask) == 0
        && ((cnt & CEN_SPECIFIC) == 0 || (cnt & XPG_SPECIFIC) == 0)
        && ((cnt & CEN_SPECIFIC) == 0 || (cnt & XPG_SPECIFIC) == 0)
        && ((cnt & XPG_CODESET) == 0 || (cnt & XPG_NORM_CODESET) == 0))
        && ((cnt & XPG_CODESET) == 0 || (cnt & XPG_NORM_CODESET) == 0))
      {
      {
        if (dirlist_count > 1)
        if (dirlist_count > 1)
          {
          {
            /* Iterate over all elements of the DIRLIST.  */
            /* Iterate over all elements of the DIRLIST.  */
            char *dir = NULL;
            char *dir = NULL;
 
 
            while ((dir = __argz_next ((char *) dirlist, dirlist_len, dir))
            while ((dir = __argz_next ((char *) dirlist, dirlist_len, dir))
                   != NULL)
                   != NULL)
              retval->successor[entries++]
              retval->successor[entries++]
                = _nl_make_l10nflist (l10nfile_list, dir, strlen (dir) + 1,
                = _nl_make_l10nflist (l10nfile_list, dir, strlen (dir) + 1,
                                      cnt, language, territory, codeset,
                                      cnt, language, territory, codeset,
                                      normalized_codeset, modifier, special,
                                      normalized_codeset, modifier, special,
                                      sponsor, revision, filename, 1);
                                      sponsor, revision, filename, 1);
          }
          }
        else
        else
          retval->successor[entries++]
          retval->successor[entries++]
            = _nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len,
            = _nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len,
                                  cnt, language, territory, codeset,
                                  cnt, language, territory, codeset,
                                  normalized_codeset, modifier, special,
                                  normalized_codeset, modifier, special,
                                  sponsor, revision, filename, 1);
                                  sponsor, revision, filename, 1);
      }
      }
  retval->successor[entries] = NULL;
  retval->successor[entries] = NULL;
 
 
  return retval;
  return retval;
}
}


/* Normalize codeset name.  There is no standard for the codeset
/* Normalize codeset name.  There is no standard for the codeset
   names.  Normalization allows the user to use any of the common
   names.  Normalization allows the user to use any of the common
   names.  The return value is dynamically allocated and has to be
   names.  The return value is dynamically allocated and has to be
   freed by the caller.  */
   freed by the caller.  */
const char *
const char *
_nl_normalize_codeset (codeset, name_len)
_nl_normalize_codeset (codeset, name_len)
     const char *codeset;
     const char *codeset;
     size_t name_len;
     size_t name_len;
{
{
  int len = 0;
  int len = 0;
  int only_digit = 1;
  int only_digit = 1;
  char *retval;
  char *retval;
  char *wp;
  char *wp;
  size_t cnt;
  size_t cnt;
 
 
  for (cnt = 0; cnt < name_len; ++cnt)
  for (cnt = 0; cnt < name_len; ++cnt)
    if (isalnum ((unsigned char) codeset[cnt]))
    if (isalnum ((unsigned char) codeset[cnt]))
      {
      {
        ++len;
        ++len;
 
 
        if (isalpha ((unsigned char) codeset[cnt]))
        if (isalpha ((unsigned char) codeset[cnt]))
          only_digit = 0;
          only_digit = 0;
      }
      }
 
 
  retval = (char *) malloc ((only_digit ? 3 : 0) + len + 1);
  retval = (char *) malloc ((only_digit ? 3 : 0) + len + 1);
 
 
  if (retval != NULL)
  if (retval != NULL)
    {
    {
      if (only_digit)
      if (only_digit)
        wp = stpcpy (retval, "iso");
        wp = stpcpy (retval, "iso");
      else
      else
        wp = retval;
        wp = retval;
 
 
      for (cnt = 0; cnt < name_len; ++cnt)
      for (cnt = 0; cnt < name_len; ++cnt)
        if (isalpha ((unsigned char) codeset[cnt]))
        if (isalpha ((unsigned char) codeset[cnt]))
          *wp++ = tolower ((unsigned char) codeset[cnt]);
          *wp++ = tolower ((unsigned char) codeset[cnt]);
        else if (isdigit ((unsigned char) codeset[cnt]))
        else if (isdigit ((unsigned char) codeset[cnt]))
          *wp++ = codeset[cnt];
          *wp++ = codeset[cnt];
 
 
      *wp = '\0';
      *wp = '\0';
    }
    }
 
 
  return (const char *) retval;
  return (const char *) retval;
}
}
 
 
 
 
/* @@ begin of epilog @@ */
/* @@ begin of epilog @@ */
 
 
/* We don't want libintl.a to depend on any other library.  So we
/* We don't want libintl.a to depend on any other library.  So we
   avoid the non-standard function stpcpy.  In GNU C Library this
   avoid the non-standard function stpcpy.  In GNU C Library this
   function is available, though.  Also allow the symbol HAVE_STPCPY
   function is available, though.  Also allow the symbol HAVE_STPCPY
   to be defined.  */
   to be defined.  */
#if !_LIBC && !HAVE_STPCPY
#if !_LIBC && !HAVE_STPCPY
static char *
static char *
stpcpy (dest, src)
stpcpy (dest, src)
     char *dest;
     char *dest;
     const char *src;
     const char *src;
{
{
  while ((*dest++ = *src++) != '\0')
  while ((*dest++ = *src++) != '\0')
    /* Do nothing. */ ;
    /* Do nothing. */ ;
  return dest - 1;
  return dest - 1;
}
}
#endif
#endif
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.