applied Matthias Christian Ott's sanity fixes (thanks a lot!) a1ad9c2a
Anselm R Garbe · 2009-02-21 19:21 2 file(s) · +7 −8
config.mk +1 −1
19 19
LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 ${XINERAMALIBS}
20 20
21 21
# flags
22 -
CPPFLAGS = -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
22 +
CPPFLAGS = -D_BSD_SOURCE -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
23 23
CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS}
24 24
LDFLAGS = -s ${LIBS}
25 25
dmenu.c +6 −7
1 1
/* See LICENSE file for copyright and license details. */
2 -
#define _BSD_SOURCE
3 2
#include <ctype.h>
4 3
#include <locale.h>
5 4
#include <stdarg.h>
141 140
		do {
142 141
			do {
143 142
				if((csub = *s++) == 0)
144 -
					return (NULL);
143 +
					return NULL;
145 144
			}
146 145
			while(tolower(csub) != c);
147 146
		}
318 317
319 318
	len = strlen(text);
320 319
	buf[0] = 0;
321 -
	num = XLookupString(e, buf, sizeof buf, &ksym, 0);
320 +
	num = XLookupString(e, buf, sizeof buf, &ksym, NULL);
322 321
	if(IsKeypadKey(ksym)) {
323 322
		if(ksym == XK_KP_Enter)
324 323
			ksym = XK_Return;
534 533
			maxname = p;
535 534
			max = len;
536 535
		}
537 -
		if((new = (Item *)malloc(sizeof(Item))) == NULL)
536 +
		if(!(new = (Item *)malloc(sizeof(Item))))
538 537
			eprint("fatal: could not malloc() %u bytes\n", sizeof(Item));
539 538
		new->next = new->left = new->right = NULL;
540 539
		new->text = p;
593 592
	initfont(font);
594 593
595 594
	/* menu window */
596 -
	wa.override_redirect = 1;
595 +
	wa.override_redirect = True;
597 596
	wa.background_pixmap = ParentRelative;
598 597
	wa.event_mask = ExposureMask | ButtonPressMask | KeyPressMask;
599 598
631 630
632 631
	/* pixmap */
633 632
	dc.drawable = XCreatePixmap(dpy, root, mw, mh, DefaultDepth(dpy, screen));
634 -
	dc.gc = XCreateGC(dpy, root, 0, 0);
633 +
	dc.gc = XCreateGC(dpy, root, 0, NULL);
635 634
	XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
636 635
	if(!dc.font.set)
637 636
		XSetFont(dpy, dc.gc, dc.font.xfont->fid);
702 701
			       "             [-p <prompt>] [-sb <color>] [-sf <color>] [-v]\n");
703 702
	if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())
704 703
		fprintf(stderr, "warning: no locale support\n");
705 -
	if(!(dpy = XOpenDisplay(0)))
704 +
	if(!(dpy = XOpenDisplay(NULL)))
706 705
		eprint("dmenu: cannot open display\n");
707 706
	screen = DefaultScreen(dpy);
708 707
	root = RootWindow(dpy, screen);