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 () | |
tree | 1e514dc337d58273f62ce4c4f686feecf28e8131 /enc | |
parent | 5f8fccb451723931dd5e733491678cec8e9134c0 (diff) |
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
-rw-r--r-- | enc/depend | 3 | ||||
-rw-r--r-- | enc/euc_jp.c | 42 | ||||
-rw-r--r-- | enc/jis/props.h | 227 | ||||
-rw-r--r-- | enc/jis/props.h.blt | 227 | ||||
-rw-r--r-- | enc/jis/props.kwd | 52 | ||||
-rw-r--r-- | enc/jis/props.src | 52 | ||||
-rw-r--r-- | enc/shift_jis.c | 42 |
7 files changed, 571 insertions, 74 deletions
@@ -144,6 +144,7 @@ clean: % @ignore_error = $nmake ? '' : ' 2> /dev/null || true' % unless inplace $(Q)$(RM) enc/unicode/name2ctype.h -$(Q)$(RMDIR) enc/unicode<%=@ignore_error%> % end % workdirs.reverse_each do|d| @@ -154,7 +155,9 @@ clean-srcs: $(Q)$(RM) <%=pathrep['$(TRANSCSRCS)']%> -$(Q)$(RMDIR) <%=pathrep['enc/trans']%><%=@ignore_error%> $(Q)$(RM) enc/unicode/name2ctype.h -$(Q)$(RMDIR) <%=pathrep['enc/unicode']%><%=@ignore_error%> -$(Q)$(RMDIR) <%=pathrep['enc']%><%=@ignore_error%> <%# vim: set ft=eruby noexpandtab ts=8 sw=2 : -%> @@ -418,12 +418,6 @@ is_allowed_reverse_match(const UChar* s, const UChar* end, OnigEncoding enc ARG_ } -static int PropertyInited = 0; -static const OnigCodePoint** PropertyList; -static int PropertyListNum; -static int PropertyListSize; -static hash_table_type* PropertyNameTable; - static const OnigCodePoint CR_Hiragana[] = { 1, #ifdef ENC_EUC_JIS_2004 @@ -504,41 +498,19 @@ static const OnigCodePoint CR_Cyrillic[] = { /* TODO: add JIS X 0212 row 7 */ }; /* CR_Cyrillic */ -static int -init_property_list(void) -{ - int r; - - PROPERTY_LIST_ADD_PROP("hiragana", CR_Hiragana); - PROPERTY_LIST_ADD_PROP("katakana", CR_Katakana); - PROPERTY_LIST_ADD_PROP("han", CR_Han); - PROPERTY_LIST_ADD_PROP("latin", CR_Latin); - PROPERTY_LIST_ADD_PROP("greek", CR_Greek); - PROPERTY_LIST_ADD_PROP("cyrillic", CR_Cyrillic); - PropertyInited = 1; - - end: - return r; -} static int property_name_to_ctype(OnigEncoding enc, UChar* p, UChar* end) { - st_data_t ctype; - UChar *s, *e; - - PROPERTY_LIST_INIT_CHECK; - s = e = ALLOCA_N(UChar, end-p+1); - for (; p < end; p++) { - *e++ = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p); - } - - if (onig_st_lookup_strend(PropertyNameTable, s, e, &ctype) == 0) { return onigenc_minimum_property_name_to_ctype(enc, s, e); } - return (int )ctype; } static int @@ -554,8 +526,6 @@ is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc ARG_UNUSE } } else { - PROPERTY_LIST_INIT_CHECK; - ctype -= (ONIGENC_MAX_STD_CTYPE + 1); if (ctype >= (unsigned int )PropertyListNum) return ONIGERR_TYPE_BUG; @@ -576,8 +546,6 @@ get_ctype_code_range(OnigCtype ctype, OnigCodePoint* sb_out, else { *sb_out = 0x80; - PROPERTY_LIST_INIT_CHECK; - ctype -= (ONIGENC_MAX_STD_CTYPE + 1); if (ctype >= (OnigCtype )PropertyListNum) return ONIGERR_TYPE_BUG; @@ -0,0 +1,227 @@ @@ -0,0 +1,227 @@ @@ -0,0 +1,52 @@ @@ -0,0 +1,52 @@ @@ -433,12 +433,6 @@ is_allowed_reverse_match(const UChar* s, const UChar* end, OnigEncoding enc ARG_ } -static int PropertyInited = 0; -static const OnigCodePoint** PropertyList; -static int PropertyListNum; -static int PropertyListSize; -static hash_table_type* PropertyNameTable; - static const OnigCodePoint CR_Hiragana[] = { 1, 0x829f, 0x82f1 @@ -493,41 +487,19 @@ static const OnigCodePoint CR_Cyrillic[] = { 0x8480, 0x8491, }; /* CR_Cyrillic */ -static int -init_property_list(void) -{ - int r; - - PROPERTY_LIST_ADD_PROP("hiragana", CR_Hiragana); - PROPERTY_LIST_ADD_PROP("katakana", CR_Katakana); - PROPERTY_LIST_ADD_PROP("han", CR_Han); - PROPERTY_LIST_ADD_PROP("latin", CR_Latin); - PROPERTY_LIST_ADD_PROP("greek", CR_Greek); - PROPERTY_LIST_ADD_PROP("cyrillic", CR_Cyrillic); - PropertyInited = 1; - - end: - return r; -} static int property_name_to_ctype(OnigEncoding enc, UChar* p, UChar* end) { - hash_data_type ctype; - UChar *s, *e; - - PROPERTY_LIST_INIT_CHECK; - s = e = ALLOCA_N(UChar, end-p+1); - for (; p < end; p++) { - *e++ = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p); - } - - if (onig_st_lookup_strend(PropertyNameTable, s, e, &ctype) == 0) { return onigenc_minimum_property_name_to_ctype(enc, s, e); } - return (int )ctype; } static int @@ -543,8 +515,6 @@ is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc) } } else { - PROPERTY_LIST_INIT_CHECK; - ctype -= (ONIGENC_MAX_STD_CTYPE + 1); if (ctype >= (unsigned int )PropertyListNum) return ONIGERR_TYPE_BUG; @@ -565,8 +535,6 @@ get_ctype_code_range(OnigCtype ctype, OnigCodePoint* sb_out, else { *sb_out = 0x80; - PROPERTY_LIST_INIT_CHECK; - ctype -= (ONIGENC_MAX_STD_CTYPE + 1); if (ctype >= (OnigCtype )PropertyListNum) return ONIGERR_TYPE_BUG; |