aboutsummaryrefslogtreecommitdiffstats
path: root/include/ruby/encoding.h
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
commitda6997ef13787ca3677e2413fd3bbf0553c057f6 (patch)
tree5076445f82418943ada0f01b50f7eef909ebd85b /include/ruby/encoding.h
parentcc4c9a2f43e1cf80328fa720f4c3401e07f61b57 (diff)
downloadruby-da6997ef13787ca3677e2413fd3bbf0553c057f6.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/ruby/encoding.h')
-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 = \