diff options
| author | Robin Haberkorn <rhaberkorn@fmsbw.de> | 2026-06-27 17:06:10 +0200 |
|---|---|---|
| committer | Robin Haberkorn <rhaberkorn@fmsbw.de> | 2026-06-27 17:11:39 +0200 |
| commit | faa449f2c2353aad5ebd61f27181fdc576a6ab78 (patch) | |
| tree | b0921ce37ca84a38d13fd0c8a24f98eae8c595e5 | |
| parent | 51b272276ff72b2856b2704708644bca143eef64 (diff) | |
| download | terex-faa449f2c2353aad5ebd61f27181fdc576a6ab78.tar.gz | |
renamed re_comp() to tere_comp() and re_exec() to tere_exec()
Fixes inclusion into programs that also include unistd.h on BSD,
which also provides re_comp() and re_exec() implementations.
| -rw-r--r-- | Makefile.linux | 2 | ||||
| -rw-r--r-- | README.md | 6 | ||||
| -rw-r--r-- | regcustom.h | 4 | ||||
| -rw-r--r-- | regex.h | 8 |
4 files changed, 11 insertions, 9 deletions
diff --git a/Makefile.linux b/Makefile.linux index e1dac8f..0f3d37f 100644 --- a/Makefile.linux +++ b/Makefile.linux @@ -1,6 +1,6 @@ CC = gcc # Either this one -CFLAGS = -Wall -DREGEX_STANDALONE -fPIC -DREG_DEBUG -g +CFLAGS = -Wall -DREGEX_STANDALONE -fPIC -DREG_DEBUG -g -O0 # Or this one #CFLAGS = -Wall -DREGEX_STANDALONE -fPIC -D_NDEBUG -O3 LDFLAGS = -shared @@ -14,16 +14,18 @@ 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()` + 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` - compilation flag. + `tere_comp()` compilation flag. ## TODO * Hook into the matching algorithm. Even though runtime cannot be as catastrophically bad as in pure - backtracking engines like PCRE, `re_exec()` calls can still be slow + backtracking engines like PCRE, `tere_exec()` calls can still be slow on extremely large texts. The hook allows interruptions. * Expose enough API to swap out the regular expression lexer. diff --git a/regcustom.h b/regcustom.h index 24bd130..6cc03ce 100644 --- a/regcustom.h +++ b/regcustom.h @@ -129,8 +129,8 @@ typedef int32_t celt; /* Type to hold chr, or NOCELT */ */ #ifdef REGEX_STANDALONE -#define compile re_comp -#define exec re_exec +#define compile tere_comp +#define exec tere_exec #undef __REG_NOCHAR #else #define compile TclReComp @@ -203,7 +203,7 @@ typedef struct { /* * compilation ^ #ifndef __REG_NOCHAR - ^ int re_comp(regex_t *, __REG_CONST char *, size_t, int); + ^ int tere_comp(regex_t *, __REG_CONST char *, size_t, int); ^ #endif ^ #ifndef __REG_NOFRONT ^ int regcomp(regex_t *, __REG_CONST char *, int); @@ -235,7 +235,7 @@ typedef struct { /* * execution ^ #ifndef __REG_NOCHAR - ^ int re_exec(regex_t *, __REG_CONST char *, size_t, + ^ int tere_exec(regex_t *, __REG_CONST char *, size_t, ^ rm_detail_t *, size_t, regmatch_t [], int); ^ #endif ^ #ifndef __REG_NOFRONT @@ -299,7 +299,7 @@ typedef struct { /* automatically gathered by fwd; do not hand-edit */ /* === regproto.h === */ #ifndef __REG_NOCHAR -int re_comp(regex_t *, __REG_CONST unsigned char *, size_t, int); +int tere_comp(regex_t *, __REG_CONST unsigned char *, size_t, int); #endif #ifndef __REG_NOFRONT int regcomp(regex_t *, __REG_CONST char *, int); @@ -308,7 +308,7 @@ int regcomp(regex_t *, __REG_CONST char *, int); MODULE_SCOPE int __REG_WIDE_COMPILE(regex_t *, __REG_CONST __REG_WIDE_T *, size_t, int); #endif #ifndef __REG_NOCHAR -int re_exec(regex_t *, __REG_CONST unsigned char *, size_t, rm_detail_t *, size_t, regmatch_t [], int); +int tere_exec(regex_t *, __REG_CONST unsigned char *, size_t, rm_detail_t *, size_t, regmatch_t [], int); #endif #ifndef __REG_NOFRONT int regexec(regex_t *, __REG_CONST char *, size_t, regmatch_t [], int); |
