From a32705e737988512113bf21c7d067de6f49b4470 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Thu, 28 Oct 2010 10:24:20 +0300 Subject: [PATCH] Use ARGV_t for package fileFile, fileList and policyList - Similar to commit 1e3db59b568b1ff7f7e1f3285fc9b18567f2f2d6, all these end up being passed to argvSplit() to process them line by line in the end, collect them in the argv to start with saving a whole lotta huffing and puffing in the process --- build/files.c | 18 ++++-------------- build/parseFiles.c | 5 ++--- build/parsePolicies.c | 4 +--- build/policies.c | 8 ++------ build/rpmbuild_internal.h | 6 +++--- build/spec.c | 9 +++++---- 6 files changed, 17 insertions(+), 33 deletions(-) diff --git a/build/files.c b/build/files.c index 9d9e28382..2692be039 100644 --- a/build/files.c +++ b/build/files.c @@ -1709,8 +1709,6 @@ static rpmRC processPackageFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags, Package pkg, int installSpecialDoc, int test) { struct FileList_s fl; - char *s, **fp; - ARGV_t files = NULL; const char *fileName; char buf[BUFSIZ]; struct AttrRec_s arbuf; @@ -1722,11 +1720,9 @@ static rpmRC processPackageFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags, if (pkg->fileFile) { char *ffn; - ARGV_t filelists = NULL; FILE *fd; - argvSplit(&filelists, getStringBuf(pkg->fileFile), "\n"); - for (fp = filelists; *fp != NULL; fp++) { + for (ARGV_const_t fp = pkg->fileFile; *fp != NULL; fp++) { if (**fp == '/') { ffn = rpmGetPath(*fp, NULL); } else { @@ -1749,11 +1745,10 @@ static rpmRC processPackageFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags, fclose(fd); return RPMRC_FAIL; } - appendStringBuf(pkg->fileList, buf); + argvAdd(&(pkg->fileList), buf); } (void) fclose(fd); } - argvFree(filelists); } /* Init the file list structure */ @@ -1803,11 +1798,8 @@ static rpmRC processPackageFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags, fl.fileListRecsAlloced = 0; fl.fileListRecsUsed = 0; - s = getStringBuf(pkg->fileList); - argvSplit(&files, s, "\n"); - - for (fp = files; *fp != NULL; fp++) { - s = *fp; + for (ARGV_const_t fp = pkg->fileList; *fp != NULL; fp++) { + const char *s = *fp; SKIPSPACE(s); if (*s == '\0') continue; @@ -1907,8 +1899,6 @@ static rpmRC processPackageFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags, specialDoc = _free(specialDoc); } - argvFree(files); - if (fl.processingFailed) goto exit; diff --git a/build/parseFiles.c b/build/parseFiles.c index 44a92bb62..f7a8369fb 100644 --- a/build/parseFiles.c +++ b/build/parseFiles.c @@ -67,8 +67,7 @@ int parseFiles(rpmSpec spec) for (arg=1; argfileFile) pkg->fileFile = newStringBuf(); - appendLineStringBuf(pkg->fileFile, file); + argvAdd(&(pkg->fileFile), file); free(file); } } @@ -79,7 +78,7 @@ int parseFiles(rpmSpec spec) goto exit; } else { while (! (nextPart = isPart(spec->line))) { - appendStringBuf(pkg->fileList, spec->line); + argvAdd(&(pkg->fileList), spec->line); if ((rc = readLine(spec, STRIP_COMMENTS)) > 0) { nextPart = PART_NONE; break; diff --git a/build/parsePolicies.c b/build/parsePolicies.c index c66d82f65..2abc00c85 100644 --- a/build/parsePolicies.c +++ b/build/parsePolicies.c @@ -64,15 +64,13 @@ int parsePolicies(rpmSpec spec) goto exit; } - pkg->policyList = newStringBuf(); - if ((rc = readLine(spec, STRIP_TRAILINGSPACE | STRIP_COMMENTS)) > 0) { nextPart = PART_NONE; } else if (rc < 0) { goto exit; } else { while (!(nextPart = isPart(spec->line))) { - appendLineStringBuf(pkg->policyList, spec->line); + argvAdd(&(pkg->policyList), spec->line); if ((rc = readLine(spec, STRIP_TRAILINGSPACE | STRIP_COMMENTS)) > 0) { nextPart = PART_NONE; break; diff --git a/build/policies.c b/build/policies.c index 8cef31866..f8bb0c430 100644 --- a/build/policies.c +++ b/build/policies.c @@ -221,8 +221,6 @@ static rpmRC processPolicies(rpmSpec spec, Package pkg, int test) uint32_t flags = 0; poptContext optCon = NULL; - ARGV_t policies = NULL; - ARGV_t pol; rpmRC rc = RPMRC_FAIL; struct poptOption optionsTable[] = { @@ -236,10 +234,9 @@ static rpmRC processPolicies(rpmSpec spec, Package pkg, int test) goto exit; } - argvSplit(&policies, getStringBuf(pkg->policyList), "\n"); - for (pol = policies; *pol != NULL; pol++) { + for (ARGV_const_t pol = pkg->policyList; *pol != NULL; pol++) { ModuleRec mod; - char *line = *pol; + const char *line = *pol; const char **argv = NULL; int argc = 0; int err; @@ -288,7 +285,6 @@ static rpmRC processPolicies(rpmSpec spec, Package pkg, int test) rc = RPMRC_OK; exit: - argvFree(policies); return rc; } diff --git a/build/rpmbuild_internal.h b/build/rpmbuild_internal.h index 8eb75e1b6..f91569942 100644 --- a/build/rpmbuild_internal.h +++ b/build/rpmbuild_internal.h @@ -129,9 +129,9 @@ struct Package_s { struct TriggerFileEntry * triggerFiles; - StringBuf fileFile; - StringBuf fileList; /* If NULL, package will not be written */ - StringBuf policyList; + ARGV_t fileFile; + ARGV_t fileList; /* If NULL, package will not be written */ + ARGV_t policyList; Package next; }; diff --git a/build/spec.c b/build/spec.c index 651faada0..fc279233a 100644 --- a/build/spec.c +++ b/build/spec.c @@ -99,7 +99,8 @@ Package newPackage(rpmSpec spec) p->header = headerNew(); p->autoProv = 1; p->autoReq = 1; - p->fileList = newStringBuf(); + p->fileList = argvNew(); + p->fileFile = NULL; p->policyList = NULL; if (spec->packages == NULL) { @@ -128,9 +129,9 @@ static Package freePackage(Package pkg) pkg->header = headerFree(pkg->header); pkg->ds = rpmdsFree(pkg->ds); - pkg->fileList = freeStringBuf(pkg->fileList); - pkg->fileFile = freeStringBuf(pkg->fileFile); - pkg->policyList = freeStringBuf(pkg->policyList); + pkg->fileList = argvFree(pkg->fileList); + pkg->fileFile = argvFree(pkg->fileFile); + pkg->policyList = argvFree(pkg->policyList); if (pkg->cpioList) { rpmfi fi = pkg->cpioList; pkg->cpioList = NULL;