From 80a569906d1fcbede2278193226fef84cdaa96f4 Mon Sep 17 00:00:00 2001 From: naruse Date: Sun, 13 Jan 2008 01:15:32 +0000 Subject: [PATCH] * encoding.c (rb_enc_init): revert removing SJIS. * enc/sjis.c: move to enc/shift_jis.c, to make encoding name equal to filename for convinience of loading lib. * enc/shift_jis.c: moved from enc/sjis.c. * common.mk: follows enc/shift_jis.c. * enc/Makefile.in: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 13 +++++++++++++ common.mk | 2 +- enc/Makefile.in | 2 +- enc/{sjis.c => shift_jis.c} | 0 encoding.c | 35 +++++++++++++++++++++-------------- 5 files changed, 36 insertions(+), 16 deletions(-) rename enc/{sjis.c => shift_jis.c} (100%) diff --git a/ChangeLog b/ChangeLog index b7a3df35e5..fb9be7bac6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +Sun Jan 13 09:58:17 2008 NARUSE, Yui + + * encoding.c (rb_enc_init): revert removing SJIS. + + * enc/sjis.c: move to enc/shift_jis.c, to make encoding name equal to + filename for convinience of loading lib. + + * enc/shift_jis.c: moved from enc/sjis.c. + + * common.mk: follows enc/shift_jis.c. + + * enc/Makefile.in: ditto. + Sun Jan 13 09:22:33 2008 Nobuyoshi Nakada * common.mk (incs): includes encdb.h. diff --git a/common.mk b/common.mk index a9722b3604..9ab8b5e6a4 100644 --- a/common.mk +++ b/common.mk @@ -667,7 +667,7 @@ ascii.$(OBJEXT): {$(VPATH)}ascii.c {$(VPATH)}regenc.h {$(VPATH)}config.h \ euc_jp.$(OBJEXT): {$(VPATH)}euc_jp.c {$(VPATH)}regint.h \ {$(VPATH)}config.h {$(VPATH)}defines.h {$(VPATH)}regenc.h \ {$(VPATH)}oniguruma.h {$(VPATH)}st.h -sjis.$(OBJEXT): {$(VPATH)}sjis.c {$(VPATH)}regint.h {$(VPATH)}config.h \ +shift_jis.$(OBJEXT): {$(VPATH)}shift_jis.c {$(VPATH)}regint.h {$(VPATH)}config.h \ {$(VPATH)}defines.h {$(VPATH)}regenc.h {$(VPATH)}oniguruma.h \ {$(VPATH)}st.h unicode.$(OBJEXT): {$(VPATH)}unicode.c {$(VPATH)}regint.h \ diff --git a/enc/Makefile.in b/enc/Makefile.in index 082be84c86..694803427f 100644 --- a/enc/Makefile.in +++ b/enc/Makefile.in @@ -15,7 +15,7 @@ DLEXT = @DLEXT@ OBJEXT = @OBJEXT@ BUILTIN_ENCS = ascii.c \ - euc_jp.c sjis.c \ + euc_jp.c shift_jis.c \ unicode.c utf8.c RUBY_SO_NAME = @RUBY_SO_NAME@ diff --git a/enc/sjis.c b/enc/shift_jis.c similarity index 100% rename from enc/sjis.c rename to enc/shift_jis.c diff --git a/encoding.c b/encoding.c index c62e32b3d7..b7debda0ba 100644 --- a/encoding.c +++ b/encoding.c @@ -292,6 +292,8 @@ rb_enc_alias(const char *alias, const char *orig) enum { ENCINDEX_ASCII, + ENCINDEX_EUC_JP, + ENCINDEX_SJIS, ENCINDEX_UTF8, ENCINDEX_BUILTIN_MAX }; @@ -302,6 +304,8 @@ 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) ENC_REGISTER(ASCII); + ENC_REGISTER(EUC_JP); + ENC_REGISTER(SJIS); ENC_REGISTER(UTF8); #undef ENC_REGISTER } @@ -366,22 +370,25 @@ rb_enc_find_index(const char *name) OBJ_FREEZE(enclib); if (RTEST(rb_protect(require_enc, enclib, 0))) i = rb_enc_registered(name); - else { - st_data_t key = (st_data_t)name, orig; - if (st_lookup(enc_table_replica_name, key, &orig)) { - i = rb_enc_find_index((char *)orig); - if (i < 0) { - rb_raise(rb_eRuntimeError, "unknown original encoding name - %s for %s", (char *)orig, name); - } - i = rb_enc_replicate(name, rb_enc_from_index(i)); - st_delete(enc_table_replica_name, &key, &orig); - } else if (st_lookup(enc_table_alias_name, key, &orig)) { - i = rb_enc_alias(name, (char *)orig); - st_delete(enc_table_replica_name, &key, &orig); - } - } rb_set_errinfo(Qnil); } + if (i < 0) { + st_data_t key = (st_data_t)name, orig; + if (st_lookup(enc_table_replica_name, key, &orig)) { + i = rb_enc_find_index((char *)orig); + if (i < 0) { + rb_raise(rb_eRuntimeError, "unknown original encoding name - '%s' for replica '%s'", (char *)orig, name); + } + i = rb_enc_replicate(name, rb_enc_from_index(i)); + st_delete(enc_table_replica_name, &key, &orig); + } else if (st_lookup(enc_table_alias_name, key, &orig)) { + i = rb_enc_alias(name, (char *)orig); + if (i < 0) { + rb_raise(rb_eRuntimeError, "unknown original encoding name - '%s' for alias '%s'", (char *)orig, name); + } + st_delete(enc_table_alias_name, &key, &orig); + } + } return i; }