Home | History | Annotate | Download | only in base
      1 /* C++ code produced by gperf version 3.0.3 */
      2 /* Command-line: gperf -a -L C++ -C -c -o -t -k '*' -NFindDomain -ZPerfect_Hash_Test1 -D effective_tld_names_unittest1.gperf  */
      3 
      4 #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
      5       && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
      6       && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
      7       && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
      8       && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
      9       && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
     10       && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
     11       && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
     12       && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
     13       && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
     14       && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
     15       && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
     16       && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
     17       && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
     18       && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
     19       && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
     20       && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
     21       && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
     22       && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
     23       && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
     24       && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
     25       && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
     26       && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
     27 /* The character set is not based on ISO-646.  */
     28 #error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf (at) gnu.org>."
     29 #endif
     30 
     31 #line 1 "effective_tld_names_unittest1.gperf"
     32 
     33 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
     34 // Use of this source code is governed by a BSD-style license that
     35 // can be found in the LICENSE file.
     36 // Test file used by registry_controlled_domain_unittest.
     37 // We edit this file manually, then run
     38 // gperf -a -L "C++" -C -G -c -o -t -k '*' -NFindDomain -ZPerfect_Hash_Test2 -Hhash_test1 -Wword_list1 -D effective_tld_names_unittest1.gperf >  effective_tld_names_unittest1.cc
     39 // to generate the perfect hashmap.
     40 #line 10 "effective_tld_names_unittest1.gperf"
     41 struct DomainRule {
     42   const char *name;
     43   int type;  // 1: exception, 2: wildcard
     44 };
     45 
     46 #define TOTAL_KEYWORDS 8
     47 #define MIN_WORD_LENGTH 1
     48 #define MAX_WORD_LENGTH 11
     49 #define MIN_HASH_VALUE 1
     50 #define MAX_HASH_VALUE 16
     51 /* maximum key range = 16, duplicates = 0 */
     52 
     53 class Perfect_Hash_Test1
     54 {
     55 private:
     56   static inline unsigned int hash (const char *str, unsigned int len);
     57 public:
     58   static const struct DomainRule *FindDomain (const char *str, unsigned int len);
     59 };
     60 
     61 inline unsigned int
     62 Perfect_Hash_Test1::hash (register const char *str, register unsigned int len)
     63 {
     64   static const unsigned char asso_values[] =
     65     {
     66       17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
     67       17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
     68       17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
     69       17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
     70       17, 17, 17, 17, 17, 17,  0, 17, 17, 17,
     71       17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
     72       17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
     73       17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
     74       17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
     75       17, 17, 17, 17, 17, 17, 17,  0,  0,  0,
     76       17,  5,  0, 17, 17, 17,  0, 17, 17,  0,
     77       17,  0,  0, 17,  0, 17, 17, 17, 17, 17,
     78       17, 17,  0, 17, 17, 17, 17, 17, 17, 17,
     79       17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
     80       17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
     81       17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
     82       17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
     83       17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
     84       17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
     85       17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
     86       17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
     87       17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
     88       17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
     89       17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
     90       17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
     91       17, 17, 17, 17, 17, 17
     92     };
     93   register int hval = len;
     94 
     95   switch (hval)
     96     {
     97       default:
     98         hval += asso_values[(unsigned char)str[10]];
     99       /*FALLTHROUGH*/
    100       case 10:
    101         hval += asso_values[(unsigned char)str[9]];
    102       /*FALLTHROUGH*/
    103       case 9:
    104         hval += asso_values[(unsigned char)str[8]];
    105       /*FALLTHROUGH*/
    106       case 8:
    107         hval += asso_values[(unsigned char)str[7]];
    108       /*FALLTHROUGH*/
    109       case 7:
    110         hval += asso_values[(unsigned char)str[6]];
    111       /*FALLTHROUGH*/
    112       case 6:
    113         hval += asso_values[(unsigned char)str[5]];
    114       /*FALLTHROUGH*/
    115       case 5:
    116         hval += asso_values[(unsigned char)str[4]];
    117       /*FALLTHROUGH*/
    118       case 4:
    119         hval += asso_values[(unsigned char)str[3]];
    120       /*FALLTHROUGH*/
    121       case 3:
    122         hval += asso_values[(unsigned char)str[2]];
    123       /*FALLTHROUGH*/
    124       case 2:
    125         hval += asso_values[(unsigned char)str[1]];
    126       /*FALLTHROUGH*/
    127       case 1:
    128         hval += asso_values[(unsigned char)str[0]];
    129         break;
    130     }
    131   return hval;
    132 }
    133 
    134 const struct DomainRule *
    135 Perfect_Hash_Test1::FindDomain (register const char *str, register unsigned int len)
    136 {
    137   static const struct DomainRule wordlist[] =
    138     {
    139 #line 21 "effective_tld_names_unittest1.gperf"
    140       {"c", 2},
    141 #line 15 "effective_tld_names_unittest1.gperf"
    142       {"jp", 0},
    143 #line 22 "effective_tld_names_unittest1.gperf"
    144       {"b.c", 1},
    145 #line 16 "effective_tld_names_unittest1.gperf"
    146       {"ac.jp", 0},
    147 #line 17 "effective_tld_names_unittest1.gperf"
    148       {"bar.jp", 2},
    149 #line 18 "effective_tld_names_unittest1.gperf"
    150       {"baz.bar.jp", 2},
    151 #line 20 "effective_tld_names_unittest1.gperf"
    152       {"bar.baz.com", 0},
    153 #line 19 "effective_tld_names_unittest1.gperf"
    154       {"pref.bar.jp", 1}
    155     };
    156 
    157   static const signed char lookup[] =
    158     {
    159       -1,  0,  1,  2, -1,  3,  4, -1, -1, -1,  5,  6, -1, -1,
    160       -1, -1,  7
    161     };
    162 
    163   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
    164     {
    165       register int key = hash (str, len);
    166 
    167       if (key <= MAX_HASH_VALUE && key >= 0)
    168         {
    169           register int index = lookup[key];
    170 
    171           if (index >= 0)
    172             {
    173               register const char *s = wordlist[index].name;
    174 
    175               if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
    176                 return &wordlist[index];
    177             }
    178         }
    179     }
    180   return 0;
    181 }
    182 #line 23 "effective_tld_names_unittest1.gperf"
    183 
    184