aboutsummarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Edgar2013-10-05 11:45:17 +0200
committerRoberto E. Vargas Caballero2013-10-07 20:56:51 +0200
commit754cf607eaee6426f10bf89125fdad076a65f294 (patch)
tree4d4f711361b06bf3ec5223b5e1d992e6649abef9
parent6afa2e4fa7086de07ace44a88122eebf4af88da9 (diff)
downloadaur-754cf607eaee6426f10bf89125fdad076a65f294.tar.gz
Simplify Mod1 logic in kpress(), eliminating locals and a memcpy.
-rw-r--r--st.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/st.c b/st.c
index 77ea0c8e9b74..331509fdb683 100644
--- a/st.c
+++ b/st.c
@@ -3563,8 +3563,8 @@ void
kpress(XEvent *ev) {
XKeyEvent *e = &ev->xkey;
KeySym ksym;
- char xstr[31], buf[32], *customkey, *cp = buf;
- int len, ret;
+ char buf[32], *customkey;
+ int len;
long c;
Status status;
Shortcut *bp;
@@ -3572,7 +3572,7 @@ kpress(XEvent *ev) {
if(IS_SET(MODE_KBDLOCK))
return;
- len = XmbLookupString(xw.xic, e, xstr, sizeof(xstr), &ksym, &status);
+ len = XmbLookupString(xw.xic, e, buf, sizeof buf, &ksym, &status);
e->state &= ~Mod2Mask;
/* 1. shortcuts */
for(bp = shortcuts; bp < shortcuts + LEN(shortcuts); bp++) {
@@ -3586,26 +3586,23 @@ kpress(XEvent *ev) {
if((customkey = kmap(ksym, e->state))) {
len = strlen(customkey);
memcpy(buf, customkey, len);
- /* 3. hardcoded (overrides X lookup) */
+ /* 3. composed string from input method */
} else {
if(len == 0)
return;
if(len == 1 && e->state & Mod1Mask) {
if(IS_SET(MODE_8BIT)) {
- if(*xstr < 0177) {
- c = *xstr | 0x80;
- ret = utf8encode(&c, cp);
- cp += ret;
- len = 0;
+ if(*buf < 0177) {
+ c = *buf | 0x80;
+ len = utf8encode(&c, buf);
}
} else {
- *cp++ = '\033';
+ buf[1] = buf[0];
+ buf[0] = '\033';
+ len = 2;
}
}
-
- memcpy(cp, xstr, len);
- len = cp - buf + len;
}
ttywrite(buf, len);