Fix a bogon with ok/cancel callback usage.

This commit is contained in:
Jordan K. Hubbard 1996-04-27 01:52:15 +00:00
parent c671b664f0
commit 396df2aa3a
2 changed files with 24 additions and 26 deletions

View File

@ -456,7 +456,7 @@ draw:
/* Select either the OK or Cancel button */
case '\n':
case '\r':
if (!button && result) {
if (ditems && result) {
if (ditems && ditems[button ? CANCEL_BUTTON : OK_BUTTON].fire) {
int st;
WINDOW *save = dupwin(newscr);
@ -470,13 +470,13 @@ draw:
if (st == DITEM_FAILURE)
continue;
}
else {
*result = '\0';
for (i = 0; i < item_no; i++) {
if (status[i]) {
strcat(result, items[i*3]);
strcat(result, "\n");
}
}
else if (result) {
*result = '\0';
for (i = 0; i < item_no; i++) {
if (status[i]) {
strcat(result, items[i*3]);
strcat(result, "\n");
}
}
}

View File

@ -452,26 +452,24 @@ draw:
case '\r':
case '\n':
if (!button && result) {
if (ditems && ditems[button ? CANCEL_BUTTON : OK_BUTTON].fire) {
int st;
WINDOW *save;
if (ditems && result && ditems[button ? CANCEL_BUTTON : OK_BUTTON].fire) {
int st;
WINDOW *save;
save = dupwin(newscr);
st = ditems[button ? CANCEL_BUTTON : OK_BUTTON].fire(&ditems[button ? CANCEL_BUTTON : OK_BUTTON]);
if (st & DITEM_RESTORE) {
touchwin(save);
wrefresh(save);
}
delwin(save);
save = dupwin(newscr);
st = ditems[button ? CANCEL_BUTTON : OK_BUTTON].fire(&ditems[button ? CANCEL_BUTTON : OK_BUTTON]);
if (st & DITEM_RESTORE) {
touchwin(save);
wrefresh(save);
}
else {
*result = '\0';
for (i = 0; i < item_no; i++) {
if (status[i]) {
strcpy(result, items[i*3]);
break;
}
delwin(save);
}
else if (!ditems && result) {
*result = '\0';
for (i = 0; i < item_no; i++) {
if (status[i]) {
strcpy(result, items[i*3]);
break;
}
}
}