Skip to content

Commit

Permalink
pp.c: Use utf8_hop_back instead of rolling our own
Browse files Browse the repository at this point in the history
This is inlined, so shouldn't be any slower, and fixing bugs will be
done in a single place
  • Loading branch information
khwilliamson committed Jul 17, 2023
1 parent ef4802e commit a21a2dd
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions pp.c
Expand Up @@ -812,9 +812,7 @@ S_do_chomp(pTHX_ SV *retval, SV *sv, bool chomping)
if (s && len) {
char * const send = s + len;
char * const start = s;
s = send - 1;
while (s > start && UTF8_IS_CONTINUATION(*s))
s--;
s = (char *) utf8_hop_back((U8 *) send, -1, (U8 *) start);
if (is_utf8_string((U8*)s, send - s)) {
sv_setpvn(retval, s, send - s);
*s = '\0';
Expand Down

0 comments on commit a21a2dd

Please sign in to comment.