ruby-changes:65062
From: Nobuyoshi <ko1@a...>
Date: Wed, 27 Jan 2021 14:46:17 +0900 (JST)
Subject: [ruby-changes:65062] b409a34b41 (master): Taint flags has been deprecated in 3.1
https://git.ruby-lang.org/ruby.git/commit/?id=b409a34b41 From b409a34b410e748553262cb4d0c9cc374746dfd8 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Wed, 27 Jan 2021 14:45:31 +0900 Subject: Taint flags has been deprecated in 3.1 --- spec/ruby/optional/capi/ext/object_spec.c | 9 ++++++++- spec/ruby/optional/capi/ext/rbasic_spec.c | 4 ++++ spec/ruby/optional/capi/ext/rubyspec.h | 4 ++++ spec/ruby/optional/capi/shared/rbasic.rb | 2 +- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/spec/ruby/optional/capi/ext/object_spec.c b/spec/ruby/optional/capi/ext/object_spec.c index fbdc199..59237e8 100644 --- a/spec/ruby/optional/capi/ext/object_spec.c +++ b/spec/ruby/optional/capi/ext/object_spec.c @@ -15,9 +15,12 @@ static VALUE object_spec_FL_ABLE(VALUE self, VALUE obj) { https://github.com/ruby/ruby/blob/trunk/spec/ruby/optional/capi/ext/object_spec.c#L15 static int object_spec_FL_TEST_flag(VALUE flag_string) { char *flag_cstr = StringValueCStr(flag_string); +#ifndef RUBY_VERSION_IS_3_1 if (strcmp(flag_cstr, "FL_TAINT") == 0) { return FL_TAINT; - } else if (strcmp(flag_cstr, "FL_FREEZE") == 0) { + } +#endif + if (strcmp(flag_cstr, "FL_FREEZE") == 0) { return FL_FREEZE; } return 0; @@ -27,6 +30,7 @@ static VALUE object_spec_FL_TEST(VALUE self, VALUE obj, VALUE flag) { https://github.com/ruby/ruby/blob/trunk/spec/ruby/optional/capi/ext/object_spec.c#L30 return INT2FIX(FL_TEST(obj, object_spec_FL_TEST_flag(flag))); } +#ifndef RUBY_VERSION_IS_3_1 static VALUE object_spec_OBJ_TAINT(VALUE self, VALUE obj) { OBJ_TAINT(obj); return Qnil; @@ -40,6 +44,7 @@ static VALUE object_spec_OBJ_INFECT(VALUE self, VALUE host, VALUE source) { https://github.com/ruby/ruby/blob/trunk/spec/ruby/optional/capi/ext/object_spec.c#L44 OBJ_INFECT(host, source); return Qnil; } +#endif static VALUE object_spec_rb_any_to_s(VALUE self, VALUE obj) { return rb_any_to_s(obj); @@ -388,9 +393,11 @@ void Init_object_spec(void) { https://github.com/ruby/ruby/blob/trunk/spec/ruby/optional/capi/ext/object_spec.c#L393 VALUE cls = rb_define_class("CApiObjectSpecs", rb_cObject); rb_define_method(cls, "FL_ABLE", object_spec_FL_ABLE, 1); rb_define_method(cls, "FL_TEST", object_spec_FL_TEST, 2); +#ifndef RUBY_VERSION_IS_3_1 rb_define_method(cls, "OBJ_TAINT", object_spec_OBJ_TAINT, 1); rb_define_method(cls, "OBJ_TAINTED", object_spec_OBJ_TAINTED, 1); rb_define_method(cls, "OBJ_INFECT", object_spec_OBJ_INFECT, 2); +#endif rb_define_method(cls, "rb_any_to_s", object_spec_rb_any_to_s, 1); rb_define_method(cls, "rb_attr_get", so_attr_get, 2); rb_define_method(cls, "rb_obj_instance_variables", object_spec_rb_obj_instance_variables, 1); diff --git a/spec/ruby/optional/capi/ext/rbasic_spec.c b/spec/ruby/optional/capi/ext/rbasic_spec.c index cf10904..6cd6c23 100644 --- a/spec/ruby/optional/capi/ext/rbasic_spec.c +++ b/spec/ruby/optional/capi/ext/rbasic_spec.c @@ -22,9 +22,11 @@ static const VALUE VISIBLE_BITS = FL_FREEZE | ~(FL_USER0 - 1); https://github.com/ruby/ruby/blob/trunk/spec/ruby/optional/capi/ext/rbasic_spec.c#L22 #endif +#ifndef RUBY_VERSION_IS_3_1 VALUE rbasic_spec_taint_flag(VALUE self) { return VALUE2NUM(RUBY_FL_TAINT); } +#endif VALUE rbasic_spec_freeze_flag(VALUE self) { return VALUE2NUM(RUBY_FL_FREEZE); @@ -75,7 +77,9 @@ VALUE rbasic_rdata_spec_get_klass(VALUE self, VALUE structure) { https://github.com/ruby/ruby/blob/trunk/spec/ruby/optional/capi/ext/rbasic_spec.c#L77 void Init_rbasic_spec(void) { VALUE cls = rb_define_class("CApiRBasicSpecs", rb_cObject); +#ifndef RUBY_VERSION_IS_3_1 rb_define_method(cls, "taint_flag", rbasic_spec_taint_flag, 0); +#endif rb_define_method(cls, "freeze_flag", rbasic_spec_freeze_flag, 0); rb_define_method(cls, "get_flags", rbasic_spec_get_flags, 1); rb_define_method(cls, "set_flags", rbasic_spec_set_flags, 2); diff --git a/spec/ruby/optional/capi/ext/rubyspec.h b/spec/ruby/optional/capi/ext/rubyspec.h index b4d604e..e614e32 100644 --- a/spec/ruby/optional/capi/ext/rubyspec.h +++ b/spec/ruby/optional/capi/ext/rubyspec.h @@ -22,6 +22,10 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/optional/capi/ext/rubyspec.h#L22 (RUBY_VERSION_MAJOR == (major) && RUBY_VERSION_MINOR < (minor)) || \ (RUBY_VERSION_MAJOR == (major) && RUBY_VERSION_MINOR == (minor) && RUBY_VERSION_TEENY < (teeny))) +#if RUBY_VERSION_MAJOR > 3 || (RUBY_VERSION_MAJOR == 3 && RUBY_VERSION_MINOR >= 1) +#define RUBY_VERSION_IS_3_1 +#endif + #if RUBY_VERSION_MAJOR > 3 || (RUBY_VERSION_MAJOR == 3 && RUBY_VERSION_MINOR >= 0) #define RUBY_VERSION_IS_3_0 #endif diff --git a/spec/ruby/optional/capi/shared/rbasic.rb b/spec/ruby/optional/capi/shared/rbasic.rb index f202b72..659cb07 100644 --- a/spec/ruby/optional/capi/shared/rbasic.rb +++ b/spec/ruby/optional/capi/shared/rbasic.rb @@ -2,7 +2,7 @@ describe :rbasic, shared: true do https://github.com/ruby/ruby/blob/trunk/spec/ruby/optional/capi/shared/rbasic.rb#L2 before :all do specs = CApiRBasicSpecs.new - @taint = specs.taint_flag + @taint = ruby_version_is(''...'3.1') ? specs.taint_flag : 0 @freeze = specs.freeze_flag end -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/