Skip to content

Commit

Permalink
regexec.c: Use utf8_hop_safe() instead of rolling our own
Browse files Browse the repository at this point in the history
  • Loading branch information
khwilliamson committed Jul 9, 2023
1 parent 2599b98 commit b677f49
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions regexec.c
Expand Up @@ -11146,26 +11146,7 @@ S_reghop4(U8 *s, SSize_t off, const U8* llim, const U8* rlim)
{
PERL_ARGS_ASSERT_REGHOP4;

if (off >= 0) {
while (off-- && s < rlim) {
/* XXX could check well-formedness here */
s += UTF8SKIP(s);
}
}
else {
while (off++ && s > llim) {
s--;
if (UTF8_IS_CONTINUED(*s)) {
while (s > llim && UTF8_IS_CONTINUATION(*s))
s--;
if (! UTF8_IS_START(*s)) {
Perl_croak_nocontext("Malformed UTF-8 character (fatal)");
}
}
/* XXX could check well-formedness here */
}
}
return s;
return utf8_hop_safe(s, off, llim, rlim);
}

/* like reghop3, but returns NULL on overrun, rather than returning last
Expand Down

0 comments on commit b677f49

Please sign in to comment.