diff options
author | Greg Hudson <ghudson@mit.edu> | 1994-12-22 00:04:05 +0000 |
---|---|---|
committer | Greg Hudson <ghudson@mit.edu> | 1994-12-22 00:04:05 +0000 |
commit | 31a2bf6de394e2653429ad292174498fdff51cd8 (patch) | |
tree | c822b202cfb07b248bebd76131c8d4ad20e0c318 /zwgc | |
parent | 8549b02d57a717b075384777d4dcdc7733716f28 (diff) |
NetBSD compatibility.
Diffstat (limited to 'zwgc')
-rw-r--r-- | zwgc/regexp.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/zwgc/regexp.c b/zwgc/regexp.c index 3fc3f0c..f6f5854 100644 --- a/zwgc/regexp.c +++ b/zwgc/regexp.c @@ -23,6 +23,35 @@ static char rcsid_regexp_c[] = "$Id$"; #include <libgen.h> #endif +#ifdef POSIX_REGEXP +#include <sys/types.h> +#include <regex.h> + +int ed_regexp_match_p(test_string, pattern) + string test_string; + string pattern; +{ + regex_t RE; + int retval; + char errbuf[512]; + + if (retval = regcomp(&RE, pattern, REG_EXTENDED|REG_NOSUB)) { + regerror(retval, &RE, errbuf, sizeof(errbuf)); + fprintf(stderr,"%s in regcomp %s\n",errbuf,pattern); + return(0); + } + retval = regexec(&RE, test_string, 0, NULL, 0); + if (retval && retval != REG_NOMATCH) { + regerror(retval, &RE, errbuf, sizeof(errbuf)); + fprintf(stderr,"%s in regexec %s\n",errbuf,pattern); + regfree(&RE); + return(0); + } + regfree(&RE); + return(retval == 0 ? 1 : 0); +} + +#else extern char *re_comp(); extern int re_exec(); @@ -44,7 +73,7 @@ int ed_regexp_match_p(test_string, pattern) return(exec_retval); } - +#endif /* * This is for AUX. |