summaryrefslogtreecommitdiffstats
path: root/gnu
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1996-04-20 01:28:20 +0000
committerjkh <jkh@FreeBSD.org>1996-04-20 01:28:20 +0000
commite1617c234c63e37eeb39e6e512a1172b0ffa0fdb (patch)
treebf879dbb965c0ec16296b80916c2bf2e70f40616 /gnu
parentc27d7d17c60af995b219e4ed02771ef3779b85b5 (diff)
downloadFreeBSD-src-e1617c234c63e37eeb39e6e512a1172b0ffa0fdb.zip
FreeBSD-src-e1617c234c63e37eeb39e6e512a1172b0ffa0fdb.tar.gz
Make the DITEM_RECREATE option work properly.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/lib/libdialog/checklist.c16
-rw-r--r--gnu/lib/libdialog/menubox.c16
-rw-r--r--gnu/lib/libdialog/radiolist.c17
3 files changed, 27 insertions, 22 deletions
diff --git a/gnu/lib/libdialog/checklist.c b/gnu/lib/libdialog/checklist.c
index c90ce9a..4be3282 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);
diff --git a/gnu/lib/libdialog/menubox.c b/gnu/lib/libdialog/menubox.c
index ca963bf..9e36601 100644
--- a/gnu/lib/libdialog/menubox.c
+++ b/gnu/lib/libdialog/menubox.c
@@ -37,30 +37,33 @@ static int menu_width, tag_x, item_x;
*/
int
dialog_menu(unsigned char *title, unsigned char *prompt, int height, int width, int menu_height,
- int item_no, void *it, unsigned char *result, int *ch, int *sc)
+ int cnt, void *it, unsigned char *result, int *ch, int *sc)
{
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, redraw_menu = FALSE;
+ l, k, scroll = 0, max_choice, item_no, redraw_menu = FALSE;
char okButton, cancelButton;
WINDOW *dialog, *menu;
- unsigned char **items;
+ unsigned char **items = NULL;
dialogMenuItem *ditems;
+draw:
if (ch) /* restore menu item info */
choice = *ch;
if (sc)
scroll = *sc;
/* If item_no is a positive integer, use old item specification format */
- if (item_no >= 0) {
+ if (cnt >= 0) {
items = it;
ditems = NULL;
+ item_no = cnt;
}
/* 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 * 2) * sizeof(unsigned char *));
+ if (!items)
+ items = (unsigned char **)alloca((item_no * 2) * sizeof(unsigned char *));
/* Initializes status */
for (i = 0; i < item_no; i++) {
@@ -99,7 +102,6 @@ dialog_menu(unsigned char *title, unsigned char *prompt, int height, int width,
x = DialogX ? DialogX : (COLS - width)/2;
y = DialogY ? DialogY : (LINES - height)/2;
-draw:
#ifdef HAVE_NCURSES
if (use_shadow)
draw_shadow(stdscr, y, x, height, width);
diff --git a/gnu/lib/libdialog/radiolist.c b/gnu/lib/libdialog/radiolist.c
index 4d40e0b..daa8881 100644
--- a/gnu/lib/libdialog/radiolist.c
+++ b/gnu/lib/libdialog/radiolist.c
@@ -38,14 +38,14 @@ static int list_width, check_x, item_x;
*/
int
dialog_radiolist(unsigned char *title, unsigned char *prompt, int height, int width, int list_height,
- int item_no, void *it, unsigned char *result)
+ 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, was_on = 0;
+ l, k, scroll = 0, max_choice, *status, item_no = 0, was_on = 0;
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,11 +55,12 @@ dialog_radiolist(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");
@@ -73,9 +74,10 @@ dialog_radiolist(unsigned char *title, unsigned char *prompt, int height, int wi
}
/* 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++) {
status[i] = ditems[i].checked ? ditems[i].checked(&ditems[i]) : FALSE;
@@ -121,7 +123,6 @@ dialog_radiolist(unsigned char *title, unsigned char *prompt, int height, int wi
x = DialogX ? DialogX : (COLS - width)/2;
y = DialogY ? DialogY : (LINES - height)/2;
-draw:
#ifdef HAVE_NCURSES
if (use_shadow)
draw_shadow(stdscr, y, x, height, width);
OpenPOWER on IntegriCloud