From 2703953ca6763176932dee45674f59f76db22262 Mon Sep 17 00:00:00 2001 From: usa Date: Fri, 25 Mar 2016 08:13:18 +0000 Subject: merge revision(s) 49096,51353,53168,53169: [Backport #11834] test_m17n.rb: split test_scrub * test/ruby/test_m17n.rb (TestM17N#test_scrub): split into some tests. * include/ruby/ruby.h: add raw FL macros, which assume always the argument object is not a special constant. * internal.h (STR_EMBED_P, STR_SHARED_P): valid only for T_STRING. * string.c: deal with taint flags directly across String instances. * transcode.c (rb_econv_substr_append, econv_primitive_convert): the result should be infected by the original string. * string.c (rb_str_scrub): the result should be infected by the original string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@54260 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- include/ruby/ruby.h | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'include/ruby') diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index 95965d6b6a..0bf3567c29 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -1167,19 +1167,27 @@ struct RBignum { #define FL_ABLE(x) (!SPECIAL_CONST_P(x) && BUILTIN_TYPE(x) != T_NODE) #define FL_TEST_RAW(x,f) (RBASIC(x)->flags&(f)) #define FL_TEST(x,f) (FL_ABLE(x)?FL_TEST_RAW((x),(f)):0) +#define FL_ANY_RAW(x,f) FL_TEST_RAW((x),(f)) #define FL_ANY(x,f) FL_TEST((x),(f)) +#define FL_ALL_RAW(x,f) (FL_TEST_RAW((x),(f)) == (f)) #define FL_ALL(x,f) (FL_TEST((x),(f)) == (f)) -#define FL_SET(x,f) do {if (FL_ABLE(x)) RBASIC(x)->flags |= (f);} while (0) -#define FL_UNSET(x,f) do {if (FL_ABLE(x)) RBASIC(x)->flags &= ~(f);} while (0) -#define FL_REVERSE(x,f) do {if (FL_ABLE(x)) RBASIC(x)->flags ^= (f);} while (0) - +#define FL_SET_RAW(x,f) (RBASIC(x)->flags |= (f)) +#define FL_SET(x,f) (FL_ABLE(x) ? FL_SET_RAW(x, f) : 0) +#define FL_UNSET_RAW(x,f) (RBASIC(x)->flags &= ~(f)) +#define FL_UNSET(x,f) (FL_ABLE(x) ? FL_UNSET_RAW(x, f) : 0) +#define FL_REVERSE_RAW(x,f) (RBASIC(x)->flags ^= (f)) +#define FL_REVERSE(x,f) (FL_ABLE(x) ? FL_REVERSE_RAW(x, f) : 0) + +#define OBJ_TAINTED_RAW(x) FL_TEST_RAW(x, FL_TAINT) #define OBJ_TAINTED(x) (!!FL_TEST((x), FL_TAINT)) +#define OBJ_TAINT_RAW(x) FL_SET_RAW(x, FL_TAINT) #define OBJ_TAINT(x) FL_SET((x), FL_TAINT) #define OBJ_UNTRUSTED(x) OBJ_TAINTED(x) #define OBJ_UNTRUST(x) OBJ_TAINT(x) +#define OBJ_INFECT_RAW(x,s) FL_SET_RAW(x, OBJ_TAINTED_RAW(s)) #define OBJ_INFECT(x,s) do { \ if (FL_ABLE(x) && FL_ABLE(s)) \ - RBASIC(x)->flags |= RBASIC(s)->flags & FL_TAINT; \ + FL_SET_RAW(x, OBJ_TAINTED_RAW(s)); \ } while (0) #define OBJ_FROZEN(x) (!!(FL_ABLE(x)?(RBASIC(x)->flags&(FL_FREEZE)):(FIXNUM_P(x)||FLONUM_P(x)||SYMBOL_P(x)))) -- cgit v1.2.3