header file changes hack.h, decl.h/.c, system.h, wintty.h

- Move secondary preprocessor defines down further in config.h
so that they can be overridden via [platform]conf.h which is
included from global.h, specifically:
    LIVELOGFILE when LIVELOG is defined
    DUMPLOG_FILE when DUMPLOG is defined

- Minimize platform-specific, or compiler-specific code in hack.h and decl.h.

- reorganize src/decl.c to align with include/decl.h.

- a new header file cstd.h added, containing calls to C99
standard header files.

- hack.h, decl.h, and decl.c have been cleaned up and had code
moved so that things line up as follows:

     hack.h     defines values that are available to all
                NetHack source files, contains enums for use in all
                NetHack source files, and contains a number of
                struct definitions for use in all NetHack source files.
                It does not contain variable declarations or variable
                definitions.

     decl.h     contains the extern declarations for variables that
                are defined in decl.c. These variables are global and
                available to all NetHack source files. The location of
                the variables within decl.h was random, so give it some
                order for now.

     decl.c     contains the definition of the variables declared in
                decl.h, and initializes them where appropriate. The
                variable definitions are laid out in much the
                same order as their declarations in decl.h.

- wintty.h: There were some varying terminal-related prototypes in
system.h, and that was the only thing left that demanded that
system.h be included. Those have been replaced by an #include
<term.h> in include/wintty.h to get the more current (and hopefully
more correct) prototypes, rather than hardcoding them in NetHack
sources.

For edge-case platform compatiblity, there is no #include <term.h>
if the build defines NO_TERMCAP_HEADERS. In that case one set of
hardcoded prototypes is still used in include/wintty.h.

The added #include "term.h" is also bypassed for NO_TERMS builds (builds
that don't link to terminfo/termcap at all, but still present a tty
interface using platform or window-port specific functions to fulfill
the same role as that of terminfo/termcap).

- some scattered, unnecessary #include "integer.h" were removed from
various files, since that's always included in current NetHack-3.7
sources, either directly from config.h or indirectly from #include
"hack.h".

- system.h references removed.

- new cstd.h added; the #include "system.h" references in Makefiles
and project files (Xcode, visual studio), were replaced
with #include "cstd.h" references. A "make depends" is probably
warranted.

Also:

 - Use of <term.h>, which defines clear_screen() as a macro, conflicts
with an actual function with that name in win/tty/termcap.c. The most
straight-forward course of action was to rename the NetHack function,
and change the references to it, from clear_screen() to
term_clear_screen(), so that was done.
This commit is contained in:
nhmall
2023-04-05 11:49:09 -04:00
parent ddca5650ea
commit 2185d325c4
30 changed files with 1294 additions and 1223 deletions
+22 -3
View File
@@ -158,7 +158,7 @@ E void xputs(const char *);
E void xputg(const glyph_info *, const glyph_info *);
#endif
E void cl_end(void);
E void clear_screen(void);
E void term_clear_screen(void);
E void home(void);
E void standoutbeg(void);
E void standoutend(void);
@@ -291,7 +291,26 @@ E win_request_info *tty_ctrl_nhwindow(winid, int, win_request_info *);
E void tty_refresh_inventory(int start, int stop, int y);
#endif
#ifdef NO_TERMS
/* termcap is implied if NO_TERMS is not defined */
#ifndef NO_TERMS
#ifndef NO_TERMCAP_HEADERS
#ifdef delay_output /* avoid conflict in curses.h */
#undef delay_output
#endif
#include <curses.h>
#ifdef clear_screen /* avoid a conflict */
#undef clear_screen
#endif
#include <term.h>
#else
extern int tgetent(char *, const char *);
extern void tputs(const char *, int, int (*)(int));
extern int tgetnum(const char *);
extern int tgetflag(const char *);
extern char *tgetstr(const char *, char **);
extern char *tgoto(const char *, int, int);
#endif /* NO_TERMCAP_HEADERS */
#else /* ?NO_TERMS */
#ifdef MAC
#ifdef putchar
#undef putchar
@@ -317,7 +336,7 @@ E int term_puts(const char *str);
E void video_update_positionbar(char *);
#endif
#endif /*MSDOS*/
#endif /*NO_TERMS*/
#endif /* NO_TERMS */
#undef E