Commit Graph

368 Commits

Author SHA1 Message Date
nhmall
fce82ac0f3 Merge branch 'patch-4' of https://github.com/nikolas/NetHack into NetHack-3.7 2024-05-07 10:15:17 -04:00
Pasi Kallinen
a57d0e6f4f Curses: add support for the palette config option
Depends on CHANGE_COLOR compile-time option.

Also allow multiple palette-definitions in the config file.
2024-04-13 12:01:43 +03:00
nhmall
d0c543748e follow-up: use VIEWDEPRECATIONS instead of KEEPDEPRECATIONS 2024-04-01 15:04:07 -04:00
nhmall
61252f5c02 allow KEEPDEPRECATIONS=1 on make command line to see what's deprecated 2024-04-01 14:59:41 -04:00
nikolas
f507ebba47 Fix typo in linux.370 hint file 2024-03-21 14:46:03 -04:00
Pasi Kallinen
4030ef13a0 Curses: implement the windowcolors option
Allow changing the curses windows foreground and background colors,
for example:

OPTIONS=windowcolor:menu #8000F0/20F080 message grey/blue
2024-03-17 18:41:52 +02:00
nhkeni
0227a2e0bf hints/macOS.370: remove testing code 2024-03-16 19:42:42 -04:00
nhkeni
59486fb8ad something concrete for discussion:
infrastructure for NOSTATICFN, replacing NOSTATICCORE
2024-03-13 11:39:24 -04:00
nhmall
bb4bcb400e cross-compiling update 2024-03-12 10:06:37 -04:00
nhkeni
7ad921ebe7 Merge branch 'keni-pending2' into NetHack-3.7 2024-03-10 10:36:24 -04:00
nhkeni
79867d78c8 Two new features primarily in Makefile.src:
NOSTATICCORE - an option for Linux to get a better backtrace
updatedepend - an easier alternative to "make depend"

- .gitignore: ignore new temporary .*.c files
- hints/linux.370: add NOSTATICCORE and instructions
- Makefile.src:
-- If NOSTATICCORE defined, run core .c files through awk to
   remove static attribute from functions.
-- add updatedepend target and related bits
2024-03-09 15:16:24 -05:00
nhmall
aacfbecf5c more CI build fixes 2024-03-07 11:44:35 -05:00
nhmall
50811037f3 split some code into separate files
new .h files: hacklib.h selvar.h stairs.h

new .c files: calendar.c, getpos.c, report.c, selvar.c, stairs.c,
              strutil.c, wizcmds.c

cleanup of hacklib.c and mdlib.c

hacklib contains functions that do not have to link with the core

relocate wiz commands from cmd.c to wizcmds.c

relocate CRASHREPORT stuff to report.c

relocate getpos stuff from do_name.c to getpos.c

remove temporary struct definition from extern.h

cross-compile PRE-section split into cross-pre1.370 and cross-pre2.370

Windows sys/windows/Makefile.nmake and sys/windows/Makefile.mingw32 and
visual studio project file updates

Unix sys/unix/Makefile.src, sys/unix/Makefile.utl

populate selvar.c and selvar.h

build on MS-DOS (not cross-compile) Makefile updates
for sys/msdos/Makefile.GCC (untested)

vms updates for above (untested)
2024-03-07 11:01:04 -05:00
RainRat
a3658f85ac fix typos 2024-02-28 20:15:56 -08:00
nhkeni
61f4d972bb Add local md4 implementation and drop libcrypto for linux. 2024-02-23 17:05:45 -05:00
nhkeni
72ae3c7282 if makedefs doesn't exist, force NOCRASHREPORT 2024-02-15 20:42:57 -05:00
nhkeni
c02220499b Add CROSSCOMPILE to mdgrep, then use it to stop CRASHREPORT when cross-compiling 2024-02-15 19:37:43 -05:00
nhkeni
727740749e Try to fix linux for installations that don't have openssl includes. 2024-02-15 18:08:58 -05:00
nhkeni
3d3ce2369c Merge branch 'keni-wincw2' into NetHack-3.7
Lots of manually resolved conflicts.
2024-02-15 16:25:12 -05:00
Pasi Kallinen
b37f1408d8 Self-recover for linux
Compile-time option SELF_RECOVER was implemented for Windows;
add it to unix systems too, with it being on by default when
compiling with the linux hints file.
2024-02-08 11:34:59 +02:00
nhkeni
dbe5c98dca add CRASHREPORT directly to browser
add CRASHREPORT for Windows
add ^P info to report (via DUMPLOG)

new options: crash_email, crash_name, crash_urlmax
new game command: #bugreport
new config option: CRASHREPORT_EXEC_NOSTDERR
new command line option: --bidshow

deleted helper scripts:
    NetHackCrashReport.Javascript
    nhcrashreport.lua

misc:
    update CRASHREPORTURL (will need to be updated before release)
    update bitrot in winchain
    winchain for Windows
    add missing synch_wait for NetHackW --showpaths
    add PANICTRACE (and CRASHREPORT) in mdlib.c:build_opts

missing:
    packaging (Windows needs the pdb file)
    no testing with MSVC command line build

port status:
    linux: working, but glibc's backtrace doesn't show static functions
    Windows VS: working.  pdb file is large - looking into options
    MacOS: working
    msdos: not supported
    VMS: not supported
    MSVC: planned, but not attempted
    MSYS2: working, but libbacktrace not showing symbols (yet?)
2024-02-06 18:33:59 -05:00
nhmall
bac8ebad34 revisit Makefile sysconf steps
Add distinct potential steps into Makefile.top for putting
sysconf into place, instead of appending the steps for doing so
to the generic POSTINSTALL.

SYSCONFINSTALL is used for 'make install' and unconditionally
copies sys/unix/sysconf to the install directory.

SYSCONFENSURE is used for 'make update' and only copies
sys/unix/sysconf to the installation directory if it doesn't
already exist.

The initial trigger for revisiting this was because of new reports
that cp from (GNU coreutils) 9.4 is now issuing a warning during
NetHack builds. The warning pertains to deprecated use of the '-n'
switch with cp, which is used to only copy the file if the target
does not exist.

After this update, the shell is used to make that determination,
and if the file doesn't exist, cp is now invoked on Linux without
the '-n' switch.

For the macOS hints file, macOS.370, cp wasn't being used for sysconf
anyway, a utility script was being invoked and this doesn't change
that. macOS.370 was updated to remain in sync with linux.370 and
Makefile.top regarding the use of SYSCONFINSTALL and SYSCONFENSURE.
2024-01-27 18:12:18 -05:00
Michael Meyer
a831bf576b Add WANT_SOURCE_INSTALL to linux.370 hints file
WANT_SOURCE_INSTALL=1 can be specified when compiling to build NetHack
within the repo/source tree, rather than in the normal system install
location.  I find it useful for development on OSX, but it wasn't
present in any other hints files, so I've been using a custom hints file
on Linux for a while that adds the same option.  The code is based on
the macOS.370 hints file.
2023-12-30 16:40:54 -08:00
nhmall
9f5f4b3c32 fix broken 'make install' with hints/linux.370 2023-12-28 11:45:36 -05:00
nhmall
c197dfe29b include symify.exe in the NetHack msdos package
Before using this updated packaging you will need
to do the following (one time):
    sh sys/msdos/fetch-cross-compiler.sh

And you'll need to update your Makefiles as follows.

On Linux:
    sh sys/msdos/setup.sh sys/unix/hints/linux.370

or on macOS;
    sh sys/msdos/setup.sh sys/unix/hints/macOS.370

Create the msdos package with:
    make CROSS_TO_MSDOS=1 package
2023-12-18 14:48:10 -05:00
nhmall
978ec6a3a7 augment include/extern.h with nonnull arg info
Define some macros in include/tradstdc.h, for compilers that support
__attribute__((nonnull)), to assist in identifying which parameters
on functions are not supposed to be null pointers.

Next, for the majority of functions declared in include/extern.h, this
adds the appropriate macro that matches the actual use of each function's
parameters. The additions were done after performing some analysis.

These were the rules that were followed when determining which function
parameters should be nonnul, and which are nullable:

    1. If the first use of, or reference to, the pointer parameter in the
       function is a dereference, then the parameter will be considered
       nonnull.

    2. If there is code in the function that tests for the pointer parameter
       being null, and adjusts the code-path accordingly so that no segfault
       will occur, then the parameter will not be considered nonnull (it can
       be null).

The use of the nonnull attributes allows the compiler to detect code in
callers of the function where a null parameter could get passed to the function.

If a warning is received the developer will have to do one of the following:

     - If the null being passed to the function is now appropriate,
       and the function should be able to expect a null parameter, then the
       NONNULLxxx macro will have to be removed from the function's prototype.

    or

     - If the null being passed to the function is not appropriate,
       correct the caller so it is not passing null.

    or

     - If the warning is about comparing to null, it may indicate an
       unnecessary null check in the code involved. If it is deemed to be
       unnecessary, it can then be removed.

Some static analysis tools apparently can work with the attribute, as well.

Following this, it was discovered that some functions were using one of the
(now) nonnull parameters in the first argument to the 'is_art(obj, ART)'
macro, which is defined like so:
 =>   #define is_art(o,art) ((o) && (o)->oartifact == (art))

That macro expansion inline resulted in a diagnostic warning because of the
'(o)' portion of the expanded macro, anywhere the macro was used with one of
the nonnull parameters. A test against null for a 'nonnull parameter' causes
a diagnostic warning.

To work around that, I replaced the is_art() macro with a function in
artifact.c, that accomplishes the same thing as the macro.

 =>   boolean
      is_art(struct obj *obj, int art)
      {
          if (obj && obj->oartifact == art)
              return TRUE;
          return FALSE;
      }

Some documentation...

These are the macros that have been defined for use when specifying the nonnull
parameters in a function prototype:

   ----------------------------------------------------------------------------
   |      Macro     |              Purpose                                    |
   +----------------+---------------------------------------------------------+
   | NONULL         | The function return value is never NULL.                |
   +----------------+---------------------------------------------------------+
   | NONNULLPTRS    | Every pointer argument is declared nonnull.             |
   +----------------+---------------------------------------------------------+
   | NONNULLARG1    | The 1st argument is declared nonnull.                   |
   +----------------+---------------------------------------------------------+
   | NONNULLARG2    | The 2nd argument is declared nonnull.                   |
   +----------------+---------------------------------------------------------+
   | NONNULLARG3    | The 3rd argument is declared nonnull.                   |
   +----------------+---------------------------------------------------------+
   | NONNULLARG4    | The 4th argument is declared nonnull (not used).        |
   +----------------+---------------------------------------------------------+
   | NONNULLARG5    | The 5th argument is declared nonnull.                   |
   +----------------+---------------------------------------------------------+
   | NONNULLARG7    | The 7th argument is declared nonnull (bhit).            |
   +----------------+---------------------------------------------------------+
   | NONNULLARG12   | The 1st and 2nd arguments are declared nonnull.         |
   +----------------+---------------------------------------------------------+
   | NONNULLARG13   | The 1st and 3rd arguments are declared nonnull.         |
   +----------------+---------------------------------------------------------+
   | NONNULLARG123  | The 1st, 2nd and 3rd arguments are declared nonnull.    |
   +----------------+---------------------------------------------------------+
   | NONNULLARG14   | The 1st and 4th arguments are declared nonnull.         |
   +----------------+---------------------------------------------------------+
   | NONNULLARG134  | The 1st, 3rd and 4th arguments are declared nonnull.    |
   +----------------+---------------------------------------------------------+
   | NONNULLARG17   | The 1st and 7th arguments are declared nonnull (this    |
   |                | was a special-case added for askchain(), where the      |
   |                | arguments are spread out that way. This macro           |
   |                | could be removed if the askchain arguments in the       |
   |                | prototype and callers were changed to make the          |
   |                | nonnull arguments side-by-side).                        |
   +----------------+---------------------------------------------------------+
   | NONNULLARG145  | The 1st, 4th and 5th arguments are declared nonnull     |
   |                | (this was a special-case added for find_roll_to_hit(),  |
   |                | in uhitm.c, where the arguments are spread out that way.|
   |                | We can't just use NONNULLPTRS there because the 3rd     |
   |                | argument 'weapon' can be NULL).                         |
   +----------------+---------------------------------------------------------+
   | NONNULLARG24   | The 2nd and 4th arguments are declared nonnull (this    |
   |                | was a special-case added for query_objlist()            |
   |                | in invent.c).                                           |
   +----------------+---------------------------------------------------------+
   | NONNULLARG45   | The 4th and 5th arguments are declared nonnull (this    |
   |                | was a special-case added for do_screen_description(),   |
   |                | in pager.c, where the arguments are spread out that     |
   |                | way. We can't just use NONNULLPTRS there because the    |
   |                | 6th argument can be NULL).                              |
   +----------------+---------------------------------------------------------+
   | NO_NONNULLS    | This macro expands to nothing. It is just used to       |
   |                | mark that analysis has been done on the function,       |
   |                | and concluded that none of the arguments could be       |
   |                | marked nonnull.That distinguishes a function that has   |
   |                | not been analyzed (yet), from one that has.             |
   +----------------+---------------------------------------------------------+

The NO_NONNULLS macro is meant to place a flag on the prototype to
make people aware that an assessed function was determined to not
be eligible for nonnull parameters. It expands to nothing.

Unfortunately, that macro was added partway through this exercise, so there
aren't many instances of it in the upper parts of include/extern.h, even though
the functions there were likely assessed and categorized as not having any
eligible nonnull parameters. It just never got any macro at all, in that case.

Following the parameter usage analysis that was done, the following was
noted:

       Some NetHack functions have added a test to catch a passed null
       parameter, and exit the function early as a result, or call
       impossible(), and then exit. While that approach prevents segfaults
       from dereferencing a null parameter, the early return is silent
       (when impossible is not called anyway), and the function's true
       purpose is not fulfilled. Also, the calling function may have no
       awareness that the function did not complete its intended purpose,
       in many instances.

       Functions with such a test and early return, cannot have the parameter
       declared 'nonnull', because the code to test for 'null' will cause a
       diagnostic to be issued if the parameter is nonnull.

       It might be good to revisit some of those functions and consider,
       on a case by case basis, declaring the parameter nonnull in the
       prototype, and the test/code-path commented out.
2023-12-14 20:06:03 -05:00
nhmall
5dd12fdc83 mandoc follow-up 2023-11-29 00:40:48 -05:00
nhmall
05c720bf9d more macOS make manpages follow-up 2023-11-29 00:11:04 -05:00
nhmall
dc7685f33c update MANDIR for macOS 2023-11-28 23:58:51 -05:00
nhmall
cbeb8a51a3 some macOS doc updates
Allow 'make USE_MANDOC=1 distrib' to be used for generating
the doc/*.txt files for systems that have mandoc and may not have groff.
(macOS Ventura doesn't include groff in the OS).
USE_MANDOC=1 is not restricted only to macOS.

Have hints/macOS.370 specify the /usr/share/man/man6 directory for the macOS
man pages, so that 'make manpages' will target the correct directory on
that platform.
2023-11-28 23:44:23 -05:00
nhmall
571de1528d some doc updates
add a 'distrib' target to the top level Makefile so that the
distribution doc/*.txt files can be created via 'make distrib'
from the top directory.  It utilizes the existing 'distrib'
target in the doc/Makefile.

Have hints/linux.370 specify the correct directory for Linux
man pages of /usr/share/man/man6, so that 'sudo make manpages'
works on that platform,
2023-11-28 22:49:31 -05:00
nhmall
521af751f3 more issue #1153
Some changes to achieve the following MAN2TXT commands...

If groff version is 1.23 or greater:
nroff -man -Tascii -P -cbou

If groff version is less than 1.23:
nroff -man -Tascii -c | col -b

If non-groff nroff:
nroff -man | col -b

Closes #1153 again.
2023-11-28 17:00:28 -05:00
nhmall
c8f4ad907f more MAN2TXT follow-up
Following a commit for Issue #1153, g-branden-robinson commented:
> Mac OS X stayed on _groff_ 1.19.2 for over a decade (presumably due to
> _groff_ 1.20 adopting to GNU GPLv3), until finally dropping _groff_
> altogether for macOS Ventura (2022).
>
> There _has_ been an interface change in that time.  The [`-P` option I
> advised about is new to _groff_ 1.23.0 (July 2023)]
> (https://git.savannah.gnu.org/cgit/groff.git/tree/NEWS?h=1.23.0#n86).
> [...]
>
> There is a significant number of _groff_ users via Homebrew (enough that
> we hear from them occasionally via bug reports).  Some of these have
> upgraded to 1.23.0 via that mechanism.
> [...]
>
> `nroff -` is not necessary with any _nroff_ known to me; like many other
> Bell Labs Unix programs, it reads from the standard input stream by default
> if not given any operands.

Action taken:

1. Remove the unnecessary ' -' from the nroff command in Makefile.doc.
2. In the misc.370 file containing make snippets to include, test whether
   groff >= 1.23, and only insert the -P option for 1.23 or greater.
2023-11-28 08:00:14 -05:00
nhmall
8a4a964ff1 minor typo fix in a comment 2023-11-27 17:54:16 -05:00
nhmall
2873706c84 hints name change and doc/Makefile
rename hints/include/multiw-3.370 to hints/include/misc.370

keep the portable nroff options in sys/unix/Makefile.doc,
and relocate the non-portable bits to a variable defined
in sys/unix/hints/include/misc.370

This assumes that the groff options are compatible between
Linux and macOS implementations of groff.

If that turns out not to be the case, this bit:

    ifneq "$(NROFFISGROFF)" ""   # It's groff
    # add the groff-specific plain text flags
    MORE_MAN2TXT_FLAGS += -Tascii -P -cbou
    endif

should relocate from sys/unix/hints/include/misc.370
to sys/unix/hints/linux.370 and sys/unix/hints/macOS.370,
immediately following the inclusion of misc.370, and the
appropriate platform-specific groff options can be
adjused in whichever of those appropriately needs it.

Closes #1153
2023-11-27 17:44:02 -05:00
nhmall
28a4afb3bb remove redundant assignment in macOS.370 and linux.370 2023-11-21 10:26:17 -05:00
nhmall
74340e0de5 follow-up to Makefile out-of-date checking
linux.370 and macOS.370 pass the name of the hints file
and the list of included files, that they use, to Makefile.check.

The name of the hints file is in variable HINTSFILE, the
definition of which is now inserted by setup.sh

The list of hints include files is in variable HINTSINCLFILES.
2023-11-21 10:18:24 -05:00
nhmall
7e3398c85d macOS follow-up 2023-11-20 22:18:35 -05:00
nhmall
4a08f20090 do the Makefile checking using make itself 2023-11-20 22:14:22 -05:00
nhmall
4c9d5a752a more follow-up 2023-11-20 16:19:54 -05:00
nhmall
2f167a4672 allow clean build without using -Wno-missing-field-initializers 2023-11-20 14:25:09 -05:00
nhmall
983000618c another general-pre.370 follow-up 2023-11-20 11:53:58 -05:00
nhmall
90c08ab6d3 follow-up to general-pre.370 change 2023-11-20 11:07:32 -05:00
nhmall
3fc24d937b inform the builder if their Makefiles need updating 2023-11-20 10:48:31 -05:00
nhmall
11ad859c4c nothing actually depends on options anymore 2023-11-18 19:21:54 -05:00
nhmall
a08b2e254a get rid of a warning during our pdcursesmod build
../lib/pdcursesmod/dos/../common/dosutil.c:36:15: warning: comparison of integer expressions of different signedness: 'long int' and 'long unsigned int' [-Wsign-compare]
   36 |     while( ms > MAX_NAP_SPAN)
      |               ^

It isn't something that we can actually resolve within NetHack,
so just suppress the submodule build warning.

This commit will trigger the CI to carry out a test of the build.
There could be some follow-up after the results.
2023-11-15 13:28:50 -05:00
G. Branden Robinson
9a96e0a198 Fix *roff string usage nit
String definitions were being used with a pointless leading double
quote.  This syntax is used only to define strings containing leading
space characters.  (You might also use it defensively if you're defining
one string whose contents start with the interpolation of another, and
the latter might interpolate leading space--but that is not the case
here.)

Remove unnecessary leading quotes from string definitions.

* doc/Guidebook.mn: Do it.  Also annotate empty strings with comment.
* sys/unix/hints/include/gbdates-post.370: Don't put them back.

https://www.gnu.org/software/groff/manual/groff.html.node/Strings.html
2023-11-06 14:43:34 -06:00
nhmall
196fd41817 comment out font warning argument to groff 1.23
The font warnings are no longer being generated as of b73e4815,
so there is no need for the '-W font' argument to groff at this time.
2023-11-02 10:31:50 -04:00
nhmall
5c87596597 support builds incl Qt6 with clang-14,15,16,17 2023-10-31 13:08:32 -04:00
nhmall
df4d945395 The same warnings resulted with groff 1.23 on macOS 2023-10-30 16:59:58 -04:00