summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2010-02-18 10:26:24 +0200
committerPanu Matilainen <pmatilai@redhat.com>2010-02-18 10:26:24 +0200
commitd72cc38d3063343e5fb7306b473861e0f008032a (patch)
tree6ccf8af15804a6ec12135188130d87b2e7dc6d98 /build
parentc315beb3193202ee2221d47c02955b786032f8ed (diff)
downloadrpm-d72cc38d3063343e5fb7306b473861e0f008032a.tar.gz
rpm-d72cc38d3063343e5fb7306b473861e0f008032a.tar.bz2
rpm-d72cc38d3063343e5fb7306b473861e0f008032a.zip
Eliminate silly redundancy
- rpmfcSaveArg() and addAttr() were the very same thing, unify - turn hasAttr() into a macro, its just dumb enough for that
Diffstat (limited to 'build')
-rw-r--r--build/rpmfc.c34
1 files changed, 9 insertions, 25 deletions
diff --git a/build/rpmfc.c b/build/rpmfc.c
index aae376bf8..108e7ffe2 100644
--- a/build/rpmfc.c
+++ b/build/rpmfc.c
@@ -282,26 +282,23 @@ exit:
return ec;
}
-/**
- */
-static int rpmfcSaveArg(ARGV_t * argvp, const char * key)
+static void argvAddUniq(ARGV_t * argvp, const char * key)
{
- int rc = 0;
-
if (argvSearch(*argvp, key, NULL) == NULL) {
- rc = argvAdd(argvp, key);
- rc = argvSort(*argvp, NULL);
+ argvAdd(argvp, key);
+ argvSort(*argvp, NULL);
}
- return rc;
}
+#define hasAttr(_a, _n) (argvSearch((_a), (_n), NULL) != NULL)
+
static void rpmfcAddFileDep(ARGV_t * argvp, int ix, rpmds ds, char deptype)
{
if (ds) {
char *key = NULL;
rasprintf(&key, "%08d%c %s %s 0x%08x", ix, deptype,
rpmdsN(ds), rpmdsEVR(ds), rpmdsFlags(ds));
- rpmfcSaveArg(argvp, key);
+ argvAddUniq(argvp, key);
free(key);
}
}
@@ -530,19 +527,6 @@ static const struct rpmfcTokens_s const rpmfcTokens[] = {
{ NULL, RPMFC_BLACK, NULL }
};
-static int hasAttr(ARGV_t attrs, const char *name)
-{
- return (argvSearch(attrs, name, NULL) != NULL);
-}
-
-static void addAttr(ARGV_t *attrs, const char *name)
-{
- if (!hasAttr(*attrs, name)) {
- argvAdd(attrs, name);
- argvSort(*attrs, NULL);
- }
-}
-
/* Return attribute tokens + color for a given libmagic classification string */
static void rpmfcAttributes(const char * fmstr, ARGV_t *attrs, int *color)
{
@@ -558,7 +542,7 @@ static void rpmfcAttributes(const char * fmstr, ARGV_t *attrs, int *color)
ARGV_t atokens = NULL;
argvSplit(&atokens, fct->attrs, ",");
for (ARGV_t token = atokens; token && *token; token++)
- addAttr(&fattrs, *token);
+ argvAddUniq(&fattrs, *token);
argvFree(atokens);
}
@@ -829,7 +813,7 @@ rpmRC rpmfcApply(rpmfc fc)
if (fn[0] == '6' && fn[1] == '4')
fn += 2;
if (rstreqn(fn, "/python", sizeof("/python")-1))
- addAttr(&fc->fattrs[fc->ix], "python");
+ argvAddUniq(&fc->fattrs[fc->ix], "python");
}
}
@@ -1008,7 +992,7 @@ rpmRC rpmfcClassify(rpmfc fc, ARGV_t argv, rpm_mode_t * fmode)
xx = argiAdd(&fc->fcolor, fc->ix, fcolor);
if (fcolor != RPMFC_WHITE && (fcolor & RPMFC_INCLUDE))
- xx = rpmfcSaveArg(&fc->cdict, ftype);
+ argvAddUniq(&fc->cdict, ftype);
}
/* Build per-file class index array. */