Back to index

glibc  2.9
Defines | Functions
charmap-kw.h File Reference
#include <string.h>
#include "locfile-token.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define TOTAL_KEYWORDS   17
#define MIN_WORD_LENGTH   3
#define MAX_WORD_LENGTH   14
#define MIN_HASH_VALUE   3
#define MAX_HASH_VALUE   35

Functions

static unsigned int hash (register const char *str, register unsigned int len)
struct keyword_tcharmap_hash (register const char *str, register unsigned int len)

Define Documentation

#define MAX_HASH_VALUE   35

Definition at line 61 of file charmap-kw.h.

#define MAX_WORD_LENGTH   14

Definition at line 59 of file charmap-kw.h.

#define MIN_HASH_VALUE   3

Definition at line 60 of file charmap-kw.h.

#define MIN_WORD_LENGTH   3

Definition at line 58 of file charmap-kw.h.

#define TOTAL_KEYWORDS   17

Definition at line 57 of file charmap-kw.h.


Function Documentation

struct keyword_t* charmap_hash ( register const char *  str,
register unsigned int  len 
) [read]

Definition at line 132 of file charmap-kw.h.

{
  static const struct keyword_t wordlist[] =
    {
      {""}, {""}, {""},
#line 38 "charmap-kw.gperf"
      {"END",             tok_end,             0},
      {""},
#line 39 "charmap-kw.gperf"
      {"WIDTH",           tok_width,           0},
#line 34 "charmap-kw.gperf"
      {"escseq",          tok_escseq,          1},
#line 36 "charmap-kw.gperf"
      {"include",         tok_include,         1},
      {""}, {""},
#line 27 "charmap-kw.gperf"
      {"mb_cur_min",      tok_mb_cur_min,      1},
#line 28 "charmap-kw.gperf"
      {"escape_char",     tok_escape_char,     1},
#line 29 "charmap-kw.gperf"
      {"comment_char",    tok_comment_char,    1},
#line 25 "charmap-kw.gperf"
      {"code_set_name",   tok_code_set_name,   1},
#line 40 "charmap-kw.gperf"
      {"WIDTH_VARIABLE",  tok_width_variable,  0},
#line 26 "charmap-kw.gperf"
      {"mb_cur_max",      tok_mb_cur_max,      1},
#line 35 "charmap-kw.gperf"
      {"addset",          tok_addset,          1},
#line 37 "charmap-kw.gperf"
      {"CHARMAP",         tok_charmap,         0},
#line 41 "charmap-kw.gperf"
      {"WIDTH_DEFAULT",   tok_width_default,   0},
      {""},
#line 33 "charmap-kw.gperf"
      {"g3esc",           tok_g3esc,           1},
      {""}, {""}, {""}, {""},
#line 32 "charmap-kw.gperf"
      {"g2esc",           tok_g2esc,           1},
      {""}, {""}, {""}, {""},
#line 31 "charmap-kw.gperf"
      {"g1esc",           tok_g1esc,           1},
      {""}, {""}, {""}, {""},
#line 30 "charmap-kw.gperf"
      {"g0esc",           tok_g0esc,           1}
    };

  if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
    {
      register int key = hash (str, len);

      if (key <= MAX_HASH_VALUE && key >= 0)
        {
          register const char *s = wordlist[key].name;

          if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
            return &wordlist[key];
        }
    }
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static unsigned int hash ( register const char *  str,
register unsigned int  len 
) [static]

Definition at line 72 of file charmap-kw.h.

{
  static const unsigned char asso_values[] =
    {
      36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
      36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
      36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
      36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
      36, 36, 36, 36, 36, 36, 36, 36, 25, 20,
      15, 10, 36, 36, 36, 36, 36, 36, 36, 36,
      36, 36, 36, 36, 36, 36, 36,  5,  0,  0,
       5, 36,  0,  0, 36, 36, 36,  5,  0, 36,
       0, 36,  0, 36,  0, 36, 36,  0, 36, 36,
      36, 36, 36, 36, 36,  0, 36,  5,  0,  0,
       5,  0, 36,  5,  0,  0, 36, 36, 36,  0,
       0,  0,  0,  0,  0,  0,  0,  0, 36, 36,
       0, 36, 36, 36, 36, 36, 36, 36, 36, 36,
      36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
      36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
      36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
      36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
      36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
      36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
      36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
      36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
      36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
      36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
      36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
      36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
      36, 36, 36, 36, 36, 36
    };
  register int hval = len;

  switch (hval)
    {
      default:
        hval += asso_values[(unsigned char)str[8]];
      /*FALLTHROUGH*/
      case 8:
      case 7:
      case 6:
      case 5:
        hval += asso_values[(unsigned char)str[4]];
      /*FALLTHROUGH*/
      case 4:
      case 3:
      case 2:
        hval += asso_values[(unsigned char)str[1]];
      /*FALLTHROUGH*/
      case 1:
        hval += asso_values[(unsigned char)str[0]];
        break;
    }
  return hval + asso_values[(unsigned char)str[len - 1]];
}

Here is the caller graph for this function: