From 49dc12554e8abfa11b764da14c65b93c545b6243 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Mon, 29 Jul 2024 17:28:13 +0100 Subject: [PATCH 1/1] Debug: support printing strings with embedded NULs --- src/src/string.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/src/string.c b/src/src/string.c index 5583d93de..1ac837abe 100644 --- a/src/src/string.c +++ b/src/src/string.c @@ -1630,13 +1630,14 @@ while (*fp) { gstring * zg = NULL; int p = precision; - for ( ; *s; s++) - { - /* Take a given precision as applying to the input; expand - it for the transformed result */ - if (p >= 0 && --p < 0) break; - switch (*s) + /* If a precision was given, we can handle embedded NULs. Take it as + applying to the input and expand it for the transformed result */ + + for ( ; precision >= 0 || *s; s++) + if (p >= 0 && --p < 0) + break; + else switch (*s) { case ' ': zg = string_catn(zg, CUS UTF8_LIGHT_SHADE, 3); @@ -1658,7 +1659,6 @@ while (*fp) zg = string_catn(zg, CUS s, 1); break; } - } if (zg) { s = CS zg->s; slen = gstring_length(zg); } else { s = ""; slen = 0; } } -- 2.30.2