diff options
author | Jason Downs <downsj@cvs.openbsd.org> | 1999-08-02 17:10:48 +0000 |
---|---|---|
committer | Jason Downs <downsj@cvs.openbsd.org> | 1999-08-02 17:10:48 +0000 |
commit | 903d8d7a4265eb1a319e39ac2ab1bd4f0ebedd8a (patch) | |
tree | fc7dc50ddf5a6436899ea766f712bc838d40f322 /lib/libcompat/4.3 | |
parent | 835096904992fef0e0da9dc303f1f2d4d3f5eef1 (diff) |
Add a hook to regexp/regerror.c for overriding the default regerror()
function.
Add support for overriding the default regerror() function in 4.3/regex.c,
and avoiding free()ing things multiple times.
Diffstat (limited to 'lib/libcompat/4.3')
-rw-r--r-- | lib/libcompat/4.3/regex.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/libcompat/4.3/regex.c b/lib/libcompat/4.3/regex.c index 8b836d6a962..31a04ca797c 100644 --- a/lib/libcompat/4.3/regex.c +++ b/lib/libcompat/4.3/regex.c @@ -43,7 +43,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char sccsid[] = "from: @(#)regex.c 5.1 (Berkeley) 3/29/92";*/ -static char rcsid[] = "$Id: regex.c,v 1.1 1995/10/18 08:42:34 deraadt Exp $"; +static char rcsid[] = "$Id: regex.c,v 1.2 1999/08/02 17:10:47 downsj Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -56,18 +56,26 @@ static regexp *re_regexp; static int re_goterr; static char *re_errstr; +static void re_error __P((const char *)); + char * re_comp(s) const char *s; { if (s == NULL) return (NULL); - if (re_regexp) + if (re_regexp) { free(re_regexp); - if (re_errstr) + re_regexp = NULL; + } + if (re_errstr) { free(re_errstr); + re_errstr = NULL; + } + v8_setregerror(re_error); + re_goterr = 0; - re_regexp = regcomp(s); + re_regexp = v8_regcomp(s); return (re_goterr ? re_errstr : NULL); } @@ -78,12 +86,12 @@ re_exec(s) int rc; re_goterr = 0; - rc = regexec(re_regexp, s); + rc = v8_regexec(re_regexp, s); return (re_goterr ? -1 : rc); } -void -regerror(s) +static void +re_error(s) const char *s; { re_goterr = 1; |