Use gperf 3.1 to generate ANSI-C code

This commit is contained in:
Nobuyoshi Nakada 2024-06-21 16:00:16 +09:00
Родитель 95ffcd3f9f
Коммит 1213623e5c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 3582D74E1FEE4465
4 изменённых файлов: 52 добавлений и 73 удалений

Просмотреть файл

@ -1,5 +1,5 @@
/* ANSI-C code produced by gperf version 3.1 */ /* ANSI-C code produced by gperf version 3.1 */
/* Command-line: gperf -k1,3 -7 -c -j1 -i1 -t -C -P -t --ignore-case -H onig_jis_property_hash -Q onig_jis_property_pool -N onig_jis_property enc/jis/props.kwd */ /* Command-line: gperf -L ANSI-C -k1,3 -7 -c -j1 -i1 -t -C -P -t --ignore-case -H onig_jis_property_hash -Q onig_jis_property_pool -N onig_jis_property enc/jis/props.kwd */
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
&& ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
@ -28,7 +28,6 @@
#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gperf@gnu.org>." #error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gperf@gnu.org>."
#endif #endif
#define gperf_offsetof(s, n) (short)offsetof(struct s##_t, s##_str##n)
#line 1 "enc/jis/props.kwd" #line 1 "enc/jis/props.kwd"
/* -*- c -*- */ /* -*- c -*- */
#define GPERF_DOWNCASE 1 #define GPERF_DOWNCASE 1
@ -82,7 +81,7 @@ struct enc_property;
#ifndef GPERF_DOWNCASE #ifndef GPERF_DOWNCASE
#define GPERF_DOWNCASE 1 #define GPERF_DOWNCASE 1
static const unsigned char gperf_downcase[256] = static unsigned char gperf_downcase[256] =
{ {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
@ -180,19 +179,19 @@ onig_jis_property (register const char *str, register size_t len)
{ {
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
#line 48 "enc/jis/props.kwd" #line 48 "enc/jis/props.kwd"
{gperf_offsetof(onig_jis_property_pool, 5), onigenc_jis_han}, {(int)(size_t)&((struct onig_jis_property_pool_t *)0)->onig_jis_property_pool_str5, onigenc_jis_han},
{-1}, {-1},
#line 49 "enc/jis/props.kwd" #line 49 "enc/jis/props.kwd"
{gperf_offsetof(onig_jis_property_pool, 7), onigenc_jis_latin}, {(int)(size_t)&((struct onig_jis_property_pool_t *)0)->onig_jis_property_pool_str7, onigenc_jis_latin},
#line 50 "enc/jis/props.kwd" #line 50 "enc/jis/props.kwd"
{gperf_offsetof(onig_jis_property_pool, 8), onigenc_jis_greek}, {(int)(size_t)&((struct onig_jis_property_pool_t *)0)->onig_jis_property_pool_str8, onigenc_jis_greek},
{-1}, {-1},
#line 46 "enc/jis/props.kwd" #line 46 "enc/jis/props.kwd"
{gperf_offsetof(onig_jis_property_pool, 10), onigenc_jis_hiragana}, {(int)(size_t)&((struct onig_jis_property_pool_t *)0)->onig_jis_property_pool_str10, onigenc_jis_hiragana},
#line 47 "enc/jis/props.kwd" #line 47 "enc/jis/props.kwd"
{gperf_offsetof(onig_jis_property_pool, 11), onigenc_jis_katakana}, {(int)(size_t)&((struct onig_jis_property_pool_t *)0)->onig_jis_property_pool_str11, onigenc_jis_katakana},
#line 51 "enc/jis/props.kwd" #line 51 "enc/jis/props.kwd"
{gperf_offsetof(onig_jis_property_pool, 12), onigenc_jis_cyrillic} {(int)(size_t)&((struct onig_jis_property_pool_t *)0)->onig_jis_property_pool_str12, onigenc_jis_cyrillic}
}; };
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)

Просмотреть файл

@ -1,5 +1,5 @@
/* ANSI-C code produced by gperf version 3.1 */ /* ANSI-C code produced by gperf version 3.1 */
/* Command-line: gperf -C -P -p -j1 -i 1 -g -o -t -N rb_reserved_word -k'1,3,$' defs/keywords */ /* Command-line: gperf -C -L ANSI-C -P -p -j1 -i 1 -g -o -t -N rb_reserved_word -k'1,3,$' defs/keywords */
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
&& ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
@ -28,7 +28,6 @@
#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gperf@gnu.org>." #error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gperf@gnu.org>."
#endif #endif
#define gperf_offsetof(s, n) (short)offsetof(struct s##_t, s##_str##n)
#line 1 "defs/keywords" #line 1 "defs/keywords"
struct kwtable {short name, id[2], state;}; struct kwtable {short name, id[2], state;};
@ -196,88 +195,88 @@ rb_reserved_word (register const char *str, register size_t len)
{ {
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
#line 19 "defs/keywords" #line 19 "defs/keywords"
{gperf_offsetof(stringpool, 8), {keyword_break, keyword_break}, EXPR_MID}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str8, {keyword_break, keyword_break}, EXPR_MID},
#line 25 "defs/keywords" #line 25 "defs/keywords"
{gperf_offsetof(stringpool, 9), {keyword_else, keyword_else}, EXPR_BEG}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str9, {keyword_else, keyword_else}, EXPR_BEG},
#line 35 "defs/keywords" #line 35 "defs/keywords"
{gperf_offsetof(stringpool, 10), {keyword_nil, keyword_nil}, EXPR_END}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str10, {keyword_nil, keyword_nil}, EXPR_END},
#line 28 "defs/keywords" #line 28 "defs/keywords"
{gperf_offsetof(stringpool, 11), {keyword_ensure, keyword_ensure}, EXPR_BEG}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str11, {keyword_ensure, keyword_ensure}, EXPR_BEG},
#line 27 "defs/keywords" #line 27 "defs/keywords"
{gperf_offsetof(stringpool, 12), {keyword_end, keyword_end}, EXPR_END}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str12, {keyword_end, keyword_end}, EXPR_END},
#line 44 "defs/keywords" #line 44 "defs/keywords"
{gperf_offsetof(stringpool, 13), {keyword_then, keyword_then}, EXPR_BEG}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str13, {keyword_then, keyword_then}, EXPR_BEG},
#line 36 "defs/keywords" #line 36 "defs/keywords"
{gperf_offsetof(stringpool, 14), {keyword_not, keyword_not}, EXPR_ARG}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str14, {keyword_not, keyword_not}, EXPR_ARG},
#line 29 "defs/keywords" #line 29 "defs/keywords"
{gperf_offsetof(stringpool, 15), {keyword_false, keyword_false}, EXPR_END}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str15, {keyword_false, keyword_false}, EXPR_END},
#line 42 "defs/keywords" #line 42 "defs/keywords"
{gperf_offsetof(stringpool, 16), {keyword_self, keyword_self}, EXPR_END}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str16, {keyword_self, keyword_self}, EXPR_END},
#line 26 "defs/keywords" #line 26 "defs/keywords"
{gperf_offsetof(stringpool, 17), {keyword_elsif, keyword_elsif}, EXPR_VALUE}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str17, {keyword_elsif, keyword_elsif}, EXPR_VALUE},
#line 39 "defs/keywords" #line 39 "defs/keywords"
{gperf_offsetof(stringpool, 18), {keyword_rescue, modifier_rescue}, EXPR_MID}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str18, {keyword_rescue, modifier_rescue}, EXPR_MID},
#line 45 "defs/keywords" #line 45 "defs/keywords"
{gperf_offsetof(stringpool, 19), {keyword_true, keyword_true}, EXPR_END}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str19, {keyword_true, keyword_true}, EXPR_END},
#line 48 "defs/keywords" #line 48 "defs/keywords"
{gperf_offsetof(stringpool, 20), {keyword_until, modifier_until}, EXPR_VALUE}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str20, {keyword_until, modifier_until}, EXPR_VALUE},
#line 47 "defs/keywords" #line 47 "defs/keywords"
{gperf_offsetof(stringpool, 21), {keyword_unless, modifier_unless}, EXPR_VALUE}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str21, {keyword_unless, modifier_unless}, EXPR_VALUE},
#line 41 "defs/keywords" #line 41 "defs/keywords"
{gperf_offsetof(stringpool, 22), {keyword_return, keyword_return}, EXPR_MID}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str22, {keyword_return, keyword_return}, EXPR_MID},
#line 22 "defs/keywords" #line 22 "defs/keywords"
{gperf_offsetof(stringpool, 23), {keyword_def, keyword_def}, EXPR_FNAME}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str23, {keyword_def, keyword_def}, EXPR_FNAME},
#line 17 "defs/keywords" #line 17 "defs/keywords"
{gperf_offsetof(stringpool, 24), {keyword_and, keyword_and}, EXPR_VALUE}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str24, {keyword_and, keyword_and}, EXPR_VALUE},
#line 24 "defs/keywords" #line 24 "defs/keywords"
{gperf_offsetof(stringpool, 25), {keyword_do, keyword_do}, EXPR_BEG}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str25, {keyword_do, keyword_do}, EXPR_BEG},
#line 51 "defs/keywords" #line 51 "defs/keywords"
{gperf_offsetof(stringpool, 26), {keyword_yield, keyword_yield}, EXPR_ARG}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str26, {keyword_yield, keyword_yield}, EXPR_ARG},
#line 30 "defs/keywords" #line 30 "defs/keywords"
{gperf_offsetof(stringpool, 27), {keyword_for, keyword_for}, EXPR_VALUE}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str27, {keyword_for, keyword_for}, EXPR_VALUE},
#line 46 "defs/keywords" #line 46 "defs/keywords"
{gperf_offsetof(stringpool, 28), {keyword_undef, keyword_undef}, EXPR_FNAME|EXPR_FITEM}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str28, {keyword_undef, keyword_undef}, EXPR_FNAME|EXPR_FITEM},
#line 37 "defs/keywords" #line 37 "defs/keywords"
{gperf_offsetof(stringpool, 29), {keyword_or, keyword_or}, EXPR_VALUE}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str29, {keyword_or, keyword_or}, EXPR_VALUE},
#line 32 "defs/keywords" #line 32 "defs/keywords"
{gperf_offsetof(stringpool, 30), {keyword_in, keyword_in}, EXPR_VALUE}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str30, {keyword_in, keyword_in}, EXPR_VALUE},
#line 49 "defs/keywords" #line 49 "defs/keywords"
{gperf_offsetof(stringpool, 31), {keyword_when, keyword_when}, EXPR_VALUE}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str31, {keyword_when, keyword_when}, EXPR_VALUE},
#line 40 "defs/keywords" #line 40 "defs/keywords"
{gperf_offsetof(stringpool, 32), {keyword_retry, keyword_retry}, EXPR_END}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str32, {keyword_retry, keyword_retry}, EXPR_END},
#line 31 "defs/keywords" #line 31 "defs/keywords"
{gperf_offsetof(stringpool, 33), {keyword_if, modifier_if}, EXPR_VALUE}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str33, {keyword_if, modifier_if}, EXPR_VALUE},
#line 20 "defs/keywords" #line 20 "defs/keywords"
{gperf_offsetof(stringpool, 34), {keyword_case, keyword_case}, EXPR_VALUE}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str34, {keyword_case, keyword_case}, EXPR_VALUE},
#line 38 "defs/keywords" #line 38 "defs/keywords"
{gperf_offsetof(stringpool, 35), {keyword_redo, keyword_redo}, EXPR_END}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str35, {keyword_redo, keyword_redo}, EXPR_END},
#line 34 "defs/keywords" #line 34 "defs/keywords"
{gperf_offsetof(stringpool, 36), {keyword_next, keyword_next}, EXPR_MID}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str36, {keyword_next, keyword_next}, EXPR_MID},
#line 43 "defs/keywords" #line 43 "defs/keywords"
{gperf_offsetof(stringpool, 37), {keyword_super, keyword_super}, EXPR_ARG}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str37, {keyword_super, keyword_super}, EXPR_ARG},
#line 33 "defs/keywords" #line 33 "defs/keywords"
{gperf_offsetof(stringpool, 38), {keyword_module, keyword_module}, EXPR_VALUE}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str38, {keyword_module, keyword_module}, EXPR_VALUE},
#line 18 "defs/keywords" #line 18 "defs/keywords"
{gperf_offsetof(stringpool, 39), {keyword_begin, keyword_begin}, EXPR_BEG}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str39, {keyword_begin, keyword_begin}, EXPR_BEG},
#line 12 "defs/keywords" #line 12 "defs/keywords"
{gperf_offsetof(stringpool, 40), {keyword__LINE__, keyword__LINE__}, EXPR_END}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str40, {keyword__LINE__, keyword__LINE__}, EXPR_END},
#line 13 "defs/keywords" #line 13 "defs/keywords"
{gperf_offsetof(stringpool, 41), {keyword__FILE__, keyword__FILE__}, EXPR_END}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str41, {keyword__FILE__, keyword__FILE__}, EXPR_END},
#line 11 "defs/keywords" #line 11 "defs/keywords"
{gperf_offsetof(stringpool, 42), {keyword__ENCODING__, keyword__ENCODING__}, EXPR_END}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str42, {keyword__ENCODING__, keyword__ENCODING__}, EXPR_END},
#line 15 "defs/keywords" #line 15 "defs/keywords"
{gperf_offsetof(stringpool, 43), {keyword_END, keyword_END}, EXPR_END}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str43, {keyword_END, keyword_END}, EXPR_END},
#line 16 "defs/keywords" #line 16 "defs/keywords"
{gperf_offsetof(stringpool, 44), {keyword_alias, keyword_alias}, EXPR_FNAME|EXPR_FITEM}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str44, {keyword_alias, keyword_alias}, EXPR_FNAME|EXPR_FITEM},
#line 14 "defs/keywords" #line 14 "defs/keywords"
{gperf_offsetof(stringpool, 45), {keyword_BEGIN, keyword_BEGIN}, EXPR_END}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str45, {keyword_BEGIN, keyword_BEGIN}, EXPR_END},
#line 23 "defs/keywords" #line 23 "defs/keywords"
{gperf_offsetof(stringpool, 46), {keyword_defined, keyword_defined}, EXPR_ARG}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str46, {keyword_defined, keyword_defined}, EXPR_ARG},
#line 21 "defs/keywords" #line 21 "defs/keywords"
{gperf_offsetof(stringpool, 47), {keyword_class, keyword_class}, EXPR_CLASS}, {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str47, {keyword_class, keyword_class}, EXPR_CLASS},
{-1}, {-1}, {-1}, {-1},
#line 50 "defs/keywords" #line 50 "defs/keywords"
{gperf_offsetof(stringpool, 50), {keyword_while, modifier_while}, EXPR_VALUE} {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str50, {keyword_while, modifier_while}, EXPR_VALUE}
}; };
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)

Просмотреть файл

@ -419,7 +419,7 @@ lex.c: defs/keywords
$(CP) $(srcdir)/lex.c.blt $@; \ $(CP) $(srcdir)/lex.c.blt $@; \
else \ else \
[ $(Q) ] && echo generating $@ || set -x; \ [ $(Q) ] && echo generating $@ || set -x; \
gperf -C -P -p -j1 -i 1 -g -o -t -N rb_reserved_word -k1,3,$$ $? \ gperf -C -L ANSI-C -P -p -j1 -i 1 -g -o -t -N rb_reserved_word -k1,3,$$ $? \
| sed -f $(tooldir)/gperf.sed \ | sed -f $(tooldir)/gperf.sed \
> $@.tmp && \ > $@.tmp && \
$(MV) $@.tmp $@ && \ $(MV) $@.tmp $@ && \
@ -427,7 +427,7 @@ lex.c: defs/keywords
$(CP) $@ $(srcdir)/lex.c.blt; \ $(CP) $@ $(srcdir)/lex.c.blt; \
fi fi
JIS_PROPS_OPTIONS = -k1,3 -7 -c -j1 -i1 -t -C -P -t --ignore-case -H onig_jis_property_hash -Q onig_jis_property_pool -N onig_jis_property JIS_PROPS_OPTIONS = -L ANSI-C -k1,3 -7 -c -j1 -i1 -t -C -P -t --ignore-case -H onig_jis_property_hash -Q onig_jis_property_pool -N onig_jis_property
$(srcdir)/enc/jis/props.h: enc/jis/props.kwd $(srcdir)/enc/jis/props.h: enc/jis/props.kwd
$(MAKEDIRS) $(@D) $(MAKEDIRS) $(@D)

Просмотреть файл

@ -1,23 +1,4 @@
/ANSI-C code/{
h
s/.*/ANSI:offset:/
x
}
/\/\*!ANSI{\*\//{
G
s/\/\*!ANSI{\*\/\(.*\)\/\*}!ANSI\*\/\(.*\)\nANSI:.*/\/\*\1\*\/\2/
}
s/(int)([a-z_]*)&((struct \([a-zA-Z_0-9][a-zA-Z_0-9]*\)_t *\*)0)->\1_str\([1-9][0-9]*\),/gperf_offsetof(\1, \2),/g
/^#line/{
G
x
s/:offset:/:/
x
s/\(.*\)\(\n\).*:offset:.*/#define gperf_offsetof(s, n) (short)offsetof(struct s##_t, s##_str##n)\2\1/
s/\n[^#].*//
}
/^[a-zA-Z_0-9]*hash/,/^}/{ /^[a-zA-Z_0-9]*hash/,/^}/{
s/ hval = / hval = (unsigned int)/ s/ hval = / hval = (unsigned int)/
s/ return / return (unsigned int)/ s/ return / return (unsigned int)/
} }
s/^\(static\) \(unsigned char gperf_downcase\)/\1 const \2/