summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorKOBAYASHI Shuji <[email protected]>2019-06-25 22:58:21 +0900
committerKOBAYASHI Shuji <[email protected]>2019-06-25 23:09:23 +0900
commit75df13a97334c162b2cf743c3e37c4933a4b0d1c (patch)
tree60968fa95933371218ab05d2493bd78d579e8445 /include
parentcb3ee2d0501612f406e2d44b1e6d55b18861b1e1 (diff)
downloadmruby-75df13a97334c162b2cf743c3e37c4933a4b0d1c.tar.gz
mruby-75df13a97334c162b2cf743c3e37c4933a4b0d1c.zip
Fix `String#byteslice` with `MRB_UTF8_STRING` and some edge cases
Example: $ bin/mruby -e ' p "あa".byteslice(1) p "bar".byteslice(3) p "bar".byteslice(4..0) ' Before this patch: "a" "" RangeError (4..0 out of range) After this patch (same as Ruby): "\x81" nil nil
Diffstat (limited to 'include')
-rw-r--r--include/mruby/string.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/mruby/string.h b/include/mruby/string.h
index 22445f654..b563541cb 100644
--- a/include/mruby/string.h
+++ b/include/mruby/string.h
@@ -438,6 +438,9 @@ mrb_value mrb_str_inspect(mrb_state *mrb, mrb_value str);
#define mrb_str_buf_cat(mrb, str, ptr, len) mrb_str_cat(mrb, str, ptr, len)
#define mrb_str_buf_append(mrb, str, str2) mrb_str_cat_str(mrb, str, str2)
+mrb_bool mrb_str_beg_len(mrb_int str_len, mrb_int *begp, mrb_int *lenp);
+mrb_value mrb_str_byte_subseq(mrb_state *mrb, mrb_value str, mrb_int beg, mrb_int len);
+
#ifdef MRB_UTF8_STRING
mrb_int mrb_utf8_len(const char *str, mrb_int byte_len);
#endif