X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=dmenu.c;h=44b425441e0bb202ef242ab12c0df7a50f2d0c84;hb=51224dcb79aef90ff53c0d6edbd7233ca9ccdb26;hp=d0c63db313a62716f0c4530ad28887e40a13e371;hpb=c24f22a36bb986287f2b53116dff6479c434bc7d;p=dmenu.git diff --git a/dmenu.c b/dmenu.c index d0c63db..44b4254 100644 --- a/dmenu.c +++ b/dmenu.c @@ -1,6 +1,7 @@ /* See LICENSE file for copyright and license details. */ #define _BSD_SOURCE #include +#include #include #include #include @@ -78,7 +79,7 @@ static unsigned int mw, mh; static unsigned int numlockmask = 0; static Bool running = True; static Display *dpy; -static DC dc = {0}; +static DC dc; static Item *allitems = NULL; /* first of all items */ static Item *item = NULL; /* first of pattern matching items */ static Item *sel = NULL; @@ -299,9 +300,6 @@ initfont(const char *fontstr) { } } else { - if(dc.font.xfont) - XFreeFont(dpy, dc.font.xfont); - dc.font.xfont = NULL; if(!(dc.font.xfont = XLoadQueryFont(dpy, fontstr)) && !(dc.font.xfont = XLoadQueryFont(dpy, "fixed"))) eprint("error, cannot load font: '%s'\n", fontstr); @@ -398,10 +396,7 @@ kpress(XKeyEvent * e) { default: if(num && !iscntrl((int) buf[0])) { buf[num] = 0; - if(len > 0) - strncat(text, buf, sizeof text); - else - strncpy(text, buf, sizeof text); + strncpy(text + len, buf, sizeof text - len); match(text); } break; @@ -705,7 +700,7 @@ main(int argc, char *argv[]) { else eprint("usage: dmenu [-i] [-b] [-fn ] [-nb ] [-nf ]\n" " [-p ] [-sb ] [-sf ] [-v]\n"); - if(!XSupportsLocale()) + if(!setlocale(LC_CTYPE, "") || !XSupportsLocale()) fprintf(stderr, "warning: no locale support\n"); if(!(dpy = XOpenDisplay(0))) eprint("dmenu: cannot open display\n");