summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dmenu.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/dmenu.c b/dmenu.c
index 6d35430..2684c91 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -1,4 +1,4 @@
-/* See LICENSE file for copyright and license details. */
+/* See LICENSE file for copynext and license details. */
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
@@ -19,8 +19,7 @@
typedef struct Item Item;
struct Item {
char *text;
- Item *next; /* traverses all items */
- Item *left, *right; /* traverses matching items */
+ Item *left, *right;
};
static void appenditem(Item *item, Item **list, Item **last);
@@ -386,7 +385,7 @@ match(void) {
len = strlen(text);
matches = lexact = lprefix = lsubstr = itemend = exactend = prefixend = substrend = NULL;
- for(item = items; item; item = item->next)
+ for(item = items; item && item->text; item++)
if(!fstrncmp(text, item->text, len + 1))
appenditem(item, &lexact, &exactend);
else if(!fstrncmp(text, item->text, len))
@@ -445,16 +444,17 @@ paste(void) {
void
readstdin(void) {
char buf[sizeof text], *p;
- Item *item, **end;
+ size_t i, size = 0;
- for(end = &items; fgets(buf, sizeof buf, stdin); *end = item, end = &item->next) {
+ for(i = 0; fgets(buf, sizeof buf, stdin); items[++i].text = NULL) {
+ if(i+1 == size / sizeof *items || !items)
+ if(!(items = realloc(items, (size += BUFSIZ))))
+ eprintf("cannot realloc %u bytes:", size);
if((p = strchr(buf, '\n')))
*p = '\0';
- if(!(item = calloc(1, sizeof *item)))
- eprintf("cannot malloc %u bytes:", sizeof *item);
- if(!(item->text = strdup(buf)))
+ if(!(items[i].text = strdup(buf)))
eprintf("cannot strdup %u bytes:", strlen(buf)+1);
- inputw = MAX(inputw, textw(dc, item->text));
+ inputw = MAX(inputw, textw(dc, items[i].text));
}
}
ra warningGravatar Connor Lane Smith 1-1/+1 2011-10-16lsx: return failure on errorGravatar Connor Lane Smith 1-2/+5 2011-10-16add xim supportGravatar Troels Henriksen 1-3/+15 2011-10-13limit lines to inputGravatar Connor Lane Smith 1-0/+1 2011-10-04input focus: fix for reparenting wmsGravatar Connor Lane Smith 1-1/+1 2011-09-30fix monitor select when no focusGravatar Connor Lane Smith 1-1/+1 2011-09-20tweak matchGravatar Connor Lane Smith 1-2/+2 2011-09-20update manpageGravatar Connor Lane Smith 1-9/+6 2011-09-19detect active monitor using input focusGravatar Connor Lane Smith 1-7/+12 2011-09-19add token matchingGravatar Connor Lane Smith 1-23/+34 2011-09-19change version to 'hg'Gravatar Connor Lane Smith 1-1/+1 2011-07-24dmenu_run: sh -cGravatar Connor Lane Smith 1-1/+1 2011-07-22fix loadfontGravatar Connor Lane Smith 1-12/+13 2011-07-19Added tag 4.4 for changeset 2b105eaae831Gravatar Connor Lane Smith 1-0/+1 2011-07-19add lsx.1 to distGravatar Connor Lane Smith 1-1/+1 2011-07-17tweaksGravatar Connor Lane Smith 2-2/+2 2011-07-14efficiency tweaksGravatar Connor Lane Smith 2-60/+44 2011-07-14fix extra warningGravatar Connor Lane Smith 1-1/+1 2011-07-06simpler vlineGravatar Connor Lane Smith 1-4/+2 2011-07-04rebind ^N ^PGravatar Connor Lane Smith 2-3/+3 2011-06-25include limits.hGravatar Connor Lane Smith 1-0/+1 2011-06-23make clean lsxGravatar Connor Lane Smith 1-1/+1 2011-06-23lsx: check snprintfGravatar Connor Lane Smith 1-4/+3 2011-06-18update draw.cGravatar Connor Lane Smith 2-14/+14 2011-06-18simpler lsxGravatar Connor Lane Smith 3-11/+6 2011-06-13new dmenu_runGravatar Connor Lane Smith 5-26/+15