From 487f26633f904913041480f9f1b78e91e0a24482 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Mon, 28 May 2012 08:54:30 +0300 Subject: [PATCH] Unify %verify and virtual file attribute handling --- build/files.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/build/files.c b/build/files.c index 34d1c9bb3..54045b74b 100644 --- a/build/files.c +++ b/build/files.c @@ -280,6 +280,19 @@ static VFA_t const verifyAttrs[] = { { NULL, 0 } }; +static rpmFlags vfaMatch(VFA_t *attrs, const char *token, rpmFlags *flags) +{ + VFA_t *vfa; + + for (vfa = attrs; vfa->attribute != NULL; vfa++) { + if (rstreq(token, vfa->attribute)) { + *flags |= vfa->flag; + break; + } + } + return vfa->flag; +} + /** * Parse %verify and %defverify from file manifest. * @param buf current spec file line @@ -338,16 +351,8 @@ static rpmRC parseForVerify(char * buf, FileEntry cur, FileEntry def) if (*pe != '\0') *pe++ = '\0'; - { VFA_t *vfa; - for (vfa = verifyAttrs; vfa->attribute != NULL; vfa++) { - if (!rstreq(p, vfa->attribute)) - continue; - verifyFlags |= vfa->flag; - break; - } - if (vfa->attribute) - continue; - } + if (vfaMatch(verifyAttrs, p, &verifyFlags)) + continue; if (rstreq(p, "not")) { negated ^= 1; @@ -810,7 +815,7 @@ exit: } /** */ -static VFA_t const virtualFileAttributes[] = { +static VFA_t const virtualAttrs[] = { { "%dir", RPMFILE_DIR }, { "%docdir", RPMFILE_DOCDIR }, { "%doc", RPMFILE_DOC }, @@ -837,18 +842,10 @@ static rpmRC parseForSimple(char * buf, FileEntry cur, ARGV_t * fileNames) t = buf; while ((s = strtokWithQuotes(t, " \t\n")) != NULL) { - VFA_t *vfa; t = NULL; /* Set flags for virtual file attributes */ - for (vfa = virtualFileAttributes; vfa->attribute != NULL; vfa++) { - if (rstreq(s, vfa->attribute)) { - cur->attrFlags |= vfa->flag; - break; - } - } - /* if we got an attribute, continue with next token */ - if (vfa->attribute != NULL) + if (vfaMatch(virtualAttrs, s, &(cur->attrFlags))) continue; /* normally paths need to be absolute */