From e0671a48bd19bf59030c2b9bdb8fd8c2d19a6795 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Thu, 22 Oct 2026 11:41:57 -0500 Subject: [PATCH] Don't print escapes when measuring string. Reported by karolkulesza on microsoft copilot/github. --- lib/utf8.c | 2 +- tests/fmt.test | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/utf8.c b/lib/utf8.c index d37812cc..b25cfcf7 100644 --- a/lib/utf8.c +++ b/lib/utf8.c @@ -74,7 +74,7 @@ int draw_str(char *start, int width) // Return utf8 columns int utf8len(char *str) { - return crunch_str(&str, INT_MAX, 0, 0, crunch_rev_escape); + return crunch_str(&str, INT_MAX, 0, 0, crunch_escape); } // Return bytes used by (up to) this many columns diff --git a/tests/fmt.test b/tests/fmt.test index 7be2e4e7..b84f76ac 100755 --- a/tests/fmt.test +++ b/tests/fmt.test @@ -30,5 +30,6 @@ testing "matched tab indent" "fmt" "\thello world\n" "" "\thello\n\tworld" toyonly testing "matched tab/space" "fmt" ' hello world\n' "" \ " hello\n\tworld" testing "matched space/tab" "fmt" "\thello world\n" "" "\thello\n world" +testing "nonprintable" "fmt" "a\001b\n" "" "a\001b\n" rm en.txt kr.txt -- 2.39.5