1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Fix r32811: add UNSPECIFIED_ENCODING case.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32816 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2011-08-02 14:27:56 +00:00
parent 027a15e958
commit 48bc63fa7a

View file

@ -159,6 +159,7 @@ rb_to_encoding_index(VALUE enc)
return rb_enc_find_index(StringValueCStr(enc)); return rb_enc_find_index(StringValueCStr(enc));
} }
/* Returns encoding index or UNSPECIFIED_ENCODING */
static int static int
str_to_encindex(VALUE enc) str_to_encindex(VALUE enc)
{ {
@ -596,6 +597,7 @@ enc_autoload(rb_encoding *enc)
return i; return i;
} }
/* Return encoding index or UNSPECIFIED_ENCODING from encoding name */
int int
rb_enc_find_index(const char *name) rb_enc_find_index(const char *name)
{ {
@ -1051,9 +1053,12 @@ enc_list(VALUE klass)
static VALUE static VALUE
enc_find(VALUE klass, VALUE enc) enc_find(VALUE klass, VALUE enc)
{ {
int idx;
if (!SPECIAL_CONST_P(enc) && BUILTIN_TYPE(enc) == T_DATA && is_data_encoding(enc)) if (!SPECIAL_CONST_P(enc) && BUILTIN_TYPE(enc) == T_DATA && is_data_encoding(enc))
return enc; return enc;
return rb_enc_from_encoding_index(str_to_encindex(enc)); idx = str_to_encindex(enc);
if (idx == UNSPECIFIED_ENCODING) return Qnil;
return rb_enc_from_encoding_index(idx);
} }
/* /*