Avoid evaluating skip_vt102_codes twice per escape

strip_vt102_codes() called skip_vt102_codes() once in the loop
condition and again in the body to advance, so every escape sequence
was classified twice. It runs on every incoming line (and on the whole
output buffer), so cache the returned length and reuse it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Jay Howard 2026-08-03 14:02:20 -05:00
parent 07969f5310
commit 7598404ef0

View file

@ -586,15 +586,16 @@ int find_secure_color_code(char *str)
int strip_vt102_codes(char *str, char *buf)
{
char *pti, *pto;
int skip;
pti = (char *) str;
pto = (char *) buf;
while (*pti)
{
while (skip_vt102_codes(pti))
while ((skip = skip_vt102_codes(pti)))
{
pti += skip_vt102_codes(pti);
pti += skip;
}
if (*pti)