aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dmenu.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/dmenu.c b/dmenu.c
index 1681a55..cf5e4a6 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -38,7 +38,7 @@ static void setup(void);
38 38
39static char text[BUFSIZ] = ""; 39static char text[BUFSIZ] = "";
40static int bh, mw, mh; 40static int bh, mw, mh;
41static int inputw = 0; 41static int inputw;
42static int lines = 0; 42static int lines = 0;
43static int monitor = -1; 43static int monitor = -1;
44static int promptw; 44static 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
220insert(const char *s, ssize_t n) { 220insert(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
465void 464void