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

Taint flags has been deprecated in 3.1

This commit is contained in:
Nobuyoshi Nakada 2021-01-27 14:45:31 +09:00
parent a67afaaa05
commit b409a34b41
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6
4 changed files with 17 additions and 2 deletions

View file

@ -15,9 +15,12 @@ static VALUE object_spec_FL_ABLE(VALUE self, VALUE obj) {
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) {
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) {
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) {
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);

View file

@ -22,9 +22,11 @@ static const VALUE VISIBLE_BITS = FL_FREEZE | ~(FL_USER0 - 1);
#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) {
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);

View file

@ -22,6 +22,10 @@
(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

View file

@ -2,7 +2,7 @@ describe :rbasic, shared: true do
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