Refactor file walk loop into rpmfcHelper()

Preliminaries for letting it handle multiple files at once
This commit is contained in:
Panu Matilainen 2023-04-14 08:50:53 +03:00
parent 2085295187
commit 35a460e509
1 changed files with 39 additions and 36 deletions

View File

@ -614,21 +614,25 @@ static void exclFini(struct exclreg_s *excl)
memset(excl, 0, sizeof(*excl)); memset(excl, 0, sizeof(*excl));
} }
static int rpmfcHelper(rpmfc fc, int ix, const struct exclreg_s *excl, static int rpmfcHelper(rpmfc fc, int *ixs, int n,
const struct exclreg_s *excl,
rpmsenseFlags dsContext, rpmTagVal tagN, rpmsenseFlags dsContext, rpmTagVal tagN,
const char *namespace, const char *mname) const char *namespace, const char *mname)
{ {
ARGV_t pav = NULL;
const char * fn = fc->fn[ix];
int pac;
int rc = 0; int rc = 0;
for (int i = 0; i < n; i++) {
ARGV_t pav = NULL;
int pac;
int fx = ixs[i];
const char * fn = fc->fn[fx];
/* If the entire path is filtered out, there's nothing more to do */ /* If the entire path is filtered out, there's nothing more to do */
if (regMatch(excl->exclude_from, fn+fc->brlen)) if (regMatch(excl->exclude_from, fn+fc->brlen))
goto exit; continue;
if (regMatch(excl->global_exclude_from, fn+fc->brlen)) if (regMatch(excl->global_exclude_from, fn+fc->brlen))
goto exit; continue;
if (rpmMacroIsParametric(NULL, mname)) { if (rpmMacroIsParametric(NULL, mname)) {
pav = runCall(mname, fc->buildRoot, fn); pav = runCall(mname, fc->buildRoot, fn);
@ -637,7 +641,7 @@ static int rpmfcHelper(rpmfc fc, int ix, const struct exclreg_s *excl,
} }
if (pav == NULL) if (pav == NULL)
goto exit; continue;
pac = argvCount(pav); pac = argvCount(pav);
@ -646,14 +650,16 @@ static int rpmfcHelper(rpmfc fc, int ix, const struct exclreg_s *excl,
data.namespace = namespace; data.namespace = namespace;
data.exclude = excl->exclude; data.exclude = excl->exclude;
for (int i = 0; i < pac; i++) { for (int dx = 0; dx < pac; dx++) {
if (parseRCPOT(NULL, fc->pkg, pav[i], tagN, ix, dsContext, addReqProvFc, &data)) if (parseRCPOT(NULL, fc->pkg, pav[dx], tagN, fx, dsContext,
addReqProvFc, &data)) {
rc++; rc++;
} }
}
argvFree(pav); argvFree(pav);
}
exit:
return rc; return rc;
} }
@ -1043,11 +1049,8 @@ static int applyAttr(rpmfc fc, int aix, const char *aname,
if (rpmMacroIsDefined(NULL, mname)) { if (rpmMacroIsDefined(NULL, mname)) {
char *ns = rpmfcAttrMacro(aname, "namespace", NULL); char *ns = rpmfcAttrMacro(aname, "namespace", NULL);
for (int i = 0; i < n; i++) { rc = rpmfcHelper(fc, ixs, n, excl, dep->type, dep->tag,
if (rpmfcHelper(fc, ixs[i], excl, dep->type, dep->tag, ns, mname);
ns, mname))
rc = 1;
}
free(ns); free(ns);
} }
free(mname); free(mname);