mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
55fc559845
commit
80a569906d
5 changed files with 36 additions and 16 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
Sun Jan 13 09:58:17 2008 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* 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 <nobu@ruby-lang.org>
|
||||
|
||||
* common.mk (incs): includes encdb.h.
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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@
|
||||
|
|
35
encoding.c
35
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue