diff options
Diffstat (limited to 'gnu/lib/libdialog/checklist.c')
| -rw-r--r-- | gnu/lib/libdialog/checklist.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/gnu/lib/libdialog/checklist.c b/gnu/lib/libdialog/checklist.c index c90ce9adb49c7..4be328276310c 100644 --- a/gnu/lib/libdialog/checklist.c +++ b/gnu/lib/libdialog/checklist.c @@ -38,14 +38,14 @@ static int list_width, check_x, item_x; */ int dialog_checklist(unsigned char *title, unsigned char *prompt, int height, int width, - int list_height, int item_no, void *it, unsigned char *result) + int list_height, int cnt, void *it, unsigned char *result) { int i, j, x, y, cur_x, cur_y, box_x, box_y, key = 0, button = 0, choice = 0, - l, k, scroll = 0, max_choice, *status; + l, k, scroll = 0, max_choice, item_no = 0, *status; int redraw_menu = FALSE; char okButton, cancelButton; WINDOW *dialog, *list; - unsigned char **items; + unsigned char **items = NULL; dialogMenuItem *ditems; /* Allocate space for storing item on/off status */ @@ -55,19 +55,22 @@ dialog_checklist(unsigned char *title, unsigned char *prompt, int height, int wi exit(-1); } +draw: /* Previous calling syntax, e.g. just a list of strings? */ - if (item_no >= 0) { + if (cnt >= 0) { items = it; ditems = NULL; + item_no = cnt; /* Initializes status */ for (i = 0; i < item_no; i++) status[i] = !strcasecmp(items[i*3 + 2], "on"); } /* It's the new specification format - fake the rest of the code out */ else { - item_no = abs(item_no); + item_no = abs(cnt); ditems = it; - items = (unsigned char **)alloca((item_no * 3) * sizeof(unsigned char *)); + if (!items) + items = (unsigned char **)alloca((item_no * 3) * sizeof(unsigned char *)); /* Initializes status */ for (i = 0; i < item_no; i++) { @@ -108,7 +111,6 @@ dialog_checklist(unsigned char *title, unsigned char *prompt, int height, int wi x = (COLS - width)/2; y = (LINES - height)/2; -draw: #ifdef HAVE_NCURSES if (use_shadow) draw_shadow(stdscr, y, x, height, width); |
