aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-17 06:39:29 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-17 06:39:29 +0000
commit137d08de4b0bb809e13158911587e08605fe576e (patch)
tree5076445f82418943ada0f01b50f7eef909ebd85b /include
parent13b3abb227789ae6db0bf0a225e6c5db65b45f22 (diff)
downloadruby-137d08de4b0bb809e13158911587e08605fe576e.tar.gz
encoding.h: ENC_CODERANGE_CLEAN_P
* include/ruby/encoding.h (ENC_CODERANGE_CLEAN_P): predicate that tells if the coderange is clean, that is 7bit or valid, and no needs to scrub. * re.c (rb_reg_expr_str): use ENC_CODERANGE_CLEAN_P. * string.c (enc_strlen, rb_enc_cr_str_buf_cat, rb_str_scrub): ditto. * string.c (rb_str_enumerate_chars): ditto, and suppress a warning by gcc6. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'include')
-rw-r--r--include/ruby/encoding.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/ruby/encoding.h b/include/ruby/encoding.h
index 7d33e538de..5eaf468059 100644
--- a/include/ruby/encoding.h
+++ b/include/ruby/encoding.h
@@ -49,6 +49,12 @@ RUBY_SYMBOL_EXPORT_BEGIN
#define ENC_CODERANGE_7BIT ((int)FL_USER8)
#define ENC_CODERANGE_VALID ((int)FL_USER9)
#define ENC_CODERANGE_BROKEN ((int)(FL_USER8|FL_USER9))
+static inline int
+rb_enc_coderange_clean_p(int cr)
+{
+ return (cr ^ (cr >> 1)) & ENC_CODERANGE_7BIT;
+}
+#define ENC_CODERANGE_CLEAN_P(cr) rb_enc_coderange_clean_p(cr)
#define ENC_CODERANGE(obj) ((int)RBASIC(obj)->flags & ENC_CODERANGE_MASK)
#define ENC_CODERANGE_ASCIIONLY(obj) (ENC_CODERANGE(obj) == ENC_CODERANGE_7BIT)
#define ENC_CODERANGE_SET(obj,cr) (RBASIC(obj)->flags = \