5 * Copyright (c) 2004 Snapgear
7 * See the file "license.terms" for information on usage and redistribution
8 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
15 #define REGEX_COMPAT_IMPL
16 #include "regex_compat.h"
18 int compat_regcomp(regex_t *preg, const char *regex, int cflags)
20 preg->preg = regcomp((char *)regex);
21 return(preg->preg == 0);
24 int compat_regexec(const regex_t *preg, const char *string, size_t nmatch, regmatch_t pmatch[], int eflags)
26 if (regexec(preg->preg, (char *)string) == 1) {
28 for (i = 0; i < NSUBEXP && i < nmatch; i++) {
29 if (preg->preg->startp[i]) {
30 pmatch[i].rm_so = preg->preg->startp[i] - string;
35 if (preg->preg->endp[i]) {
36 pmatch[i].rm_eo = preg->preg->endp[i] - string;
48 size_t compat_regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size)
50 return snprintf(errbuf, errbuf_size, "regex_compat() error %d", errcode);
53 void compat_regfree(regex_t *preg)