Use ARGV_t for package fileFile, fileList and policyList
authorPanu Matilainen <pmatilai@redhat.com>
Thu, 28 Oct 2010 07:24:20 +0000 (10:24 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Thu, 28 Oct 2010 07:24:20 +0000 (10:24 +0300)
- 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
build/parseFiles.c
build/parsePolicies.c
build/policies.c
build/rpmbuild_internal.h
build/spec.c

index 9d9e283..2692be0 100644 (file)
@@ -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;
 
index 44a92bb..f7a8369 100644 (file)
@@ -67,8 +67,7 @@ int parseFiles(rpmSpec spec)
     for (arg=1; arg<argc; arg++) {
        if (rstreq(argv[arg], "-f") && argv[arg+1]) {
            char *file = rpmGetPath(argv[arg+1], NULL);
-           if (!pkg->fileFile) 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;
index c66d82f..2abc00c 100644 (file)
@@ -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;
index 8cef318..f8bb0c4 100644 (file)
@@ -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;
 }
index 8eb75e1..f915699 100644 (file)
@@ -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;
 };
index 651faad..fc27923 100644 (file)
@@ -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;