depends.c and rpmal.c have opaque TFI_t.
authorjbj <devnull@localhost>
Wed, 14 Nov 2001 00:14:01 +0000 (00:14 +0000)
committerjbj <devnull@localhost>
Wed, 14 Nov 2001 00:14:01 +0000 (00:14 +0000)
CVS patchset: 5180
CVS date: 2001/11/14 00:14:01

lib/depends.c
lib/depends.h
lib/rpmal.c
lib/rpmds.h
lib/rpmfi.c
lib/rpmfi.h
lib/transaction.c
po/rpm.pot

index bfafe6a..e56fee8 100644 (file)
@@ -17,8 +17,8 @@
 
 #include "debug.h"
 
-/*@access TFI_t @*/            /* XXX abstraction wrappers needed */
 /*@access tsortInfo @*/
+/*@access transactionElement @*/
 /*@access rpmTransactionSet @*/
 
 /*@access alKey @*/    /* XXX for reordering and RPMAL_NOMATCH assign */
@@ -1740,8 +1740,6 @@ int rpmdepCheck(rpmTransactionSet ts,
 {
     rpmdbMatchIterator mi = NULL;
     teIterator pi = NULL; transactionElement p;
-    char * fn = NULL;
-    int fileAlloced = 0;
     int closeatexit = 0;
     int xx;
     int rc;
@@ -1840,29 +1838,13 @@ int rpmdepCheck(rpmTransactionSet ts,
        if (rc)
            goto exit;
 
-       fi = tfiInit(p->fi, 0);
 
-       if (fi == NULL)
-           continue;
-       if (fi->bnl == NULL)
-           continue;   /* XXX can't happen */
-       if (fi->dnl == NULL)
-           continue;   /* XXX can't happen */
-       if (fi->dil == NULL)
-           continue;   /* XXX can't happen */
 
        rc = 0;
+       if ((fi = tfiInit(p->fi, 0)) != NULL)
        while (tfiNext(fi) >= 0) {
-           int len;
+           const char * fn = tfiGetFN(fi);
 
-           len = strlen(fi->bnl[fi->i]) + 1 +
-                               strlen(fi->dnl[fi->dil[fi->i]]);
-           if (len > fileAlloced) {
-               fileAlloced = len * 2;
-               fn = xrealloc(fn, fileAlloced);
-           }
-           *fn = '\0';
-           (void) stpcpy( stpcpy(fn, fi->dnl[fi->dil[fi->i]]), fi->bnl[fi->i]);
            /* Erasing: check filename against requiredby matches. */
            if (!checkDependentPackages(ts, fn))
                /*@innercontinue@*/ continue;
@@ -1885,7 +1867,6 @@ int rpmdepCheck(rpmTransactionSet ts,
     rc = 0;
 
 exit:
-    fn = _free(fn);
     mi = rpmdbFreeIterator(mi);
     pi = teFreeIterator(pi);
     /*@-branchstate@*/
index 610e080..d5190bd 100644 (file)
@@ -206,7 +206,6 @@ extern "C" {
 #if defined(_NEED_TEITERATOR)
 /*@access teIterator @*/
 
-/*@access TFI_t @*/
 /*@access transactionElement @*/
 /*@access rpmTransactionSet @*/
 
@@ -223,28 +222,6 @@ int teGetOc(teIterator tei)
 }
 
 /**
- * Return transaction element's file info.
- * @todo Take a TFI_t refcount here.
- * @param tei          transaction element iterator
- * @return             transaction element file info
- */
-/*@unused@*/ static inline /*@null@*/
-TFI_t teGetFi(teIterator tei)
-       /*@modifies tei @*/
-{
-    TFI_t fi = NULL;
-
-    if (tei != NULL && tei->ocsave != -1) {
-       transactionElement te = tei->ts->order + tei->ocsave;
-       if ((fi = te->fi) != NULL)
-           fi->te = te;
-    }
-    /*@-compdef -refcounttrans -usereleased @*/
-    return fi;
-    /*@=compdef =refcounttrans =usereleased @*/
-}
-
-/**
  * Destroy transaction element iterator.
  * @param tei          transaction element iterator
  * @return             NULL always
index 2987bcc..a5fc2a6 100644 (file)
@@ -12,6 +12,9 @@
 
 typedef /*@abstract@*/ struct availablePackage_s * availablePackage;
 
+/*@unchecked@*/
+static int _al_debug = 0;
+
 /*@access alKey @*/
 /*@access alNum @*/
 /*@access availableList @*/
@@ -19,8 +22,6 @@ typedef /*@abstract@*/ struct availablePackage_s * availablePackage;
 
 /*@access fnpyKey @*/  /* XXX suggestedKeys array */
 
-/*@access TFI_t @*/    /* XXX abstraction wrappers needed */
-
 /** \ingroup rpmdep
  * Info about a single package to be installed.
  */
@@ -28,7 +29,7 @@ struct availablePackage_s {
 /*@refcounted@*/ /*@null@*/
     rpmDepSet provides;                /*!< Provides: dependencies. */
 /*@refcounted@*/ /*@null@*/
-    TFI_t fi;          /*!< File info set. */
+    TFI_t fi;                  /*!< File info set. */
 
 #ifdef DYING
     uint_32 multiLib;  /* MULTILIB */
@@ -77,7 +78,7 @@ typedef /*@abstract@*/ struct fileIndexEntry_s *      fileIndexEntry;
  * A file to be installed/removed.
  */
 struct fileIndexEntry_s {
-/*@dependent@*/
+/*@dependent@*/ /*@null@*/
     const char * baseName;     /*!< File basename. */
     int baseNameLen;
     alNum pkgNum;              /*!< Containing package index. */
@@ -91,7 +92,7 @@ typedef /*@abstract@*/ struct dirInfo_s *             dirInfo;
  * A directory to be installed/removed.
  */
 struct dirInfo_s {
-/*@owned@*/
+/*@owned@*/ /*@null@*/
     const char * dirName;      /*!< Directory path (+ trailing '/'). */
     int dirNameLen;            /*!< No. bytes in directory path. */
 /*@owned@*/
@@ -114,9 +115,6 @@ struct availableList_s {
     dirInfo dirs;              /*!< Set of directories. */
 };
 
-/*@unchecked@*/
-static int _al_debug = 0;
-
 /**
  * Destroy available item index.
  * @param al           available list
@@ -247,7 +245,10 @@ static int dieCompare(const void * one, const void * two)
     /*@=castexpose@*/
     int lenchk = a->dirNameLen - b->dirNameLen;
 
-    if (lenchk)
+    if (lenchk || a->dirNameLen == 0)
+       return lenchk;
+
+    if (a->dirName == NULL || b->dirName == NULL)
        return lenchk;
 
     /* XXX FIXME: this might do "backward" strcmp for speed */
@@ -272,6 +273,9 @@ static int fieCompare(const void * one, const void * two)
     if (lenchk)
        return lenchk;
 
+    if (a->baseName == NULL || b->baseName == NULL)
+       return lenchk;
+
     /* XXX FIXME: this might do "backward" strcmp for speed */
     return strcmp(a->baseName, b->baseName);
 }
@@ -294,9 +298,9 @@ fprintf(stderr, "*** del %p[%d]\n", al->list, pkgNum);
 
     /* Delete directory/file info entries from added package list. */
     if ((fi = alp->fi) != NULL)
-    if (fi->bnl != NULL && fi->fc > 0) {
+    if (tfiGetFC(fi) > 0) {
        int origNumDirs = al->numDirs;
-       int dirNum;
+       int dx;
        dirInfo dieNeedle =
                memset(alloca(sizeof(*dieNeedle)), 0, sizeof(*dieNeedle));
        dirInfo die;
@@ -306,14 +310,17 @@ fprintf(stderr, "*** del %p[%d]\n", al->list, pkgNum);
        /* XXX FIXME: We ought to relocate the directory list here */
 
        if (al->dirs != NULL)
-       if (fi->dnl != NULL)
-       for (dirNum = fi->dc - 1; dirNum >= 0; dirNum--) {
+       for (dx = tfiGetDC(fi) - 1; dx >= 0; dx--)
+       {
            fileIndexEntry fie;
 
+           (void) tfiSetDX(fi, dx);
+
            /*@-assignexpose@*/
-           dieNeedle->dirName = (char *) fi->dnl[dirNum];
+           dieNeedle->dirName = (char *) tfiGetDN(fi);
            /*@=assignexpose@*/
-           dieNeedle->dirNameLen = strlen(dieNeedle->dirName);
+           dieNeedle->dirNameLen = (dieNeedle->dirName != NULL
+                       ? strlen(dieNeedle->dirName) : 0);
            die = bsearch(dieNeedle, al->dirs, al->numDirs,
                               sizeof(*dieNeedle), dieCompare);
            if (die == NULL)
@@ -391,47 +398,55 @@ fprintf(stderr, "*** add %p[%d]\n", al->list, pkgNum);
 
     fi = rpmfiLink(alp->fi, "Files index (alAddPackage)");
     if ((fi = tfiInit(fi, 0)) != NULL)
-    if (fi->bnl != NULL)       /* XXX can't happen */
-    if (fi->dil != NULL)       /* XXX can't happen */
-    if (fi->dnl != NULL)       /* XXX can't happen */
-    if (fi->fflags != NULL)    /* XXX can't happen */
-    if (fi->fc > 0) {
+    if (tfiGetFC(fi) > 0) {
        int * dirMapping;
        dirInfo dieNeedle =
                memset(alloca(sizeof(*dieNeedle)), 0, sizeof(*dieNeedle));
        dirInfo die;
-       int first, dirNum;
+       int first;
        int origNumDirs;
+       int dx;
+       int dc;
+
+       dc = tfiGetDC(fi);
 
        /* XXX FIXME: We ought to relocate the directory list here */
 
-       dirMapping = alloca(sizeof(*dirMapping) * fi->dc);
+       dirMapping = alloca(sizeof(*dirMapping) * dc);
 
        /*
         * Allocated enough space for all the directories we could possible
         * need to add
         */
-       al->dirs = xrealloc(al->dirs,
-                       (al->numDirs + fi->dc) * sizeof(*al->dirs));
+       al->dirs = xrealloc(al->dirs, (al->numDirs + dc) * sizeof(*al->dirs));
        origNumDirs = al->numDirs;
 
-       if (fi->dnl != NULL)
-       for (dirNum = 0; dirNum < fi->dc; dirNum++) {
+       for (dx = 0; dx < dc; dx++) {
+
+           (void) tfiSetDX(fi, dx);
+
            /*@-assignexpose@*/
-           dieNeedle->dirName = (char *) fi->dnl[dirNum];
+           dieNeedle->dirName = (char *) tfiGetDN(fi);
            /*@=assignexpose@*/
-           dieNeedle->dirNameLen = strlen(fi->dnl[dirNum]);
+           dieNeedle->dirNameLen = (dieNeedle->dirName != NULL
+                       ? strlen(dieNeedle->dirName) : 0);
            die = bsearch(dieNeedle, al->dirs, origNumDirs,
                               sizeof(*dieNeedle), dieCompare);
            if (die) {
-               dirMapping[dirNum] = die - al->dirs;
+               dirMapping[dx] = die - al->dirs;
            } else {
-               dirMapping[dirNum] = al->numDirs;
+               dirMapping[dx] = al->numDirs;
                die = al->dirs + al->numDirs;
-               die->dirName = xstrdup(fi->dnl[dirNum]);
-               die->dirNameLen = strlen(die->dirName);
+               if (dieNeedle->dirName != NULL)
+                   die->dirName = xstrdup(dieNeedle->dirName);
+               die->dirNameLen = dieNeedle->dirNameLen;
                die->files = NULL;
                die->numFiles = 0;
+/*@-modfilesys@*/
+if (_al_debug)
+fprintf(stderr, "+++ die[%3d] %p [%d] %s\n", al->numDirs, die, die->dirNameLen, die->dirName);
+/*@=modfilesys@*/
+
                al->numDirs++;
            }
        }
@@ -441,13 +456,14 @@ fprintf(stderr, "*** add %p[%d]\n", al->list, pkgNum);
            int next;
 
            /* Find the first file of the next directory. */
+           dx = tfiGetDX(fi);
            while ((next = tfiNext(fi)) >= 0) {
-               if (fi->dil[first] != fi->dil[next])
+               if (dx != tfiGetDX(fi))
                    /*@innerbreak@*/ break;
            }
-           if (next < 0) next = fi->fc;        /* XXX reset end-of-list */
+           if (next < 0) next = tfiGetFC(fi);  /* XXX reset end-of-list */
 
-           die = al->dirs + dirMapping[fi->dil[first]];
+           die = al->dirs + dirMapping[dx];
            die->files = xrealloc(die->files,
                        (die->numFiles + next - first) * sizeof(*die->files));
            fie = die->files + die->numFiles;
@@ -456,12 +472,12 @@ fprintf(stderr, "*** add %p[%d]\n", al->list, pkgNum);
            fi = tfiInit(fi, first);
            if (fi != NULL)
            while ((first = tfiNext(fi)) >= 0 && first < next) {
-               /*@-assignexpose@*/
-               fie->baseName = fi->bnl[fi->i];
-               fie->baseNameLen = strlen(fi->bnl[fi->i]);
-               /*@=assignexpose@*/
+               /*@-assignexpose -onlytrans @*/
+               fie->baseName = tfiGetBN(fi);
+               /*@=assignexpose =onlytrans @*/
+               fie->baseNameLen = (fie->baseName ? strlen(fie->baseName) : 0);
                fie->pkgNum = pkgNum;
-               fie->fileFlags = fi->fflags[fi->i];
+               fie->fileFlags = tfiGetFFlags(fi);
                die->numFiles++;
                fie++;
            }
@@ -628,6 +644,11 @@ alAllFileSatisfiesDepend(const availableList al, const rpmDepSet ds, alKey * key
         die++)
     {
 
+/*@-modfilesys@*/
+if (_al_debug)
+fprintf(stderr, "==> die %p %s\n", die, (die->dirName ? die->dirName : "(nil)"));
+/*@=modfilesys@*/
+
        fieNeedle->baseName = baseName;
        fieNeedle->baseNameLen = strlen(fieNeedle->baseName);
        fie = bsearch(fieNeedle, die->files, die->numFiles,
@@ -635,6 +656,11 @@ alAllFileSatisfiesDepend(const availableList al, const rpmDepSet ds, alKey * key
        if (fie == NULL)
            continue;   /* XXX shouldn't happen */
 
+/*@-modfilesys@*/
+if (_al_debug)
+fprintf(stderr, "==> fie %p %s\n", fie, (fie->baseName ? fie->baseName : "(nil)"));
+/*@=modfilesys@*/
+
 #ifdef DYING   /* XXX FIXME: multilib colored dependency search */
        /*
         * If a file dependency would be satisfied by a file
index eb01fe6..c90ec97 100644 (file)
@@ -175,15 +175,15 @@ const char * dsiGetEVR(/*@null@*/ rpmDepSet ds)
        /*@*/;
 
 /**
- * Return current dependency Flags.
+ * Return current dependency flags.
  * @param ds           dependency set
- * @return             current dependency EVR, 0 on invalid
+ * @return             current dependency flags, 0 on invalid
  */
 int_32 dsiGetFlags(/*@null@*/ rpmDepSet ds)
        /*@*/;
 
 /**
- * Notify of results of dependency match;
+ * Notify of results of dependency match.
  * @param ds           dependency set
  * @param where                where dependency was resolved (or NULL)
  * @param rc           0 == YES, otherwise NO
index 000795d..fc890f0 100644 (file)
@@ -46,16 +46,116 @@ fnpyKey rpmfiGetKey(TFI_t fi)
     return fi->te->key;
 }
 
+int tfiGetFC(TFI_t fi)
+{
+    return (fi != NULL ? fi->fc : 0);
+}
+
+int tfiGetDC(TFI_t fi)
+{
+    return (fi != NULL ? fi->dc : 0);
+}
+
+#ifdef NOTYET
+int tfiGetDI(TFI_t fi)
+{
+}
+#endif
+
+int tfiGetFX(TFI_t fi)
+{
+    return (fi != NULL ? fi->i : -1);
+}
+
+int tfiSetFX(TFI_t fi, int fx)
+{
+    int i = -1;
+
+    if (fi != NULL && fx >= 0 && fx < fi->fc) {
+       i = fi->i;
+       fi->i = fx;
+       fi->j = fi->dil[fi->i];
+    }
+    return i;
+}
+
+int tfiGetDX(TFI_t fi)
+{
+    return (fi != NULL ? fi->j : -1);
+}
+
+int tfiSetDX(TFI_t fi, int dx)
+{
+    int j = -1;
+
+    if (fi != NULL && dx >= 0 && dx < fi->dc) {
+       j = fi->j;
+       fi->j = dx;
+    }
+    return j;
+}
+
+const char * tfiGetBN(TFI_t fi)
+{
+    const char * BN = NULL;
+
+    if (fi != NULL && fi->i >= 0 && fi->i < fi->fc) {
+       if (fi->bnl != NULL)
+           BN = fi->bnl[fi->i];
+    }
+    return BN;
+}
+
+const char * tfiGetDN(TFI_t fi)
+{
+    const char * DN = NULL;
+
+    if (fi != NULL && fi->j >= 0 && fi->j < fi->dc) {
+       if (fi->dnl != NULL)
+           DN = fi->dnl[fi->j];
+    }
+    return DN;
+}
 
-int tfiNext(/*@null@*/ TFI_t fi)
-       /*@modifies fi @*/
+const char * tfiGetFN(TFI_t fi)
+{
+    const char * FN = "";
+
+    /*@-branchstate@*/
+    if (fi != NULL && fi->i >= 0 && fi->i < fi->fc) {
+       char * t;
+       if (fi->fn == NULL)
+           fi->fn = xmalloc(fi->fnlen);
+       FN = t = fi->fn;
+       *t = '\0';
+       t = stpcpy(t, fi->dnl[fi->dil[fi->i]]);
+       t = stpcpy(t, fi->bnl[fi->i]);
+    }
+    /*@=branchstate@*/
+    return FN;
+}
+
+int_32 tfiGetFFlags(TFI_t fi)
+{
+    int_32 FFlags = 0;
+
+    if (fi != NULL && fi->i >= 0 && fi->i < fi->fc) {
+       if (fi->fflags != NULL)
+           FFlags = fi->fflags[fi->i];
+    }
+    return FFlags;
+}
+
+int tfiNext(TFI_t fi)
 {
     int i = -1;
 
     if (fi != NULL && ++fi->i >= 0) {
-       if (fi->i < fi->fc)
+       if (fi->i < fi->fc) {
            i = fi->i;
-       else
+           if (fi->dil != NULL)
+               fi->j = fi->dil[fi->i];
+       } else
            fi->i = -1;
 
 /*@-modfilesystem @*/
@@ -68,12 +168,46 @@ fprintf(stderr, "*** fi %p\t%s[%d]\n", fi, (fi->Type ? fi->Type : "?Type?"), i);
     return i;
 }
 
-TFI_t tfiInit(/*@returned@*/ /*@null@*/ TFI_t fi, int ix)
-       /*@modifies fi @*/
+TFI_t tfiInit(TFI_t fi, int fx)
+{
+    if (fi != NULL) {
+       if (fx >= 0 && fx < fi->fc) {
+           fi->i = fx - 1;
+           fi->j = -1;
+       } else
+           fi = NULL;
+    }
+
+    /*@-refcounttrans@*/
+    return fi;
+    /*@=refcounttrans@*/
+}
+
+int tdiNext(TFI_t fi)
+{
+    int j = -1;
+
+    if (fi != NULL && ++fi->j >= 0) {
+       if (fi->j < fi->dc)
+           j = fi->j;
+       else
+           fi->j = -1;
+
+/*@-modfilesystem @*/
+if (_fi_debug  < 0 && j != -1)
+fprintf(stderr, "*** fi %p\t%s[%d]\n", fi, (fi->Type ? fi->Type : "?Type?"), j);
+/*@=modfilesystem @*/
+
+    }
+
+    return j;
+}
+
+TFI_t tdiInit(TFI_t fi, int dx)
 {
     if (fi != NULL) {
-       if (ix >= 0 && ix < fi->fc)
-           fi->i = ix - 1;
+       if (dx >= 0 && dx < fi->fc)
+           fi->j = dx - 1;
        else
            fi = NULL;
     }
@@ -596,6 +730,7 @@ fprintf(stderr, "*** fi %p\t%s[%d]\n", fi, fi->Type, fi->fc);
 
     fi->fsm = freeFSM(fi->fsm);
 
+    fi->fn = _free(fi->fn);
     fi->apath = _free(fi->apath);
     fi->fmapflags = _free(fi->fmapflags);
 
@@ -634,6 +769,7 @@ TFI_t fiNew(rpmTransactionSet ts, TFI_t fi,
     const char * Type;
     uint_32 * uip;
     int malloced = 0;
+    int dnlmax, bnlmax;
     int len;
     int xx;
     int i;
@@ -745,16 +881,19 @@ TFI_t fiNew(rpmTransactionSet ts, TFI_t fi,
        fi->h = headerFree(fi->h, fi->Type);
     }
 
-    fi->dnlmax = -1;
+    dnlmax = -1;
     for (i = 0; i < fi->dc; i++) {
-       if ((len = strlen(fi->dnl[i])) > fi->dnlmax)
-           fi->dnlmax = len;
+       if ((len = strlen(fi->dnl[i])) > dnlmax)
+           dnlmax = len;
     }
-    fi->bnlmax = -1;
+    bnlmax = -1;
     for (i = 0; i < fi->fc; i++) {
-       if ((len = strlen(fi->bnl[i])) > fi->bnlmax)
-           fi->bnlmax = len;
+       if ((len = strlen(fi->bnl[i])) > bnlmax)
+           bnlmax = len;
     }
+    fi->fnlen = dnlmax + bnlmax + 1;
+    fi->fn = NULL;
+
     fi->dperms = 0755;
     fi->fperms = 0644;
 
index b2d4272..9a61e95 100644 (file)
@@ -3,7 +3,7 @@
 
 /** \ingroup rpmdep rpmtrans
  * \file lib/rpmfi.h
- * Structure used for file info tag sets.
+ * Structure(s) used for file info tag sets.
  */
 
 /**
@@ -23,7 +23,8 @@ struct sharedFileInfo_s {
  * A package filename set.
  */
 struct TFI_s {
-    int i;                     /*!< File index. */
+    int i;                     /*!< Current file index. */
+    int j;                     /*!< Current directory index. */
 
 /*@observer@*/
     const char * Type;         /*!< Tag name. */
@@ -96,8 +97,11 @@ struct TFI_s {
     const char ** odnl;                /*!< Original dirname(s) (from header) */
 /*@unused@*/
     int_32 * odil;             /*!< Original dirindex(s) (from header) */
-    int bnlmax;                        /*!< Length (in bytes) of longest basename. */
-    int dnlmax;                        /*!< Length (in bytes) of longest dirname. */
+
+/*@only@*/ /*@null@*/
+    char * fn;                 /*!< File name buffer. */
+    int fnlen;                 /*!< FIle name buffer length. */
+
     int astriplen;
     int striplen;
     unsigned int archiveSize;
@@ -171,6 +175,130 @@ fnpyKey rpmfiGetKey(TFI_t fi)
        /*@*/;
 
 /**
+ * Return file count from file info set.
+ * @param fi           file info set
+ * @return             current file count
+ */
+int tfiGetFC(/*@null@*/ TFI_t fi)
+       /*@*/;
+
+/**
+ * Return current file index from file info set.
+ * @param fi           file info set
+ * @return             current file index
+ */
+/*@unused@*/
+int tfiGetFX(/*@null@*/ TFI_t fi)
+       /*@*/;
+
+/**
+ * Set current file index in file info set.
+ * @param fi           file info set
+ * @param fx           new file index
+ * @return             current file index
+ */
+/*@unused@*/
+int tfiSetFX(/*@null@*/ TFI_t fi, int fx)
+       /*@modifies fi @*/;
+
+/**
+ * Return directory count from file info set.
+ * @param fi           file info set
+ * @return             current directory count
+ */
+int tfiGetDC(/*@null@*/ TFI_t fi)
+       /*@*/;
+
+/**
+ * Return current directory index from file info set.
+ * @param fi           file info set
+ * @return             current directory index
+ */
+int tfiGetDX(/*@null@*/ TFI_t fi)
+       /*@*/;
+
+/**
+ * Set current directory index in file info set.
+ * @param fi           file info set
+ * @param fx           new directory index
+ * @return             current directory index
+ */
+int tfiSetDX(/*@null@*/ TFI_t fi, int dx)
+       /*@modifies fi @*/;
+
+/**
+ * Return current base name from file info set.
+ * @param fi           file info set
+ * @return             current base name, NULL on invalid
+ */
+/*@null@*/
+const char * tfiGetBN(/*@null@*/ TFI_t fi)
+       /*@*/;
+
+/**
+ * Return current directory name from file info set.
+ * @param fi           file info set
+ * @return             current directory, NULL on invalid
+ */
+/*@null@*/
+const char * tfiGetDN(/*@null@*/ TFI_t fi)
+       /*@*/;
+
+/**
+ * Return current file name from file info set.
+ * @param fi           file info set
+ * @return             current file name
+ */
+/*@observer@*/
+const char * tfiGetFN(/*@null@*/ TFI_t fi)
+       /*@modifies fi @*/;
+
+/**
+ * Return current file flags from file info set.
+ * @param fi           file info set
+ * @return             current file flags, 0 on invalid
+ */
+int_32 tfiGetFFlags(/*@null@*/ TFI_t fi)
+       /*@*/;
+
+/**
+ * Return next file iterator index.
+ * @param fi           file info set
+ * @return             file iterator index, -1 on termination
+ */
+int tfiNext(/*@null@*/ TFI_t fi)
+       /*@modifies fi @*/;
+
+/**
+ * Initialize file iterator index.
+ * @param fi           file info set
+ * @param fx           file iterator index
+ * @return             file info set, NULL if fx is out of range
+ */
+/*@null@*/
+TFI_t tfiInit(/*@null@*/ TFI_t fi, int fx)
+       /*@modifies fi @*/;
+
+/**
+ * Return next directory iterator index.
+ * @param fi           file info set
+ * @return             directory iterator index, -1 on termination
+ */
+/*@unused@*/
+int tdiNext(/*@null@*/ TFI_t fi)
+       /*@modifies fi @*/;
+
+/**
+ * Initialize directory iterator index.
+ * @param fi           file info set
+ * @param dx           directory iterator index
+ * @return             file info set, NULL if dx is out of range
+ */
+/*@unused@*/ /*@null@*/
+TFI_t tdiInit(/*@null@*/ TFI_t fi, int dx)
+       /*@modifies fi @*/;
+
+/**
  * Destroy a file info set.
  * @param fi           file set
  * @param freefimem    free fi memory too?
@@ -195,24 +323,6 @@ TFI_t fiNew(rpmTransactionSet ts, /*@null@*/ TFI_t fi,
        /*@modifies ts, fi, h @*/;
 
 /**
- * Return next file info set iterator index.
- * @param fi           file info set
- * @return             file info set iterator index, -1 on termination
- */
-int tfiNext(/*@null@*/ TFI_t fi)
-       /*@modifies fi @*/;
-
-/**
- * Initialize file info set iterator.
- * @param fi           file info set
- * @param ix           file info set index
- * @return             file info set, NULL if ix is out of range
- */
-/*@null@*/
-TFI_t tfiInit(/*@null@*/ TFI_t fi, int ix)
-       /*@modifies fi @*/;
-
-/**
  * Return file type from mode_t.
  * @param mode         file mode bits (from header)
  * @return             file type
index 7de3a19..4e5baeb 100644 (file)
@@ -157,8 +157,8 @@ static int sharedCmp(const void * one, const void * two)
 
 /**
  */
-static fileAction decideFileFate(const char * dirName,
-                       const char * baseName, short dbMode,
+static fileAction decideFileFate(const char * fn,
+                       short dbMode,
                        const char * dbMd5, const char * dbLink, short newMode,
                        const char * newMd5, const char * newLink, int newFlags,
                        rpmtransFlags transFlags)
@@ -171,11 +171,8 @@ static fileAction decideFileFate(const char * dirName,
     struct stat sb;
     int i, rc;
     int save = (newFlags & RPMFILE_NOREPLACE) ? FA_ALTNAME : FA_SAVE;
-    char * filespec = alloca(strlen(dirName) + strlen(baseName) + 1);
 
-    (void) stpcpy( stpcpy(filespec, dirName), baseName);
-
-    if (lstat(filespec, &sb)) {
+    if (lstat(fn, &sb)) {
        /*
         * The file doesn't exist on the disk. Create it unless the new
         * package has marked it as missingok, or allfiles is requested.
@@ -183,7 +180,7 @@ static fileAction decideFileFate(const char * dirName,
        if (!(transFlags & RPMTRANS_FLAG_ALLFILES) &&
           (newFlags & RPMFILE_MISSINGOK)) {
            rpmMessage(RPMMESS_DEBUG, _("%s skipped due to missingok flag\n"),
-                       filespec);
+                       fn);
            return FA_SKIP;
        } else {
            return FA_CREATE;
@@ -211,7 +208,7 @@ static fileAction decideFileFate(const char * dirName,
     }
 
     if (dbWhat == REG) {
-       rc = mdfile(filespec, buffer);
+       rc = mdfile(fn, buffer);
 
        if (rc) {
            /* assume the file has been removed, don't freak */
@@ -221,7 +218,7 @@ static fileAction decideFileFate(const char * dirName,
        newAttr = newMd5;
     } else /* dbWhat == LINK */ {
        memset(buffer, 0, sizeof(buffer));
-       i = readlink(filespec, buffer, sizeof(buffer) - 1);
+       i = readlink(fn, buffer, sizeof(buffer) - 1);
        if (i == -1) {
            /* assume the file has been removed, don't freak */
            return FA_CREATE;
@@ -313,13 +310,18 @@ static int handleInstInstalledFiles(const rpmTransactionSet ts,
     xx = hge(h, RPMTAG_FILEFLAGS, NULL, (void **) &otherFlags, NULL);
     xx = hge(h, RPMTAG_FILESIZES, NULL, (void **) &otherSizes, NULL);
 
-    fi->replaced = xmalloc(sharedCount * sizeof(*fi->replaced));
+    fi->replaced = xcalloc(sharedCount, sizeof(*fi->replaced));
 
     for (i = 0; i < sharedCount; i++, shared++) {
        int otherFileNum, fileNum;
+       const char * fn;
+
        otherFileNum = shared->otherFileNum;
        fileNum = shared->pkgFileNum;
 
+       (void) tfiSetFX(fi, fileNum);
+       fn = tfiGetFN(fi);
+
        /* XXX another tedious segfault, assume file state normal. */
        if (otherStates && otherStates[otherFileNum] != RPMFILE_STATE_NORMAL)
            continue;
@@ -337,7 +339,7 @@ static int handleInstInstalledFiles(const rpmTransactionSet ts,
                const char * altNEVR = hGetNEVR(h, NULL);
                rpmProblemSetAppend(ts->probs, RPMPROB_FILE_CONFLICT,
                        p->NEVR, p->key,
-                       fi->dnl[fi->dil[fileNum]], fi->bnl[fileNum],
+                       tfiGetDN(fi), tfiGetBN(fi),
                        altNEVR,
                        0);
                altNEVR = _free(altNEVR);
@@ -352,9 +354,7 @@ static int handleInstInstalledFiles(const rpmTransactionSet ts,
        }
 
        if ((otherFlags[otherFileNum] | fi->fflags[fileNum]) & RPMFILE_CONFIG) {
-           fi->actions[fileNum] = decideFileFate(
-                       fi->dnl[fi->dil[fileNum]],
-                       fi->bnl[fileNum],
+           fi->actions[fileNum] = decideFileFate(fn,
                        otherModes[otherFileNum],
                        otherMd5s[otherFileNum],
                        otherLinks[otherFileNum],
@@ -431,11 +431,12 @@ static void handleOverlappedFiles(const rpmTransactionSet ts,
 {
     struct diskspaceInfo * ds = NULL;
     uint_32 fixupSize = 0;
-    char * filespec = NULL;
-    int fileSpecAlloced = 0;
+    const char * fn;
     int i, j;
   
-    for (i = 0; i < fi->fc; i++) {
+    fi = tfiInit(fi, 0);
+    if (fi != NULL)
+    while ((i = tfiNext(fi)) >= 0) {
        int otherPkgNum, otherFileNum;
        const TFI_t * recs;
        int numRecs;
@@ -443,15 +444,7 @@ static void handleOverlappedFiles(const rpmTransactionSet ts,
        if (XFA_SKIPPING(fi->actions[i]))
            continue;
 
-       j = strlen(fi->dnl[fi->dil[i]]) + strlen(fi->bnl[i]) + 1;
-       /*@-branchstate@*/
-       if (j > fileSpecAlloced) {
-           fileSpecAlloced = j * 2;
-           filespec = xrealloc(filespec, fileSpecAlloced);
-       }
-       /*@=branchstate@*/
-
-       (void) stpcpy( stpcpy( filespec, fi->dnl[fi->dil[i]]), fi->bnl[i]);
+       fn = tfiGetFN(fi);
 
        if (ts->di) {
            ds = ts->di;
@@ -530,7 +523,7 @@ static void handleOverlappedFiles(const rpmTransactionSet ts,
                if (fi->actions[i] != FA_UNKNOWN)
                    /*@switchbreak@*/ break;
                if ((fi->fflags[i] & RPMFILE_CONFIG) && 
-                       !lstat(filespec, &sb)) {
+                       !lstat(fn, &sb)) {
                    /* Here is a non-overlapped pre-existing config file. */
                    fi->actions[i] = (fi->fflags[i] & RPMFILE_NOREPLACE)
                        ? FA_ALTNAME : FA_BACKUP;
@@ -552,7 +545,7 @@ static void handleOverlappedFiles(const rpmTransactionSet ts,
                const char * altNEVR = recs[otherPkgNum]->te->NEVR;
                rpmProblemSetAppend(ts->probs, RPMPROB_NEW_FILE_CONFLICT,
                        p->NEVR, p->key,
-                       filespec, NULL,
+                       fn, NULL,
                        altNEVR,
                        0);
            }
@@ -560,7 +553,7 @@ static void handleOverlappedFiles(const rpmTransactionSet ts,
            /* Try to get the disk accounting correct even if a conflict. */
            fixupSize = recs[otherPkgNum]->fsizes[otherFileNum];
 
-           if ((fi->fflags[i] & RPMFILE_CONFIG) && !lstat(filespec, &sb)) {
+           if ((fi->fflags[i] & RPMFILE_CONFIG) && !lstat(fn, &sb)) {
                /* Here is an overlapped  pre-existing config file. */
                fi->actions[i] = (fi->fflags[i] & RPMFILE_NOREPLACE)
                        ? FA_ALTNAME : FA_SKIP;
@@ -590,7 +583,7 @@ static void handleOverlappedFiles(const rpmTransactionSet ts,
                
            /* Here is a pre-existing modified config file that needs saving. */
            {   char mdsum[50];
-               if (!mdfile(filespec, mdsum) && strcmp(fi->fmd5s[i], mdsum)) {
+               if (!mdfile(fn, mdsum) && strcmp(fi->fmd5s[i], mdsum)) {
                    fi->actions[i] = FA_BACKUP;
                    /*@switchbreak@*/ break;
                }
@@ -632,7 +625,6 @@ static void handleOverlappedFiles(const rpmTransactionSet ts,
            ds->bneeded -= BLOCK_ROUND(fixupSize, ds->bsize);
        }
     }
-    filespec = _free(filespec);
 }
 
 /**
@@ -860,6 +852,28 @@ static void skipFiles(const rpmTransactionSet ts, TFI_t fi)
     if (languages) freeSplitString((char **)languages);
 }
 
+/**
+ * Return transaction element's file info.
+ * @todo Take a TFI_t refcount here.
+ * @param tei          transaction element iterator
+ * @return             transaction element file info
+ */
+static /*@null@*/
+TFI_t teGetFi(const teIterator tei)
+       /*@modifies tei @*/
+{
+    TFI_t fi = NULL;
+
+    if (tei != NULL && tei->ocsave != -1) {
+       transactionElement te = tei->ts->order + tei->ocsave;
+       if ((fi = te->fi) != NULL)
+           fi->te = te;
+    }
+    /*@-compdef -refcounttrans -usereleased @*/
+    return fi;
+    /*@=compdef =refcounttrans =usereleased @*/
+}
+
 #define        NOTIFY(_ts, _al)        if ((_ts)->notify) (void) (_ts)->notify _al
 
 int rpmRunTransactions(        rpmTransactionSet ts,
@@ -1055,7 +1069,6 @@ int rpmRunTransactions(   rpmTransactionSet ts,
     pi = teInitIterator(ts);
     while ((p = teNextIterator(pi)) != NULL) {
 
-       fi = teGetFi(pi);
        if ((fi = teGetFi(pi)) == NULL)
            continue;   /* XXX can't happen */
 
index 93657dd..508d289 100644 (file)
@@ -6,7 +6,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2001-11-13 13:56-0500\n"
+"POT-Creation-Date: 2001-11-13 19:04-0500\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -2363,11 +2363,11 @@ msgstr ""
 msgid "package %s is not installed\n"
 msgstr ""
 
-#: lib/rpmal.c:647
+#: lib/rpmal.c:673
 msgid "(added files)"
 msgstr ""
 
-#: lib/rpmal.c:744
+#: lib/rpmal.c:770
 msgid "(added provide)"
 msgstr ""
 
@@ -2777,18 +2777,18 @@ msgstr ""
 msgid "Signature: UNKNOWN (%d)\n"
 msgstr ""
 
-#: lib/transaction.c:185
+#: lib/transaction.c:182
 #, c-format
 msgid "%s skipped due to missingok flag\n"
 msgstr ""
 
 #. @innercontinue@
-#: lib/transaction.c:850
+#: lib/transaction.c:842
 #, c-format
 msgid "excluding directory %s\n"
 msgstr ""
 
-#: lib/transaction.c:918
+#: lib/transaction.c:932
 msgid "getting list of mounted filesystems\n"
 msgstr ""