From faa449f2c2353aad5ebd61f27181fdc576a6ab78 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sat, 27 Jun 2026 17:06:10 +0200 Subject: 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. --- Makefile.linux | 2 +- README.md | 6 ++++-- regcustom.h | 4 ++-- 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 diff --git a/README.md b/README.md index dc5d19c..d63d030 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/regex.h b/regex.h index 2a37ce6..65455f9 100644 --- a/regex.h +++ b/regex.h @@ -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); -- cgit v1.2.3