fix brace mismatch in winami.c

Reported directly to devteam, so no #H number.  Conditional code in
amii_get_ext_cmd() included an unmatched '{', which would break
compilation (at least if EXTMENU was enabled) and also resulted in
the remainder of winami.c being mis-formatted (the functions there
were treated as being inside a block rather than at file level).

This is completely untested.

There's some code suppressed via '#if 0' with a comment "fix for PL2".
We haven't used the patch-level nomenclature since version 3.0!
This commit is contained in:
PatR
2017-08-05 17:58:20 -07:00
parent 0d7101cd29
commit 1614f8f5ee
+53 -57
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 winami.c $NHDT-Date: 1432512794 2015/05/25 00:13:14 $ $NHDT-Branch: master $:$NHDT-Revision: 1.19 $ */
/* NetHack 3.6 winami.c $NHDT-Date: 1501981093 2017/08/06 00:58:13 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.20 $ */
/* Copyright (c) Gregg Wonderly, Naperville, Illinois, 1991,1992,1993,1996.
*/
/* NetHack may be freely redistributed. See license for details. */
@@ -807,8 +807,8 @@ amii_get_ext_cmd(void)
}
return (-1);
} else {
#else
}
#endif
amii_clear_nhwindow(WIN_MESSAGE); /* Was NHW_MESSAGE */
if (scrollmsg) {
@@ -932,10 +932,11 @@ amii_get_ext_cmd(void)
DisplayBeep(NULL);
}
return (-1);
#endif
}
static int put_ext_cmd(obufp, colx, cw, bottom) char * obufp;
static int
put_ext_cmd(obufp, colx, cw, bottom)
char * obufp;
int colx, bottom;
struct amii_WinDesc *cw;
{
@@ -953,8 +954,8 @@ amii_get_ext_cmd(void)
SetAPen(w->RPort, C_WHITE);
Text(w->RPort, "># ", 3);
/* SetAPen( w->RPort, C_BLACK ); */ /* Black text on black
screen doesn't look too
well ... -jhsa */
* screen doesn't look
* too well ... -jhsa */
Text(w->RPort, t + 3, strlen(t) - 3);
} else {
sprintf(t, "# %s", obufp);
@@ -977,13 +978,15 @@ amii_get_ext_cmd(void)
}
amii_curs(WIN_MESSAGE, colx = strlen(obufp) + 3 + (scrollmsg != 0),
bottom);
return (colx);
return colx;
}
/* Ask a question and get a response */
char amii_yn_function(query, resp, def) const char * query, *resp;
char
amii_yn_function(query, resp, def)
const char * query, *resp;
char def;
{
/*
* Generic yes/no function. 'def' is the default (returned by space or
* return; 'esc' returns 'q', or 'n', or the default, depending on
@@ -995,7 +998,6 @@ amii_get_ext_cmd(void)
* are allowed); if it includes an <esc>, anything beyond that won't
* be shown in the prompt to the user but will be acceptable as input.
*/
{
register char q;
char rtmp[40];
boolean digit_ok, allow_num;
@@ -1025,7 +1027,7 @@ amii_get_ext_cmd(void)
q = WindowGetchar();
cursor_off(WIN_MESSAGE);
*rtmp = q;
rtmp[1] = 0;
rtmp[1] = '\0';
amii_addtopl(rtmp);
goto clean_up;
}
@@ -1037,7 +1039,8 @@ amii_get_ext_cmd(void)
#if 0
/* fix for PL2 */
if (q == '\020') { /* ctrl-P */
if(!doprev) (void) tty_doprev_message(); /* need two initially */
if(!doprev)
(void) tty_doprev_message(); /* need two initially */
(void) tty_doprev_message();
q = (char)0;
doprev = 1;
@@ -1049,7 +1052,7 @@ amii_get_ext_cmd(void)
amii_addtopl(prompt);
continue;
}
#endif
#endif /*0*/
digit_ok = allow_num && isdigit(q);
if (q == '\033') {
if (index(resp, 'q'))
@@ -1070,6 +1073,7 @@ amii_get_ext_cmd(void)
char z, digit_string[2];
int n_len = 0;
long value = 0;
amii_addtopl("#"), n_len++;
digit_string[1] = '\0';
if (q != '#') {
@@ -1127,7 +1131,9 @@ amii_get_ext_cmd(void)
return q;
}
void amii_display_file(fn, complain) const char * fn;
void
amii_display_file(fn, complain)
const char * fn;
boolean complain;
{
register struct amii_WinDesc *cw;
@@ -1170,7 +1176,6 @@ amii_get_ext_cmd(void)
dlb_fclose(fp);
/* If there were lines in the file, display those lines */
if (amii_wins[win]->cury > 0)
amii_display_nhwindow(win, TRUE);
@@ -1182,8 +1187,9 @@ amii_get_ext_cmd(void)
* which do not have highlighting are rendered down. Boolean gadgets
* are rendered in the up position by default.
*/
void SetBorder(gd) register struct Gadget * gd;
void
SetBorder(gd)
register struct Gadget * gd;
{
register struct Border *bp;
register short *sp;
@@ -1197,7 +1203,7 @@ amii_get_ext_cmd(void)
#ifdef INTUI_NEW_LOOK
if (IntuitionBase->LibNode.lib_Version >= 37) {
if (dip = GetScreenDrawInfo(HackScreen)) {
if ((dip = GetScreenDrawInfo(HackScreen)) != 0) {
hipen = dip->dri_Pens[SHINEPEN];
shadowpen = dip->dri_Pens[SHADOWPEN];
FreeScreenDrawInfo(HackScreen, dip);
@@ -1207,10 +1213,8 @@ amii_get_ext_cmd(void)
/* Allocate two border structures one for up image and one for down
* image, plus vector arrays for the border lines.
*/
if (gd->GadgetType == STRGADGET)
borders = 12;
if ((bp = (struct Border *) alloc(((sizeof (struct Border) * 2)
+ (sizeof (short) * borders)) * 2))
== NULL) {
@@ -1221,9 +1225,7 @@ amii_get_ext_cmd(void)
* the text will be entered.
*/
/* Remove any special rendering flags to avoid confusing intuition
*/
/* Remove any special rendering flags to avoid confusing intuition */
gd->Flags &= ~(GADGHIGHBITS | GADGIMAGE);
sp = (short *) (bp + 4);
@@ -1280,7 +1282,6 @@ amii_get_ext_cmd(void)
/* Create the border vector values for up and left side, and
* also the lower and right side.
*/
sp[0] = dec;
sp[1] = gd->Height + inc;
sp[2] = dec;
@@ -1299,12 +1300,10 @@ amii_get_ext_cmd(void)
* rectangle share the border vectors with the opposite image,
* but specify different colors.
*/
for (i = 0; i < 4; ++i) {
bp[i].TopEdge = bp[i].LeftEdge = 0;
/* A GADGHNONE is always down */
if (gd->GadgetType == BOOLGADGET
&& (gd->Flags & GADGHIGHBITS) != GADGHNONE) {
bp[i].FrontPen = (i == 1 || i == 2) ? shadowpen : hipen;
@@ -1329,10 +1328,10 @@ amii_get_ext_cmd(void)
}
}
/* Following function copied from wintty.c */
/* Modified slightly to fit amiga needs */
void amii_player_selection()
/* Following function copied from wintty.c;
Modified slightly to fit amiga needs */
void
amii_player_selection()
{
int i, k, n;
char pick4u = 'n', thisch, lastch = 0;
@@ -1346,9 +1345,11 @@ amii_get_ext_cmd(void)
/* Should we randomly pick for the player? */
if (flags.initrole == ROLE_NONE || flags.initrace == ROLE_NONE
|| flags.initgend == ROLE_NONE || flags.initalign == ROLE_NONE) {
char *prompt = build_plselection_prompt(
pbuf, QBUFSZ, flags.initrole, flags.initrace, flags.initgend,
flags.initalign);
char *prompt;
prompt = build_plselection_prompt(pbuf, QBUFSZ,
flags.initrole, flags.initrace,
flags.initgend, flags.initalign);
pline("%s", prompt);
do { /* loop until we get valid input */
cursor_on(WIN_MESSAGE);
@@ -1373,9 +1374,9 @@ amii_get_ext_cmd(void)
}
}
(void) root_plselection_prompt(plbuf, QBUFSZ - 1, flags.initrole,
flags.initrace, flags.initgend,
flags.initalign);
(void) root_plselection_prompt(plbuf, QBUFSZ - 1,
flags.initrole, flags.initrace,
flags.initgend, flags.initalign);
/* Select a role, if necessary */
/* we'll try to be compatible with pre-selected race/gender/alignment,
@@ -1443,9 +1444,9 @@ amii_get_ext_cmd(void)
flags.initrole = selected[0].item.a_int - 1;
free((genericptr_t) selected), selected = 0;
}
(void) root_plselection_prompt(plbuf, QBUFSZ - 1, flags.initrole,
flags.initrace, flags.initgend,
flags.initalign);
(void) root_plselection_prompt(plbuf, QBUFSZ - 1,
flags.initrole, flags.initrace,
flags.initgend, flags.initalign);
}
/* Select a race, if necessary */
@@ -1516,9 +1517,9 @@ amii_get_ext_cmd(void)
}
flags.initrace = k;
}
(void) root_plselection_prompt(plbuf, QBUFSZ - 1, flags.initrole,
flags.initrace, flags.initgend,
flags.initalign);
(void) root_plselection_prompt(plbuf, QBUFSZ - 1,
flags.initrole, flags.initrace,
flags.initgend, flags.initalign);
}
/* Select a gender, if necessary */
@@ -1564,15 +1565,13 @@ amii_get_ext_cmd(void)
if (ok_gend(flags.initrole, flags.initrace, i,
flags.initalign)) {
any.a_int = i + 1;
add_menu(win, NO_GLYPH, &any, genders[i].adj[0],
0, ATR_NONE, genders[i].adj,
MENU_UNSELECTED);
add_menu(win, NO_GLYPH, &any, genders[i].adj[0], 0,
ATR_NONE, genders[i].adj, MENU_UNSELECTED);
}
any.a_int = pick_gend(flags.initrole, flags.initrace,
flags.initalign, PICK_RANDOM) + 1;
if (any.a_int == 0) /* must be non-zero */
any.a_int =
randgend(flags.initrole, flags.initrace) + 1;
any.a_int = randgend(flags.initrole, flags.initrace) + 1;
add_menu(win, NO_GLYPH, &any, '*', 0, ATR_NONE, "Random",
MENU_UNSELECTED);
any.a_int = i + 1; /* must be non-zero */
@@ -1590,9 +1589,9 @@ amii_get_ext_cmd(void)
}
flags.initgend = k;
}
(void) root_plselection_prompt(plbuf, QBUFSZ - 1, flags.initrole,
flags.initrace, flags.initgend,
flags.initalign);
(void) root_plselection_prompt(plbuf, QBUFSZ - 1,
flags.initrole, flags.initrace,
flags.initgend, flags.initalign);
}
/* Select an alignment, if necessary */
@@ -1606,8 +1605,7 @@ amii_get_ext_cmd(void)
flags.initgend, PICK_RANDOM);
if (flags.initalign < 0) {
amii_putstr(WIN_MESSAGE, 0, "Incompatible alignment!");
flags.initalign =
randalign(flags.initrole, flags.initrace);
flags.initalign = randalign(flags.initrole, flags.initrace);
}
} else { /* pick4u == 'n' */
/* Count the number of valid alignments */
@@ -1639,14 +1637,12 @@ amii_get_ext_cmd(void)
flags.initgend, i)) {
any.a_int = i + 1;
add_menu(win, NO_GLYPH, &any, aligns[i].adj[0], 0,
ATR_NONE, aligns[i].adj,
MENU_UNSELECTED);
ATR_NONE, aligns[i].adj, MENU_UNSELECTED);
}
any.a_int = pick_align(flags.initrole, flags.initrace,
flags.initgend, PICK_RANDOM) + 1;
if (any.a_int == 0) /* must be non-zero */
any.a_int =
randalign(flags.initrole, flags.initrace) + 1;
any.a_int = randalign(flags.initrole, flags.initrace) + 1;
add_menu(win, NO_GLYPH, &any, '*', 0, ATR_NONE, "Random",
MENU_UNSELECTED);
any.a_int = i + 1; /* must be non-zero */