Back to index

glibc  2.9
Classes | Functions | Variables
charmap.h File Reference
#include <obstack.h>
#include <stdbool.h>
#include "repertoire.h"
#include "simple-hash.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  width_rule
struct  charmap_t
struct  charseq

Functions

struct charmap_tcharmap_read (const char *filename, int verbose, int error_not_found, int be_quiet, int use_default)
struct charseqcharmap_find_value (const struct charmap_t *charmap, const char *name, size_t len)
struct charseqcharmap_find_symbol (const struct charmap_t *charmap, const char *name, size_t len)

Variables

bool enc_not_ascii_compatible

Class Documentation

struct width_rule

Definition at line 29 of file charmap.h.

Collaboration diagram for width_rule:
Class Members
struct charseq * from
struct charseq * to
unsigned int width
struct charmap_t

Definition at line 37 of file charmap.h.

Collaboration diagram for charmap_t:
Class Members
hash_table byte_table
hash_table char_table
const char * code_set_name
int mb_cur_max
int mb_cur_min
size_t nwidth_rules
size_t nwidth_rules_max
const char * repertoiremap
hash_table ucs4_table
unsigned int width_default
struct width_rule * width_rules
struct charseq

Definition at line 58 of file charmap.h.

Class Members
unsigned char bytes
const char * name
int nbytes
uint32_t ucs4

Function Documentation

struct charseq* charmap_find_symbol ( const struct charmap_t charmap,
const char *  name,
size_t  len 
) [read]

Definition at line 1097 of file charmap.c.

{
  void *result;

  return (find_entry ((hash_table *) &cm->byte_table, bytes, nbytes, &result)
         < 0 ? NULL : (struct charseq *) result);
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct charseq* charmap_find_value ( const struct charmap_t charmap,
const char *  name,
size_t  len 
) [read]

Definition at line 918 of file charmap.c.

{
  void *result;

  return (find_entry ((hash_table *) &cm->char_table, name, len, &result)
         < 0 ? NULL : (struct charseq *) result);
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct charmap_t* charmap_read ( const char *  filename,
int  verbose,
int  error_not_found,
int  be_quiet,
int  use_default 
) [read]

Definition at line 90 of file charmap.c.

{
  struct charmap_t *result = NULL;

  if (filename != NULL)
    {
      struct linereader *cmfile;

      /* First try the name as found in the parameter.  */
      cmfile = lr_open (filename, charmap_hash);
      if (cmfile == NULL)
       {
         /* No successful.  So start looking through the directories
            in the I18NPATH if this is a simple name.  */
         if (strchr (filename, '/') == NULL)
           {
             char *i18npath = getenv ("I18NPATH");
             if (i18npath != NULL && *i18npath != '\0')
              {
                const size_t pathlen = strlen (i18npath);
                char i18npathbuf[pathlen + 1];
                char path[pathlen + sizeof ("/charmaps")];
                char *next;
                i18npath = memcpy (i18npathbuf, i18npath, pathlen + 1);

                while (cmfile == NULL
                      && (next = strsep (&i18npath, ":")) != NULL)
                  {
                    stpcpy (stpcpy (path, next), "/charmaps");
                    cmfile = cmlr_open (path, filename, charmap_hash);

                    if (cmfile == NULL)
                     /* Try without the "/charmaps" part.  */
                     cmfile = cmlr_open (next, filename, charmap_hash);
                  }
              }

             if (cmfile == NULL)
              /* Try the default directory.  */
              cmfile = cmlr_open (CHARMAP_PATH, filename, charmap_hash);
           }
       }

      if (cmfile != NULL)
       result = parse_charmap (cmfile, verbose, be_quiet);

      if (result == NULL && error_not_found)
       WITH_CUR_LOCALE (error (0, errno, _("\
character map file `%s' not found"), filename));
    }

  if (result == NULL && filename != NULL && strchr (filename, '/') == NULL)
    {
      /* OK, one more try.  We also accept the names given to the
        character sets in the files.  Sometimes they differ from the
        file name.  */
      CHARMAP_DIR *dir;

      dir = charmap_opendir (CHARMAP_PATH);
      if (dir != NULL)
       {
         const char *dirent;

         while ((dirent = charmap_readdir (dir)) != NULL)
           {
             char **aliases;
             char **p;
             int found;

             aliases = charmap_aliases (CHARMAP_PATH, dirent);
             found = 0;
             for (p = aliases; *p; p++)
              if (strcasecmp (*p, filename) == 0)
                {
                  found = 1;
                  break;
                }
             charmap_free_aliases (aliases);

             if (found)
              {
                struct linereader *cmfile;

                cmfile = cmlr_open (CHARMAP_PATH, dirent, charmap_hash);
                if (cmfile != NULL)
                  result = parse_charmap (cmfile, verbose, be_quiet);

                break;
              }
           }

         charmap_closedir (dir);
       }
    }

  if (result == NULL && DEFAULT_CHARMAP != NULL)
    {
      struct linereader *cmfile;

      cmfile = cmlr_open (CHARMAP_PATH, DEFAULT_CHARMAP, charmap_hash);
      if (cmfile != NULL)
       result = parse_charmap (cmfile, verbose, be_quiet);

      if (result == NULL)
       WITH_CUR_LOCALE (error (4, errno, _("\
default character map file `%s' not found"), DEFAULT_CHARMAP));
    }

  if (result != NULL && result->code_set_name == NULL)
    /* The input file does not specify a code set name.  This
       shouldn't happen but we should cope with it.  */
    result->code_set_name = basename (filename);

  /* Test of ASCII compatibility of locale encoding.

     Verify that the encoding to be used in a locale is ASCII compatible,
     at least for the graphic characters, excluding the control characters,
     '$' and '@'.  This constraint comes from an ISO C 99 restriction.

     ISO C 99 section 7.17.(2) (about wchar_t):
       the null character shall have the code value zero and each member of
       the basic character set shall have a code value equal to its value
       when used as the lone character in an integer character constant.
     ISO C 99 section 5.2.1.(3):
       Both the basic source and basic execution character sets shall have
       the following members: the 26 uppercase letters of the Latin alphabet
            A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
       the 26 lowercase letters of the Latin alphabet
            a b c d e f g h i j k l m n o p q r s t u v w x y z
       the 10 decimal digits
            0 1 2 3 4 5 6 7 8 9
       the following 29 graphic characters
            ! " # % & ' ( ) * + , - . / : ; < = > ? [ \ ] ^ _ { | } ~
       the space character, and control characters representing horizontal
       tab, vertical tab, and form feed.

     Therefore, for all members of the "basic character set", the 'char' code
     must have the same value as the 'wchar_t' code, which in glibc is the
     same as the Unicode code, which for all of the enumerated characters
     is identical to the ASCII code. */
  if (result != NULL && use_default)
    {
      static const char basic_charset[] =
       {
         'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
         'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
         'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
         'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
         '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
         '!', '"', '#', '%', '&', '\'', '(', ')', '*', '+', ',', '-',
         '.', '/', ':', ';', '<', '=', '>', '?', '[', '\\', ']', '^',
         '_', '{', '|', '}', '~', ' ', '\t', '\v', '\f', '\0'
       };
      int failed = 0;
      const char *p = basic_charset;

      do
       {
         struct charseq *seq = charmap_find_symbol (result, p, 1);

         if (seq == NULL || seq->ucs4 != (uint32_t) *p)
           failed = 1;
       }
      while (*p++ != '\0');

      if (failed)
       {
         WITH_CUR_LOCALE (fprintf (stderr, _("\
character map `%s' is not ASCII compatible, locale not ISO C compliant\n"),
                                result->code_set_name));
         enc_not_ascii_compatible = true;
       }
    }

  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 56 of file charmap.c.