aboutsummaryrefslogtreecommitdiffstats
path: root/internal
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2023-08-24 18:32:46 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2023-08-26 08:58:02 +0900
commit00ac3a64ba57ecd8f10bf54f03297cdec0c538d6 (patch)
treedb4c230a17629f0e8996ffa01c300088a8305efe /internal
parentcfdbbd67268a77177e485263cdd8fb416315e9a6 (diff)
downloadruby-00ac3a64ba57ecd8f10bf54f03297cdec0c538d6.tar.gz
Introduce `at_char_boundary` function
Diffstat (limited to 'internal')
-rw-r--r--internal/string.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/internal/string.h b/internal/string.h
index 5f59d9621b..cfaf628e02 100644
--- a/internal/string.h
+++ b/internal/string.h
@@ -119,6 +119,12 @@ is_broken_string(VALUE str)
return rb_enc_str_coderange(str) == ENC_CODERANGE_BROKEN;
}
+static inline bool
+at_char_boundary(const char *s, const char *p, const char *e, rb_encoding *enc)
+{
+ return rb_enc_left_char_head(s, p, e, enc) == p;
+}
+
/* expect tail call optimization */
// YJIT needs this function to never allocate and never raise
static inline VALUE