summaryrefslogtreecommitdiff
path: root/dmenu.c
diff options
context:
space:
mode:
authorpancake <nopcode.org>2010-04-01 19:30:21 +0200
committerpancake <nopcode.org>2010-04-01 19:30:21 +0200
commit7ffe51981607c72abc969b23e79a1a46f6e2e422 (patch)
tree4509781190cfa844a8e13196d6f1e93e3d25b59c /dmenu.c
parent29686bd1b8513ba7512ab089cfdbc7df44986409 (diff)
apply nibble patch removing per-item length limit
Diffstat (limited to 'dmenu.c')
-rw-r--r--dmenu.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/dmenu.c b/dmenu.c
index 4c87d6a..f6552aa 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -622,24 +622,31 @@ match(char *pattern) {
void
readstdin(void) {
char *p, buf[1024];
- unsigned int len = 0, max = 0;
+ unsigned int len = 0, blen = 0, max = 0;
Item *i, *new;
- i = NULL;
+ i = 0, p = NULL;
while(fgets(buf, sizeof buf, stdin)) {
- len = strlen(buf);
- if(buf[len-1] == '\n')
- buf[--len] = '\0';
- if(!(p = strdup(buf)))
- eprint("fatal: could not strdup() %u bytes\n", len);
+ len += (blen = strlen(buf));
+ if(!(p = realloc(p, len))) {
+ eprint("fatal: could not realloc() %u bytes\n", len);
+ return;
+ }
+ memcpy (p + len - blen, buf, blen);
+ if (p[len - 1] == '\n')
+ p[len - 1] = 0;
+ else if (!feof(stdin))
+ continue;
if(max < len) {
maxname = p;
max = len;
}
+ len = 0;
if(!(new = (Item *)malloc(sizeof(Item))))
eprint("fatal: could not malloc() %u bytes\n", sizeof(Item));
new->next = new->left = new->right = NULL;
new->text = p;
+ p = NULL;
if(!i)
allitems = new;
else