diff options
| author | jtc <jtc@NetBSD.org> | 1994-02-01 17:45:53 +0000 |
|---|---|---|
| committer | jtc <jtc@NetBSD.org> | 1994-02-01 17:45:53 +0000 |
| commit | ec22bca1e7d8bfd4140e14d296fcbd62b24ecf5b (patch) | |
| tree | c78b34a38f6ba8752964c19a2b683e0b37b71daf /lib/libcompat | |
| parent | d4498ee608634cd1a45cf933674eebfb10628d28 (diff) | |
Since V8 regex routines have been moved to libcompat(), the BSD regex
routines must again be defined as wrappers around them.
Diffstat (limited to 'lib/libcompat')
| -rw-r--r-- | lib/libcompat/4.3/regex.c | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/lib/libcompat/4.3/regex.c b/lib/libcompat/4.3/regex.c index ac79675fb6c..e40f6b7e53f 100644 --- a/lib/libcompat/4.3/regex.c +++ b/lib/libcompat/4.3/regex.c @@ -43,51 +43,51 @@ #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.3 1993/11/11 01:24:50 jtc Exp $"; +static char rcsid[] = "$Id: regex.c,v 1.4 1994/02/01 17:45:53 jtc Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> #include <stddef.h> -#include <stdlib.h> +#include <regexp.h> #include <string.h> -#include <regex.h> +#include <stdlib.h> -static int compiled_regexp = 0; -static char errbuf[256]; -static regex_t rp; +static regexp *re_regexp; +static int re_goterr; +static char *re_errstr; char * re_comp(s) char *s; { - int eval; - if (s == NULL) return (NULL); - - if (compiled_regexp) { - regfree(&rp); - compiled_regexp = 0; - } - - if ((eval = regcomp(&rp, s, REG_NOSUB)) != 0) { - regerror (eval, &rp, errbuf, sizeof(errbuf)); - return errbuf; - } - - compiled_regexp = 1; - return NULL; + if (re_regexp) + free(re_regexp); + if (re_errstr) + free(re_errstr); + re_goterr = 0; + re_regexp = regcomp(s); + return (re_goterr ? re_errstr : NULL); } int re_exec(s) char *s; { - regmatch_t rm[1]; - int eval; + int rc; - if ((eval = regexec(&rp, s, 0, rm, 0)) == 0) - return 1; + re_goterr = 0; + rc = regexec(re_regexp, s); + return (re_goterr ? -1 : rc); +} - return eval == REG_NOMATCH ? 0 : -1; +void +regerror(s) + const char *s; +{ + re_goterr = 1; + if (re_errstr) + free(re_errstr); + re_errstr = strdup(s); } |
