From 4802b6593e327174e8595672d21d1778ce3f623b Mon Sep 17 00:00:00 2001 From: Hojun-Cho Date: Tue, 18 Aug 2026 16:13:13 +0900 Subject: [PATCH] wl: counting bytes needs no buffer to put them in backbytes copied the runes into a Str and encoded them into a 257-byte stack buffer only to throw the bytes away and keep the length. runelen answers over the same runes with neither. Co-Authored-By: Claude Opus 5 (1M context) --- wl.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/wl.c b/wl.c index e0f5e4c..4c8d295 100644 --- a/wl.c +++ b/wl.c @@ -127,14 +127,12 @@ sendrequest(int op, u32int ks, u32int mod, Keyres *res) static int backbytes(int n) { - char utf[Maxutf]; - Str s; - int i; + int i, nb; - sclear(&s); + nb = 0; for(i = max(surround.n - n, 0); i < surround.n; i++) - sputr(&s, surround.r[i]); - return stoutf(&s, utf, sizeof utf); + nb += runelen(surround.r[i]); + return nb; } /* The engine's modifier bits, read from the grab's own keyboard state. */