Xinqi Bao's Git
projects
/
dmenu.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
Added tag 4.0 for changeset 78f9f72cc9c6
[dmenu.git]
/
dmenu.c
diff --git
a/dmenu.c
b/dmenu.c
index
18f2a56
..
0f95af6
100644
(file)
--- a/
dmenu.c
+++ b/
dmenu.c
@@
-1,5
+1,4
@@
/* See LICENSE file for copyright and license details. */
/* See LICENSE file for copyright and license details. */
-#define _BSD_SOURCE
#include <ctype.h>
#include <locale.h>
#include <stdarg.h>
#include <ctype.h>
#include <locale.h>
#include <stdarg.h>
@@
-79,7
+78,7
@@
static unsigned int mw, mh;
static unsigned int numlockmask = 0;
static Bool running = True;
static Display *dpy;
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;
static Item *allitems = NULL; /* first of all items */
static Item *item = NULL; /* first of pattern matching items */
static Item *sel = NULL;
@@
-141,7
+140,7
@@
cistrstr(const char *s, const char *sub) {
do {
do {
if((csub = *s++) == 0)
do {
do {
if((csub = *s++) == 0)
- return
(NULL)
;
+ return
NULL
;
}
while(tolower(csub) != c);
}
}
while(tolower(csub) != c);
}
@@
-300,9
+299,6
@@
initfont(const char *fontstr) {
}
}
else {
}
}
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);
if(!(dc.font.xfont = XLoadQueryFont(dpy, fontstr))
&& !(dc.font.xfont = XLoadQueryFont(dpy, "fixed")))
eprint("error, cannot load font: '%s'\n", fontstr);
@@
-321,7
+317,7
@@
kpress(XKeyEvent * e) {
len = strlen(text);
buf[0] = 0;
len = strlen(text);
buf[0] = 0;
- num = XLookupString(e, buf, sizeof buf, &ksym,
0
);
+ num = XLookupString(e, buf, sizeof buf, &ksym,
NULL
);
if(IsKeypadKey(ksym)) {
if(ksym == XK_KP_Enter)
ksym = XK_Return;
if(IsKeypadKey(ksym)) {
if(ksym == XK_KP_Enter)
ksym = XK_Return;
@@
-399,10
+395,7
@@
kpress(XKeyEvent * e) {
default:
if(num && !iscntrl((int) buf[0])) {
buf[num] = 0;
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;
match(text);
}
break;
@@
-540,7
+533,7
@@
readstdin(void) {
maxname = p;
max = len;
}
maxname = p;
max = len;
}
- if(
(new = (Item *)malloc(sizeof(Item))) == NULL
)
+ if(
!(new = (Item *)malloc(sizeof(Item)))
)
eprint("fatal: could not malloc() %u bytes\n", sizeof(Item));
new->next = new->left = new->right = NULL;
new->text = p;
eprint("fatal: could not malloc() %u bytes\n", sizeof(Item));
new->next = new->left = new->right = NULL;
new->text = p;
@@
-599,7
+592,7
@@
setup(Bool topbar) {
initfont(font);
/* menu window */
initfont(font);
/* menu window */
- wa.override_redirect =
1
;
+ wa.override_redirect =
True
;
wa.background_pixmap = ParentRelative;
wa.event_mask = ExposureMask | ButtonPressMask | KeyPressMask;
wa.background_pixmap = ParentRelative;
wa.event_mask = ExposureMask | ButtonPressMask | KeyPressMask;
@@
-637,7
+630,7
@@
setup(Bool topbar) {
/* pixmap */
dc.drawable = XCreatePixmap(dpy, root, mw, mh, DefaultDepth(dpy, screen));
/* pixmap */
dc.drawable = XCreatePixmap(dpy, root, mw, mh, DefaultDepth(dpy, screen));
- dc.gc = XCreateGC(dpy, root, 0,
0
);
+ dc.gc = XCreateGC(dpy, root, 0,
NULL
);
XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
if(!dc.font.set)
XSetFont(dpy, dc.gc, dc.font.xfont->fid);
XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
if(!dc.font.set)
XSetFont(dpy, dc.gc, dc.font.xfont->fid);
@@
-708,7
+701,7
@@
main(int argc, char *argv[]) {
" [-p <prompt>] [-sb <color>] [-sf <color>] [-v]\n");
if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())
fprintf(stderr, "warning: no locale support\n");
" [-p <prompt>] [-sb <color>] [-sf <color>] [-v]\n");
if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())
fprintf(stderr, "warning: no locale support\n");
- if(!(dpy = XOpenDisplay(
0
)))
+ if(!(dpy = XOpenDisplay(
NULL
)))
eprint("dmenu: cannot open display\n");
screen = DefaultScreen(dpy);
root = RootWindow(dpy, screen);
eprint("dmenu: cannot open display\n");
screen = DefaultScreen(dpy);
root = RootWindow(dpy, screen);