diff --git a/src/console/console.c b/src/console/console.c index bcf84c93239..844d11d1c64 100644 --- a/src/console/console.c +++ b/src/console/console.c @@ -459,7 +459,7 @@ void init_items() static void match_kw(regex_t *preg, const char *what, int len, POOLMEM **buf) { int rc, size; - int nmatch=20; + int nmatch = 20; regmatch_t pmatch[20]; if (len <= 0) { diff --git a/src/dird/dird.c b/src/dird/dird.c index e3a304dbf2e..8c311fc76eb 100644 --- a/src/dird/dird.c +++ b/src/dird/dird.c @@ -1242,8 +1242,6 @@ static void cleanup_old_files() POOLMEM *basename = get_pool_memory(PM_MESSAGE); regex_t preg1; char prbuf[500]; - const int nmatch = 30; - regmatch_t pmatch[nmatch]; berrno be; /* Exclude spaces and look for .mail or .restore.xx.bsr files */ @@ -1290,7 +1288,7 @@ static void cleanup_old_files() } /* Unlink files that match regexes */ - if (regexec(&preg1, result->d_name, nmatch, pmatch, 0) == 0) { + if (regexec(&preg1, result->d_name, 0, NULL, 0) == 0) { pm_strcpy(cleanup, basename); pm_strcat(cleanup, result->d_name); Dmsg1(100, "Unlink: %s\n", cleanup); diff --git a/src/dird/migrate.c b/src/dird/migrate.c index 8c1196eebbe..c3748668272 100644 --- a/src/dird/migrate.c +++ b/src/dird/migrate.c @@ -1131,15 +1131,13 @@ static bool regex_find_jobids(JCR *jcr, idpkt *ids, } /* Now apply the regex to the names and remove any item not matched */ foreach_dlist(item, item_chain) { - const int nmatch = 30; - regmatch_t pmatch[nmatch]; if (last_item) { Dmsg1(dbglevel, "Remove item %s\n", last_item->item); free(last_item->item); item_chain->remove(last_item); } Dmsg1(dbglevel, "get name Item=%s\n", item->item); - rc = regexec(&preg, item->item, nmatch, pmatch, 0); + rc = regexec(&preg, item->item, 0, NULL, 0); if (rc == 0) { last_item = NULL; /* keep this one */ } else { diff --git a/src/findlib/find.c b/src/findlib/find.c index c04f6abbafa..7693ee90dc6 100644 --- a/src/findlib/find.c +++ b/src/findlib/find.c @@ -404,9 +404,7 @@ bool accept_file(FF_PKT *ff) } if (S_ISDIR(ff->statp.st_mode)) { for (k = 0; k < fo->regexdir.size(); k++) { - const int nmatch = 30; - regmatch_t pmatch[nmatch]; - if (regexec((regex_t *)fo->regexdir.get(k), ff->fname, nmatch, pmatch, 0) == 0) { + if (regexec((regex_t *)fo->regexdir.get(k), ff->fname, 0, NULL, 0) == 0) { if (ff->flags & FO_EXCLUDE) { return false; /* reject file */ } @@ -415,9 +413,7 @@ bool accept_file(FF_PKT *ff) } } else { for (k = 0; k < fo->regexfile.size(); k++) { - const int nmatch = 30; - regmatch_t pmatch[nmatch]; - if (regexec((regex_t *)fo->regexfile.get(k), ff->fname, nmatch, pmatch, 0) == 0) { + if (regexec((regex_t *)fo->regexfile.get(k), ff->fname, 0, NULL, 0) == 0) { if (ff->flags & FO_EXCLUDE) { return false; /* reject file */ } @@ -426,9 +422,7 @@ bool accept_file(FF_PKT *ff) } } for (k = 0; k < fo->regex.size(); k++) { - const int nmatch = 30; - regmatch_t pmatch[nmatch]; - if (regexec((regex_t *)fo->regex.get(k), ff->fname, nmatch, pmatch, 0) == 0) { + if (regexec((regex_t *)fo->regex.get(k), ff->fname, 0, NULL, 0) == 0) { if (ff->flags & FO_EXCLUDE) { return false; /* reject file */ } diff --git a/src/lib/bregex.c b/src/lib/bregex.c index ca6a30ce60d..08d0dd6ee0f 100644 --- a/src/lib/bregex.c +++ b/src/lib/bregex.c @@ -1488,7 +1488,7 @@ void re_registers_to_regmatch(regexp_registers_t old_regs, } } -int regexec(regex_t * preg, const char *string, size_t nmatch, +int regexec(regex_t *preg, const char *string, size_t nmatch, regmatch_t pmatch[], int eflags) { int status; diff --git a/src/lib/bsys.c b/src/lib/bsys.c index 4d1f5bcfa78..e8d6e211971 100644 --- a/src/lib/bsys.c +++ b/src/lib/bsys.c @@ -49,8 +49,6 @@ int safer_unlink(const char *pathname, const char *regx) int rc; regex_t preg1; char prbuf[500]; - const int nmatch = 30; - regmatch_t pmatch[nmatch]; int rtn; /* Name must start with working directory */ @@ -68,8 +66,10 @@ int safer_unlink(const char *pathname, const char *regx) return ENOENT; } - /* Unlink files that match regexes */ - if (regexec(&preg1, pathname, nmatch, pmatch, 0) == 0) { + /* + * Unlink files that match regexes + */ + if (regexec(&preg1, pathname, 0, NULL, 0) == 0) { Dmsg1(100, "safe_unlink unlinking: %s\n", pathname); rtn = unlink(pathname); } else { diff --git a/src/lib/var.c b/src/lib/var.c index e724d838380..2602e13a1fd 100644 --- a/src/lib/var.c +++ b/src/lib/var.c @@ -1054,10 +1054,9 @@ op_search_and_replace( /* no (more) matching */ tokenbuf_append(&tmp, p, mydata.end - p); break; - } - else if ( multiline - && (p + pmatch[0].rm_so) == mydata.end - && (pmatch[0].rm_eo - pmatch[0].rm_so) == 0) { + } else if (multiline && + (p + pmatch[0].rm_so) == mydata.end && + (pmatch[0].rm_eo - pmatch[0].rm_so) == 0) { /* special case: found empty pattern (usually /^/ or /$/ only) in multi-line at end of data (after the last newline) */ tokenbuf_append(&tmp, p, mydata.end - p); diff --git a/src/stored/stored.c b/src/stored/stored.c index 5cc8546bf4f..89b6f7c72b6 100644 --- a/src/stored/stored.c +++ b/src/stored/stored.c @@ -500,8 +500,6 @@ static void cleanup_old_files() POOLMEM *basename = get_pool_memory(PM_MESSAGE); regex_t preg1; char prbuf[500]; - const int nmatch = 30; - regmatch_t pmatch[nmatch]; berrno be; /* Look for .spool files but don't allow spaces */ @@ -547,7 +545,7 @@ static void cleanup_old_files() } /* Unlink files that match regex */ - if (regexec(&preg1, result->d_name, nmatch, pmatch, 0) == 0) { + if (regexec(&preg1, result->d_name, 0, NULL, 0) == 0) { pm_strcpy(cleanup, basename); pm_strcat(cleanup, result->d_name); Dmsg1(500, "Unlink: %s\n", cleanup); diff --git a/src/tools/bregex.c b/src/tools/bregex.c index a9b4cff5147..9c0d953b6ca 100644 --- a/src/tools/bregex.c +++ b/src/tools/bregex.c @@ -147,11 +147,9 @@ int main(int argc, char *const *argv) } lineno = 0; while (fgets(data, sizeof(data)-1, fd)) { - const int nmatch = 30; - regmatch_t pmatch[nmatch]; strip_trailing_newline(data); lineno++; - rc = regexec(&preg, data, nmatch, pmatch, 0); + rc = regexec(&preg, data, 0, NULL, 0); if ((match_only && rc == 0) || (!match_only && rc != 0)) { if (no_linenos) { printf("%s\n", data);