diff options
| author | Robin Haberkorn <rhaberkorn@fmsbw.de> | 2026-06-27 20:35:36 +0200 |
|---|---|---|
| committer | Robin Haberkorn <rhaberkorn@fmsbw.de> | 2026-06-27 21:08:53 +0200 |
| commit | fa3d463a4cd563f3c5f29331f48a0161bf586863 (patch) | |
| tree | 349a2508d2f7bbb6624076abbe268e34f19d11db | |
| parent | 5337d33cc6e46a6eb281f2abb325b29c882a82b2 (diff) | |
| download | terex-fa3d463a4cd563f3c5f29331f48a0161bf586863.tar.gz | |
re_free() and re_error() have also been renamed to tere_free() and tere_error() for consistency
The headers still define regfree() and regerror() functions,
but they shouldn't collide with libc unless you include the POSIX regex.h.
Also tere_free() can now be called on nullified regex_t objects, which
eases error handling a bit.
| -rw-r--r-- | README.md | 4 | ||||
| -rw-r--r-- | regex.h | 4 | ||||
| -rw-r--r-- | regfree.c | 2 | ||||
| -rwxr-xr-x | regtest_terex.sh | 4 |
4 files changed, 8 insertions, 6 deletions
@@ -14,13 +14,15 @@ It is still kept as a standalone library and may be useful to other projects as Compared to hsrex, this library has the following changes: -* Renamed `re_comp()` to `tere_comp()` and `re_exec()` to `tere_exec()` +* Renamed `re_comp()` to `tere_comp()`, `re_exec()` to `tere_exec()`, + `re_free()` to `tere_free()` and `re_error()` to `tere_error()` to avoid collisions with BSD's functions from unistd.h. * Native UTF-8 support - no need to convert UTF-8 to UTF-32 first. You no longer need to compile a special version of the library. It expects Unicode strings by default unless specifying the `REG_RAW` `tere_comp()` compilation flag. * Support the `REG_ANCHORED` flag for `tere_exec()`. +* `tere_free()` ignores nullified `regex_t` objects. ## TODO @@ -117,8 +117,8 @@ extern "C" { #ifdef REGEX_STANDALONE # undef regfree # undef regerror -# define regfree re_free -# define regerror re_error +# define regfree tere_free +# define regerror tere_error # undef __REG_WIDE_T # define __REG_WIDE_T unsigned char # undef __REG_NOCHAR @@ -45,7 +45,7 @@ void regfree( regex_t *re) { - if (re == NULL) { + if (re == NULL || re->re_fns == NULL) { return; } (*((struct fns *)re->re_fns)->free)(re); diff --git a/regtest_terex.sh b/regtest_terex.sh index 0f903d3..4ac9083 100755 --- a/regtest_terex.sh +++ b/regtest_terex.sh @@ -140,7 +140,7 @@ cat<<-EOF>$rgsrc rc = tere_exec(&cre, dat, datlen, NULL, 100, pmatch, eflags); if ( rc != REG_OKAY ) { - regerror(rc, &cre, buf, sizeof(buf)); + tere_error(rc, &cre, buf, sizeof(buf)); fprintf(stderr, "Execution error. %s\n", buf); return 1; } @@ -156,7 +156,7 @@ cat<<-EOF>$rgsrc argv[2]+pmatch[i].rm_so); printf("%s\n", buf); } - regfree(&cre); + tere_free(&cre); return 0; } EOF |
