laurikari / tre

The approximate regex matching library and agrep command line tool.
Other
803 stars 133 forks source link

Update Windows build and add Windows to the CI lineup #112

Closed dag-erling closed 1 month ago

dag-erling commented 2 months ago

This is a work in progress. Visual Studio reports a heap overflow in retest, so I'm not running tests in CI until I've found and fixed the cause.

dag-erling commented 1 month ago

I believe the heap corruption comes from retest setting use_regnexec set to 1 despite HAVE_REGNEXEC being undefined (because win32/config.h does not define TRE_VERSION). This results in a buffer overflow when wrap_regexec() appends a terminating null character to a buffer that does not have room for one.

dag-erling commented 1 month ago

I've added error checking for tre_regcomp() to test-str-source. I've also added an error message when make_str_source() fails.

GerHobbelt commented 1 month ago

Re your getopt for a windows platform:

On Fri, 13 Sep 2024, 01:54 trushworth, @.***> wrote:

@.**** approved this pull request.

These all look good to me, with two minor questions.

1.

I have an ancient (pre-ANSI-C) minimal implementation of getopt() that I use for windows stuff. It uses (for fprintf(stderr,...) and

(for strchr()). If I clean it up to the GNU style conventions would it make sense to have it in the "tests" directory (or maybe the "win32" directory) for retest and test-str-source? We'd use the system getopt() when available obviously, but I'd like a working "-o" option on Windows. Adding it would probably be best as a completely separate pull req May I suggest https://github.com/kimgr/getopt_port as a very nice getopt +getopt_long replacement instead? It's BSD licensed so nicely unburdened that way too. I've used my own getopt implementation for years (decades, really) on Win32 and other platforms but switched to using this one a few years ago and it hasn't failed me since. git submodule add or git subtree add... :-)

Thanks for maintaining tre and all the recent activity. Respectable.