File nethack-address-H4266-build-problem-with-clang-Modules.patch of Package nethack

From 7a5fb72787412a9989b3ca80b529688265331bc8 Mon Sep 17 00:00:00 2001
From: PatR <rankin@nethack.org>
Date: Wed, 2 Mar 2016 00:37:56 -0800
Subject: address #H4266 - build problem with clang Modules

Report states that using OSX Xcode IDE results in use of 'clang
Modules', whatever those are, and role.c's 'filter' struct ends up
conflicting with a function declared by <curses.h> (or possibly
<ncurses.h> since one includes the other).  src/role.c does not
include <curses.h>, so this smacks of the problems caused by using
precompiled headers on pre-OSX Mac.

Instead of trying to import nethack into Xcode, I temporarily
inserted '#include <curses.h>' at the end of unixconf.h.  gcc did
complain about 'filter' in role.c (but not in invent.c, despite
-Wshadow), and then complained about termcap.c using TRUE when it
wasn't defined (after in had been #undef'd, where there's a comment
stating that it won't be used in the rest of that file), and also
complained about static function winch() in wintty.c conflicting
with external winch() in curses.

This renames 'filter' and 'winch()' to things that won't conflict.
Also, our winch() is a signal handler but had the wrong signature
for one.  And the troublesome use of TRUE was in code that was
supposed to be dealing with int rather than boolean.

Backporting notes:
- only take changes to winch()

---
 doc/fixes36.1     |  2 ++
 src/invent.c      | 10 +++++-----
 src/role.c        | 44 ++++++++++++++++++++++----------------------
 win/tty/termcap.c | 14 ++++++++------
 win/tty/wintty.c  | 22 +++++++++++++++++-----
 5 files changed, 54 insertions(+), 38 deletions(-)

Index: nethack-3.4.3/win/tty/wintty.c
===================================================================
--- nethack-3.4.3.orig/win/tty/wintty.c
+++ nethack-3.4.3/win/tty/wintty.c
@@ -198,8 +198,21 @@ const char *mesg;
 }
 
 #if defined(SIGWINCH) && defined(CLIPPING)
+STATIC_DCL void FDECL(winch_handler, (int));
+
+    /*
+     * This really ought to just set a flag like the hangup handler does,
+     * then check the flag at "safe" times, in case the signal arrives
+     * while something fragile is executing.  Better to have a brief period
+     * where display updates don't fit the new size than for tty internals
+     * to become corrupted.
+     *
+     * 'winch_seen' has been "notyet" for a long time....
+     */
+/*ARGUSED*/
 STATIC_OVL void
-winch()
+winch_handler(sig_unused) /* signal handler is called with at least 1 arg */
+int sig_unused UNUSED;
 {
     int oldLI = LI, oldCO = CO, i;
     register struct WinDesc *cw;
@@ -298,7 +311,7 @@ char** argv;
     ttyDisplay->lastwin = WIN_ERR;
 
 #if defined(SIGWINCH) && defined(CLIPPING)
-    (void) signal(SIGWINCH, winch);
+    (void) signal(SIGWINCH, (SIG_RET_TYPE) winch_handler);
 #endif
 
     /* add one a space forward menu command alias */
openSUSE Build Service is sponsored by