Commit Graph

216 Commits

Author SHA1 Message Date
Bart House
a588541a27 Win32GUI: Gather raw_print text and display it all in single dialog
Defined strbuf_t and related routines to support dynamically sized
strings. Modified strip_newline() to strip the last newline in a string
instead of the first.

Simplified splash window code using new strbuf_t.

Prior to exiting game, re-enable getreturn and call wait_synch() in
case there is buffered raw prints that must be displayed to user.
2017-10-25 10:34:27 +03:00
Pasi Kallinen
9c118b5b6b Secure config errors
If user can make NETHACKOPTIONS point to a file, that user could then
get the file contents via the extended config file error reporting.
Add CONFIG_ERROR_SECURE compile-time option to make that case output
only the first error, no line number or error context.
2017-09-10 21:05:51 +03:00
Pasi Kallinen
cfb09c9bf8 Handle windowtype and CHOOSE config errors 2017-09-09 13:50:34 +03:00
PatR
d69f0787be add '(uchar)' casts to ctype calls
This is from the pull request for the assertion failure fix.  It
did not mention how to reproduce the assertion failure, just added
casts to a bunch of isspace/isprint/tolower calls that didn't already
have such.

I removed an obsolete change for win/tty/topl.c and changed the
win/win32/mswproc.c code to avoid using an expression with side-effects
(*colorstring++) in calls to tolower() in case someone overrides that
with a macro which evaluates its argument more than once as some pre-
ANSI ones used to do.  Not tested, might have typos....

sys/wince/*.c still needs similar casts.
2016-07-19 05:40:09 -07:00
nhmall
78857961d2 some of Ray Chason's MSDOS and other fixes 2016-03-05 14:44:50 -05:00
PatR
cd932656ff sys/share/lev_yacc.c 2016-02-17 14:10:36 -08:00
PatR
87edc53f31 sys/share/ dgn_comp and lev_comp code 2016-02-13 18:00:44 -08:00
PatR
9d1a3be7d7 revert fix for #H4041 - decl for has_color()
Since the attempted fix for the warning about has_color() being
implicitly declared introduced a worse problem of conflicting
declaration in cases where it's already declared, back that change
out.
2016-01-26 17:39:41 -08:00
PatR
7482be39e8 lev_comp update for older Unix system
Increase the lex paramaters in lev_comp.l and replace use of snprintf
with sprintf in lev_comp.y and lev_main.c.

Also some reformatting for lev_comp.y, but I gave up pretty quickly:
some early tab replacement and adjusting of the spacing for casts.
2016-01-19 16:27:39 -08:00
nhmall
61148f05bb SYSCF_FILE corrections for windows
Changes to be committed:
	modified:   src/files.c
	modified:   sys/share/pcmain.c

Related to #H4170, bz274

The current startup code seeks out the SYSCONFPREFIX using:
	envp = nh_getenv("COMMONPROGRAMFILES");
which is fine and usually translates to something like
"C:\\Program Files (x86)\\Common Files\\
NetHack then tacks on the NetHack subfolder to the path
"C:\\Program Files (x86)\\Common Files\\NetHack\\"

That should always be the definitive location.

However, in the event that there is no SYSCF_FILE actually
located at that system-wide spot (and ONLY in that event),
fall back to a secondary location of HACKDIR for locating
the SYSCF_FILE.

Also, there's some explicit tweaking added for the Microsoft
visual studio compiler debug execution to all a debug
session to correctly locate things. By default, on a
visual studio build, the executables are linked down in
subfolders of the build directory (Release, or Debug,
depending on visual studio build configuration options).
2016-01-01 20:33:14 -05:00
PatR
ad838c7e79 fix #H4041 - implicit declaration of has_colors()
_M_UNIX (SCO UNIX) and __linux__ (all flavors of linux?) both call
has_colors() for TTY_GRAPHICS+TEXTCOLOR configuration, but neither
declared it.  The new declaration is just a guess based on usage.
2015-12-23 16:25:06 -08:00
nhmall
215060219d fix windows bugs H4030 and H4045 (123 and 138)
Changes to be committed:
	modified:   sys/share/pcmain.c
	modified:   sys/winnt/nttty.c
	modified:   sys/winnt/stubs.c

Bug 123 Report 4030:
Minor thing I've noticed - if I quit the game, at the "Hit <Enter> to end."
prompt, if I close the window rather than pressing Enter, I get the following:

Bug 138  - #H4045:
 "nethack -s" leads to "-s is not supported for the Graphical Interface".
 That's wrong.
 (The Graphical Interface comes with "nethackw".)
2015-12-11 23:08:01 -05:00
PatR
48f1c6711e update sys/share/{dgn,lev}_lex.c
The HP C compiler for VMS issued a pair of diagnostics for both *_lex.c
files, about an expression of the form (unsigned_var <= 0) maybe not
being what was really intended, and it was right.  Changing that to
'< 1' would have suppressed the diagnostic but left the bug, which was
in code that performed a subtraction and then checked for a negative
result.  It worked in older flex versions when the variables were
signed, but got broken when they were changed to unsigned (no doubt in
respose to gcc complaining about comparing signed and unsigned in some
other spot where one of them was used).

The bug is in flex's original skeleton, so was inherited by our new
custom skeleton.  I've fixed it in the custom skeleton, which means
that sys/share/*_lex.c became out of date even though util/*_comp.l
remain unchanged.
2015-12-08 14:52:01 -08:00
PatR
c964ae023b sys/share/???_lex.c
Generated with flex 2.6.0 and a new custom skeleton for that version
(which almost certainly won't work with any older or newer version of
flex, but that limitation has no effect on the usefulness of the
generated scanner code).

Function definitions are oldstyle:
  int foo(bar)
    char *bar;
  {...}
rather than ANSI, like nethack's core code.  Advance declarations use
FDECL for prototypes, so should also fit nethack, although the usage
'FDECL(, (arglist))' makes me feel a bit uneasy.  gcc doesn't mind the
omitted first argument but other compilers might not like it.

The system headers (stdlib.h and a few others) that flex has been
insisting on including are gone (with this skeleton).  It starts out
including "config.h" and that header has the responsibility for any
definitions and declarations necessary.  That shouldn't be a big deal
since config.h -> XXXconf.h -> system.h is what we're already relying
on for everything else, but it does need testing for any configuration
that uses sys/share/{dgn,lev}_{lex,yacc}.c.

I'll be checking the skeleton into the NHinternals repository after
adding some documentation, but I'm wondering whether it should really
become part of the source distribution.
2015-12-05 23:02:35 -08:00
nhmall
6cfa4bbbe5 lev_yacc and lev_lex from master 2015-12-04 07:57:35 -05:00
nhmall
eed4549f53 'pull' prebuilts from master into release branch 2015-12-04 07:46:21 -05:00
nhmall
786ac8abe6 'Merge' prebuilts from master 2015-12-03 04:23:53 -05:00
nhmall
8bd70be165 windows build without DEBUG defined in global.h
Changes to be committed:
	modified:   include/global.h
	modified:   sys/share/pcmain.c
	modified:   win/win32/mswproc.c
2015-12-02 23:19:04 -05:00
Pasi Kallinen
c20638938e Update precompiled lev_comp lex and yacc files 2015-12-02 18:33:44 +02:00
Pasi Kallinen
b2ab8f2504 Update precompiled lev_comp lex and yacc files 2015-11-15 09:09:45 +02:00
Pasi Kallinen
bdb5cb2b73 Free the compiled regex buffer 2015-11-01 10:23:11 +02:00
Pasi Kallinen
af1c77808b Comment typofixes, pt 4 2015-10-17 18:47:31 +03:00
nhmall
3ba5def8f1 fix windows console bug reveals monster (console tty) 2015-06-22 15:06:00 -04:00
nhmall
5dc0a5747a majority opinion on cppregex.cpp declaration 2015-06-16 21:45:59 -04:00
nhmall
c289784d49 revert recent const addition in cppregex.cpp 2015-06-16 06:05:06 -04:00
PatR
1547e676f3 finish implementing pmatchregex
I started out cleaning up a bit of lint in the recent run-time options
handling and discovered that pmatchregex wasn't finished.  Finish it and
also deal with the version lint.  Argument declarations for function
definitions in pmatchregex.c have been switched to K&R style.  (The ones
in posixregex.c have been left in ANSI style.)

There wasn't any build rule for pmatchregex.o; now there is (for Unix).
posixregex.o is still the default.

There isn't any build rule for cppregex.o (again, for Unix); the change
to cppregex.cpp is untested.
2015-06-16 02:29:22 -07:00
nhmall
37f0eafa93 support for link-time option in #version
Changes to be committed:
	modified:   src/version.c
	modified:   sys/share/cppregex.cpp
	modified:   sys/share/pmatchregex.c
	modified:   sys/share/posixregex.c
	modified:   util/makedefs.c

Some options in 3.6.0 are determined by what you link with.
The choice of regex support is one.
Let #version show that linked option along with the compile-time options.
2015-06-12 19:23:18 -04:00
Derek S. Ray
f606b367ab no, really, use the right header 2015-05-27 21:00:00 -04:00
Derek S. Ray
a65c568e49 New precompiled versions of these 2015-05-26 22:54:55 -04:00
Sean Hunt
1c081b1647 Remove stale version control lines. 2015-05-25 09:21:31 +09:00
Sean Hunt
8b57d96fd2 Reformat .h files.
I did my best to exempt some of the bigger aligned blocks from the reformatting
using the /* clang-format off */ and /* clang-format on */ tags. Probably some
that shouldn't have been formatted were anyway; if you encounter them, please
fix.

The clang-format tags were left in on the basis that it's much easier to prune
those out later than to put them back in, and it means that, modulo my custom
version of clang-format, I should be able to run clang-format on the source tree
again without changing anything, now that Pat has fixed the VA_DECL issues.
2015-05-25 09:21:15 +09:00
Sean Hunt
84d63e169b Use the common regex engine in more places.
In particular, in autopickup_exceptions and user sounds.
2015-05-24 10:17:58 -04:00
Sean Hunt
44f4bc240c Add pmatch-based regex engine.
As mentioned, this is not tested. It should be simple though.
2015-05-24 09:42:56 -04:00
PatR
fabf9cd901 VA_DECL/VA_END usage
Make the variadic functions look more like ordinary code rather than
have the function opening brace be hidden inside the VA_DECL() macro.
That brace is still there, but VA_DECL() now needs to be followed by
a visible brace (which introduces a nested block rather than the
start of the funciton).  VA_END() now provides a hidden closing brace
to end the nested block, and the existing closing brace still matches
the one in VA_DECL().

Sample usage:
void foo VA_DECL(int, arg)  --macro expansion has a hidden opening brace
{  --new, explicit opening brace (actually introduces a nested block)
  VA_START(bar);
  ...code for foo...
  VA_END();  --expansion now provides a closing brace for the nested block
}  --existing closing brace, still pairs with the hidden one in VA_DECL()

This should help if/when another round of reformatting ever takes place,
and also with editors or other tools that do brace/bracket/parenthesis
matching.

I had forgotten that there were variadic functions in sys/* and ended
up modifying a lot more files than intended.  The majority of changes
to those just inserted a new '{' line so that revised VA_END()'s '}'
won't introduce a syntax error.  A couple of them needed VA_END() moved
so that local variables wouldn't go out of scope too soon.  Only the
Unix ones have been tested.
2015-05-15 17:45:21 -07:00
Derek S. Ray
b55f6f30ba ...don't forget to include the prebuilt headers
derp.
2015-05-09 20:50:07 -04:00
Derek S. Ray
6d232df8ab update pre-built versions of these 2015-05-09 14:47:46 -04:00
Sean Hunt
97d6fade74 Reformat all C files.
I'll push a formatting guide at some point. There may still be
outstanding changes, but please feel free to resolve those as you arrive
a them.

To the best of my knowledge, there is no changes to the actual code
content, but the formatter does have the occasional bug. If you run into
an issue, please fix it!
2015-05-09 13:43:16 -04:00
nhmall
20069798d4 Merge branch 'master' into win32-x64-working 2015-05-07 04:52:30 -04:00
karnov
2a907f894e Version number increment 2015-05-06 22:04:27 -04:00
nhmall
77dd76ed17 Merge branch 'master' into win32-x64-working
Resolved Conflicts:
	src/cmd.c
	src/mkobj.c

 All conflicts fixed but you are still merging.

 Changes to be committed:
	modified:   dat/Priest.des
	modified:   dat/Rogue.des
	modified:   dat/Valkyrie.des
	modified:   dat/Wizard.des
	modified:   dat/gehennom.des
	modified:   src/cmd.c
	modified:   src/mkobj.c
	modified:   src/steal.c
	modified:   sys/share/lev_yacc.c
	modified:   util/lev_comp.y
2015-05-02 13:53:08 -04:00
Pasi Kallinen
537acc98dc Update pregenerated levcomp lex and yacc files 2015-05-02 18:33:14 +03:00
nhmall
aaca36a6d5 build both tty NetHack.exe and gui NetHackW.exe
Changes to be committed:
	modified:   include/config.h
	modified:   include/extern.h
	modified:   include/flag.h
	modified:   include/global.h
	modified:   include/ntconf.h
	modified:   include/wintty.h
	modified:   src/cmd.c
	modified:   src/files.c
	modified:   src/options.c
	modified:   sys/share/pcmain.c
	modified:   sys/share/pcsys.c
	modified:   sys/share/pcunix.c
	modified:   sys/winnt/Makefile.gcc
	modified:   sys/winnt/Makefile.msc
	modified:   sys/winnt/nttty.c
	new file:   sys/winnt/stubs.c
	modified:   sys/winnt/winnt.c
	modified:   util/makedefs.c
	modified:   win/tty/wintty.c

Adjust the code and the command line Makefile so that
you no longer have to choose whether to build the tty
version NetHack.exe, or the gui version NetHackW.exe.

Both will now be built in a single 'nmake install' pass.
2015-04-22 00:07:46 -04:00
Derek S. Ray
7c644c1507 Merge branch 'win32-x64-working' of https://rodney.nethack.org:20040/git/NHsource into win32-x64-working
* 'win32-x64-working' of https://rodney.nethack.org:20040/git/NHsource: (27 commits)
  Makefile bit
  gcc Makefile updates for recent file additions
  ...

Conflicts:
	src/files.c
2015-04-15 18:30:13 -04:00
Derek S. Ray
df52ba17ec add debugger window support via _RPT*; add regex
currently it's locked behind _MSC_VER, but anything that runs on Win32
should be able to use those functions as long as it has something that
can pass as a debug window.

also, add a non-wildcard-accepting version of showdebug for the dumpit()
functions in dungeon.c and questpgr.c; this makes DEBUGFILES=* workable
without being excruciatingly painful
2015-04-15 18:19:16 -04:00
nhmall
3d3ee78a0b Merge branch 'master' into win32-x64-working
Conflicts:
	src/files.c
	src/potion.c
	sys/winnt/Makefile.msc

 Changes to be committed:
	modified:   .gitignore
	modified:   DEVEL/hooksdir/nhsub
	modified:   dat/.gitignore
	modified:   dat/opthelp
	modified:   doc/Guidebook.mn
	modified:   doc/Guidebook.tex
	modified:   doc/fixes35.0
	modified:   include/context.h
	modified:   include/decl.h
	modified:   include/extern.h
	modified:   include/flag.h
	modified:   include/hack.h
	modified:   include/patchlevel.h
	modified:   src/apply.c
	modified:   src/attrib.c
	modified:   src/decl.c
	modified:   src/do.c
	modified:   src/do_name.c
	modified:   src/dothrow.c
	modified:   src/eat.c
	modified:   src/files.c
	modified:   src/hack.c
	modified:   src/invent.c
	modified:   src/lock.c
	modified:   src/mklev.c
	modified:   src/mondata.c
	modified:   src/monmove.c
	modified:   src/music.c
	modified:   src/options.c
	modified:   src/potion.c
	modified:   src/pray.c
	modified:   src/sit.c
	modified:   src/sp_lev.c
	modified:   src/uhitm.c
	modified:   sys/share/posixregex.c
	modified:   sys/winnt/Makefile.msc
	modified:   util/.gitignore
	modified:   win/win32/vs2010/NetHackW.vcxproj
2015-04-14 18:23:48 -04:00
PatR
cf74f1cfd8 regex lint
For the POSIX regexp interface, move local declaration to beginning
of block to avoid requiring C99.  Also switch to alloc() from bare
malloc() so that MONITOR_HEAP won't log a free which doesn't match
up to any allocation.  This results in a change in behavior:  if
the allocation fails, nethack will panic rather than report an
option parsing error.  In practice there will be no difference
because nethack is not going to run out of dynamic memory during
initial options processing.
2015-04-13 17:21:59 -07:00
nhmall
7e781d4013 Merge branch 'master' into win32-x64-working
Conflicts:
	include/config.h
	src/options.c
2015-04-12 11:58:14 -04:00
Sean Hunt
c7578b7c34 Add POSIX implementation of regex.
This also includes documentation of the regex engine in posixregex.c,
because I couldn't think of anywhere better to put it.
2015-04-12 11:46:56 -04:00
Sean Hunt
302ad5025f Catch regex matching errors to avoid crashing. 2015-04-12 11:46:56 -04:00
Sean Hunt
80aa109855 Use extern.h for regexes.
I was planning to do this anyway, but it created an include loop that
was breaking it on Windows.
2015-04-12 11:46:54 -04:00