mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Fixed symbol misused as ID
`rb_funcallv_public` and `rb_respond_to` require an `ID`, not a `Symbol`. [Bug #16649]
This commit is contained in:
parent
f8401732de
commit
8b6e2685a4
3 changed files with 13 additions and 4 deletions
|
@ -3954,6 +3954,7 @@ transcode.$(OBJEXT): {$(VPATH)}assert.h
|
|||
transcode.$(OBJEXT): {$(VPATH)}config.h
|
||||
transcode.$(OBJEXT): {$(VPATH)}defines.h
|
||||
transcode.$(OBJEXT): {$(VPATH)}encoding.h
|
||||
transcode.$(OBJEXT): {$(VPATH)}id.h
|
||||
transcode.$(OBJEXT): {$(VPATH)}intern.h
|
||||
transcode.$(OBJEXT): {$(VPATH)}internal.h
|
||||
transcode.$(OBJEXT): {$(VPATH)}missing.h
|
||||
|
|
|
@ -2183,6 +2183,14 @@ class TestTranscode < Test::Unit::TestCase
|
|||
assert_equal("U+3042", "\u{3042}".encode("US-ASCII", fallback: fallback.method(:escape)))
|
||||
end
|
||||
|
||||
def test_fallback_aref
|
||||
fallback = Object.new
|
||||
def fallback.[](x)
|
||||
"U+%.4X" % x.unpack("U")
|
||||
end
|
||||
assert_equal("U+3042", "\u{3042}".encode("US-ASCII", fallback: fallback))
|
||||
end
|
||||
|
||||
bug8940 = '[ruby-core:57318] [Bug #8940]'
|
||||
%w[UTF-32 UTF-16].each do |enc|
|
||||
define_method("test_pseudo_encoding_inspect(#{enc})") do
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "ruby/encoding.h"
|
||||
|
||||
#include "transcode_data.h"
|
||||
#include "id.h"
|
||||
|
||||
#define ENABLE_ECONV_NEWLINE_OPTION 1
|
||||
|
||||
|
@ -31,7 +32,7 @@ static VALUE rb_eConverterNotFoundError;
|
|||
|
||||
VALUE rb_cEncodingConverter;
|
||||
|
||||
static VALUE sym_invalid, sym_undef, sym_replace, sym_fallback, sym_aref;
|
||||
static VALUE sym_invalid, sym_undef, sym_replace, sym_fallback;
|
||||
static VALUE sym_xml, sym_text, sym_attr;
|
||||
static VALUE sym_universal_newline;
|
||||
static VALUE sym_crlf_newline;
|
||||
|
@ -2249,7 +2250,7 @@ method_fallback(VALUE fallback, VALUE c)
|
|||
static VALUE
|
||||
aref_fallback(VALUE fallback, VALUE c)
|
||||
{
|
||||
return rb_funcall3(fallback, sym_aref, 1, &c);
|
||||
return rb_funcallv_public(fallback, idAREF, 1, &c);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -2550,7 +2551,7 @@ rb_econv_prepare_options(VALUE opthash, VALUE *opts, int ecflags)
|
|||
if (!NIL_P(v)) {
|
||||
VALUE h = rb_check_hash_type(v);
|
||||
if (NIL_P(h)
|
||||
? (rb_obj_is_proc(v) || rb_obj_is_method(v) || rb_respond_to(v, sym_aref))
|
||||
? (rb_obj_is_proc(v) || rb_obj_is_method(v) || rb_respond_to(v, idAREF))
|
||||
: (v = h, 1)) {
|
||||
if (NIL_P(newhash))
|
||||
newhash = rb_hash_new();
|
||||
|
@ -4423,7 +4424,6 @@ Init_transcode(void)
|
|||
sym_undef = ID2SYM(rb_intern("undef"));
|
||||
sym_replace = ID2SYM(rb_intern("replace"));
|
||||
sym_fallback = ID2SYM(rb_intern("fallback"));
|
||||
sym_aref = ID2SYM(rb_intern("[]"));
|
||||
sym_xml = ID2SYM(rb_intern("xml"));
|
||||
sym_text = ID2SYM(rb_intern("text"));
|
||||
sym_attr = ID2SYM(rb_intern("attr"));
|
||||
|
|
Loading…
Reference in a new issue