From 45b2a6c49ac240f06aab363c8169174b23e499cd Mon Sep 17 00:00:00 2001 From: nhmall Date: Fri, 20 Dec 2024 10:32:38 -0500 Subject: [PATCH] more C standard progress There was a transcription error in the comments in cstd.h for the standard list of header files, where only the description remained for , not the name of the file itself. Remove several extraneous inclusions of the standard C99 headers. Tested on the following afterwards: Linux (using hints/linux.370) including tty, curses, qt6, and X11 macOS (using hints/macOS.370) including tty, curses, qt5, and X11 Windows MSYS2 using sys/windows/GNUmakefile Windows Visual Studio using sys/windows/Makefile.nmake msdos cross-compile on Ubuntu using djgpp cross-compiler --- include/cstd.h | 12 ++++++++---- include/global.h | 2 -- include/pcconf.h | 16 ---------------- include/unixconf.h | 5 ----- include/vmsconf.h | 3 --- include/windconf.h | 6 ------ src/allmain.c | 1 - src/attrib.c | 1 - src/coloratt.c | 1 - src/end.c | 1 - src/files.c | 2 -- src/makemon.c | 2 -- src/mon.c | 1 - src/report.c | 1 - src/utf8map.c | 1 - sys/libnh/libnhmain.c | 1 - sys/msdos/Makefile.GCC | 11 ++--------- sys/msdos/msdos.c | 1 - sys/msdos/tile2bin.c | 4 ---- sys/msdos/video.c | 1 - sys/msdos/vidtxt.c | 1 - sys/msdos/vidvga.c | 1 - sys/share/pcmain.c | 2 -- sys/share/pcsys.c | 1 - sys/unix/hints/include/cross-post.370 | 10 ++++++++-- sys/unix/hints/include/cross-pre2.370 | 2 ++ sys/unix/unixmain.c | 1 - sys/vms/vmsfiles.c | 1 - sys/vms/vmsmail.c | 1 - sys/vms/vmsunix.c | 1 - sys/windows/GNUmakefile | 2 ++ sys/windows/win32api.h | 3 ++- sys/windows/windmain.c | 2 -- sys/windows/windsys.c | 1 - win/X11/winval.c | 2 +- win/chain/wc_trace.c | 1 - win/curses/cursdial.c | 1 - win/curses/cursinit.c | 2 -- win/curses/cursmesg.c | 1 - win/curses/cursmisc.c | 2 -- 40 files changed, 25 insertions(+), 86 deletions(-) diff --git a/include/cstd.h b/include/cstd.h index 64028749f..3e4764b52 100644 --- a/include/cstd.h +++ b/include/cstd.h @@ -27,9 +27,9 @@ * Common macro definitions * (C99) Fixed-width integer types * Input/output program utilities - * - * General utilities: memory management, program utilities, string - * conversions, random numbers, algorithms + * General utilities: memory management, + * program utilities, string conversions, + * random numbers, algorithms * String handling * (C99) Type-generic math (macros wrapping math.h and * complex.h) @@ -51,13 +51,17 @@ * */ #if !defined(__cplusplus) - #include +#include #include #include #include #include #include +#include +#else /* !__cplusplus */ +/* for FILE */ +#include #endif /* !__cplusplus */ #endif /* CSTD_H */ diff --git a/include/global.h b/include/global.h index 7a32d105f..197a92da1 100644 --- a/include/global.h +++ b/include/global.h @@ -6,8 +6,6 @@ #ifndef GLOBAL_H #define GLOBAL_H -#include - /* * Files expected to exist in the playground directory (possibly inside * a dlb container file). diff --git a/include/pcconf.h b/include/pcconf.h index 5f8de8fb5..6736d8d9d 100644 --- a/include/pcconf.h +++ b/include/pcconf.h @@ -111,33 +111,21 @@ #if defined(_MSC_VER) && (_MSC_VER >= 7) #include -#include #ifdef strcmpi #undef strcmpi #endif -#include /* Provides prototypes of strncmpi(), etc. */ #include #include #include #define SIG_RET_TYPE void(__cdecl *)(int) -#define M(c) ((char) (0x80 | (c))) #define vprintf printf #define vfprintf fprintf #define vsprintf sprintf #endif -#if defined(__BORLANDC__) && defined(STRNCMPI) -#include /* Provides prototypes of strncmpi(), etc. */ -#endif - -#if defined(__DJGPP__) -#define _NAIVE_DOS_REGS -#include -#include /* Provides prototypes of strncmpi(), etc. */ #ifndef M #define M(c) ((char) (0x80 | (c))) #endif -#endif /* * On the VMS and unix, this option controls whether a delay is done by @@ -226,10 +214,6 @@ #define HLOCK "NHPERM" #endif -#ifndef AMIGA -#include -#endif - /* the high quality random number routines */ #ifndef USE_ISAAC64 # ifdef RANDOM diff --git a/include/unixconf.h b/include/unixconf.h index e27f542d2..1e346d3d5 100644 --- a/include/unixconf.h +++ b/include/unixconf.h @@ -302,8 +302,6 @@ #if defined(BSD) || defined(ULTRIX) #include -#else -#include #endif /* these might be needed for include/system.h; @@ -324,10 +322,7 @@ #define SHELL /* do not delete the '!' command */ #endif -/* #include "system.h" */ - #if defined(POSIX_TYPES) || defined(__GNUC__) -#include #include #endif diff --git a/include/vmsconf.h b/include/vmsconf.h index 7eac14895..57b8a7b05 100644 --- a/include/vmsconf.h +++ b/include/vmsconf.h @@ -213,7 +213,6 @@ PANICTRACE_GDB=2 #at conclusion of panic, show a call traceback and then #include #include #include -#include #include #include #include @@ -246,8 +245,6 @@ typedef int32_t off_t; #endif #endif /* _DECC_V4_SOURCE */ -#include - #ifndef VMSVSI #if 0 /* is missing for old gcc versions; skip it to save time */ #include diff --git a/include/windconf.h b/include/windconf.h index 63c58cdbc..55b68dfa5 100644 --- a/include/windconf.h +++ b/include/windconf.h @@ -165,8 +165,6 @@ typedef SSIZE_T ssize_t; #include -#include -#include #ifdef __BORLANDC__ #undef randomize #undef random @@ -185,10 +183,6 @@ typedef SSIZE_T ssize_t; #endif #define NO_SIGNAL - -/* Time stuff */ -#include - #define USE_STDARG /* Use the high quality random number routines. */ diff --git a/src/allmain.c b/src/allmain.c index 852904683..18e163b5a 100644 --- a/src/allmain.c +++ b/src/allmain.c @@ -6,7 +6,6 @@ /* various code that was replicated in *main.c */ #include "hack.h" -#include #ifndef NO_SIGNAL #include diff --git a/src/attrib.c b/src/attrib.c index 36dd9ea91..079607c1b 100644 --- a/src/attrib.c +++ b/src/attrib.c @@ -5,7 +5,6 @@ /* attribute modification routines. */ #include "hack.h" -#include /* part of the output on gain or loss of attribute */ static const char diff --git a/src/coloratt.c b/src/coloratt.c index 8e68a469d..e2053e238 100644 --- a/src/coloratt.c +++ b/src/coloratt.c @@ -3,7 +3,6 @@ /* NetHack may be freely redistributed. See license for details. */ #include "hack.h" -#include struct color_names { const char *name; diff --git a/src/end.c b/src/end.c index ace45f699..1bacb7547 100644 --- a/src/end.c +++ b/src/end.c @@ -9,7 +9,6 @@ #ifndef NO_SIGNAL #include #endif -#include #ifndef LONG_MAX #include #endif diff --git a/src/files.c b/src/files.c index b214c7a55..d7ce06f60 100644 --- a/src/files.c +++ b/src/files.c @@ -7,7 +7,6 @@ #include "hack.h" #include "dlb.h" -#include #ifdef TTY_GRAPHICS #include "wintty.h" /* more() */ @@ -45,7 +44,6 @@ const #if defined(UNIX) && defined(SELECTSAVED) #include #include -#include #endif #if defined(UNIX) || defined(VMS) || !defined(NO_SIGNAL) diff --git a/src/makemon.c b/src/makemon.c index e8c6bf298..9ff2c2da5 100644 --- a/src/makemon.c +++ b/src/makemon.c @@ -5,8 +5,6 @@ #include "hack.h" -#include - /* this assumes that a human quest leader or nemesis is an archetype of the corresponding role; that isn't so for some roles (tourist for instance) but is for the priests and monks we use it for... */ diff --git a/src/mon.c b/src/mon.c index 7a381420b..cda5f4b65 100644 --- a/src/mon.c +++ b/src/mon.c @@ -5,7 +5,6 @@ #include "hack.h" #include "mfndpos.h" -#include staticfn void sanity_check_single_mon(struct monst *, boolean, const char *); staticfn struct obj *make_corpse(struct monst *, unsigned); diff --git a/src/report.c b/src/report.c index 5be3e93dd..6e82c66c3 100644 --- a/src/report.c +++ b/src/report.c @@ -9,7 +9,6 @@ # ifndef NO_SIGNAL #include # endif -#include # ifndef LONG_MAX #include # endif diff --git a/src/utf8map.c b/src/utf8map.c index f39ce26a1..87688b9ce 100644 --- a/src/utf8map.c +++ b/src/utf8map.c @@ -3,7 +3,6 @@ /* NetHack may be freely redistributed. See license for details. */ #include "hack.h" -#include #ifdef ENHANCED_SYMBOLS diff --git a/sys/libnh/libnhmain.c b/sys/libnh/libnhmain.c index 56ee3cb58..20835dda6 100644 --- a/sys/libnh/libnhmain.c +++ b/sys/libnh/libnhmain.c @@ -8,7 +8,6 @@ #include "hack.h" #include "dlb.h" -#include #include #include #include diff --git a/sys/msdos/Makefile.GCC b/sys/msdos/Makefile.GCC index 6b4a7cc6f..9ed3b27a2 100644 --- a/sys/msdos/Makefile.GCC +++ b/sys/msdos/Makefile.GCC @@ -458,18 +458,11 @@ endif INCLDIR=$(PDCINCL) -I../include -I../sys/msdos $(LUAINCL) # Debugging -#cflags = -pg -c $(INCLDIR) $(DLBFLG) $(CURSESDEF) -DSUPPRESS_GRAPHICS +#cflags = -pg -c -D_NAIVE_DOS_REGS $(INCLDIR) $(DLBFLG) $(CURSESDEF) -DSUPPRESS_GRAPHICS #LFLAGS = -pg -cflags = -c -O $(INCLDIR) $(DLBFLG) $(CURSESDEF) -DSUPPRESS_GRAPHICS -LFLAGS = - -# Debugging -#cflags = -g -c $(INCLDIR) $(DLBFLG) $(CURSESDEF) -DTILES_IN_GLYPHMAP -#LFLAGS = -g - # Normal -cflags = -c -O $(INCLDIR) $(DLBFLG) $(CURSESDEF) -DTILES_IN_GLYPHMAP +cflags = -c -O -D_NAIVE_DOS_REGS $(INCLDIR) $(DLBFLG) $(CURSESDEF) -DTILES_IN_GLYPHMAP LFLAGS = #========================================== diff --git a/sys/msdos/msdos.c b/sys/msdos/msdos.c index 735e84dd9..8a059008d 100644 --- a/sys/msdos/msdos.c +++ b/sys/msdos/msdos.c @@ -15,7 +15,6 @@ #include "pcvideo.h" #include -#include /* * MS-DOS functions diff --git a/sys/msdos/tile2bin.c b/sys/msdos/tile2bin.c index 1fa622d11..0e90935fc 100644 --- a/sys/msdos/tile2bin.c +++ b/sys/msdos/tile2bin.c @@ -18,10 +18,6 @@ #include "pctiles.h" /* #include */ -#ifndef MONITOR_HEAP -#include -#endif -#include #ifdef __GO32__ #include diff --git a/sys/msdos/video.c b/sys/msdos/video.c index ae03e2541..a849027eb 100644 --- a/sys/msdos/video.c +++ b/sys/msdos/video.c @@ -105,7 +105,6 @@ void g_pututf8(uint8 *utf8str) #ifdef NO_TERMS -#include #include "wintty.h" #ifdef __GO32__ diff --git a/sys/msdos/vidtxt.c b/sys/msdos/vidtxt.c index b89d3616c..35b314b26 100644 --- a/sys/msdos/vidtxt.c +++ b/sys/msdos/vidtxt.c @@ -18,7 +18,6 @@ #include "wintty.h" #include -#include #if defined(_MSC_VER) #if _MSC_VER >= 700 diff --git a/sys/msdos/vidvga.c b/sys/msdos/vidvga.c index f2473cfc5..506068ac9 100644 --- a/sys/msdos/vidvga.c +++ b/sys/msdos/vidvga.c @@ -14,7 +14,6 @@ #include "font.h" #include -#include #include "wintty.h" #ifdef __GO32__ diff --git a/sys/share/pcmain.c b/sys/share/pcmain.c index 3e0a4c355..0bb30b488 100644 --- a/sys/share/pcmain.c +++ b/sys/share/pcmain.c @@ -12,8 +12,6 @@ #include #endif -#include - #if !defined(AMIGA) && !defined(__DJGPP__) #include #else diff --git a/sys/share/pcsys.c b/sys/share/pcsys.c index 20b68c3e3..ed779a284 100644 --- a/sys/share/pcsys.c +++ b/sys/share/pcsys.c @@ -10,7 +10,6 @@ #include "hack.h" #include "wintty.h" -#include #include #if !defined(MSDOS) && !defined(WIN_CE) && !defined(CROSS_TO_AMIGA) #include diff --git a/sys/unix/hints/include/cross-post.370 b/sys/unix/hints/include/cross-post.370 index c6f40e52d..5c4c9ba08 100644 --- a/sys/unix/hints/include/cross-post.370 +++ b/sys/unix/hints/include/cross-post.370 @@ -79,8 +79,14 @@ ifeq "$(WANT_DEBUG)" "1" pwd; echo "$(GDBEXE) not found and WANT_DEBUG=1 specified"; \ fi; ) else - -rm $(TARGETPFX)pkg/GDB.EXE - -rm $(TARGETPFX)pkg/NHGDB.BAT + -( if [ -f $(TARGETPFX)pkg/GDB.EXE ]; \ + then \ + rm $(TARGETPFX)pkg/GDB.EXE; \ + fi; ) + -( if [ -f $(TARGETPFX)pkg/NHGDB.BAT ]; \ + then \ + rm $(TARGETPFX)pkg/NHGDB.BAT; \ + fi; ) endif -touch $(TARGETPFX)pkg/RECORD cd $(TARGETPFX)pkg ; zip -9 ../NH370DOS.ZIP * ; cd ../../.. diff --git a/sys/unix/hints/include/cross-pre2.370 b/sys/unix/hints/include/cross-pre2.370 index 15fbe719c..e1ade8fb3 100644 --- a/sys/unix/hints/include/cross-pre2.370 +++ b/sys/unix/hints/include/cross-pre2.370 @@ -177,10 +177,12 @@ MSDOS_GPP_CFLAGS = -Wall -Wextra -Wno-missing-field-initializers -Wreturn-type \ MSDOS_TARGET_CFLAGS = -c -O $(DBGFLAGS) -I../include -I../sys/msdos -I../win/share \ $(LUAINCL) -DDLB $(PDCURSESDEF) -DTILES_IN_GLYPHMAP \ -DCROSSCOMPILE -DCROSSCOMPILE_TARGET -DCROSS_TO_MSDOS \ + -D_NAIVE_DOS_REGS \ $(MSDOS_GCC_CFLAGS) MSDOS_TARGET_CXXFLAGS = -c -O $(DBGFLAGS) -I../include -I../sys/msdos -I../win/share \ $(LUAINCL) -DDLB $(PDCURSESDEF) \ -DUSE_TILES -DCROSSCOMPILE -DCROSSCOMPILE_TARGET -DCROSS_TO_MSDOS \ + -D_NAIVE_DOS_REGS \ $(MSDOS_GPP_CFLAGS) PDCINCL += -I$(PDCPORT) PDC_TARGET_CFLAGS = $(MSDOS_TARGET_CFLAGS) -Wno-unused-parameter \ diff --git a/sys/unix/unixmain.c b/sys/unix/unixmain.c index 2da734fd0..e6b09492c 100644 --- a/sys/unix/unixmain.c +++ b/sys/unix/unixmain.c @@ -8,7 +8,6 @@ #include "hack.h" #include "dlb.h" -#include #include #include #include diff --git a/sys/vms/vmsfiles.c b/sys/vms/vmsfiles.c index 885b4c5f1..38a80b9a8 100644 --- a/sys/vms/vmsfiles.c +++ b/sys/vms/vmsfiles.c @@ -8,7 +8,6 @@ * routines or substitute for ones where we want behavior modification. */ #include "config.h" -#include #ifdef VMSVSI #include diff --git a/sys/vms/vmsmail.c b/sys/vms/vmsmail.c index d29fdb888..24f9ad5fa 100644 --- a/sys/vms/vmsmail.c +++ b/sys/vms/vmsmail.c @@ -20,7 +20,6 @@ struct mail_info *parse_next_broadcast(void); #ifdef MAIL #include "wintype.h" #include "winprocs.h" -#include #include #include #ifndef __GNUC__ diff --git a/sys/vms/vmsunix.c b/sys/vms/vmsunix.c index 090ce9e64..89b18a174 100644 --- a/sys/vms/vmsunix.c +++ b/sys/vms/vmsunix.c @@ -29,7 +29,6 @@ #include #undef umask #endif -#include extern int debuggable; /* defined in vmsmisc.c */ diff --git a/sys/windows/GNUmakefile b/sys/windows/GNUmakefile index f38aaf4f6..4e6ee45e5 100644 --- a/sys/windows/GNUmakefile +++ b/sys/windows/GNUmakefile @@ -97,6 +97,8 @@ GCC_EXTRA_WARNINGS = N # #============================================================================== +$(info Using $(lastword $(MAKEFILE_LIST))) + SKIP_NETHACKW = N USE_LUADLL = Y WANT_LUAC = N diff --git a/sys/windows/win32api.h b/sys/windows/win32api.h index d37daf7f3..1089f8b45 100644 --- a/sys/windows/win32api.h +++ b/sys/windows/win32api.h @@ -30,6 +30,8 @@ #error win32api.h should be included first #endif +#include "config.h" + #if defined(_MSC_VER) #pragma warning(disable : 4142) /* Warning, Benign redefinition of type */ #pragma pack(8) @@ -37,7 +39,6 @@ #ifdef DEBUG #define _CRTDBG_MAP_ALLOC -#include #include #endif diff --git a/sys/windows/windmain.c b/sys/windows/windmain.c index cd1bdf9bd..df7144a20 100644 --- a/sys/windows/windmain.c +++ b/sys/windows/windmain.c @@ -10,8 +10,6 @@ #ifdef DLB #include "dlb.h" #endif -#include -#include #include #include #include diff --git a/sys/windows/windsys.c b/sys/windows/windsys.c index 93d7f5f58..05b073a45 100644 --- a/sys/windows/windsys.c +++ b/sys/windows/windsys.c @@ -20,7 +20,6 @@ #ifndef __BORLANDC__ #include #endif -#include #ifdef TTY_GRAPHICS #include "wintty.h" #endif diff --git a/win/X11/winval.c b/win/X11/winval.c index c333a5483..651ba2cbb 100644 --- a/win/X11/winval.c +++ b/win/X11/winval.c @@ -6,7 +6,7 @@ * Routines that define a name-value label widget pair that fit inside a * form widget. */ -#include +/* #include */ #ifndef SYSV #define PRESERVE_NO_SYSV /* X11 include files may define SYSV */ diff --git a/win/chain/wc_trace.c b/win/chain/wc_trace.c index 6738d0b0b..2048a05c4 100644 --- a/win/chain/wc_trace.c +++ b/win/chain/wc_trace.c @@ -6,7 +6,6 @@ #include "wintty.h" #include "func_tab.h" -#include #include #ifdef WIN32 diff --git a/win/curses/cursdial.c b/win/curses/cursdial.c index a0e93d093..dddfd400e 100644 --- a/win/curses/cursdial.c +++ b/win/curses/cursdial.c @@ -11,7 +11,6 @@ #include "cursmisc.h" #include "cursdial.h" #include "func_tab.h" -#include #if defined(FILENAME_CMP) && !defined(strcasecmp) #define strcasecmp FILENAME_CMP diff --git a/win/curses/cursinit.c b/win/curses/cursinit.c index fcf13ec19..529b46182 100644 --- a/win/curses/cursinit.c +++ b/win/curses/cursinit.c @@ -8,8 +8,6 @@ #include "wincurs.h" #include "cursinit.h" -#include - /* Initialization and startup functions for curses interface */ /* Private declarations */ diff --git a/win/curses/cursmesg.c b/win/curses/cursmesg.c index 2709d592a..6a30c159c 100644 --- a/win/curses/cursmesg.c +++ b/win/curses/cursmesg.c @@ -8,7 +8,6 @@ #include "wincurs.h" #include "cursmesg.h" #include "curswins.h" -#include /* defined in sys//tty.c or cursmain.c as last resort; set up by curses_init_nhwindows() */ diff --git a/win/curses/cursmisc.c b/win/curses/cursmisc.c index 71b9f31f6..42dd6250b 100644 --- a/win/curses/cursmisc.c +++ b/win/curses/cursmisc.c @@ -10,8 +10,6 @@ #include "func_tab.h" #include "dlb.h" -#include - /* Misc. curses interface functions */ /* Private declarations */