X11 fixes

Fix the warnings issued when compiling win/X11/.  The error handler
one is presumeably due to a change in /usr/include/X11/Intrinsic.h
between different releases of X11 and is inconsequential.  The
indentation ones represented real bugs.  The X11 convention of using
'foo(); argcount++;' requires braces when preceded by 'if' or 'else'.
I don't know why the convention doesn't use comma instead of semi-colon
between the function that adds an entry to an argument list and the
accumulating count of the number of those arguments.

A few years ago I added code to zero out various argument lists prior
to their use, which shouldn't have been necessary.  The wrong argument
count being used when the 'if (whatever)' check fails could possibly
have been the reason that pre-zeroing solved mystery problems.  I don't
remember enough details to attempt to go back and retest with this fix
in place.
This commit is contained in:
PatR
2022-01-09 13:27:23 -08:00
parent e4e65c4b8b
commit 415cfd808c
2 changed files with 13 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 winX.c $NHDT-Date: 1613985000 2021/02/22 09:10:00 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.102 $ */
/* NetHack 3.7 winX.c $NHDT-Date: 1641763627 2022/01/09 21:27:07 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.108 $ */
/* Copyright (c) Dean Luick, 1992 */
/* NetHack may be freely redistributed. See license for details. */
@@ -86,6 +86,9 @@ int click_x, click_y, click_button; /* Click position on a map window */
/* (filled by set_button_values()). */
int updated_inventory; /* used to indicate perm_invent updating */
static void X11_error_handler(String) NORETURN;
static int X11_io_error_handler(Display *);
static int (*old_error_handler) (Display *, XErrorEvent *);
#if !defined(NO_SIGNAL) && defined(SAFERHANGUP)
@@ -1479,6 +1482,8 @@ X11_error_handler(String str)
{
nhUse(str);
hangup(1);
nh_terminate(EXIT_FAILURE);
/*NOTREACHED*/
}
static int

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 winstat.c $NHDT-Date: 1611697183 2021/01/26 21:39:43 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.30 $ */
/* NetHack 3.7 winstat.c $NHDT-Date: 1641763638 2022/01/09 21:27:18 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.35 $ */
/* Copyright (c) Dean Luick, 1992 */
/* NetHack may be freely redistributed. See license for details. */
@@ -942,10 +942,12 @@ create_tty_status_field(int fld, int condindx, Widget above, Widget left)
/* set up widget attributes which (mostly) aren't going to be changing */
(void) memset((genericptr_t) args, 0, sizeof args);
num_args = 0;
if (above)
if (above) {
XtSetArg(args[num_args], nhStr(XtNfromVert), above); num_args++;
if (left)
}
if (left) {
XtSetArg(args[num_args], nhStr(XtNfromHoriz), left); num_args++;
}
XtSetArg(args[num_args], nhStr(XtNhorizDistance), gap); num_args++;
XtSetArg(args[num_args], nhStr(XtNvertDistance), 0); num_args++;
@@ -977,8 +979,9 @@ create_tty_status(Widget parent, Widget top)
(void) memset((genericptr_t) args, 0, sizeof args);
num_args = 0;
if (top)
if (top) {
XtSetArg(args[num_args], nhStr(XtNfromVert), top); num_args++;
}
XtSetArg(args[num_args], nhStr(XtNdefaultDistance), 0); num_args++;
XtSetArg(args[num_args], XtNborderWidth, 0); num_args++;
XtSetArg(args[num_args], XtNwidth, 400); num_args++;