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) <noreply@anthropic.com>
This commit is contained in:
2026-08-18 16:13:13 +09:00
parent ba0a08abe2
commit 4802b6593e

10
wl.c
View File

@@ -127,14 +127,12 @@ sendrequest(int op, u32int ks, u32int mod, Keyres *res)
static int static int
backbytes(int n) backbytes(int n)
{ {
char utf[Maxutf]; int i, nb;
Str s;
int i;
sclear(&s); nb = 0;
for(i = max(surround.n - n, 0); i < surround.n; i++) for(i = max(surround.n - n, 0); i < surround.n; i++)
sputr(&s, surround.r[i]); nb += runelen(surround.r[i]);
return stoutf(&s, utf, sizeof utf); return nb;
} }
/* The engine's modifier bits, read from the grab's own keyboard state. */ /* The engine's modifier bits, read from the grab's own keyboard state. */