Start deconstructing TFI_t in favor of a per-transactionElement rpmFNSet.

CVS patchset: 5164
CVS date: 2001/11/09 19:22:29
This commit is contained in:
jbj 2001-11-09 19:22:29 +00:00
parent ac15c68ca5
commit 978a87ed82
4 changed files with 114 additions and 66 deletions

View File

@ -199,7 +199,7 @@ int alGetFilesCount(const availableList al, alKey pkgKey)
int_32 filesCount = 0; int_32 filesCount = 0;
if (alp != NULL) if (alp != NULL)
if (alp->fns != NULL) if (alp->fns != NULL)
filesCount = alp->fns->Count; filesCount = alp->fns->fc;
return filesCount; return filesCount;
} }
#endif #endif
@ -369,7 +369,7 @@ fprintf(stderr, "*** del %p[%d] %s-%s-%s\n", al->list, pkgNum, alp->name, alp->v
/* Delete directory/file info entries from added package list. */ /* Delete directory/file info entries from added package list. */
if ((fns = alp->fns) != NULL) if ((fns = alp->fns) != NULL)
if (fns->BN != NULL && fns->Count > 0) { if (fns->bnl != NULL && fns->fc > 0) {
int origNumDirs = al->numDirs; int origNumDirs = al->numDirs;
int dirNum; int dirNum;
dirInfo dieNeedle = dirInfo dieNeedle =
@ -381,12 +381,12 @@ fprintf(stderr, "*** del %p[%d] %s-%s-%s\n", al->list, pkgNum, alp->name, alp->v
/* XXX FIXME: We ought to relocate the directory list here */ /* XXX FIXME: We ought to relocate the directory list here */
if (al->dirs != NULL) if (al->dirs != NULL)
if (fns->DN != NULL) if (fns->dnl != NULL)
for (dirNum = fns->DCount - 1; dirNum >= 0; dirNum--) { for (dirNum = fns->dc - 1; dirNum >= 0; dirNum--) {
fileIndexEntry fie; fileIndexEntry fie;
/*@-assignexpose@*/ /*@-assignexpose@*/
dieNeedle->dirName = (char *) fns->DN[dirNum]; dieNeedle->dirName = (char *) fns->dnl[dirNum];
/*@=assignexpose@*/ /*@=assignexpose@*/
dieNeedle->dirNameLen = strlen(dieNeedle->dirName); dieNeedle->dirNameLen = strlen(dieNeedle->dirName);
die = bsearch(dieNeedle, al->dirs, al->numDirs, die = bsearch(dieNeedle, al->dirs, al->numDirs,
@ -510,7 +510,7 @@ fprintf(stderr, "*** add %p[%d] %s-%s-%s\n", al->list, pkgNum, alp->name, alp->v
alp->fns = fns = fnsNew(h, RPMTAG_BASENAMES, scareMem); alp->fns = fns = fnsNew(h, RPMTAG_BASENAMES, scareMem);
if (fns && fns->Count > 0) { if (fns && fns->fc > 0) {
int * dirMapping; int * dirMapping;
dirInfo dieNeedle = dirInfo dieNeedle =
memset(alloca(sizeof(*dieNeedle)), 0, sizeof(*dieNeedle)); memset(alloca(sizeof(*dieNeedle)), 0, sizeof(*dieNeedle));
@ -520,20 +520,20 @@ fprintf(stderr, "*** add %p[%d] %s-%s-%s\n", al->list, pkgNum, alp->name, alp->v
/* XXX FIXME: We ought to relocate the directory list here */ /* XXX FIXME: We ought to relocate the directory list here */
dirMapping = alloca(sizeof(*dirMapping) * fns->DCount); dirMapping = alloca(sizeof(*dirMapping) * fns->dc);
/* allocated enough space for all the directories we could possible /* allocated enough space for all the directories we could possible
need to add */ need to add */
al->dirs = xrealloc(al->dirs, al->dirs = xrealloc(al->dirs,
(al->numDirs + fns->DCount) * sizeof(*al->dirs)); (al->numDirs + fns->dc) * sizeof(*al->dirs));
origNumDirs = al->numDirs; origNumDirs = al->numDirs;
if (fns->DN != NULL) if (fns->dnl != NULL)
for (dirNum = 0; dirNum < fns->DCount; dirNum++) { for (dirNum = 0; dirNum < fns->dc; dirNum++) {
/*@-assignexpose@*/ /*@-assignexpose@*/
dieNeedle->dirName = (char *) fns->DN[dirNum]; dieNeedle->dirName = (char *) fns->dnl[dirNum];
/*@=assignexpose@*/ /*@=assignexpose@*/
dieNeedle->dirNameLen = strlen(fns->DN[dirNum]); dieNeedle->dirNameLen = strlen(fns->dnl[dirNum]);
die = bsearch(dieNeedle, al->dirs, origNumDirs, die = bsearch(dieNeedle, al->dirs, origNumDirs,
sizeof(*dieNeedle), dieCompare); sizeof(*dieNeedle), dieCompare);
if (die) { if (die) {
@ -541,7 +541,7 @@ fprintf(stderr, "*** add %p[%d] %s-%s-%s\n", al->list, pkgNum, alp->name, alp->v
} else { } else {
dirMapping[dirNum] = al->numDirs; dirMapping[dirNum] = al->numDirs;
die = al->dirs + al->numDirs; die = al->dirs + al->numDirs;
die->dirName = xstrdup(fns->DN[dirNum]); die->dirName = xstrdup(fns->dnl[dirNum]);
die->dirNameLen = strlen(die->dirName); die->dirNameLen = strlen(die->dirName);
die->files = NULL; die->files = NULL;
die->numFiles = 0; die->numFiles = 0;
@ -550,34 +550,34 @@ fprintf(stderr, "*** add %p[%d] %s-%s-%s\n", al->list, pkgNum, alp->name, alp->v
} }
last = 0; last = 0;
for (first = 0; first < fns->Count; first = last + 1) { for (first = 0; first < fns->fc; first = last + 1) {
fileIndexEntry fie; fileIndexEntry fie;
if (fns->DI == NULL) /* XXX can't happen */ if (fns->dil == NULL) /* XXX can't happen */
continue; continue;
for (last = first; (last + 1) < fns->Count; last++) { for (last = first; (last + 1) < fns->fc; last++) {
if (fns->DI[first] != fns->DI[last + 1]) if (fns->dil[first] != fns->dil[last + 1])
/*@innerbreak@*/ break; /*@innerbreak@*/ break;
} }
die = al->dirs + dirMapping[fns->DI[first]]; die = al->dirs + dirMapping[fns->dil[first]];
die->files = xrealloc(die->files, die->files = xrealloc(die->files,
(die->numFiles + last - first + 1) * (die->numFiles + last - first + 1) *
sizeof(*die->files)); sizeof(*die->files));
fie = die->files + die->numFiles; fie = die->files + die->numFiles;
for (fns->i = first; fns->i <= last; fns->i++) { for (fns->i = first; fns->i <= last; fns->i++) {
if (fns->BN == NULL) /* XXX can't happen */ if (fns->bnl == NULL) /* XXX can't happen */
/*@innercontinue@*/ continue; /*@innercontinue@*/ continue;
if (fns->Flags == NULL) /* XXX can't happen */ if (fns->fflags == NULL) /* XXX can't happen */
/*@innercontinue@*/ continue; /*@innercontinue@*/ continue;
/*@-assignexpose@*/ /*@-assignexpose@*/
fie->baseName = fns->BN[fns->i]; fie->baseName = fns->bnl[fns->i];
fie->baseNameLen = strlen(fns->BN[fns->i]); fie->baseNameLen = strlen(fns->bnl[fns->i]);
/*@=assignexpose@*/ /*@=assignexpose@*/
fie->pkgNum = pkgNum; fie->pkgNum = pkgNum;
fie->fileFlags = fns->Flags[fns->i]; fie->fileFlags = fns->fflags[fns->i];
die->numFiles++; die->numFiles++;
fie++; fie++;
} }

View File

@ -44,20 +44,32 @@ rpmFNSet fnsFree(rpmFNSet fns)
/*@-modfilesystem@*/ /*@-modfilesystem@*/
if (_fns_debug) if (_fns_debug)
fprintf(stderr, "*** fns %p -- %s[%d]\n", fns, fns->Type, fns->Count); fprintf(stderr, "*** fns %p -- %s[%d]\n", fns, fns->Type, fns->fc);
/*@=modfilesystem@*/ /*@=modfilesystem@*/
/*@-branchstate@*/ /*@-branchstate@*/
if (fns->Count > 0) { if (fns->fc > 0) {
fns->DN = hfd(fns->DN, fns->DNt); fns->bnl = hfd(fns->bnl, -1);
fns->BN = hfd(fns->BN, fns->BNt); fns->dnl = hfd(fns->dnl, -1);
fns->flinks = hfd(fns->flinks, -1);
fns->flangs = hfd(fns->flangs, -1);
fns->fmd5s = hfd(fns->fmd5s, -1);
fns->fstates = _free(fns->fstates);
/*@-evalorder@*/ /*@-evalorder@*/
fns->DI = if (fns->h != NULL) {
(fns->h != NULL ? hfd(fns->DI, fns->DIt) : _free(fns->DI));
fns->Flags =
(fns->h != NULL ? hfd(fns->Flags, fns->Ft) : _free(fns->Flags));
/*@=evalorder@*/
fns->h = headerFree(fns->h, "fnsFree"); fns->h = headerFree(fns->h, "fnsFree");
} else {
fns->fmtimes = _free(fns->fmtimes);
fns->fmodes = _free(fns->fmodes);
fns->fflags = _free(fns->fflags);
fns->fsizes = _free(fns->fsizes);
fns->frdevs = _free(fns->frdevs);
fns->dil = _free(fns->dil);
}
/*@=evalorder@*/
} }
/*@=branchstate@*/ /*@=branchstate@*/
@ -66,6 +78,11 @@ fprintf(stderr, "*** fns %p -- %s[%d]\n", fns, fns->Type, fns->Count);
return NULL; return NULL;
} }
#define _fdupe(_fns, _data) \
if ((_fns)->_data != NULL) \
(_fns)->_data = memcpy(xmalloc((_fns)->fc * sizeof(*(_fns)->_data)), \
(_fns)->_data, (_fns)->fc * sizeof(*(_fns)->_data))
rpmFNSet fnsNew(Header h, rpmTag tagN, int scareMem) rpmFNSet fnsNew(Header h, rpmTag tagN, int scareMem)
{ {
HGE_t hge = HGE_t hge =
@ -75,52 +92,64 @@ rpmFNSet fnsNew(Header h, rpmTag tagN, int scareMem)
const char ** N; const char ** N;
rpmTagType Nt; rpmTagType Nt;
int_32 Count; int_32 Count;
rpmTag tagBN, tagDI, tagF, tagDN;
if (tagN == RPMTAG_BASENAMES) { if (tagN == RPMTAG_BASENAMES) {
Type = "Files"; Type = "Files";
tagBN = tagN;
tagDI = RPMTAG_DIRINDEXES;
tagF = RPMTAG_FILEFLAGS;
tagDN = RPMTAG_DIRNAMES;
} else } else
goto exit; goto exit;
/*@-branchstate@*/ /*@-branchstate@*/
if (hge(h, tagBN, &Nt, (void **) &N, &Count) if (hge(h, tagN, &Nt, (void **) &N, &Count)
&& N != NULL && Count > 0) && N != NULL && Count > 0)
{ {
int xx; int xx;
fns = xcalloc(1, sizeof(*fns)); fns = xcalloc(1, sizeof(*fns));
fns->h = (scareMem ? headerLink(h, "fnsNew") : NULL); fns->h = headerLink(h, "fnsNew");
fns->i = -1; fns->i = -1;
fns->Type = Type; fns->Type = Type;
fns->tagN = tagN; fns->tagN = tagN;
fns->BN = N; fns->bnl = N;
fns->BNt = Nt; fns->fc = Count;
fns->Count = Count;
xx = hge(h, tagDN, &fns->DNt, (void **) &fns->DN, &fns->DCount); xx = hge(h, RPMTAG_DIRNAMES, NULL, (void **) &fns->dnl, &fns->dc);
xx = hge(h, tagDI, &fns->DIt, (void **) &fns->DI, NULL);
if (!scareMem && fns->DI != NULL) xx = hge(h, RPMTAG_FILELINKTOS, NULL, (void **) &fns->flinks, NULL);
fns->DI = memcpy(xmalloc(fns->Count * sizeof(*fns->DI)), xx = hge(h, RPMTAG_FILELANGS, NULL, (void **) &fns->flangs, NULL);
fns->DI, fns->Count * sizeof(*fns->DI)); xx = hge(h, RPMTAG_FILEMD5S, NULL, (void **) &fns->fmd5s, NULL);
xx = hge(h, tagF, &fns->Ft, (void **) &fns->Flags, NULL);
if (!scareMem && fns->Flags != NULL) xx = hge(h, RPMTAG_FILEMTIMES, NULL, (void **) &fns->fmtimes, NULL);
fns->Flags = memcpy(xmalloc(fns->Count * sizeof(*fns->Flags)), xx = hge(h, RPMTAG_FILEMODES, NULL, (void **) &fns->fmodes, NULL);
fns->Flags, fns->Count * sizeof(*fns->Flags)); xx = hge(h, RPMTAG_FILEFLAGS, NULL, (void **) &fns->fflags, NULL);
xx = hge(h, RPMTAG_FILESIZES, NULL, (void **) &fns->fsizes, NULL);
xx = hge(h, RPMTAG_FILERDEVS, NULL, (void **) &fns->frdevs, NULL);
xx = hge(h, RPMTAG_DIRINDEXES, NULL, (void **) &fns->dil, NULL);
xx = hge(h, RPMTAG_FILESTATES, NULL, (void **) &fns->fstates, NULL);
_fdupe(fns, fstates);
if (xx == 0 || fns->fstates == NULL)
fns->fstates = xcalloc(fns->fc, sizeof(*fns->fstates));
if (!scareMem) {
_fdupe(fns, fmtimes);
_fdupe(fns, fmodes);
_fdupe(fns, fflags);
_fdupe(fns, fsizes);
_fdupe(fns, frdevs);
_fdupe(fns, dil);
fns->h = headerFree(fns->h, "fnsNew");
}
/*@-modfilesystem@*/ /*@-modfilesystem@*/
if (_fns_debug) if (_fns_debug)
fprintf(stderr, "*** fns %p ++ %s[%d]\n", fns, fns->Type, fns->Count); fprintf(stderr, "*** fns %p ++ %s[%d]\n", fns, fns->Type, fns->fc);
/*@=modfilesystem@*/ /*@=modfilesystem@*/
} }
/*@-branchstate@*/ /*@-branchstate@*/
exit: exit:
/*@-nullret@*/ /* FIX: fns->{DI,Flags} may be NULL. */ /*@-nullret@*/ /* FIX: fns->{dil,fflags} may be NULL. */
/*@i@*/ return fns; /*@i@*/ return fns;
/*@=nullret@*/ /*@=nullret@*/
} }

View File

@ -24,16 +24,35 @@ struct rpmFNSet_s {
Header h; /*!< Header for file name set (or NULL) */ Header h; /*!< Header for file name set (or NULL) */
/*@only@*/ /*@only@*/
const char ** BN; /*!< File base name(s). */ const char ** bnl; /*!< Base name(s) (from header) */
/*@only@*/ /*@only@*/
const int_32 * DI; /*!< File directory index. */ const char ** dnl; /*!< Directory name(s) (from header) */
/*@only@*/ /*@only@*/
const uint_32 * Flags; /*!< File flags. */ const char ** fmd5s; /*!< File MD5 sum(s) (from header) */
/*@only@*/ /*@only@*/
const char ** DN; /*!< Directory name(s). */ const char ** flinks; /*!< File link(s) (from header) */
int_32 DCount; /*!< No. of directories. */ /*@only@*/
rpmTagType BNt, DIt, Ft, DNt; /*!< Tag data types. */ const char ** flangs; /*!< File lang(s) */
int_32 Count; /*!< No. of files. */
/*@only@*/
const uint_32 * dil; /*!< Directory indice(s) (from header) */
/*@only@*/
const uint_32 * fflags; /*!< File flag(s) (from header) */
/*@only@*/
const uint_32 * fsizes; /*!< File size(s) (from header) */
/*@only@*/
const uint_32 * fmtimes; /*!< File modification time(s) (from header) */
/*@only@*/
const uint_16 * fmodes; /*!< File mode(s) (from header) */
/*@only@*/
const uint_16 * frdevs; /*!< File rdev(s) (from header) */
/*@only@*/
char * fstates; /*!< File state(s) (from header) */
int_32 dc; /*!< No. of directories. */
int_32 fc; /*!< No. of files. */
}; };
/** /**

View File

@ -6,7 +6,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2001-11-09 12:21-0500\n" "POT-Creation-Date: 2001-11-09 14:05-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -1459,11 +1459,11 @@ msgstr ""
msgid "%9s: (%s, %s) added to Depends cache.\n" msgid "%9s: (%s, %s) added to Depends cache.\n"
msgstr "" msgstr ""
#: lib/depends.c:758 lib/rpmds.c:375 lib/rpmds.c:530 #: lib/depends.c:758 lib/rpmds.c:404 lib/rpmds.c:559
msgid "NO " msgid "NO "
msgstr "" msgstr ""
#: lib/depends.c:758 lib/rpmds.c:375 lib/rpmds.c:530 #: lib/depends.c:758 lib/rpmds.c:404 lib/rpmds.c:559
msgid "YES" msgid "YES"
msgstr "" msgstr ""
@ -2483,20 +2483,20 @@ msgid "OK"
msgstr "" msgstr ""
#. XXX legacy epoch-less requires/conflicts compatibility #. XXX legacy epoch-less requires/conflicts compatibility
#: lib/rpmds.c:500 #: lib/rpmds.c:529
#, c-format #, c-format
msgid "" msgid ""
"the \"B\" dependency needs an epoch (assuming same as \"A\")\n" "the \"B\" dependency needs an epoch (assuming same as \"A\")\n"
"\tA %s\tB %s\n" "\tA %s\tB %s\n"
msgstr "" msgstr ""
#: lib/rpmds.c:529 #: lib/rpmds.c:558
#, c-format #, c-format
msgid " %s A %s\tB %s\n" msgid " %s A %s\tB %s\n"
msgstr "" msgstr ""
#. @=branchstate@ #. @=branchstate@
#: lib/rpmds.c:554 #: lib/rpmds.c:583
#, c-format #, c-format
msgid "package %s has unsatisfied %s: %s\n" msgid "package %s has unsatisfied %s: %s\n"
msgstr "" msgstr ""