diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-08-24 18:32:46 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-08-26 08:58:02 +0900 |
commit | 00ac3a64ba57ecd8f10bf54f03297cdec0c538d6 (patch) | |
tree | db4c230a17629f0e8996ffa01c300088a8305efe /internal | |
parent | cfdbbd67268a77177e485263cdd8fb416315e9a6 (diff) |
Introduce `at_char_boundary` function
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/8296
Diffstat (limited to 'internal')
-rw-r--r-- | internal/string.h | 6 |
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 |