-- Leo's gemini proxy

-- Connecting to git.thebackupbox.net:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

repo: html_entities_decode
action: commit
revision:
path_from:
revision_from: 02352168edd05bf9f4fda5344fe1977aec376fd9:
path_to:
revision_to:

git.thebackupbox.net

html_entities_decode

git://git.thebackupbox.net/html_entities_decode

commit 02352168edd05bf9f4fda5344fe1977aec376fd9
Author: epoch <epoch@hack.thebackupbox.net>
Date:   Sat Sep 21 08:04:28 2019 +0000

    used gperf to add hash-table lookup instead of derpily looping over everything every check

diff --git a/Makefile b/Makefile

index b57adcaf73a3b0592706d00b201f8ff4072d7ef8..

index ..15d5191232014c33eac3e98eec15da278057c1f0 100644

--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,25 @@
-.PHONEY: all clean
+PREFIX:=/usr/local
+CFLAGS:=-DGPERF
+
+.PHONEY: all clean install veryclean

 all: html_entities_decode

+install: all
+	install html_entities_decode $(PREFIX)/bin
+
+veryclean: clean
+	rm -f entities_gperf.h
+	rm -f entities_h.h
+
 clean:
 	rm -f html_entities_decode
+
+entities_h.h: entities.h
+	printf 'struct entity { char *name; char *value; }\n%%%%\n' > entities_h.h
+	sed 's/^ //g' entities.h | tail -n+2 | tac | tail -n+3 | tac >> entities_h.h
+
+entities_gperf.h: entities_h.h
+	gperf -t entities_h.h > entities_gperf.h
+
+test: test.c
diff --git a/entities_gperf.h b/entities_gperf.h
new file mode 100644
index 0000000000000000000000000000000000000000..e828a83aba6db6152a371294ab84f5d80a7cb149
--- /dev/null
+++ b/entities_gperf.h
@@ -0,0 +1,758 @@
+/* ANSI-C code produced by gperf version 3.1 */
+/* Command-line: gperf -t entities_h.h  */
+/* Computed positions: -k'1-3,5,$' */
+
+#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
+      && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
+      && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
+      && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
+      && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
+      && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
+      && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
+      && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
+      && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
+      && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
+      && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
+      && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
+      && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
+      && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
+      && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
+      && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
+      && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
+      && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
+      && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
+      && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
+      && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
+      && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
+      && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
+/* The character set is not based on ISO-646.  */
+#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gperf@gnu.org>."
+#endif
+
+#line 1 "entities_h.h"
+struct entity { char *name; char *value; };
+
+#define TOTAL_KEYWORDS 252
+#define MIN_WORD_LENGTH 2
+#define MAX_WORD_LENGTH 8
+#define MIN_HASH_VALUE 8
+#define MAX_HASH_VALUE 617
+/* maximum key range = 610, duplicates = 0 */
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static unsigned int
+hash (register const char *str, register size_t len)
+{
+  static unsigned short asso_values[] =
+    {
+      618, 618, 618, 618, 618, 618, 618, 618, 618, 618,
+      618, 618, 618, 618, 618, 618, 618, 618, 618, 618,
+      618, 618, 618, 618, 618, 618, 618, 618, 618, 618,
+      618, 618, 618, 618, 618, 618, 618, 618, 618, 618,
+      618, 618, 618, 618, 618, 618, 618, 618, 618,   0,
+       20,  10,   0, 618, 618, 618, 618, 618, 618, 618,
+      618, 618, 618, 618, 618, 135, 165,  55,  90, 225,
+       10,   0,  10, 205, 618,  20,   5,   0,  15,  73,
+       30, 618,   5,  30,  10,  20, 618, 618,  10, 165,
+        0, 618, 618, 618, 618, 618, 618,   5,  60,  50,
+        0,  15, 144, 115, 160,  10, 215,  10,  95, 125,
+       25,   0,   5, 207,  90,  20,   0,  65,  35,  35,
+       35, 194,   5,   5, 618, 618, 618, 618, 618, 618,
+      618, 618, 618, 618, 618, 618, 618, 618, 618, 618,
+      618, 618, 618, 618, 618, 618, 618, 618, 618, 618,
+      618, 618, 618, 618, 618, 618, 618, 618, 618, 618,
+      618, 618, 618, 618, 618, 618, 618, 618, 618, 618,
+      618, 618, 618, 618, 618, 618, 618, 618, 618, 618,
+      618, 618, 618, 618, 618, 618, 618, 618, 618, 618,
+      618, 618, 618, 618, 618, 618, 618, 618, 618, 618,
+      618, 618, 618, 618, 618, 618, 618, 618, 618, 618,
+      618, 618, 618, 618, 618, 618, 618, 618, 618, 618,
+      618, 618, 618, 618, 618, 618, 618, 618, 618, 618,
+      618, 618, 618, 618, 618, 618, 618, 618, 618, 618,
+      618, 618, 618, 618, 618, 618, 618, 618, 618, 618,
+      618, 618, 618, 618, 618, 618, 618
+    };
+  register unsigned int hval = len;
+
+  switch (hval)
+    {
+      default:
+        hval += asso_values[(unsigned char)str[4]];
+      /*FALLTHROUGH*/
+      case 4:
+      case 3:
+        hval += asso_values[(unsigned char)str[2]];
+      /*FALLTHROUGH*/
+      case 2:
+        hval += asso_values[(unsigned char)str[1]+1];
+      /*FALLTHROUGH*/
+      case 1:
+        hval += asso_values[(unsigned char)str[0]];
+        break;
+    }
+  return hval + asso_values[(unsigned char)str[len - 1]];
+}
+
+struct entity *
+in_word_set (register const char *str, register size_t len)
+{
+  static struct entity wordlist[] =
+    {
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+#line 190 "entities_h.h"
+      {"and","&#8743;",},
+      {""}, {""}, {""}, {""},
+#line 194 "entities_h.h"
+      {"int","&#8747;",},
+      {""}, {""}, {""}, {""},
+#line 116 "entities_h.h"
+      {"Rho","&#929;",},
+      {""}, {""}, {""}, {""}, {""},
+#line 132 "entities_h.h"
+      {"iota","&#953;",},
+      {""}, {""}, {""},
+#line 147 "entities_h.h"
+      {"psi","&#968;",},
+#line 182 "entities_h.h"
+      {"prod","&#8719;",},
+      {""}, {""}, {""},
+#line 15 "entities_h.h"
+      {"not","&#172;",},
+#line 187 "entities_h.h"
+      {"prop","&#8733;",},
+      {""}, {""}, {""},
+#line 145 "entities_h.h"
+      {"phi","&#966;",},
+#line 211 "entities_h.h"
+      {"sdot","&#8901;",},
+#line 131 "entities_h.h"
+      {"theta","&#952;",},
+      {""}, {""},
+#line 224 "entities_h.h"
+      {"amp","&#38;",},
+#line 234 "entities_h.h"
+      {"ensp","&#8194;",},
+      {""},
+#line 195 "entities_h.h"
+      {"there4","&#8756;",},
+      {""}, {""},
+#line 179 "entities_h.h"
+      {"isin","&#8712;",},
+#line 107 "entities_h.h"
+      {"Theta","&#920;",},
+#line 236 "entities_h.h"
+      {"thinsp","&#8201;",},
+      {""},
+#line 122 "entities_h.h"
+      {"Psi","&#936;",},
+      {""},
+#line 148 "entities_h.h"
+      {"omega","&#969;",},
+#line 230 "entities_h.h"
+      {"scaron","&#353;",},
+      {""}, {""}, {""},
+#line 161 "entities_h.h"
+      {"trade","&#8482;",},
+      {""}, {""},
+#line 120 "entities_h.h"
+      {"Phi","&#934;",},
+#line 28 "entities_h.h"
+      {"sup1","&#185;",},
+#line 97 "entities_h.h"
+      {"thorn","&#254;",},
+#line 229 "entities_h.h"
+      {"Scaron","&#352;",},
+      {""},
+#line 204 "entities_h.h"
+      {"sup","&#8835;",},
+#line 235 "entities_h.h"
+      {"emsp","&#8195;",},
+#line 154 "entities_h.h"
+      {"prime","&#8242;",},
+      {""}, {""}, {""},
+#line 22 "entities_h.h"
+      {"sup3","&#179;",},
+#line 159 "entities_h.h"
+      {"image","&#8465;",},
+      {""}, {""}, {""},
+#line 207 "entities_h.h"
+      {"supe","&#8839;",},
+#line 6 "entities_h.h"
+      {"pound","&#163;",},
+      {""}, {""},
+#line 146 "entities_h.h"
+      {"chi","&#967;",},
+#line 21 "entities_h.h"
+      {"sup2","&#178;",},
+#line 180 "entities_h.h"
+      {"notin","&#8713;",},
+      {""}, {""},
+#line 121 "entities_h.h"
+      {"Chi","&#935;",},
+      {""},
+#line 133 "entities_h.h"
+      {"kappa","&#954;",},
+      {""}, {""},
+#line 130 "entities_h.h"
+      {"eta","&#951;",},
+      {""},
+#line 155 "entities_h.h"
+      {"Prime","&#8243;",},
+#line 88 "entities_h.h"
+      {"otilde","&#245;",},
+      {""},
+#line 193 "entities_h.h"
+      {"cup","&#8746;",},
+      {""},
+#line 109 "entities_h.h"
+      {"Kappa","&#922;",},
+#line 70 "entities_h.h"
+      {"atilde","&#227;",},
+#line 111 "entities_h.h"
+      {"Mu","&#924;",},
+#line 140 "entities_h.h"
+      {"rho","&#961;",},
+#line 3 "entities_h.h"
+      {"nbsp","&#160;",},
+#line 23 "entities_h.h"
+      {"acute","&#180;",},
+      {""}, {""}, {""}, {""}, {""},
+#line 52 "entities_h.h"
+      {"Ntilde","&#209;",},
+#line 191 "entities_h.h"
+      {"or","&#8744;",},
+#line 218 "entities_h.h"
+      {"loz","&#9674;",},
+      {""},
+#line 87 "entities_h.h"
+      {"ocirc","&#244;",},
+#line 209 "entities_h.h"
+      {"otimes","&#8855;",},
+#line 112 "entities_h.h"
+      {"Nu","&#925;",},
+      {""}, {""},
+#line 69 "entities_h.h"
+      {"acirc","&#226;",},
+#line 84 "entities_h.h"
+      {"ntilde","&#241;",},
+      {""},
+#line 192 "entities_h.h"
+      {"cap","&#8745;",},
+      {""},
+#line 81 "entities_h.h"
+      {"icirc","&#238;",},
+      {""},
+#line 136 "entities_h.h"
+      {"nu","&#957;",},
+#line 123 "entities_h.h"
+      {"Omega","&#937;",},
+      {""},
+#line 77 "entities_h.h"
+      {"ecirc","&#234;",},
+#line 86 "entities_h.h"
+      {"oacute","&#243;",},
+      {""}, {""},
+#line 206 "entities_h.h"
+      {"sube","&#8838;",},
+#line 62 "entities_h.h"
+      {"Ucirc","&#219;",},
+#line 68 "entities_h.h"
+      {"aacute","&#225;",},
+      {""}, {""}, {""}, {""},
+#line 80 "entities_h.h"
+      {"iacute","&#237;",},
+      {""}, {""},
+#line 254 "entities_h.h"
+      {"euro","&#8364;",},
+      {""},
+#line 76 "entities_h.h"
+      {"eacute","&#233;",},
+      {""}, {""},
+#line 29 "entities_h.h"
+      {"ordm","&#186;",},
+#line 124 "entities_h.h"
+      {"alpha","&#945;",},
+#line 61 "entities_h.h"
+      {"Uacute","&#218;",},
+      {""},
+#line 105 "entities_h.h"
+      {"Zeta","&#918;",},
+#line 205 "entities_h.h"
+      {"nsub","&#8836;",},
+      {""}, {""},
+#line 138 "entities_h.h"
+      {"omicron","&#959;",},
+#line 129 "entities_h.h"
+      {"zeta","&#950;",},
+#line 175 "entities_h.h"
+      {"part","&#8706;",},
+#line 178 "entities_h.h"
+      {"nabla","&#8711;",},
+#line 185 "entities_h.h"
+      {"lowast","&#8727;",},
+#line 225 "entities_h.h"
+      {"lt","&#60;",},
+#line 149 "entities_h.h"
+      {"thetasym","&#977;",},
+#line 25 "entities_h.h"
+      {"para","&#182;",},
+      {""},
+#line 253 "entities_h.h"
+      {"rsaquo","&#8250;",},
+      {""},
+#line 13 "entities_h.h"
+      {"ordf","&#170;",},
+#line 56 "entities_h.h"
+      {"Otilde","&#213;",},
+#line 156 "entities_h.h"
+      {"oline","&#8254;",},
+#line 252 "entities_h.h"
+      {"lsaquo","&#8249;",},
+      {""}, {""}, {""},
+#line 31 "entities_h.h"
+      {"frac14","&#188;",},
+#line 74 "entities_h.h"
+      {"ccedil","&#231;",},
+      {""},
+#line 203 "entities_h.h"
+      {"sub","&#8834;",},
+      {""},
+#line 94 "entities_h.h"
+      {"ucirc","&#251;",},
+#line 42 "entities_h.h"
+      {"Ccedil","&#199;",},
+#line 226 "entities_h.h"
+      {"gt","&#62;",},
+      {""}, {""},
+#line 33 "entities_h.h"
+      {"frac34","&#190;",},
+#line 199 "entities_h.h"
+      {"ne","&#8800;",},
+      {""},
+#line 55 "entities_h.h"
+      {"Ocirc","&#212;",},
+      {""}, {""},
+#line 34 "entities_h.h"
+      {"iquest","&#191;",},
+      {""},
+#line 143 "entities_h.h"
+      {"tau","&#964;",},
+      {""},
+#line 32 "entities_h.h"
+      {"frac12","&#189;",},
+#line 93 "entities_h.h"
+      {"uacute","&#250;",},
+      {""}, {""},
+#line 197 "entities_h.h"
+      {"cong","&#8773;",},
+#line 102 "entities_h.h"
+      {"Gamma","&#915;",},
+#line 110 "entities_h.h"
+      {"Lambda","&#923;",},
+      {""},
+#line 118 "entities_h.h"
+      {"Tau","&#932;",},
+#line 54 "entities_h.h"
+      {"Oacute","&#211;",},
+      {""}, {""}, {""}, {""},
+#line 188 "entities_h.h"
+      {"infin","&#8734;",},
+      {""}, {""}, {""},
+#line 125 "entities_h.h"
+      {"beta","&#946;",},
+#line 198 "entities_h.h"
+      {"asymp","&#8776;",},
+      {""},
+#line 9 "entities_h.h"
+      {"brvbar","&#166;",},
+      {""},
+#line 10 "entities_h.h"
+      {"sect","&#167;",},
+#line 108 "entities_h.h"
+      {"Iota","&#921;",},
+      {""},
+#line 7 "entities_h.h"
+      {"curren","&#164;",},
+      {""},
+#line 5 "entities_h.h"
+      {"cent","&#162;",},
+#line 176 "entities_h.h"
+      {"exist","&#8707;",},
+      {""}, {""},
+#line 135 "entities_h.h"
+      {"mu","&#956;",},
+      {""}, {""},
+#line 114 "entities_h.h"
+      {"Omicron","&#927;",},
+#line 38 "entities_h.h"
+      {"Atilde","&#195;",},
+#line 139 "entities_h.h"
+      {"pi","&#960;",},
+      {""}, {""}, {""}, {""},
+#line 113 "entities_h.h"
+      {"Xi","&#926;",},
+#line 189 "entities_h.h"
+      {"ang","&#8736;",},
+      {""}, {""}, {""}, {""}, {""},
+#line 166 "entities_h.h"
+      {"darr","&#8595;",},
+#line 200 "entities_h.h"
+      {"equiv","&#8801;",},
+#line 223 "entities_h.h"
+      {"quot","&#34;",},
+      {""},
+#line 210 "entities_h.h"
+      {"perp","&#8869;",},
+      {""},
+#line 37 "entities_h.h"
+      {"Acirc","&#194;",},
+      {""},
+#line 181 "entities_h.h"
+      {"ni","&#8715;",},
+      {""},
+#line 127 "entities_h.h"
+      {"delta","&#948;",},
+#line 186 "entities_h.h"
+      {"radic","&#8730;",},
+#line 201 "entities_h.h"
+      {"le","&#8804;",},
+#line 115 "entities_h.h"
+      {"Pi","&#928;",},
+#line 12 "entities_h.h"
+      {"copy","&#169;",},
+#line 89 "entities_h.h"
+      {"ouml","&#246;",},
+#line 168 "entities_h.h"
+      {"crarr","&#8629;",},
+      {""},
+#line 137 "entities_h.h"
+      {"xi","&#958;",},
+      {""},
+#line 71 "entities_h.h"
+      {"auml","&#228;",},
+#line 222 "entities_h.h"
+      {"diams","&#9830;",},
+#line 36 "entities_h.h"
+      {"Aacute","&#193;",},
+      {""},
+#line 51 "entities_h.h"
+      {"ETH","&#208;",},
+#line 82 "entities_h.h"
+      {"iuml","&#239;",},
+#line 72 "entities_h.h"
+      {"aring","&#229;",},
+#line 90 "entities_h.h"
+      {"divide","&#247;",},
+      {""},
+#line 219 "entities_h.h"
+      {"spades","&#9824;",},
+#line 78 "entities_h.h"
+      {"euml","&#235;",},
+      {""},
+#line 202 "entities_h.h"
+      {"ge","&#8805;",},
+      {""}, {""},
+#line 63 "entities_h.h"
+      {"Uuml","&#220;",},
+#line 100 "entities_h.h"
+      {"Alpha","&#913;",},
+#line 91 "entities_h.h"
+      {"oslash","&#248;",},
+#line 245 "entities_h.h"
+      {"sbquo","&#8218;",},
+#line 11 "entities_h.h"
+      {"uml","&#168;",},
+#line 237 "entities_h.h"
+      {"zwnj","&#8204;",},
+#line 220 "entities_h.h"
+      {"clubs","&#9827;",},
+#line 249 "entities_h.h"
+      {"dagger","&#8224;",},
+#line 248 "entities_h.h"
+      {"bdquo","&#8222;",},
+      {""},
+#line 152 "entities_h.h"
+      {"bull","&#8226;",},
+#line 158 "entities_h.h"
+      {"weierp","&#8472;",},
+#line 134 "entities_h.h"
+      {"lambda","&#955;",},
+#line 99 "entities_h.h"
+      {"fnof","&#402;",},
+#line 151 "entities_h.h"
+      {"piv","&#982;",},
+#line 217 "entities_h.h"
+      {"rang","&#9002;",},
+      {""},
+#line 64 "entities_h.h"
+      {"Yacute","&#221;",},
+#line 162 "entities_h.h"
+      {"alefsym","&#8501;",},
+      {""},
+#line 216 "entities_h.h"
+      {"lang","&#9001;",},
+#line 213 "entities_h.h"
+      {"rceil","&#8969;",},
+      {""},
+#line 244 "entities_h.h"
+      {"rsquo","&#8217;",},
+#line 106 "entities_h.h"
+      {"Eta","&#919;",},
+      {""},
+#line 212 "entities_h.h"
+      {"lceil","&#8968;",},
+#line 85 "entities_h.h"
+      {"ograve","&#242;",},
+#line 243 "entities_h.h"
+      {"lsquo","&#8216;",},
+#line 183 "entities_h.h"
+      {"sum","&#8721;",},
+#line 164 "entities_h.h"
+      {"uarr","&#8593;",},
+      {""},
+#line 67 "entities_h.h"
+      {"agrave","&#224;",},
+      {""}, {""}, {""},
+#line 126 "entities_h.h"
+      {"gamma","&#947;",},
+#line 79 "entities_h.h"
+      {"igrave","&#236;",},
+#line 247 "entities_h.h"
+      {"rdquo","&#8221;",},
+#line 101 "entities_h.h"
+      {"Beta","&#914;",},
+      {""},
+#line 49 "entities_h.h"
+      {"Icirc","&#206;",},
+#line 75 "entities_h.h"
+      {"egrave","&#232;",},
+#line 246 "entities_h.h"
+      {"ldquo","&#8220;",},
+#line 65 "entities_h.h"
+      {"THORN","&#222;",},
+#line 95 "entities_h.h"
+      {"uuml","&#252;",},
+#line 96 "entities_h.h"
+      {"yacute","&#253;",},
+#line 60 "entities_h.h"
+      {"Ugrave","&#217;",},
+      {""}, {""},
+#line 18 "entities_h.h"
+      {"macr","&#175;",},
+      {""}, {""},
+#line 57 "entities_h.h"
+      {"Ouml","&#214;",},
+      {""},
+#line 165 "entities_h.h"
+      {"rarr","&#8594;",},
+#line 221 "entities_h.h"
+      {"hearts","&#9829;",},
+#line 48 "entities_h.h"
+      {"Iacute","&#205;",},
+      {""},
+#line 160 "entities_h.h"
+      {"real","&#8476;",},
+#line 163 "entities_h.h"
+      {"larr","&#8592;",},
+#line 45 "entities_h.h"
+      {"Ecirc","&#202;",},
+      {""}, {""}, {""},
+#line 103 "entities_h.h"
+      {"Delta","&#916;",},
+#line 233 "entities_h.h"
+      {"tilde","&#732;",},
+#line 26 "entities_h.h"
+      {"middot","&#183;",},
+#line 208 "entities_h.h"
+      {"oplus","&#8853;",},
+      {""},
+#line 172 "entities_h.h"
+      {"dArr","&#8659;",},
+#line 251 "entities_h.h"
+      {"permil","&#8240;",},
+#line 20 "entities_h.h"
+      {"plusmn","&#177;",},
+      {""}, {""},
+#line 59 "entities_h.h"
+      {"Oslash","&#216;",},
+#line 66 "entities_h.h"
+      {"szlig","&#223;",},
+#line 44 "entities_h.h"
+      {"Eacute","&#201;",},
+      {""}, {""}, {""}, {""}, {""},
+#line 30 "entities_h.h"
+      {"raquo","&#187;",},
+      {""},
+#line 157 "entities_h.h"
+      {"frasl","&#8260;",},
+#line 142 "entities_h.h"
+      {"sigma","&#963;",},
+      {""},
+#line 14 "entities_h.h"
+      {"laquo","&#171;",},
+#line 239 "entities_h.h"
+      {"lrm","&#8206;",},
+#line 128 "entities_h.h"
+      {"epsilon","&#949;",},
+#line 241 "entities_h.h"
+      {"ndash","&#8211;",},
+#line 92 "entities_h.h"
+      {"ugrave","&#249;",},
+      {""}, {""},
+#line 119 "entities_h.h"
+      {"Upsilon","&#933;",},
+#line 117 "entities_h.h"
+      {"Sigma","&#931;",},
+#line 250 "entities_h.h"
+      {"Dagger","&#8225;",},
+#line 19 "entities_h.h"
+      {"deg","&#176;",},
+      {""},
+#line 53 "entities_h.h"
+      {"Ograve","&#210;",},
+      {""}, {""}, {""}, {""},
+#line 4 "entities_h.h"
+      {"iexcl","&#161;",},
+#line 58 "entities_h.h"
+      {"times","&#215;",},
+      {""}, {""}, {""},
+#line 27 "entities_h.h"
+      {"cedil","&#184;",},
+      {""},
+#line 8 "entities_h.h"
+      {"yen","&#165;",},
+      {""}, {""},
+#line 39 "entities_h.h"
+      {"Auml","&#196;",},
+#line 24 "entities_h.h"
+      {"micro","&#181;",},
+#line 215 "entities_h.h"
+      {"rfloor","&#8971;",},
+      {""}, {""}, {""},
+#line 40 "entities_h.h"
+      {"Aring","&#197;",},
+#line 214 "entities_h.h"
+      {"lfloor","&#8970;",},
+      {""},
+#line 83 "entities_h.h"
+      {"eth","&#240;",},
+#line 167 "entities_h.h"
+      {"harr","&#8596;",},
+      {""}, {""}, {""}, {""},
+#line 232 "entities_h.h"
+      {"circ","&#710;",},
+#line 184 "entities_h.h"
+      {"minus","&#8722;",},
+      {""}, {""},
+#line 227 "entities_h.h"
+      {"OElig","&#338;",},
+#line 170 "entities_h.h"
+      {"uArr","&#8657;",},
+      {""}, {""}, {""}, {""},
+#line 144 "entities_h.h"
+      {"upsilon","&#965;",},
+#line 153 "entities_h.h"
+      {"hellip","&#8230;",},
+#line 16 "entities_h.h"
+      {"shy","&#173;",},
+      {""}, {""},
+#line 231 "entities_h.h"
+      {"Yuml","&#376;",},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""},
+#line 174 "entities_h.h"
+      {"forall","&#8704;",},
+      {""}, {""},
+#line 177 "entities_h.h"
+      {"empty","&#8709;",},
+#line 171 "entities_h.h"
+      {"rArr","&#8658;",},
+      {""},
+#line 35 "entities_h.h"
+      {"Agrave","&#192;",},
+      {""}, {""},
+#line 169 "entities_h.h"
+      {"lArr","&#8656;",},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+#line 98 "entities_h.h"
+      {"yuml","&#255;",},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""},
+#line 50 "entities_h.h"
+      {"Iuml","&#207;",},
+      {""}, {""},
+#line 17 "entities_h.h"
+      {"reg","&#174;",},
+#line 240 "entities_h.h"
+      {"rlm","&#8207;",},
+      {""},
+#line 242 "entities_h.h"
+      {"mdash","&#8212;",},
+      {""}, {""},
+#line 238 "entities_h.h"
+      {"zwj","&#8205;",},
+#line 228 "entities_h.h"
+      {"oelig","&#339;",},
+#line 41 "entities_h.h"
+      {"AElig","&#198;",},
+      {""}, {""}, {""},
+#line 73 "entities_h.h"
+      {"aelig","&#230;",},
+      {""}, {""}, {""}, {""},
+#line 46 "entities_h.h"
+      {"Euml","&#203;",},
+      {""}, {""}, {""},
+#line 196 "entities_h.h"
+      {"sim","&#8764;",},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""},
+#line 141 "entities_h.h"
+      {"sigmaf","&#962;",},
+      {""}, {""}, {""},
+#line 173 "entities_h.h"
+      {"hArr","&#8660;",},
+      {""},
+#line 47 "entities_h.h"
+      {"Igrave","&#204;",},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""},
+#line 43 "entities_h.h"
+      {"Egrave","&#200;",},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""},
+#line 104 "entities_h.h"
+      {"Epsilon","&#917;",},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""},
+#line 150 "entities_h.h"
+      {"upsih","&#978;",}
+    };
+
+  if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
+    {
+      register unsigned int key = hash (str, len);
+
+      if (key <= MAX_HASH_VALUE)
+        {
+          register const char *s = wordlist[key].name;
+
+          if (*str == *s && !strcmp (str + 1, s + 1))
+            return &wordlist[key];
+        }
+    }
+  return 0;
+}
diff --git a/html_entities_decode.c b/html_entities_decode.c

index 9ae2316b8063166a763e26506fcfd43dd89830f2..

index ..a2ffee983586b3a6b7ab25285af38202ac9ea84e 100644

--- a/html_entities_decode.c
+++ b/html_entities_decode.c
@@ -1,6 +1,26 @@
 #include <stdio.h>
-#include <string.h>
+#include <string.h>
+#include <unistd.h>//write()
+#include <stdlib.h>//strtol()
+#ifdef GPERF
+#include "entities_gperf.h"
+char *get_entity(char *name) {
+  struct entity *e=in_word_set(name,strlen(name));
+  if(e) return e->value;
+  else return 0;
+}
+#else
 #include "entities.h"
+char *get_entity(char *name) {
+  int i;
+  for(i=0;entities[i];i+=2) {
+    if(!strcmp(name,entities[i])) {
+      return entities[i+1];
+    }
+  }
+  return 0;
+}
+#endif
 // https://www.w3.org/MarkUp/html-spec/html-spec_3.html#SEC3.2.3
 #define NAMELEN 72

@@ -8,15 +28,12 @@ void print_entity(char *name,int len) {
   int i;
   unsigned int c;//we can store one unicode point in here.
   int l;
+  char *t;
   char b[10];//dunno
   name[len-1]=0;//fuck it. we'll null out the ; and we can play with this string as a C string.
   if(*name != '&') printf("how in the hell did this happen?!?\n");
-  for(i=0;entities[i];i+=2) {
-    if(!strcmp(name+1,entities[i])) {
-      name=entities[i+1];
-      break;
-    }
-  }
+  t=get_entity(name+1); //skip the leading &
+  if(t) name=t;
   if(!strncasecmp(name,"&#x",3)) {
     c=strtol(name+3,0,16);
     //we have some hex here. need to convert to decimal.
@@ -42,10 +59,10 @@ int main(int argc,char *argv[]) {
   char in_entity_name=0;
   int i=0;
   short in;
-  for(;(in=fgetc(stdin)) != -1;) {
+  for(;(in=fgetc(stdin)) != -1;) {//this loop needs to be fixed to read larger amounts of data so it'll go faster
    buffer[i]=in;
    i++;
-   if(in_entity_name && i < NAMELEN &&
+   if(in_entity_name && i < NAMELEN &&
      (
       (i > 1 && in == ';') || //if we have an empty entitity... fuck this shit.
       (i > 1 && (in >= 'a' && in <= 'z') || (in >= 'A' && in <= 'Z') || (in >= '0' && in <='9') || (in == '-') || (in == '.') ) ||
diff --git a/test.c b/test.c
new file mode 100644
index 0000000000000000000000000000000000000000..ffdfe65514499a328100d395fd46a517c4a4d481
--- /dev/null
+++ b/test.c
@@ -0,0 +1,9 @@
+#include <stdio.h>
+#include "entities_gperf.h"
+
+int main(int argc,char *argv[]) {
+  if(argc < 2) return 1;
+  struct entity *e = in_word_set(argv[1],strlen(argv[1]));
+  if(e) printf("%s -> %s\n",e->name,e->value);
+  else printf("not found\n");
+}

-----END OF PAGE-----

-- Response ended

-- Page fetched on Sun Jun 2 13:50:29 2024