diff options
-rw-r--r-- | dmenu.c | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -38,7 +38,7 @@ static void setup(void); | |||
38 | 38 | ||
39 | static char text[BUFSIZ] = ""; | 39 | static char text[BUFSIZ] = ""; |
40 | static int bh, mw, mh; | 40 | static int bh, mw, mh; |
41 | static int inputw = 0; | 41 | static int inputw; |
42 | static int lines = 0; | 42 | static int lines = 0; |
43 | static int monitor = -1; | 43 | static int monitor = -1; |
44 | static int promptw; | 44 | static int promptw; |
@@ -78,7 +78,7 @@ main(int argc, char *argv[]) { | |||
78 | fast = True; | 78 | fast = True; |
79 | else if(!strcmp(argv[i], "-i")) | 79 | else if(!strcmp(argv[i], "-i")) |
80 | fstrncmp = strncasecmp; | 80 | fstrncmp = strncasecmp; |
81 | else if(i == argc-1) | 81 | else if(i+1 == argc) |
82 | goto usage; | 82 | goto usage; |
83 | /* double flags */ | 83 | /* double flags */ |
84 | else if(!strcmp(argv[i], "-l")) | 84 | else if(!strcmp(argv[i], "-l")) |
@@ -220,9 +220,9 @@ void | |||
220 | insert(const char *s, ssize_t n) { | 220 | insert(const char *s, ssize_t n) { |
221 | if(strlen(text) + n > sizeof text - 1) | 221 | if(strlen(text) + n > sizeof text - 1) |
222 | return; | 222 | return; |
223 | memmove(text + cursor + n, text + cursor, sizeof text - cursor - MAX(n, 0)); | 223 | memmove(&text[cursor + n], &text[cursor], sizeof text - cursor - MAX(n, 0)); |
224 | if(n > 0) | 224 | if(n > 0) |
225 | memcpy(text + cursor, s, n); | 225 | memcpy(&text[cursor], s, n); |
226 | cursor += n; | 226 | cursor += n; |
227 | match(); | 227 | match(); |
228 | } | 228 | } |
@@ -458,8 +458,7 @@ readstdin(void) { | |||
458 | if(strlen(items[i].text) > max) | 458 | if(strlen(items[i].text) > max) |
459 | max = strlen(maxstr = items[i].text); | 459 | max = strlen(maxstr = items[i].text); |
460 | } | 460 | } |
461 | if(maxstr) | 461 | inputw = maxstr ? textw(dc, maxstr) : 0; |
462 | inputw = textw(dc, maxstr); | ||
463 | } | 462 | } |
464 | 463 | ||
465 | void | 464 | void |