Xinqi Bao's Git
projects
/
dmenu.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
no exe should be unquoted, agreed to Peter Hartlich
[dmenu.git]
/
dmenu.c
diff --git
a/dmenu.c
b/dmenu.c
index
5191a20
..
3d3a928
100644
(file)
--- a/
dmenu.c
+++ b/
dmenu.c
@@
-1,5
+1,6
@@
/* See LICENSE file for copyright and license details. */
#include <ctype.h>
/* See LICENSE file for copyright and license details. */
#include <ctype.h>
+#include <limits.h>
#include <locale.h>
#include <stdarg.h>
#include <stdlib.h>
#include <locale.h>
#include <stdarg.h>
#include <stdlib.h>
@@
-76,7
+77,6
@@
int ret = 0;
unsigned int cmdw = 0;
unsigned int mw, mh;
unsigned int promptw = 0;
unsigned int cmdw = 0;
unsigned int mw, mh;
unsigned int promptw = 0;
-unsigned int nitem = 0;
unsigned int numlockmask = 0;
Bool running = True;
Display *dpy;
unsigned int numlockmask = 0;
Bool running = True;
Display *dpy;
@@
-296,7
+296,7
@@
grabkeyboard(void) {
for(len = 1000; len; len--) {
if(XGrabKeyboard(dpy, root, True, GrabModeAsync, GrabModeAsync, CurrentTime)
for(len = 1000; len; len--) {
if(XGrabKeyboard(dpy, root, True, GrabModeAsync, GrabModeAsync, CurrentTime)
-
== GrabSuccess)
+ == GrabSuccess)
break;
usleep(1000);
}
break;
usleep(1000);
}
@@
-354,16
+354,14
@@
kpress(XKeyEvent * e) {
len = strlen(text);
buf[0] = 0;
num = XLookupString(e, buf, sizeof buf, &ksym, 0);
len = strlen(text);
buf[0] = 0;
num = XLookupString(e, buf, sizeof buf, &ksym, 0);
- if(IsKeypadKey(ksym))
{
- if(ksym == XK_KP_Enter)
{
+ if(IsKeypadKey(ksym))
+ if(ksym == XK_KP_Enter)
ksym = XK_Return;
ksym = XK_Return;
- } else if(ksym >= XK_KP_0 && ksym <= XK_KP_9) {
+ else if(ksym >= XK_KP_0 && ksym <= XK_KP_9)
ksym = (ksym - XK_KP_0) + XK_0;
ksym = (ksym - XK_KP_0) + XK_0;
- }
- }
if(IsFunctionKey(ksym) || IsKeypadKey(ksym)
if(IsFunctionKey(ksym) || IsKeypadKey(ksym)
-
|| IsMiscFunctionKey(ksym) || IsPFKey(ksym)
-
|| IsPrivateKeypadKey(ksym))
+ || IsMiscFunctionKey(ksym) || IsPFKey(ksym)
+ || IsPrivateKeypadKey(ksym))
return;
/* first check if a control mask is omitted */
if(e->state & ControlMask) {
return;
/* first check if a control mask is omitted */
if(e->state & ControlMask) {
@@
-524,27
+522,20
@@
match(char *pattern) {
return;
plen = strlen(pattern);
item = lexact = lprefix = lsubstr = itemend = exactend = prefixend = substrend = NULL;
return;
plen = strlen(pattern);
item = lexact = lprefix = lsubstr = itemend = exactend = prefixend = substrend = NULL;
- nitem = 0;
for(i = allitems; i; i = i->next)
for(i = allitems; i; i = i->next)
- if(!fstrncmp(pattern, i->text, plen + 1))
{
+ if(!fstrncmp(pattern, i->text, plen + 1))
appenditem(i, &lexact, &exactend);
appenditem(i, &lexact, &exactend);
- nitem++;
- }
- else if(!fstrncmp(pattern, i->text, plen)) {
+ else if(!fstrncmp(pattern, i->text, plen))
appenditem(i, &lprefix, &prefixend);
appenditem(i, &lprefix, &prefixend);
- nitem++;
- }
- else if(fstrstr(i->text, pattern)) {
+ else if(fstrstr(i->text, pattern))
appenditem(i, &lsubstr, &substrend);
appenditem(i, &lsubstr, &substrend);
- nitem++;
- }
if(lexact) {
item = lexact;
itemend = exactend;
}
if(lprefix) {
if(itemend) {
if(lexact) {
item = lexact;
itemend = exactend;
}
if(lprefix) {
if(itemend) {
- itemend->right
-
lprefix;
+ itemend->right
=
lprefix;
lprefix->left = itemend;
}
else
lprefix->left = itemend;
}
else
@@
-639,7
+630,7
@@
setup(int x, int y, int w) {
mw = w ? w : DisplayWidth(dpy, screen);
mh = dc.font.height + 2;
if(y < 0) {
mw = w ? w : DisplayWidth(dpy, screen);
mh = dc.font.height + 2;
if(y < 0) {
- if(y ==
(int)(unsigned int)-1
)
+ if(y ==
INT_MIN
)
y = DisplayHeight(dpy, screen) - mh;
else
y = (-1 * y) - mh;
y = DisplayHeight(dpy, screen) - mh;
else
y = (-1 * y) - mh;
@@
-717,12
+708,11
@@
main(int argc, char *argv[]) {
if(++i < argc) x = atoi(argv[i]);
}
else if(!strcmp(argv[i], "-y")) {
if(++i < argc) x = atoi(argv[i]);
}
else if(!strcmp(argv[i], "-y")) {
- if(++i < argc)
{
+ if(++i < argc)
if(!strcmp(argv[i], "-0"))
if(!strcmp(argv[i], "-0"))
- y =
(int)(unsigned int)-1
;
+ y =
INT_MIN
;
else
y = atoi(argv[i]);
else
y = atoi(argv[i]);
- }
}
else if(!strcmp(argv[i], "-w")) {
if(++i < argc) w = atoi(argv[i]);
}
else if(!strcmp(argv[i], "-w")) {
if(++i < argc) w = atoi(argv[i]);