From 415cfd808c5cea58ec3d42c443799e2b6fd6709f Mon Sep 17 00:00:00 2001 From: PatR Date: Sun, 9 Jan 2022 13:27:23 -0800 Subject: [PATCH] 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. --- win/X11/winX.c | 7 ++++++- win/X11/winstat.c | 11 +++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/win/X11/winX.c b/win/X11/winX.c index 66a0ac184..d0209ca64 100644 --- a/win/X11/winX.c +++ b/win/X11/winX.c @@ -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 diff --git a/win/X11/winstat.c b/win/X11/winstat.c index c4c8adb6e..87d6b7be3 100644 --- a/win/X11/winstat.c +++ b/win/X11/winstat.c @@ -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++;