aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConnor Lane Smith <cls@lubutu.com>2010-04-07 16:15:34 +0000
committerConnor Lane Smith <cls@lubutu.com>2010-04-07 16:15:34 +0000
commite3623cd7f24af660ef2b8cce89a232495d654237 (patch)
tree28f23d4127c1f3c1fd5f9bdeda872456f238697f
parent0ba3bae98196ec8a0887f494cb8a2dd5b645f763 (diff)
fixed 3 bugs and some inconsistency
-rw-r--r--dmenu.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/dmenu.c b/dmenu.c
index fbbfac0..15a6152 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -159,12 +159,12 @@ cistrstr(const char *s, const char *sub) {
159 159
160 if(!sub) 160 if(!sub)
161 return (char *)s; 161 return (char *)s;
162 if((c = *sub++) != 0) { 162 if((c = *sub++) != '\0') {
163 c = tolower(c); 163 c = tolower(c);
164 len = strlen(sub); 164 len = strlen(sub);
165 do { 165 do {
166 do { 166 do {
167 if((csub = *s++) == 0) 167 if((csub = *s++) == '\0')
168 return NULL; 168 return NULL;
169 } 169 }
170 while(tolower(csub) != c); 170 while(tolower(csub) != c);
@@ -220,7 +220,7 @@ drawmenu(void) {
220 dc.x += promptw; 220 dc.x += promptw;
221 dc.w = mw - promptw; 221 dc.w = mw - promptw;
222 /* print command */ 222 /* print command */
223 if(cmdw && item) 223 if(cmdw && item && !vlist)
224 dc.w = cmdw; 224 dc.w = cmdw;
225 drawtext(text[0] ? text : NULL, dc.norm); 225 drawtext(text[0] ? text : NULL, dc.norm);
226 drawcursor(); 226 drawcursor();
@@ -371,7 +371,7 @@ kpress(XKeyEvent * e) {
371 KeySym ksym; 371 KeySym ksym;
372 372
373 len = strlen(text); 373 len = strlen(text);
374 buf[0] = 0; 374 buf[0] = '\0';
375 num = XLookupString(e, buf, sizeof buf, &ksym, NULL); 375 num = XLookupString(e, buf, sizeof buf, &ksym, NULL);
376 if(IsKeypadKey(ksym)) { 376 if(IsKeypadKey(ksym)) {
377 if(ksym == XK_KP_Enter) 377 if(ksym == XK_KP_Enter)
@@ -414,7 +414,8 @@ kpress(XKeyEvent * e) {
414 break; 414 break;
415 case XK_u: 415 case XK_u:
416 case XK_U: 416 case XK_U:
417 text[0] = 0; 417 cursor = 0;
418 text[0] = '\0';
418 match(text); 419 match(text);
419 break; 420 break;
420 case XK_w: 421 case XK_w:
@@ -626,7 +627,7 @@ readstdin(void) {
626 buf[--len] = '\0'; 627 buf[--len] = '\0';
627 if(!(p = strdup(buf))) 628 if(!(p = strdup(buf)))
628 eprint("fatal: could not strdup() %u bytes\n", len); 629 eprint("fatal: could not strdup() %u bytes\n", len);
629 if(max < len) { 630 if(max < len || !maxname) {
630 maxname = p; 631 maxname = p;
631 max = len; 632 max = len;
632 } 633 }
@@ -740,7 +741,7 @@ setup(Bool topbar) {
740 cmdw = MIN(textw(maxname), mw / 3); 741 cmdw = MIN(textw(maxname), mw / 3);
741 if(prompt) 742 if(prompt)
742 promptw = MIN(textw(prompt), mw / 5); 743 promptw = MIN(textw(prompt), mw / 5);
743 text[0] = 0; 744 text[0] = '\0';
744 match(text); 745 match(text);
745 XMapRaised(dpy, win); 746 XMapRaised(dpy, win);
746} 747}