From a21a2dda119c764ed17277d02fcc79e8e7a0a025 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Sun, 10 Jul 2022 11:12:15 -0600 Subject: [PATCH] pp.c: Use utf8_hop_back instead of rolling our own This is inlined, so shouldn't be any slower, and fixing bugs will be done in a single place --- pp.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pp.c b/pp.c index dd47b7330ace..51c60dd5fd94 100644 --- a/pp.c +++ b/pp.c @@ -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';