Skip to content

Commit

Permalink
Fix rb_enc_left_char_head()
Browse files Browse the repository at this point in the history
* Fixes #3267
  • Loading branch information
eregon committed Sep 20, 2023
1 parent 124a255 commit 4d17ba4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ New features:

Bug fixes:

* Fix `rb_enc_left_char_head()` so it is not always `ArgumentError` (#3267, @eregon).

Compatibility:

Expand Down
2 changes: 1 addition & 1 deletion lib/cext/ABI_check.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4
5
5 changes: 4 additions & 1 deletion src/main/c/cext/encoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,10 @@ int rb_enc_get_index(VALUE obj) {
}

char* rb_enc_left_char_head(const char *start, const char *p, const char *end, rb_encoding *enc) {
int length = start - end;
if (p <= start || p >= end) {
return p;
}
int length = end - start;
int position = polyglot_as_i32(polyglot_invoke(RUBY_CEXT, "rb_enc_left_char_head",
rb_tr_unwrap(rb_enc_from_encoding(enc)),
rb_tr_unwrap(rb_str_new(start, length)),
Expand Down

0 comments on commit 4d17ba4

Please sign in to comment.