diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2008-05-12 17:08:12 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2008-05-12 17:08:12 +0300 |
commit | fe3ba9991019dcf5de7f92577cfd04872fe7584d (patch) | |
tree | e7b500b62665115364521eee0c1a3bc56528a82f /lib | |
parent | ecd8c6c44149b880e672accc416d593c551de72e (diff) | |
download | rpm-fe3ba9991019dcf5de7f92577cfd04872fe7584d.tar.gz rpm-fe3ba9991019dcf5de7f92577cfd04872fe7584d.tar.bz2 rpm-fe3ba9991019dcf5de7f92577cfd04872fe7584d.zip |
Simplify header extension handling
- remove the now unnecessary chaining to different extension tables
Diffstat (limited to 'lib')
-rw-r--r-- | lib/formats.c | 20 | ||||
-rw-r--r-- | lib/header.h | 8 | ||||
-rw-r--r-- | lib/headerfmt.c | 16 | ||||
-rw-r--r-- | lib/query.c | 4 |
4 files changed, 11 insertions, 37 deletions
diff --git a/lib/formats.c b/lib/formats.c index e32d3fb58..66493a302 100644 --- a/lib/formats.c +++ b/lib/formats.c @@ -1076,17 +1076,6 @@ static int groupTag(Header h, rpmTagType* type, return i18nTag(h, RPMTAG_GROUP, type, data, count, freeData); } -/* FIX: cast? */ -const struct headerSprintfExtension_s headerDefaultFormats[] = { - { HEADER_EXT_FORMAT, "octal", { octalFormat } }, - { HEADER_EXT_FORMAT, "hex", { hexFormat } }, - { HEADER_EXT_FORMAT, "date", { dateFormat } }, - { HEADER_EXT_FORMAT, "day", { dayFormat } }, - { HEADER_EXT_FORMAT, "shescape", { shescapeFormat } }, - { HEADER_EXT_LAST, NULL, { NULL } } -}; - -/* FIX: cast? */ const struct headerSprintfExtension_s rpmHeaderFormats[] = { { HEADER_EXT_TAG, "RPMTAG_GROUP", { groupTag } }, { HEADER_EXT_TAG, "RPMTAG_DESCRIPTION", { descriptionTag } }, @@ -1109,5 +1098,10 @@ const struct headerSprintfExtension_s rpmHeaderFormats[] = { { HEADER_EXT_FORMAT, "permissions", { permsFormat } }, { HEADER_EXT_FORMAT, "triggertype", { triggertypeFormat } }, { HEADER_EXT_FORMAT, "xml", { xmlFormat } }, - { HEADER_EXT_MORE, NULL, { (void *) headerDefaultFormats } } -} ; + { HEADER_EXT_FORMAT, "octal", { octalFormat } }, + { HEADER_EXT_FORMAT, "hex", { hexFormat } }, + { HEADER_EXT_FORMAT, "date", { dateFormat } }, + { HEADER_EXT_FORMAT, "day", { dayFormat } }, + { HEADER_EXT_FORMAT, "shescape", { shescapeFormat } }, + { HEADER_EXT_LAST, NULL, { NULL } } +}; diff --git a/lib/header.h b/lib/header.h index d9aa6d30c..8ade39fc2 100644 --- a/lib/header.h +++ b/lib/header.h @@ -40,7 +40,6 @@ typedef struct headerTagIndices_s * headerTagIndices; enum headerSprintfExtensionType { HEADER_EXT_LAST = 0, /*!< End of extension chain. */ HEADER_EXT_FORMAT, /*!< headerTagFormatFunction() extension */ - HEADER_EXT_MORE, /*!< Chain to next table. */ HEADER_EXT_TAG /*!< headerTagTagFunction() extension */ }; @@ -88,15 +87,9 @@ struct headerSprintfExtension_s { void * generic; /*!< Private extension. */ headerTagFormatFunction formatFunction; /*!< HEADER_EXT_TAG extension. */ headerTagTagFunction tagFunction; /*!< HEADER_EXT_FORMAT extension. */ - struct headerSprintfExtension_s * more; /*!< Chained table extension. */ } u; }; -/** \ingroup header - * Supported default header tag output formats. - */ -extern const struct headerSprintfExtension_s headerDefaultFormats[]; - /** \ingroup rpmtag * Automatically generated table of tag name/value pairs. */ @@ -113,7 +106,6 @@ extern headerTagIndices const rpmTags; /** \ingroup header * Table of query format extensions. - * @note Chains to headerDefaultFormats[]. */ extern const struct headerSprintfExtension_s rpmHeaderFormats[]; diff --git a/lib/headerfmt.c b/lib/headerfmt.c index 2bf208e5c..bb5acd21a 100644 --- a/lib/headerfmt.c +++ b/lib/headerfmt.c @@ -297,9 +297,7 @@ static int findTag(headerSprintfArgs hsa, sprintfToken token, const char * name) } /* Search extensions for specific tag override. */ - for (ext = hsa->exts; ext != NULL && ext->type != HEADER_EXT_LAST; - ext = (ext->type == HEADER_EXT_MORE ? ext->u.more : ext+1)) - { + for (ext = hsa->exts; ext != NULL && ext->type != HEADER_EXT_LAST; ext++) { if (ext->name == NULL || ext->type != HEADER_EXT_TAG) continue; if (!rstrcasecmp(ext->name + sizeof("RPMTAG"), tagname)) { @@ -319,9 +317,7 @@ static int findTag(headerSprintfArgs hsa, sprintfToken token, const char * name) bingo: /* Search extensions for specific format. */ if (stag->type != NULL) - for (ext = hsa->exts; ext != NULL && ext->type != HEADER_EXT_LAST; - ext = (ext->type == HEADER_EXT_MORE ? ext->u.more : ext+1)) - { + for (ext = hsa->exts; ext != NULL && ext->type != HEADER_EXT_LAST; ext++) { if (ext->name == NULL || ext->type != HEADER_EXT_FORMAT) continue; if (!strcmp(ext->name, stag->type)) { @@ -1025,9 +1021,7 @@ rpmecNew(const headerSprintfExtension exts) rpmec ec; int i = 0; - for (ext = exts; ext != NULL && ext->type != HEADER_EXT_LAST; - ext = (ext->type == HEADER_EXT_MORE ? ext->u.more : ext+1)) - { + for (ext = exts; ext != NULL && ext->type != HEADER_EXT_LAST; ext++) { i++; } @@ -1047,9 +1041,7 @@ rpmecFree(const headerSprintfExtension exts, rpmec ec) headerSprintfExtension ext; int i = 0; - for (ext = exts; ext != NULL && ext->type != HEADER_EXT_LAST; - ext = (ext->type == HEADER_EXT_MORE ? ext->u.more : ext+1)) - { + for (ext = exts; ext != NULL && ext->type != HEADER_EXT_LAST; ext++) { if (ec[i].freeit) ec[i].data = _free(ec[i].data); i++; } diff --git a/lib/query.c b/lib/query.c index 47bd596a0..15b4043d4 100644 --- a/lib/query.c +++ b/lib/query.c @@ -277,10 +277,6 @@ void rpmDisplayQueryTags(FILE * fp) } while (ext->name != NULL) { - if (ext->type == HEADER_EXT_MORE) { - ext = ext->u.more; - continue; - } /* XXX don't print query tags twice. */ for (i = 0, t = rpmTagTable; i < rpmTagTableSize; i++, t++) { if (t->name == NULL) /* XXX programmer error. */ |