"Fossies" - the Fresh Open Source Software Archive

Member "dateutils-0.4.6/src/strpdt-special.c" (19 Mar 2019, 7283 Bytes) of package /linux/privat/dateutils-0.4.6.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "strpdt-special.c" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 0.4.1_vs_0.4.2.

    1 /* ANSI-C code produced by gperf version 3.0.4 */
    2 /* Command-line: /usr/bin/gperf -L ANSI-C --output-file strpdt-special.c strpdt-special.gperf  */
    3 /* Computed positions: -k'2' */
    4 
    5 #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
    6       && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
    7       && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
    8       && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
    9       && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
   10       && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
   11       && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
   12       && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
   13       && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
   14       && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
   15       && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
   16       && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
   17       && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
   18       && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
   19       && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
   20       && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
   21       && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
   22       && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
   23       && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
   24       && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
   25       && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
   26       && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
   27       && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
   28 /* The character set is not based on ISO-646.  */
   29 #error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
   30 #endif
   31 
   32 #line 1 "strpdt-special.gperf"
   33 
   34 #line 14 "strpdt-special.gperf"
   35 struct dt_strpdt_special_s {
   36     const char *special;
   37     dt_strpdt_special_t e;
   38 };
   39 /* maximum key range = 17, duplicates = 0 */
   40 
   41 #ifndef GPERF_DOWNCASE
   42 #define GPERF_DOWNCASE 1
   43 static unsigned char gperf_downcase[256] =
   44   {
   45       0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,  14,
   46      15,  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,
   47      30,  31,  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,
   48      45,  46,  47,  48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,
   49      60,  61,  62,  63,  64,  97,  98,  99, 100, 101, 102, 103, 104, 105, 106,
   50     107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
   51     122,  91,  92,  93,  94,  95,  96,  97,  98,  99, 100, 101, 102, 103, 104,
   52     105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
   53     120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
   54     135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
   55     150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
   56     165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
   57     180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
   58     195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
   59     210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224,
   60     225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
   61     240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254,
   62     255
   63   };
   64 #endif
   65 
   66 #ifndef GPERF_CASE_STRCMP
   67 #define GPERF_CASE_STRCMP 1
   68 static int
   69 gperf_case_strcmp (register const char *s1, register const char *s2)
   70 {
   71   for (;;)
   72     {
   73       unsigned char c1 = gperf_downcase[(unsigned char)*s1++];
   74       unsigned char c2 = gperf_downcase[(unsigned char)*s2++];
   75       if (c1 != 0 && c1 == c2)
   76         continue;
   77       return (int)c1 - (int)c2;
   78     }
   79 }
   80 #endif
   81 
   82 #ifdef __GNUC__
   83 __inline
   84 #else
   85 #ifdef __cplusplus
   86 inline
   87 #endif
   88 #endif
   89 static unsigned int
   90 ____strpdt_special (register const char *str, register unsigned int len)
   91 {
   92   static const unsigned char asso_values[] =
   93     {
   94       20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
   95       20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
   96       20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
   97       20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
   98       20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
   99       20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
  100       20, 20, 20, 20, 20, 14, 20, 20,  9,  5,
  101       20, 20, 20, 15, 20, 20, 20, 20, 20,  0,
  102       20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
  103       20, 20, 20, 20, 20, 20, 20, 14, 20, 20,
  104        9,  5, 20, 20, 20, 15, 20, 20, 20, 20,
  105       20,  0, 20, 20, 20, 20, 20, 20, 20, 20,
  106       20, 20, 20, 20, 20, 20, 20, 20
  107     };
  108   return len + asso_values[(unsigned char)str[1]];
  109 }
  110 
  111 #ifdef __GNUC__
  112 __inline
  113 #if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
  114 __attribute__ ((__gnu_inline__))
  115 #endif
  116 #endif
  117 const struct dt_strpdt_special_s *
  118 __strpdt_special (register const char *str, register unsigned int len)
  119 {
  120   enum
  121     {
  122       TOTAL_KEYWORDS = 9,
  123       MIN_WORD_LENGTH = 3,
  124       MAX_WORD_LENGTH = 9,
  125       MIN_HASH_VALUE = 3,
  126       MAX_HASH_VALUE = 19
  127     };
  128 
  129   static const struct dt_strpdt_special_s wordlist[] =
  130     {
  131 #line 20 "strpdt-special.gperf"
  132       {"now", STRPDT_NOW},
  133 #line 23 "strpdt-special.gperf"
  134       {"tomo", STRPDT_TOMO},
  135 #line 21 "strpdt-special.gperf"
  136       {"today", STRPDT_DATE},
  137 #line 24 "strpdt-special.gperf"
  138       {"tomorrow", STRPDT_TOMO},
  139 #line 26 "strpdt-special.gperf"
  140       {"yest", STRPDT_YDAY},
  141 #line 25 "strpdt-special.gperf"
  142       {"yday", STRPDT_YDAY},
  143 #line 27 "strpdt-special.gperf"
  144       {"yesterday", STRPDT_YDAY},
  145 #line 22 "strpdt-special.gperf"
  146       {"date", STRPDT_DATE},
  147 #line 28 "strpdt-special.gperf"
  148       {"time", STRPDT_TIME}
  149     };
  150 
  151   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
  152     {
  153       register int key = ____strpdt_special (str, len);
  154 
  155       if (key <= MAX_HASH_VALUE && key >= MIN_HASH_VALUE)
  156         {
  157           register const struct dt_strpdt_special_s *resword;
  158 
  159           switch (key - 3)
  160             {
  161               case 0:
  162                 resword = &wordlist[0];
  163                 goto compare;
  164               case 1:
  165                 resword = &wordlist[1];
  166                 goto compare;
  167               case 2:
  168                 resword = &wordlist[2];
  169                 goto compare;
  170               case 5:
  171                 resword = &wordlist[3];
  172                 goto compare;
  173               case 6:
  174                 resword = &wordlist[4];
  175                 goto compare;
  176               case 10:
  177                 resword = &wordlist[5];
  178                 goto compare;
  179               case 11:
  180                 resword = &wordlist[6];
  181                 goto compare;
  182               case 15:
  183                 resword = &wordlist[7];
  184                 goto compare;
  185               case 16:
  186                 resword = &wordlist[8];
  187                 goto compare;
  188             }
  189           return 0;
  190         compare:
  191           {
  192             register const char *s = resword->special;
  193 
  194             if ((((unsigned char)*str ^ (unsigned char)*s) & ~32) == 0 && !gperf_case_strcmp (str, s))
  195               return resword;
  196           }
  197         }
  198     }
  199   return 0;
  200 }