Commit Graph

19 Commits

Author SHA1 Message Date
PatR
dda4cd0530 regex handling
Change the regex_error_desc() interface.  Have the caller pass in
a pointer to a buffer of at least BUFSZ characters and have
regex_error_desc() populate that.  No need for static buffers or
extra dynamic alloction.

Also, change it to never return Null.  None of its callers were
checking for that and could have passed Null to config_error_add()
or raw_print().  printf("%s", NULL) produces "null" on OSX but other
systems would probably crash if a Null result ever actually occurred.

The error explanation returned by cppregex included a trailing period.
config_error_add() adds one, so the message ended up with two.  Have
regex_error_desc() check for final period and strip it off if found.
(My test case used a menucolor pattern of "[" which triggers an error
about mismatched brackets.)

Reformat cppregex.cpp; treat 'extern "C" {' as if it isn't introducing
a nested block.  Fix the '#include <hack.h>' that 'make depend' was
ignoring.
2022-07-01 13:08:43 -07:00
nhmall
751b6e646f Revert "follow-up: use only the memory that's required"
This reverts commit 4a0654c708.
2022-06-30 22:38:14 -04:00
nhmall
66a1e19d26 Revert "follow-up 2: follow the conventional approach"
This reverts commit 6920632df0.
2022-06-30 22:37:12 -04:00
nhmall
43941afe19 Revert "follow-up 3"
This reverts commit cd57dfa5ff.
2022-06-30 22:36:45 -04:00
nhmall
cd57dfa5ff follow-up 3 2022-06-30 13:27:46 -04:00
nhmall
6920632df0 follow-up 2: follow the conventional approach 2022-06-30 13:15:58 -04:00
nhmall
4a0654c708 follow-up: use only the memory that's required 2022-06-30 13:10:56 -04:00
nhmall
0fd999a6b5 cppregex regex_error_desc()
Address sanitizer caught a use after free.
cppregex.cpp regex_error_desc() was not returning a pointer
to a static buffer, yet the posixregex was. Follow suit.
2022-06-30 13:02:07 -04:00
nhmall
ac9ba38449 file header bump from "NetHack 3.6" to "NetHack 3.7" 2020-08-03 22:07:36 -04:00
keni
09502df9f1 force expand unexpanded substitution variables 2018-04-25 15:36:11 -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
karnov
2a907f894e Version number increment 2015-05-06 22:04:27 -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
Sean Hunt
b86ad06d6b Implement a new system-based matching harness.
The intent is to look for platform-specific facilities for regex
matching, to provide portable MENUCOLORS configuration files.

This is a prototype implementation being committed to see if Windows can
use the POSIX regex implementation provided with the C++11 standard
library. If this works, I will write a harness for POSIX regexes and for
pmatch(), and those can be linked in by platforms as appropriate.

pmatch() should be used only as a very last resort, because it breaks
compatibility between platforms.
2015-04-12 11:46:26 -04:00