aboutsummaryrefslogtreecommitdiffstats
path: root/enc/shift_jis.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-22 05:02:15 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-22 05:02:15 +0000
commitf1b49b7bb9118e336b8ce2ebe5a12af5881f83c3 (patch)
tree1e514dc337d58273f62ce4c4f686feecf28e8131 /enc/shift_jis.c
parent5f8fccb451723931dd5e733491678cec8e9134c0 (diff)
downloadruby-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/shift_jis.c')
-rw-r--r--enc/shift_jis.c42
1 files changed, 5 insertions, 37 deletions
diff --git a/enc/shift_jis.c b/enc/shift_jis.c
index 5f5a802874..530415b87c 100644
--- a/enc/shift_jis.c
+++ b/enc/shift_jis.c
@@ -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;
-}
+#include "enc/jis/props.h"
static int
property_name_to_ctype(OnigEncoding enc, UChar* p, UChar* end)
{
- hash_data_type ctype;
- UChar *s, *e;
-
- PROPERTY_LIST_INIT_CHECK;
+ UChar *s = p, *e = end;
+ const struct enc_property *prop = onig_jis_property((const char *)s, (unsigned int)(e-s));
- 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) {
+ if (!prop) {
return onigenc_minimum_property_name_to_ctype(enc, s, e);
}
- return (int )ctype;
+ return (int)prop->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;