diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-05-22 05:02:15 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-05-22 05:02:15 +0000 |
commit | f1b49b7bb9118e336b8ce2ebe5a12af5881f83c3 (patch) | |
tree | 1e514dc337d58273f62ce4c4f686feecf28e8131 /enc/jis/props.src | |
parent | 5f8fccb451723931dd5e733491678cec8e9134c0 (diff) | |
download | ruby-f1b49b7bb9118e336b8ce2ebe5a12af5881f83c3.tar.gz |
constify character property tables
* enc/jis/props.kwd: constify character property tables of JIS
based encodings by perfect hash.
* enc/euc_jp.c, enc/shift_jis.c: use character property functions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enc/jis/props.src')
-rw-r--r-- | enc/jis/props.src | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/enc/jis/props.src b/enc/jis/props.src new file mode 100644 index 0000000000..b2ddde50c9 --- /dev/null +++ b/enc/jis/props.src @@ -0,0 +1,52 @@ +%{/* -*- c -*- */ +#define GPERF_DOWNCASE 1 +#define GPERF_CASE_STRNCMP 1 + +static inline int +gperf_case_strncmp(const char *s1, const char *s2, unsigned int n) +{ + const UChar *str = (const UChar *)s1; + const UChar *s = (const UChar *)s2; + return onigenc_with_ascii_strnicmp(ONIG_ENCODING_ASCII, str, str + n, s, n); +} + +enum onigenc_jis_ctype { + onigenc_jis_min = ONIGENC_MAX_STD_CTYPE, + onigenc_jis_hiragana, + onigenc_jis_katakana, + onigenc_jis_han, + onigenc_jis_latin, + onigenc_jis_greek, + onigenc_jis_cyrillic, + onigenc_jis_max +}; + +enum {PropertyListNum = onigenc_jis_max - onigenc_jis_min - 1}; + +static const OnigCodePoint* PropertyList[PropertyListNum] = { + CR_Hiragana, + CR_Katakana, + CR_Han, + CR_Latin, + CR_Greek, + CR_Cyrillic, +}; + +struct enc_property { + signed char name; + unsigned char ctype; +}; + +static const struct enc_property *onig_jis_property(const char *str, unsigned int len); +%} + +struct enc_property; + +%% +hiragana, onigenc_jis_hiragana +katakana, onigenc_jis_katakana +han, onigenc_jis_han +latin, onigenc_jis_latin +greek, onigenc_jis_greek +cyrillic, onigenc_jis_cyrillic +%% |