ruby-changes:3578
From: ko1@a...
Date: Tue, 15 Jan 2008 22:36:37 +0900 (JST)
Subject: [ruby-changes:3578] naruse - Ruby:r15067 (trunk): * encoding.c (ENC_REGISTER): use &OnigEncoding*.
naruse 2008-01-15 22:36:18 +0900 (Tue, 15 Jan 2008) New Revision: 15067 Modified files: trunk/ChangeLog trunk/enc/big5.c trunk/enc/euc_jp.c trunk/enc/euc_kr.c trunk/enc/euc_tw.c trunk/enc/gb18030.c trunk/enc/shift_jis.c trunk/enc/utf_16be.c trunk/enc/utf_16le.c trunk/enc/utf_32be.c trunk/enc/utf_32le.c trunk/enc/utf_8.c trunk/encoding.c trunk/include/ruby/oniguruma.h Log: * encoding.c (ENC_REGISTER): use &OnigEncoding*. (ENCINDEX_UTF_8): renamed from ENCINDEX_UTF8. (rb_enc_init): use ENC_REGISTER. * include/ruby/oniguruma.h (OnigEncodingUTF8, ONIG_ENCODING_UTF8): removed. * enc/*.c: remove use of &encoding_*; use enc argument instead. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/include/ruby/oniguruma.h?r1=15067&r2=15066&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/enc/euc_tw.c?r1=15067&r2=15066&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/enc/utf_32le.c?r1=15067&r2=15066&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15067&r2=15066&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/enc/euc_jp.c?r1=15067&r2=15066&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/enc/euc_kr.c?r1=15067&r2=15066&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/encoding.c?r1=15067&r2=15066&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/enc/big5.c?r1=15067&r2=15066&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/enc/utf_8.c?r1=15067&r2=15066&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/enc/utf_32be.c?r1=15067&r2=15066&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/enc/utf_16le.c?r1=15067&r2=15066&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/enc/utf_16be.c?r1=15067&r2=15066&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/enc/gb18030.c?r1=15067&r2=15066&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/enc/shift_jis.c?r1=15067&r2=15066&diff_format=u Index: encoding.c =================================================================== --- encoding.c (revision 15066) +++ encoding.c (revision 15067) @@ -303,21 +303,22 @@ enum { ENCINDEX_ASCII, - ENCINDEX_UTF8, + ENCINDEX_UTF_8, ENCINDEX_US_ASCII, ENCINDEX_BUILTIN_MAX }; +extern rb_encoding OnigEncodingUTF_8; extern rb_encoding OnigEncodingUS_ASCII; void rb_enc_init(void) { enc_table.count = enc_table_expand(ENCINDEX_BUILTIN_MAX); -#define ENC_REGISTER(enc) enc_register_at(ENCINDEX_##enc, rb_enc_name(ONIG_ENCODING_##enc), ONIG_ENCODING_##enc) +#define ENC_REGISTER(enc) enc_register_at(ENCINDEX_##enc, rb_enc_name(&OnigEncoding##enc), &OnigEncoding##enc) ENC_REGISTER(ASCII); - ENC_REGISTER(UTF8); - enc_register_at(ENCINDEX_US_ASCII, rb_enc_name(&OnigEncodingUS_ASCII), &OnigEncodingUS_ASCII); + ENC_REGISTER(UTF_8); + ENC_REGISTER(US_ASCII); #undef ENC_REGISTER } @@ -868,7 +869,7 @@ if (!enc_table.list) { rb_enc_init(); } - return enc_table.list[ENCINDEX_UTF8].enc; + return enc_table.list[ENCINDEX_UTF_8].enc; } rb_encoding * Index: include/ruby/oniguruma.h =================================================================== --- include/ruby/oniguruma.h (revision 15066) +++ include/ruby/oniguruma.h (revision 15067) @@ -173,10 +173,8 @@ typedef OnigEncodingType* OnigEncoding; ONIG_EXTERN OnigEncodingType OnigEncodingASCII; -ONIG_EXTERN OnigEncodingType OnigEncodingUTF8; #define ONIG_ENCODING_ASCII (&OnigEncodingASCII) -#define ONIG_ENCODING_UTF8 (&OnigEncodingUTF8) #define ONIG_ENCODING_UNDEF ((OnigEncoding )0) Index: ChangeLog =================================================================== --- ChangeLog (revision 15066) +++ ChangeLog (revision 15067) @@ -1,3 +1,14 @@ +Tue Jan 15 22:30:43 2008 NARUSE, Yui <naruse@r...> + + * encoding.c (ENC_REGISTER): use &OnigEncoding*. + (ENCINDEX_UTF_8): renamed from ENCINDEX_UTF8. + (rb_enc_init): use ENC_REGISTER. + + * include/ruby/oniguruma.h (OnigEncodingUTF8, ONIG_ENCODING_UTF8): + removed. + + * enc/*.c: remove use of &encoding_*; use enc argument instead. + Tue Jan 15 18:44:46 2008 Yukihiro Matsumoto <matz@r...> * enc/utf_8.c: remove use of ONIG_ENCODING_UTF8 altogether; use Index: enc/euc_jp.c =================================================================== --- enc/euc_jp.c (revision 15066) +++ enc/euc_jp.c (revision 15067) @@ -29,7 +29,6 @@ #include "regint.h" -OnigEncodingDeclare(EUC_JP); #define eucjp_islead(c) ((UChar )((c) - 0xa1) > 0xfe - 0xa1) @@ -139,7 +138,7 @@ int c, i, len; OnigCodePoint n; - len = enclen(&OnigEncodingName(EUC_JP), p, end); + len = enclen(enc, p, end); n = (OnigCodePoint )*p++; if (len == 1) return n; @@ -191,7 +190,7 @@ *p++ = (UChar )(code & 0xff); #if 1 - if (enclen(&OnigEncodingName(EUC_JP), buf, p) != (p - buf)) + if (enclen(enc, buf, p) != (p - buf)) return ONIGERR_INVALID_CODE_POINT_VALUE; #endif return p - buf; @@ -213,7 +212,7 @@ else { int i; - len = enclen(&OnigEncodingName(EUC_JP), p, end); + len = enclen(enc, p, end); for (i = 0; i < len; i++) { *lower++ = *p++; } @@ -235,7 +234,7 @@ p = s; while (!eucjp_islead(*p) && p > start) p--; - len = enclen(&OnigEncodingName(EUC_JP), p, s); + len = enclen(enc, p, s); if (p + len > s) return (UChar* )p; p += len; return (UChar* )(p + ((s - p) & ~1)); Index: enc/shift_jis.c =================================================================== --- enc/shift_jis.c (revision 15066) +++ enc/shift_jis.c (revision 15067) @@ -29,8 +29,6 @@ #include "regint.h" -OnigEncodingDeclare(Shift_JIS); - static const int EncLen_SJIS[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -152,7 +150,7 @@ int c, i, len; OnigCodePoint n; - len = enclen(&OnigEncodingName(Shift_JIS), p, end); + len = enclen(enc, p, end); c = *p++; n = c; if (len == 1) return n; @@ -174,7 +172,7 @@ *p++ = (UChar )(code & 0xff); #if 0 - if (enclen(&OnigEncodingName(Shift_JIS), buf) != (p - buf)) + if (enclen(enc, buf) != (p - buf)) return REGERR_INVALID_CODE_POINT_VALUE; #endif return p - buf; @@ -194,7 +192,7 @@ } else { int i; - int len = enclen(&OnigEncodingName(Shift_JIS), p, end); + int len = enclen(enc, p, end); for (i = 0; i < len; i++) { *lower++ = *p++; @@ -209,7 +207,7 @@ is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end) { - return onigenc_mbn_is_mbc_ambiguous(&OnigEncodingName(Shift_JIS), flag, pp, end); + return onigenc_mbn_is_mbc_ambiguous(enc, flag, pp, end); } #endif @@ -247,7 +245,7 @@ } } } - len = enclen(&OnigEncodingName(Shift_JIS), p, s); + len = enclen(enc, p, s); if (p + len > s) return (UChar* )p; p += len; return (UChar* )(p + ((s - p) & ~1)); Index: enc/utf_8.c =================================================================== --- enc/utf_8.c (revision 15066) +++ enc/utf_8.c (revision 15067) @@ -424,7 +424,7 @@ return onigenc_unicode_get_case_fold_codes_by_str(enc, flag, p, end, items); } -OnigEncodingDefine(utf8, UTF8) = { +OnigEncodingDefine(utf_8, UTF_8) = { mbc_enc_len, "UTF-8", /* name */ 6, /* max byte length */ Index: enc/big5.c =================================================================== --- enc/big5.c (revision 15066) +++ enc/big5.c (revision 15067) @@ -29,8 +29,6 @@ #include "regenc.h" -OnigEncodingDeclare(BIG5); - static const int EncLen_BIG5[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -59,20 +57,20 @@ static OnigCodePoint big5_mbc_to_code(const UChar* p, const UChar* end, OnigEncoding enc) { - return onigenc_mbn_mbc_to_code(&OnigEncodingName(BIG5), p, end); + return onigenc_mbn_mbc_to_code(enc, p, end); } static int big5_code_to_mbc(OnigCodePoint code, UChar *buf, OnigEncoding enc) { - return onigenc_mb2_code_to_mbc(&OnigEncodingName(BIG5), code, buf); + return onigenc_mb2_code_to_mbc(enc, code, buf); } static int big5_mbc_case_fold(OnigCaseFoldType flag, const UChar** pp, const UChar* end, UChar* lower, OnigEncoding enc) { - return onigenc_mbn_mbc_case_fold(&OnigEncodingName(BIG5), flag, + return onigenc_mbn_mbc_case_fold(enc, flag, pp, end, lower); } @@ -81,14 +79,14 @@ big5_is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end, OnigEncoding enc) { - return onigenc_mbn_is_mbc_ambiguous(&OnigEncodingName(BIG5), flag, pp, end); + return onigenc_mbn_is_mbc_ambiguous(enc, flag, pp, end); } #endif static int big5_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc) { - return onigenc_mb2_is_code_ctype(&OnigEncodingName(BIG5), code, ctype); + return onigenc_mb2_is_code_ctype(enc, code, ctype); } static const char BIG5_CAN_BE_TRAIL_TABLE[256] = { @@ -130,7 +128,7 @@ } } } - len = enclen(&OnigEncodingName(BIG5), p, s); + len = enclen(enc, p, s); if (p + len > s) return (UChar* )p; p += len; return (UChar* )(p + ((s - p) & ~1)); Index: enc/euc_tw.c =================================================================== --- enc/euc_tw.c (revision 15066) +++ enc/euc_tw.c (revision 15067) @@ -29,8 +29,6 @@ #include "regenc.h" -OnigEncodingDeclare(EUC_TW); - static const int EncLen_EUCTW[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -59,20 +57,20 @@ static OnigCodePoint euctw_mbc_to_code(const UChar* p, const UChar* end, OnigEncoding enc) { - return onigenc_mbn_mbc_to_code(&OnigEncodingName(EUC_TW), p, end); + return onigenc_mbn_mbc_to_code(enc, p, end); } static int euctw_code_to_mbc(OnigCodePoint code, UChar *buf, OnigEncoding enc) { - return onigenc_mb4_code_to_mbc(&OnigEncodingName(EUC_TW), code, buf); + return onigenc_mb4_code_to_mbc(enc, code, buf); } static int euctw_mbc_case_fold(OnigCaseFoldType flag, const UChar** pp, const UChar* end, UChar* lower, OnigEncoding enc) { - return onigenc_mbn_mbc_case_fold(&OnigEncodingName(EUC_TW), flag, + return onigenc_mbn_mbc_case_fold(enc, flag, pp, end, lower); } @@ -81,14 +79,14 @@ euctw_is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end, OnigEncoding enc) { - return onigenc_mbn_is_mbc_ambiguous(&OnigEncodingName(EUC_TW), flag, pp, end); + return onigenc_mbn_is_mbc_ambiguous(enc, flag, pp, end); } #endif static int euctw_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc) { - return onigenc_mb4_is_code_ctype(&OnigEncodingName(EUC_TW), code, ctype); + return onigenc_mb4_is_code_ctype(enc, code, ctype); } #define euctw_islead(c) (((c) < 0xa1 && (c) != 0x8e) || (c) == 0xff) @@ -106,7 +104,7 @@ p = s; while (!euctw_islead(*p) && p > start) p--; - len = enclen(&OnigEncodingName(EUC_TW), p, s); + len = enclen(enc, p, s); if (p + len > s) return (UChar* )p; p += len; return (UChar* )(p + ((s - p) & ~1)); Index: enc/euc_kr.c =================================================================== --- enc/euc_kr.c (revision 15066) +++ enc/euc_kr.c (revision 15067) @@ -29,8 +29,6 @@ #include "regenc.h" -OnigEncodingDeclare(EUC_KR); - static const int EncLen_EUCKR[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -59,20 +57,20 @@ static OnigCodePoint euckr_mbc_to_code(const UChar* p, const UChar* end, OnigEncoding enc) { - return onigenc_mbn_mbc_to_code(&OnigEncodingName(EUC_KR), p, end); + return onigenc_mbn_mbc_to_code(enc, p, end); } static int euckr_code_to_mbc(OnigCodePoint code, UChar *buf, OnigEncoding enc) { - return onigenc_mb2_code_to_mbc(&OnigEncodingName(EUC_KR), code, buf); + return onigenc_mb2_code_to_mbc(enc, code, buf); } static int euckr_mbc_case_fold(OnigCaseFoldType flag, const UChar** pp, const UChar* end, UChar* lower, OnigEncoding enc) { - return onigenc_mbn_mbc_case_fold(&OnigEncodingName(EUC_KR), flag, + return onigenc_mbn_mbc_case_fold(enc, flag, pp, end, lower); } @@ -81,14 +79,14 @@ euckr_is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end, OnigEncoding enc) { - return onigenc_mbn_is_mbc_ambiguous(&OnigEncodingName(EUC_KR), flag, pp, end); + return onigenc_mbn_is_mbc_ambiguous(enc, flag, pp, end); } #endif static int euckr_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc) { - return onigenc_mb2_is_code_ctype(&OnigEncodingName(EUC_KR), code, ctype); + return onigenc_mb2_is_code_ctype(enc, code, ctype); } #define euckr_islead(c) ((c) < 0xa1 || (c) == 0xff) @@ -106,7 +104,7 @@ p = s; while (!euckr_islead(*p) && p > start) p--; - len = enclen(&OnigEncodingName(EUC_KR), p, s); + len = enclen(enc, p, s); if (p + len > s) return (UChar* )p; p += len; return (UChar* )(p + ((s - p) & ~1)); Index: enc/utf_32be.c =================================================================== --- enc/utf_32be.c (revision 15066) +++ enc/utf_32be.c (revision 15067) @@ -29,8 +29,6 @@ #include "regenc.h" -OnigEncodingDeclare(UTF_32BE); - static int utf32be_mbc_enc_len(const UChar* p ARG_UNUSED, const OnigUChar* e ARG_UNUSED, struct OnigEncodingTypeST* enc ARG_UNUSED) @@ -116,7 +114,7 @@ return 4; } else - return onigenc_unicode_mbc_case_fold(&OnigEncodingName(UTF_32BE), flag, pp, + return onigenc_unicode_mbc_case_fold(enc, flag, pp, end, fold); } @@ -171,7 +169,7 @@ OnigCaseFoldCodeItem items[], struct OnigEncodingTypeST* enc ARG_UNUSED) { - return onigenc_unicode_get_case_fold_codes_by_str(&OnigEncodingName(UTF_32BE), + return onigenc_unicode_get_case_fold_codes_by_str(enc, flag, p, end, items); } Index: enc/utf_16be.c =================================================================== --- enc/utf_16be.c (revision 15066) +++ enc/utf_16be.c (revision 15067) @@ -29,8 +29,6 @@ #include "regenc.h" -OnigEncodingDeclare(UTF_16BE); - #define UTF16_IS_SURROGATE_FIRST(c) (c >= 0xd8 && c <= 0xdb) #define UTF16_IS_SURROGATE_SECOND(c) (c >= 0xdc && c <= 0xdf) @@ -155,7 +153,7 @@ return 2; } else - return onigenc_unicode_mbc_case_fold(&OnigEncodingName(UTF_16BE), flag, + return onigenc_unicode_mbc_case_fold(enc, flag, pp, end, fold); } @@ -215,7 +213,7 @@ OnigCaseFoldCodeItem items[], struct OnigEncodingTypeST* enc ARG_UNUSED) { - return onigenc_unicode_get_case_fold_codes_by_str(&OnigEncodingName(UTF_16BE), + return onigenc_unicode_get_case_fold_codes_by_str(enc, flag, p, end, items); } Index: enc/utf_32le.c =================================================================== --- enc/utf_32le.c (revision 15066) +++ enc/utf_32le.c (revision 15067) @@ -29,8 +29,6 @@ #include "regenc.h" -OnigEncodingDeclare(UTF_32LE); - static int utf32le_mbc_enc_len(const UChar* p ARG_UNUSED, const OnigUChar* e ARG_UNUSED, struct OnigEncodingTypeST* enc ARG_UNUSED) @@ -117,7 +115,7 @@ return 4; } else - return onigenc_unicode_mbc_case_fold(&OnigEncodingName(UTF_32LE), flag, pp, + return onigenc_unicode_mbc_case_fold(enc, flag, pp, end, fold); } @@ -171,7 +169,7 @@ OnigCaseFoldCodeItem items[], struct OnigEncodingTypeST* enc ARG_UNUSED) { - return onigenc_unicode_get_case_fold_codes_by_str(&OnigEncodingName(UTF_32LE), + return onigenc_unicode_get_case_fold_codes_by_str(enc, flag, p, end, items); } Index: enc/gb18030.c =================================================================== --- enc/gb18030.c (revision 15066) +++ enc/gb18030.c (revision 15067) @@ -30,8 +30,6 @@ #include "regenc.h" -OnigEncodingDeclare(GB18030); - #if 1 #define DEBUG_GB18030(arg) #else @@ -80,20 +78,20 @@ static OnigCodePoint gb18030_mbc_to_code(const UChar* p, const UChar* end, OnigEncoding enc) { - return onigenc_mbn_mbc_to_code(&OnigEncodingName(GB18030), p, end); + return onigenc_mbn_mbc_to_code(enc, p, end); } static int gb18030_code_to_mbc(OnigCodePoint code, UChar *buf, OnigEncoding enc) { - return onigenc_mb4_code_to_mbc(&OnigEncodingName(GB18030), code, buf); + return onigenc_mb4_code_to_mbc(enc, code, buf); } static int gb18030_mbc_case_fold(OnigCaseFoldType flag, const UChar** pp, const UChar* end, UChar* lower, OnigEncoding enc) { - return onigenc_mbn_mbc_case_fold(&OnigEncodingName(GB18030), flag, + return onigenc_mbn_mbc_case_fold(enc, flag, pp, end, lower); } @@ -102,14 +100,14 @@ gb18030_is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end, OnigEncoding enc) { - return onigenc_mbn_is_mbc_ambiguous(&OnigEncodingName(GB18030), flag, pp, end); + return onigenc_mbn_is_mbc_ambiguous(enc, flag, pp, end); } #endif static int gb18030_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc) { - return onigenc_mb4_is_code_ctype(&OnigEncodingName(GB18030), code, ctype); + return onigenc_mb4_is_code_ctype(enc, code, ctype); } enum state { Index: enc/utf_16le.c =================================================================== --- enc/utf_16le.c (revision 15066) +++ enc/utf_16le.c (revision 15067) @@ -29,8 +29,6 @@ #include "regenc.h" -OnigEncodingDeclare(UTF_16LE); - #define UTF16_IS_SURROGATE_FIRST(c) (c >= 0xd8 && c <= 0xdb) #define UTF16_IS_SURROGATE_SECOND(c) (c >= 0xdc && c <= 0xdf) @@ -157,7 +155,7 @@ return 2; } else - return onigenc_unicode_mbc_case_fold(&OnigEncodingName(UTF_16LE), flag, pp, + return onigenc_unicode_mbc_case_fold(enc, flag, pp, end, fold); } @@ -216,7 +214,7 @@ OnigCaseFoldCodeItem items[], struct OnigEncodingTypeST* enc ARG_UNUSED) { - return onigenc_unicode_get_case_fold_codes_by_str(&OnigEncodingName(UTF_16LE), + return onigenc_unicode_get_case_fold_codes_by_str(enc, flag, p, end, items); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/