}
} while (!feof(f));
+ newtFormDestroy(form);
+
return DLG_OKAY;
}
*result = val;
+ newtFormDestroy(form);
+
return rc;
}
int len, j;
len = mystrncpyw(buf, itemInfo[i].tag, MAXBUF, &w);
for (j = 0; j < tagWidth - w; j++) {
- if (len >= MAXBUF) break;
+ if (len + 1 >= MAXBUF)
+ break;
buf[len++] = ' ';
}
buf[len] = '\0';
i = (long) newtListboxGetCurrent(listBox);
*result = itemInfo[i].tag;
+ newtFormDestroy(form);
+ free(itemInfo);
+
return rc;
}
const char * tag;
newtComponent comp;
} * cbInfo = malloc(allocedBoxes * sizeof(*cbInfo));
- char * cbStates = malloc(allocedBoxes * sizeof(cbStates));
+ char * cbStates = malloc(allocedBoxes * sizeof(*cbStates));
if ( (cbInfo == NULL) || (cbStates == NULL)) return DLG_ERROR;
if (!(arg = poptGetArg(optCon))) return DLG_ERROR;
(*selections)[numSelected] = NULL;
}
+ newtFormDestroy(form);
+
return rc;
}
newtDrawForm(form);
newtRefresh();
}
-
+ newtFormDestroy(form);
return rc;
}
for(i = 0, item = li->boxItems; item != NULL && i < num;
i++, item = item->next);
- item->data = data;
+ if (item)
+ item->data = data;
}
int newtListboxAppendEntry(newtComponent co, const char * text,
li->currItem > li->startShowItem)
li->startShowItem =
li->currItem > li->numItems - li->curHeight ?
- li->startShowItem = li->numItems - li->curHeight :
+ li->numItems - li->curHeight :
li->currItem;
if(li->sb)
newtScrollbarSet(li->sb, li->currItem + 1, li->numItems);
exit(DLG_ERROR);
}
- if ( (buf = malloc(s.st_size + 1)) == 0 )
+ if ( (buf = malloc(s.st_size + 1)) == 0 ) {
fprintf(stderr, _("%s: too large to display.\n"), filename);
+ exit(DLG_ERROR);
+ }
if ( read(fd, buf, s.st_size) != s.st_size ) {
perror(filename);
if (!(nextArg = poptGetArg(optCon))) usage(WAS_ERROR);
text = strdup(nextArg);
- if (mode == MODE_TEXTBOX ) text = readTextFile(text);
+ if (mode == MODE_TEXTBOX) {
+ char *t = text;
+ text = readTextFile(t);
+ free(t);
+ }
if (!(nextArg = poptGetArg(optCon))) usage(WAS_ERROR);
height = strtoul(nextArg, &end, 10);
if (mode == MODE_GAUGE) {
fd = dup(0);
- close(0);
- if (open("/dev/tty", O_RDWR) != 0) perror("open /dev/tty");
+ if (fd < 0 || close(0) < 0) {
+ perror("dup/close stdin");
+ exit(DLG_ERROR);
+ }
+ if (open("/dev/tty", O_RDWR) != 0) {
+ perror("open /dev/tty");
+ exit(DLG_ERROR);
+ }
}
newtInit();
newtPopWindow();
newtFinished();
+ free(text);
+ poptFreeContext(optCon);
+
return ( rc == DLG_ESCAPE ) ? -1 : rc;
}
++totalButtons;
va_end(args);
- buttons = (newtComponent *)alloca(sizeof(newtComponent*)*(totalButtons));
+ buttons = (newtComponent *)alloca(sizeof(newtComponent)*(totalButtons));
va_start(args, button1);
for (buttonName = button1; buttonName; buttonName = va_arg(args, char *))
buttons[numButtons++] = newtButton(-1, -1, buttonName);
++totalButtons;
va_end(args);
- buttons = (newtComponent *)alloca(sizeof(newtComponent*)*(totalButtons));
+ buttons = (newtComponent *)alloca(sizeof(newtComponent)*(totalButtons));
va_start(args, button1);
for (buttonName = button1; buttonName; buttonName = va_arg(args, char *))
buttons[numButtons++] = newtButton(-1, -1, buttonName);