diff options
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | encoding.c | 12 |
2 files changed, 11 insertions, 4 deletions
@@ -16,6 +16,9 @@ Fri Jan 18 09:22:07 2008 Yukihiro Matsumoto <matz@ruby-lang.org> * parse.y (ripper_initialize): move parser->enc initialization. + * encoding.c (rb_enc_aliases_enc_i): exclude non alias names from + Encoding.aliases. + Fri Jan 18 07:06:25 2008 Yukihiro Matsumoto <matz@ruby-lang.org> * io.c (Init_IO): stdin/stdout may not be duplex. diff --git a/encoding.c b/encoding.c index 38d2cf2c90..07a1f8bfc9 100644 --- a/encoding.c +++ b/encoding.c @@ -498,8 +498,7 @@ rb_enc_find_index(const char *name) } else { i = load_encoding(name); - enc = rb_enc_from_index(i); - if (!enc->precise_mbc_enc_len) { + if (enc_autoload_p(rb_enc_from_index(i))) { rb_warn("failed to load encoding (%s); use ASCII-8BIT instead", name); return 0; @@ -1149,11 +1148,16 @@ rb_enc_aliases_enc_i(st_data_t name, st_data_t orig, st_data_t arg) VALUE str = rb_ary_entry(ary, idx); if (NIL_P(str)) { - str = rb_str_new2(rb_enc_name(rb_enc_from_index(idx))); + rb_encoding *enc = rb_enc_from_index(idx); + + if (STRCASECMP((char*)name, rb_enc_name(enc)) == 0) { + return ST_CONTINUE; + } + str = rb_str_new2(rb_enc_name(enc)); rb_ary_store(ary, idx, str); } rb_hash_aset(aliases, rb_str_new2((char *)name), str); - return 0; + return ST_CONTINUE; } /* |