Improvements to the gperf flow
This commit is contained in:
parent
28946e6ea8
commit
2508c4b5c7
4 changed files with 82 additions and 93 deletions
8
Makefile
8
Makefile
|
@ -30,7 +30,8 @@ HOEDOWN_SRC=\
|
||||||
src/autolink.o \
|
src/autolink.o \
|
||||||
src/escape.o \
|
src/escape.o \
|
||||||
src/html.o \
|
src/html.o \
|
||||||
src/html_smartypants.o \
|
src/html_blocks.o \
|
||||||
|
src/html_smartypants.o
|
||||||
|
|
||||||
all: libhoedown.so hoedown smartypants html_blocks
|
all: libhoedown.so hoedown smartypants html_blocks
|
||||||
|
|
||||||
|
@ -53,10 +54,9 @@ smartypants: examples/smartypants.o $(HOEDOWN_SRC)
|
||||||
$(CC) $(LDFLAGS) $^ -o $@
|
$(CC) $(LDFLAGS) $^ -o $@
|
||||||
|
|
||||||
# perfect hashing
|
# perfect hashing
|
||||||
html_blocks: src/html_blocks.h
|
|
||||||
|
|
||||||
src/html_blocks.h: html_block_names.txt
|
src/html_blocks.c: html_block_names.gperf
|
||||||
gperf -N hoedown_find_block_tag -H hash_block_tag -C -c -E -S 1 --ignore-case $^ > $@
|
gperf -L ANSI-C -N hoedown_find_block_tag -c -C -E -S 1 --ignore-case -m100 $^ > $@
|
||||||
|
|
||||||
test: hoedown
|
test: hoedown
|
||||||
perl test/MarkdownTest_1.0.3/MarkdownTest.pl \
|
perl test/MarkdownTest_1.0.3/MarkdownTest.pl \
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
##
|
|
||||||
p
|
p
|
||||||
dl
|
dl
|
||||||
h1
|
h1
|
||||||
|
@ -15,11 +14,11 @@ ins
|
||||||
pre
|
pre
|
||||||
form
|
form
|
||||||
math
|
math
|
||||||
|
style
|
||||||
table
|
table
|
||||||
figure
|
figure
|
||||||
iframe
|
iframe
|
||||||
script
|
script
|
||||||
style
|
|
||||||
fieldset
|
fieldset
|
||||||
noscript
|
noscript
|
||||||
blockquote
|
blockquote
|
|
@ -1,5 +1,5 @@
|
||||||
/* C code produced by gperf version 3.0.3 */
|
/* ANSI-C code produced by gperf version 3.0.3 */
|
||||||
/* Command-line: gperf -N hoedown_find_block_tag -H hash_block_tag -C -c -E -P -S 1 --ignore-case html_block_names.txt */
|
/* Command-line: gperf -L ANSI-C -N hoedown_find_block_tag -c -C -E -S 1 --ignore-case -m100 html_block_names.gperf */
|
||||||
/* Computed positions: -k'1-2' */
|
/* Computed positions: -k'1-2' */
|
||||||
|
|
||||||
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
|
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
|
||||||
|
@ -26,10 +26,10 @@
|
||||||
&& ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
|
&& ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
|
||||||
&& ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
|
&& ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
|
||||||
/* The character set is not based on ISO-646. */
|
/* 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-gnu-gperf@gnu.org>."
|
#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* maximum key range = 37, duplicates = 0 */
|
/* maximum key range = 24, duplicates = 0 */
|
||||||
|
|
||||||
#ifndef GPERF_DOWNCASE
|
#ifndef GPERF_DOWNCASE
|
||||||
#define GPERF_DOWNCASE 1
|
#define GPERF_DOWNCASE 1
|
||||||
|
@ -59,10 +59,7 @@ static unsigned char gperf_downcase[256] =
|
||||||
#ifndef GPERF_CASE_STRNCMP
|
#ifndef GPERF_CASE_STRNCMP
|
||||||
#define GPERF_CASE_STRNCMP 1
|
#define GPERF_CASE_STRNCMP 1
|
||||||
static int
|
static int
|
||||||
gperf_case_strncmp (s1, s2, n)
|
gperf_case_strncmp (register const char *s1, register const char *s2, register unsigned int n)
|
||||||
register const char *s1;
|
|
||||||
register const char *s2;
|
|
||||||
register unsigned int n;
|
|
||||||
{
|
{
|
||||||
for (; n > 0;)
|
for (; n > 0;)
|
||||||
{
|
{
|
||||||
|
@ -87,38 +84,36 @@ inline
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
static unsigned int
|
static unsigned int
|
||||||
hash_block_tag (str, len)
|
hash (register const char *str, register unsigned int len)
|
||||||
register const char *str;
|
|
||||||
register unsigned int len;
|
|
||||||
{
|
{
|
||||||
static const unsigned char asso_values[] =
|
static const unsigned char asso_values[] =
|
||||||
{
|
{
|
||||||
38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
|
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||||
38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
|
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||||
38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
|
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||||
38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
|
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||||
38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
|
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||||
8, 30, 25, 20, 15, 10, 38, 38, 38, 38,
|
22, 21, 19, 18, 16, 0, 25, 25, 25, 25,
|
||||||
38, 38, 38, 38, 38, 38, 0, 38, 0, 38,
|
25, 25, 25, 25, 25, 25, 1, 25, 0, 25,
|
||||||
5, 5, 5, 15, 0, 38, 38, 0, 15, 10,
|
1, 0, 0, 13, 0, 25, 25, 11, 2, 1,
|
||||||
0, 38, 38, 15, 0, 5, 38, 38, 38, 38,
|
0, 25, 25, 5, 0, 2, 25, 25, 25, 25,
|
||||||
38, 38, 38, 38, 38, 38, 38, 38, 0, 38,
|
25, 25, 25, 25, 25, 25, 25, 25, 1, 25,
|
||||||
0, 38, 5, 5, 5, 15, 0, 38, 38, 0,
|
0, 25, 1, 0, 0, 13, 0, 25, 25, 11,
|
||||||
15, 10, 0, 38, 38, 15, 0, 5, 38, 38,
|
2, 1, 0, 25, 25, 5, 0, 2, 25, 25,
|
||||||
38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
|
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||||
38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
|
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||||
38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
|
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||||
38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
|
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||||
38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
|
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||||
38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
|
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||||
38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
|
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||||
38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
|
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||||
38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
|
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||||
38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
|
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||||
38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
|
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||||
38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
|
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||||
38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
|
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||||
38, 38, 38, 38, 38, 38, 38
|
25, 25, 25, 25, 25, 25, 25
|
||||||
};
|
};
|
||||||
register int hval = (int)len;
|
register int hval = (int)len;
|
||||||
|
|
||||||
|
@ -141,9 +136,7 @@ __attribute__ ((__gnu_inline__))
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
const char *
|
const char *
|
||||||
hoedown_find_block_tag (str, len)
|
hoedown_find_block_tag (register const char *str, register unsigned int len)
|
||||||
register const char *str;
|
|
||||||
register unsigned int len;
|
|
||||||
{
|
{
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -151,12 +144,12 @@ hoedown_find_block_tag (str, len)
|
||||||
MIN_WORD_LENGTH = 1,
|
MIN_WORD_LENGTH = 1,
|
||||||
MAX_WORD_LENGTH = 10,
|
MAX_WORD_LENGTH = 10,
|
||||||
MIN_HASH_VALUE = 1,
|
MIN_HASH_VALUE = 1,
|
||||||
MAX_HASH_VALUE = 37
|
MAX_HASH_VALUE = 24
|
||||||
};
|
};
|
||||||
|
|
||||||
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
|
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
|
||||||
{
|
{
|
||||||
register int key = hash_block_tag (str, len);
|
register int key = hash (str, len);
|
||||||
|
|
||||||
if (key <= MAX_HASH_VALUE && key >= MIN_HASH_VALUE)
|
if (key <= MAX_HASH_VALUE && key >= MIN_HASH_VALUE)
|
||||||
{
|
{
|
||||||
|
@ -168,74 +161,74 @@ hoedown_find_block_tag (str, len)
|
||||||
resword = "p";
|
resword = "p";
|
||||||
goto compare;
|
goto compare;
|
||||||
case 1:
|
case 1:
|
||||||
resword = "dl";
|
resword = "h6";
|
||||||
goto compare;
|
goto compare;
|
||||||
case 2:
|
case 2:
|
||||||
resword = "div";
|
resword = "div";
|
||||||
goto compare;
|
goto compare;
|
||||||
case 3:
|
case 3:
|
||||||
resword = "math";
|
resword = "del";
|
||||||
goto compare;
|
goto compare;
|
||||||
case 4:
|
case 4:
|
||||||
|
resword = "form";
|
||||||
|
goto compare;
|
||||||
|
case 5:
|
||||||
resword = "table";
|
resword = "table";
|
||||||
goto compare;
|
goto compare;
|
||||||
case 6:
|
case 6:
|
||||||
resword = "ul";
|
|
||||||
goto compare;
|
|
||||||
case 7:
|
|
||||||
resword = "del";
|
|
||||||
goto compare;
|
|
||||||
case 8:
|
|
||||||
resword = "form";
|
|
||||||
goto compare;
|
|
||||||
case 9:
|
|
||||||
resword = "blockquote";
|
|
||||||
goto compare;
|
|
||||||
case 10:
|
|
||||||
resword = "figure";
|
resword = "figure";
|
||||||
goto compare;
|
goto compare;
|
||||||
case 11:
|
case 7:
|
||||||
resword = "ol";
|
|
||||||
goto compare;
|
|
||||||
case 12:
|
|
||||||
resword = "fieldset";
|
|
||||||
goto compare;
|
|
||||||
case 14:
|
|
||||||
resword = "h1";
|
|
||||||
goto compare;
|
|
||||||
case 16:
|
|
||||||
resword = "h6";
|
|
||||||
goto compare;
|
|
||||||
case 17:
|
|
||||||
resword = "pre";
|
resword = "pre";
|
||||||
goto compare;
|
goto compare;
|
||||||
case 20:
|
case 8:
|
||||||
resword = "script";
|
resword = "fieldset";
|
||||||
goto compare;
|
goto compare;
|
||||||
case 21:
|
case 9:
|
||||||
resword = "h5";
|
|
||||||
goto compare;
|
|
||||||
case 22:
|
|
||||||
resword = "noscript";
|
resword = "noscript";
|
||||||
goto compare;
|
goto compare;
|
||||||
case 24:
|
case 10:
|
||||||
|
resword = "script";
|
||||||
|
goto compare;
|
||||||
|
case 11:
|
||||||
resword = "style";
|
resword = "style";
|
||||||
goto compare;
|
goto compare;
|
||||||
case 25:
|
case 12:
|
||||||
resword = "iframe";
|
resword = "dl";
|
||||||
goto compare;
|
goto compare;
|
||||||
case 26:
|
case 13:
|
||||||
resword = "h4";
|
resword = "ol";
|
||||||
goto compare;
|
goto compare;
|
||||||
case 27:
|
case 14:
|
||||||
|
resword = "ul";
|
||||||
|
goto compare;
|
||||||
|
case 15:
|
||||||
|
resword = "math";
|
||||||
|
goto compare;
|
||||||
|
case 16:
|
||||||
resword = "ins";
|
resword = "ins";
|
||||||
goto compare;
|
goto compare;
|
||||||
case 31:
|
case 17:
|
||||||
|
resword = "h5";
|
||||||
|
goto compare;
|
||||||
|
case 18:
|
||||||
|
resword = "iframe";
|
||||||
|
goto compare;
|
||||||
|
case 19:
|
||||||
|
resword = "h4";
|
||||||
|
goto compare;
|
||||||
|
case 20:
|
||||||
resword = "h3";
|
resword = "h3";
|
||||||
goto compare;
|
goto compare;
|
||||||
case 36:
|
case 21:
|
||||||
|
resword = "blockquote";
|
||||||
|
goto compare;
|
||||||
|
case 22:
|
||||||
resword = "h2";
|
resword = "h2";
|
||||||
goto compare;
|
goto compare;
|
||||||
|
case 23:
|
||||||
|
resword = "h1";
|
||||||
|
goto compare;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
compare:
|
compare:
|
|
@ -19,10 +19,7 @@
|
||||||
|
|
||||||
#define MKD_LI_END 8 /* internal list flag */
|
#define MKD_LI_END 8 /* internal list flag */
|
||||||
|
|
||||||
#define gperf_case_strncmp(s1, s2, n) strncasecmp(s1, s2, n)
|
const char *hoedown_find_block_tag(const char *str, unsigned int len);
|
||||||
#define GPERF_DOWNCASE 1
|
|
||||||
#define GPERF_CASE_STRNCMP 1
|
|
||||||
#include "html_blocks.h"
|
|
||||||
|
|
||||||
/***************
|
/***************
|
||||||
* LOCAL TYPES *
|
* LOCAL TYPES *
|
||||||
|
|
Loading…
Reference in a new issue