pull request #1146 - choose_classes_menu()
Pull request from argrath would have made sure that an uninitialized buffer wasn't used after choose_classes_menu() issued an impossible warning, but there was no point in continuing if bad (or not yet supported) arguments were passed, so panic instead. Bypass the pull request's commit because it would have been immediately replaced. Closes #1146
This commit is contained in:
+29
-18
@@ -3148,8 +3148,8 @@ optfn_pickup_types(
|
|||||||
if (use_menu) {
|
if (use_menu) {
|
||||||
if (wizard && !strchr(ocl, VENOM_SYM))
|
if (wizard && !strchr(ocl, VENOM_SYM))
|
||||||
strkitten(ocl, VENOM_SYM);
|
strkitten(ocl, VENOM_SYM);
|
||||||
(void) choose_classes_menu("Autopickup what?", 1, TRUE, ocl,
|
(void) choose_classes_menu("Autopickup what?",
|
||||||
tbuf);
|
1, TRUE, ocl, tbuf);
|
||||||
op = tbuf;
|
op = tbuf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9715,12 +9715,12 @@ choose_classes_menu(const char *prompt,
|
|||||||
winid win;
|
winid win;
|
||||||
anything any;
|
anything any;
|
||||||
char buf[BUFSZ];
|
char buf[BUFSZ];
|
||||||
int i, n;
|
const char *text = 0;
|
||||||
int ret;
|
boolean selected;
|
||||||
int next_accelerator, accelerator;
|
int ret, i, n, next_accelerator, accelerator;
|
||||||
int clr = NO_COLOR;
|
int clr = NO_COLOR;
|
||||||
|
|
||||||
if (class_list == (char *) 0 || class_select == (char *) 0)
|
if (!class_list || !class_select)
|
||||||
return 0;
|
return 0;
|
||||||
accelerator = 0;
|
accelerator = 0;
|
||||||
next_accelerator = 'a';
|
next_accelerator = 'a';
|
||||||
@@ -9728,10 +9728,6 @@ choose_classes_menu(const char *prompt,
|
|||||||
win = create_nhwindow(NHW_MENU);
|
win = create_nhwindow(NHW_MENU);
|
||||||
start_menu(win, MENU_BEHAVE_STANDARD);
|
start_menu(win, MENU_BEHAVE_STANDARD);
|
||||||
while (*class_list) {
|
while (*class_list) {
|
||||||
const char *text;
|
|
||||||
boolean selected;
|
|
||||||
|
|
||||||
text = (char *) 0;
|
|
||||||
selected = FALSE;
|
selected = FALSE;
|
||||||
switch (category) {
|
switch (category) {
|
||||||
case 0:
|
case 0:
|
||||||
@@ -9745,7 +9741,8 @@ choose_classes_menu(const char *prompt,
|
|||||||
Sprintf(buf, "%c %s", *class_list, text);
|
Sprintf(buf, "%c %s", *class_list, text);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
impossible("choose_classes_menu: invalid category %d", category);
|
panic("choose_classes_menu: invalid category %d", category);
|
||||||
|
/*NOTREACHED*/
|
||||||
}
|
}
|
||||||
if (way && *class_select) { /* Selections there already */
|
if (way && *class_select) { /* Selections there already */
|
||||||
if (strchr(class_select, *class_list)) {
|
if (strchr(class_select, *class_list)) {
|
||||||
@@ -9756,19 +9753,20 @@ choose_classes_menu(const char *prompt,
|
|||||||
add_menu(win, &nul_glyphinfo, &any, accelerator,
|
add_menu(win, &nul_glyphinfo, &any, accelerator,
|
||||||
category ? *class_list : 0, ATR_NONE, clr, buf,
|
category ? *class_list : 0, ATR_NONE, clr, buf,
|
||||||
selected ? MENU_ITEMFLAGS_SELECTED : MENU_ITEMFLAGS_NONE);
|
selected ? MENU_ITEMFLAGS_SELECTED : MENU_ITEMFLAGS_NONE);
|
||||||
++class_list;
|
|
||||||
if (category > 0) {
|
if (category > 0) {
|
||||||
++next_accelerator;
|
if (next_accelerator == 'Z')
|
||||||
if (next_accelerator == ('z' + 1))
|
|
||||||
next_accelerator = 'A';
|
|
||||||
if (next_accelerator == ('Z' + 1))
|
|
||||||
break;
|
break;
|
||||||
|
else if (next_accelerator == 'z')
|
||||||
|
next_accelerator = 'A';
|
||||||
|
else
|
||||||
|
++next_accelerator;
|
||||||
}
|
}
|
||||||
|
++class_list;
|
||||||
}
|
}
|
||||||
if (category == 1 && next_accelerator <= 'z') {
|
if (category == 1 && next_accelerator <= 'z') {
|
||||||
/* for objects, add "A - ' ' all classes", after a separator */
|
/* for objects, add "A - ' ' all classes", after a separator */
|
||||||
any = cg.zeroany;
|
|
||||||
add_menu_str(win, "");
|
add_menu_str(win, "");
|
||||||
|
any = cg.zeroany;
|
||||||
any.a_int = (int) ' ';
|
any.a_int = (int) ' ';
|
||||||
Sprintf(buf, "%c %s", (char) any.a_int, "all classes of objects");
|
Sprintf(buf, "%c %s", (char) any.a_int, "all classes of objects");
|
||||||
/* we won't preselect this even if the incoming list is empty;
|
/* we won't preselect this even if the incoming list is empty;
|
||||||
@@ -9776,6 +9774,18 @@ choose_classes_menu(const char *prompt,
|
|||||||
de-selected in order to select anything else */
|
de-selected in order to select anything else */
|
||||||
add_menu(win, &nul_glyphinfo, &any, 'A', 0,
|
add_menu(win, &nul_glyphinfo, &any, 'A', 0,
|
||||||
ATR_NONE, clr, buf, MENU_ITEMFLAGS_NONE);
|
ATR_NONE, clr, buf, MENU_ITEMFLAGS_NONE);
|
||||||
|
if (!strcmp(prompt, "Autopickup what?")) {
|
||||||
|
Sprintf(buf, "%4s%c %s", " ", ' ',
|
||||||
|
"Note: when no choices are selected, \"all\" is implied.");
|
||||||
|
add_menu_str(win, buf);
|
||||||
|
if (flags.pickup) {
|
||||||
|
/* for 'O', "toggle" should be intuitive; for 'm O', it would
|
||||||
|
probably be better to say "Set 'autopickup' to false..." */
|
||||||
|
Sprintf(buf, "%4s%c %s", " ", ' ',
|
||||||
|
"Toggle off 'autopickup' to not pick up anything.");
|
||||||
|
add_menu_str(win, buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
end_menu(win, prompt);
|
end_menu(win, prompt);
|
||||||
n = select_menu(win, way ? PICK_ANY : PICK_ONE, &pick_list);
|
n = select_menu(win, way ? PICK_ANY : PICK_ONE, &pick_list);
|
||||||
@@ -9797,8 +9807,9 @@ choose_classes_menu(const char *prompt,
|
|||||||
} else if (n == -1) {
|
} else if (n == -1) {
|
||||||
class_select = eos(class_select);
|
class_select = eos(class_select);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
} else
|
} else {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
}
|
||||||
*class_select = '\0';
|
*class_select = '\0';
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user