зеркало из https://github.com/github/ruby.git
Revert "encoding.c (rb_enc_get_index): return -1 for non-encoding capable objects"
* This reverts commit fb253d2032
.
* The CI is failing, this seems a bug in the JSON C extension.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64174 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
fb253d2032
Коммит
bd58361e58
18
encoding.c
18
encoding.c
|
@ -793,26 +793,24 @@ rb_enc_get_index(VALUE obj)
|
|||
obj = rb_sym2str(obj);
|
||||
}
|
||||
switch (BUILTIN_TYPE(obj)) {
|
||||
as_default:
|
||||
default:
|
||||
case T_STRING:
|
||||
case T_SYMBOL:
|
||||
case T_REGEXP:
|
||||
i = enc_get_index_str(obj);
|
||||
break;
|
||||
case T_FILE:
|
||||
tmp = rb_funcallv(obj, rb_intern("internal_encoding"), 0, 0);
|
||||
if (NIL_P(tmp)) {
|
||||
tmp = rb_funcallv(obj, rb_intern("external_encoding"), 0, 0);
|
||||
}
|
||||
if (is_data_encoding(tmp)) {
|
||||
i = enc_check_encoding(tmp);
|
||||
}
|
||||
break;
|
||||
if (NIL_P(tmp)) obj = rb_funcallv(obj, rb_intern("external_encoding"), 0, 0);
|
||||
else obj = tmp;
|
||||
if (NIL_P(obj)) break;
|
||||
case T_DATA:
|
||||
if (is_data_encoding(obj)) {
|
||||
i = enc_check_encoding(obj);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
else {
|
||||
goto as_default;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return i;
|
||||
|
|
|
@ -147,11 +147,6 @@ describe "C-API Encoding function" do
|
|||
it "returns -1 as the index for immediates" do
|
||||
@s.send(@method, 1).should == -1
|
||||
end
|
||||
|
||||
it "returns -1 for an object without an encoding" do
|
||||
obj = Object.new
|
||||
@s.send(@method, obj).should == -1
|
||||
end
|
||||
end
|
||||
|
||||
describe "rb_enc_set_index" do
|
||||
|
|
Загрузка…
Ссылка в новой задаче