apply nibble patch removing per-item length limit

main
pancake 2010-04-01 19:30:21 +02:00
parent 29686bd1b8
commit 7ffe519816
1 changed files with 14 additions and 7 deletions

21
dmenu.c
View File

@ -622,24 +622,31 @@ match(char *pattern) {
void void
readstdin(void) { readstdin(void) {
char *p, buf[1024]; char *p, buf[1024];
unsigned int len = 0, max = 0; unsigned int len = 0, blen = 0, max = 0;
Item *i, *new; Item *i, *new;
i = NULL; i = 0, p = NULL;
while(fgets(buf, sizeof buf, stdin)) { while(fgets(buf, sizeof buf, stdin)) {
len = strlen(buf); len += (blen = strlen(buf));
if(buf[len-1] == '\n') if(!(p = realloc(p, len))) {
buf[--len] = '\0'; eprint("fatal: could not realloc() %u bytes\n", len);
if(!(p = strdup(buf))) return;
eprint("fatal: could not strdup() %u bytes\n", len); }
memcpy (p + len - blen, buf, blen);
if (p[len - 1] == '\n')
p[len - 1] = 0;
else if (!feof(stdin))
continue;
if(max < len) { if(max < len) {
maxname = p; maxname = p;
max = len; max = len;
} }
len = 0;
if(!(new = (Item *)malloc(sizeof(Item)))) if(!(new = (Item *)malloc(sizeof(Item))))
eprint("fatal: could not malloc() %u bytes\n", sizeof(Item)); eprint("fatal: could not malloc() %u bytes\n", sizeof(Item));
new->next = new->left = new->right = NULL; new->next = new->left = new->right = NULL;
new->text = p; new->text = p;
p = NULL;
if(!i) if(!i)
allitems = new; allitems = new;
else else