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:
parent
027a15e958
commit
48bc63fa7a
1 changed files with 6 additions and 1 deletions
|
@ -159,6 +159,7 @@ rb_to_encoding_index(VALUE enc)
|
|||
return rb_enc_find_index(StringValueCStr(enc));
|
||||
}
|
||||
|
||||
/* Returns encoding index or UNSPECIFIED_ENCODING */
|
||||
static int
|
||||
str_to_encindex(VALUE enc)
|
||||
{
|
||||
|
@ -596,6 +597,7 @@ enc_autoload(rb_encoding *enc)
|
|||
return i;
|
||||
}
|
||||
|
||||
/* Return encoding index or UNSPECIFIED_ENCODING from encoding name */
|
||||
int
|
||||
rb_enc_find_index(const char *name)
|
||||
{
|
||||
|
@ -1051,9 +1053,12 @@ enc_list(VALUE klass)
|
|||
static VALUE
|
||||
enc_find(VALUE klass, VALUE enc)
|
||||
{
|
||||
int idx;
|
||||
if (!SPECIAL_CONST_P(enc) && BUILTIN_TYPE(enc) == T_DATA && is_data_encoding(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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue