test: a key passed through is not committed text

A Korean Enter commits the syllable and lets the key on, so xim.c sends
the commit and then forwards the key.  pumpinput took the text of either
and kept the last, so under load the Return's own carriage return
overwrote 가: 22 of 25 runs failed on a loaded machine and none on an
idle one.  An XIM commit arrives as XLookupChars; a forwarded key comes
back as XLookupBoth, and is not a commit.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-17 18:38:12 +09:00
parent f6477cb97d
commit 27180bc0fe

View File

@@ -129,10 +129,10 @@ pumpinput(Display *dpy, XIC ic, char *commit, size_t cap, int timeout)
continue; continue;
n = Xutf8LookupString(ic, &ev.xkey, buf, sizeof buf - 1, n = Xutf8LookupString(ic, &ev.xkey, buf, sizeof buf - 1,
&sym, &status); &sym, &status);
if(n < 0 || ((status == XLookupChars || status == XLookupBoth) && if(n < 0 || (status == XLookupChars &&
((size_t)n >= cap || commit == NULL))) ((size_t)n >= cap || commit == NULL)))
return 0; return 0;
if((status == XLookupChars || status == XLookupBoth) && n != 0){ if(status == XLookupChars && n != 0){
memcpy(commit, buf, n); memcpy(commit, buf, n);
commit[n] = '\0'; commit[n] = '\0';
} }
@@ -273,7 +273,7 @@ sendkey(Display *dpy, XIC ic, Window win, KeySym sym, unsigned int state,
if(n < 0) if(n < 0)
return fail("Xutf8LookupString failed for keysym %#lx", return fail("Xutf8LookupString failed for keysym %#lx",
(unsigned long)sym); (unsigned long)sym);
if((status == XLookupChars || status == XLookupBoth) && n != 0){ if(status == XLookupChars && n != 0){
if((size_t)n >= cap) if((size_t)n >= cap)
return fail("commit buffer overflow"); return fail("commit buffer overflow");
memcpy(commit, buf, n); memcpy(commit, buf, n);