RPM Package Manager, CVS Repository
http://rpm5.org/cvs/
____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson
Root: /v/rpm/cvs Email: jbj@rpm5.org
Module: rpm Date: 18-Oct-2007 17:03:41
Branch: HEAD Handle: 2007101816034000
Modified files:
rpm CHANGES
rpm/rpmdb hdrfmt.c header.c header.h
Log:
- eliminate type arg in (*headerTagFormatFunction), use he->t instead.
Summary:
Revision Changes Path
1.1727 +1 -0 rpm/CHANGES
1.17 +28 -31 rpm/rpmdb/hdrfmt.c
1.88 +35 -33 rpm/rpmdb/header.c
1.43 +1 -2 rpm/rpmdb/header.h
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: rpm/CHANGES
============================================================================
$ cvs diff -u -r1.1726 -r1.1727 CHANGES
--- rpm/CHANGES 18 Oct 2007 14:08:48 -0000 1.1726
+++ rpm/CHANGES 18 Oct 2007 15:03:40 -0000 1.1727
@@ -1,4 +1,5 @@
4.5 -> 5.0:
+ - jbj: eliminate type arg in (*headerTagFormatFunction), use he->t instead.
- jbj: drill HE_t through (*headerTagFormatFunction).
- jbj: debugedit segfault (#336951,#337011) see #337051 too.
- jbj: commit to hge(h, he, ...) extraction in API. ABI not yet.
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmdb/hdrfmt.c
============================================================================
$ cvs diff -u -r1.16 -r1.17 hdrfmt.c
--- rpm/rpmdb/hdrfmt.c 18 Oct 2007 14:08:48 -0000 1.16
+++ rpm/rpmdb/hdrfmt.c 18 Oct 2007 15:03:40 -0000 1.17
@@ -71,14 +71,13 @@
/**
* Identify type of trigger.
* @param he tag container
- * @param type tag type
* @param data tag value
* @param formatPrefix (unused)
* @param padding (unused)
* @param element (unused)
* @return formatted string
*/
-static /*@only@*/ char * triggertypeFormat(HE_t he, rpmTagType type, hPTR_t data,
+static /*@only@*/ char * triggertypeFormat(HE_t he, hPTR_t data,
/*@unused@*/ char * formatPrefix, /*@unused@*/ int padding,
/*@unused@*/ int element)
/*@requires maxRead(data) >= 0 @*/
@@ -86,7 +85,7 @@
const int_32 * item = (*data).i32p;
char * val;
- if (type != RPM_INT32_TYPE)
+ if (he->t != RPM_INT32_TYPE)
val = xstrdup(_("(invalid type)"));
else if (*item & RPMSENSE_TRIGGERPREIN)
val = xstrdup("prein");
@@ -104,14 +103,13 @@
/**
* Format file permissions for display.
* @param he tag container
- * @param type tag type
* @param data tag value
* @param formatPrefix
* @param padding
* @param element (unused)
* @return formatted string
*/
-static /*@only@*/ char * permsFormat(HE_t he, rpmTagType type, hPTR_t data,
+static /*@only@*/ char * permsFormat(HE_t he, hPTR_t data,
char * formatPrefix, int padding, /*@unused@*/ int element)
/*@modifies formatPrefix @*/
/*@requires maxRead(data) >= 0 @*/
@@ -119,12 +117,12 @@
char * val;
char * buf;
- if (type != RPM_INT32_TYPE) {
+ if (he->t != RPM_INT32_TYPE) {
val = xstrdup(_("(invalid type)"));
} else {
val = xmalloc(15 + padding);
strcat(formatPrefix, "s");
- buf = rpmPermsString(*((int_32 *) data));
+ buf = rpmPermsString((*data).i32p[0]);
/*@-formatconst@*/
sprintf(val, formatPrefix, buf);
/*@=formatconst@*/
@@ -137,14 +135,13 @@
/**
* Format file flags for display.
* @param he tag container
- * @param type tag type
* @param data tag value
* @param formatPrefix
* @param padding
* @param element (unused)
* @return formatted string
*/
-static /*@only@*/ char * fflagsFormat(HE_t he, rpmTagType type, hPTR_t data,
+static /*@only@*/ char * fflagsFormat(HE_t he, hPTR_t data,
char * formatPrefix, int padding, /*@unused@*/ int element)
/*@modifies formatPrefix @*/
/*@requires maxRead(data) >= 0 @*/
@@ -153,7 +150,7 @@
char buf[15];
int anint = *((int_32 *) data);
- if (type != RPM_INT32_TYPE) {
+ if (he->t != RPM_INT32_TYPE) {
val = xstrdup(_("(invalid type)"));
} else {
buf[0] = '\0';
@@ -188,14 +185,13 @@
* Wrap a pubkey in ascii armor for display.
* @todo Permit selectable display formats (i.e. binary).
* @param he tag container
- * @param type tag type
* @param data tag value
* @param formatPrefix (unused)
* @param padding (unused)
* @param element no. bytes of binary data
* @return formatted string
*/
-static /*@only@*/ char * armorFormat(HE_t he, rpmTagType type, hPTR_t data,
+static /*@only@*/ char * armorFormat(HE_t he, hPTR_t data,
/*@unused@*/ char * formatPrefix, /*@unused@*/ int padding,
int element)
/*@*/
@@ -206,7 +202,7 @@
int atype;
char * val;
- switch (type) {
+ switch (he->t) {
case RPM_OPENPGP_TYPE:
case RPM_ASN1_TYPE: /* XXX WRONG */
case RPM_BIN_TYPE:
@@ -249,20 +245,19 @@
* Encode binary data in base64 for display.
* @todo Permit selectable display formats (i.e. binary).
* @param he tag container
- * @param type tag type
* @param data tag value
* @param formatPrefix (unused)
* @param padding
* @param element
* @return formatted string
*/
-static /*@only@*/ char * base64Format(HE_t he, rpmTagType type, hPTR_t data,
+static /*@only@*/ char * base64Format(HE_t he, hPTR_t data,
/*@unused@*/ char * formatPrefix, int padding, int element)
/*@*/
{
char * val;
- if (!(type == RPM_BIN_TYPE || type == RPM_ASN1_TYPE || type == RPM_OPENPGP_TYPE)) {
+ if (!(he->t == RPM_BIN_TYPE || he->t == RPM_ASN1_TYPE || he->t == RPM_OPENPGP_TYPE)) {
val = xstrdup(_("(not a blob)"));
} else {
const char * enc;
@@ -353,14 +348,13 @@
/**
* Wrap tag data in simple header xml markup.
* @param he tag container
- * @param type tag type
* @param data tag value
* @param formatPrefix
* @param padding
* @param element (unused)
* @return formatted string
*/
-static /*@only@*/ char * xmlFormat(HE_t he, rpmTagType type, hPTR_t data,
+static /*@only@*/ char * xmlFormat(HE_t he, hPTR_t data,
char * formatPrefix, int padding,
/*@unused@*/ int element)
/*@modifies formatPrefix @*/
@@ -374,7 +368,7 @@
int freeit = 0;
int xx;
- switch (type) {
+ switch (he->t) {
case RPM_I18NSTRING_TYPE:
case RPM_STRING_TYPE:
s = (*data).str;
@@ -391,7 +385,7 @@
{ int cpl = b64encode_chars_per_line;
b64encode_chars_per_line = 0;
/*@-formatconst@*/
- s = base64Format(he, type, data, formatPrefix, padding, element);
+ s = base64Format(he, data, formatPrefix, padding, element);
/*@=formatconst@*/
b64encode_chars_per_line = cpl;
xtag = "base64";
@@ -517,14 +511,13 @@
/**
* Wrap tag data in simple header yaml markup.
* @param he tag container
- * @param type tag type
* @param data tag value
* @param formatPrefix
* @param padding
* @param element element index (or -1 for non-array).
* @return formatted string
*/
-static /*@only@*/ char * yamlFormat(HE_t he, rpmTagType type, hPTR_t data,
+static /*@only@*/ char * yamlFormat(HE_t he, hPTR_t data,
char * formatPrefix, int padding,
int element)
/*@modifies formatPrefix @*/
@@ -541,7 +534,7 @@
int xx;
int c;
- switch (type) {
+ switch (he->t) {
case RPM_I18NSTRING_TYPE:
case RPM_STRING_TYPE:
xx = 0;
@@ -589,7 +582,7 @@
{ int cpl = b64encode_chars_per_line;
b64encode_chars_per_line = 0;
/*@-formatconst@*/
- s = base64Format(he, type, data, formatPrefix, padding, element);
+ s = base64Format(he, data, formatPrefix, padding, element);
element = -element; /* XXX skip " " indent. */
/*@=formatconst@*/
b64encode_chars_per_line = cpl;
@@ -674,14 +667,13 @@
/**
* Display signature fingerprint and time.
* @param he tag container
- * @param type tag type
* @param data tag value
* @param formatPrefix (unused)
* @param padding
* @param element (unused)
* @return formatted string
*/
-static /*@only@*/ char * pgpsigFormat(HE_t he, rpmTagType type, hPTR_t data,
+static /*@only@*/ char * pgpsigFormat(HE_t he, hPTR_t data,
/*@unused@*/ char * formatPrefix, /*@unused@*/ int padding,
/*@unused@*/ int element)
/*@globals fileSystem, internalState @*/
@@ -689,7 +681,7 @@
{
char * val, * t;
- if (!(type == RPM_BIN_TYPE || type == RPM_ASN1_TYPE || type == RPM_OPENPGP_TYPE)) {
+ if (!(he->t == RPM_BIN_TYPE || he->t == RPM_ASN1_TYPE || he->t == RPM_OPENPGP_TYPE)) {
val = xstrdup(_("(not a blob)"));
} else {
unsigned char * pkt = (byte *) data;
@@ -784,21 +776,20 @@
/**
* Format dependency flags for display.
* @param he tag container
- * @param type tag type
* @param data tag value
* @param formatPrefix
* @param padding
* @param element (unused)
* @return formatted string
*/
-static /*@only@*/ char * depflagsFormat(HE_t he, rpmTagType type, hPTR_t data,
+static /*@only@*/ char * depflagsFormat(HE_t he, hPTR_t data,
char * formatPrefix, int padding, /*@unused@*/ int element)
/*@modifies formatPrefix @*/
/*@requires maxRead(data) >= 0 @*/
{
char * val;
- if (type != RPM_INT32_TYPE) {
+ if (he->t != RPM_INT32_TYPE) {
val = xstrdup(_("(invalid type)"));
} else {
int anint = *((int_32 *) data);
@@ -915,8 +906,14 @@
item = xmalloc(strlen(names.argv[j]) + strlen(versions.argv[j]) + 20);
if (flags.i32p[j] & RPMSENSE_SENSEMASK) {
+ HE_s _he_s = { .tag = 0, .t = 0, .p = NULL, .c = 0, .freeData = 0 };
+ HE_t _he = &_he_s;
buf[0] = '%', buf[1] = '\0';
- flagsStr = depflagsFormat(he, RPM_INT32_TYPE, &flags, buf, 0, j);
+ _he->tag = he->tag;
+ _he->t = RPM_INT32_TYPE;
+ _he->p = &flags;
+ _he->c = 1;
+ flagsStr = depflagsFormat(_he, he->p, buf, 0, j);
sprintf(item, "%s %s %s", names.argv[j], flagsStr, versions.argv[j]);
flagsStr = _free(flagsStr);
} else
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmdb/header.c
============================================================================
$ cvs diff -u -r1.87 -r1.88 header.c
--- rpm/rpmdb/header.c 18 Oct 2007 14:08:48 -0000 1.87
+++ rpm/rpmdb/header.c 18 Oct 2007 15:03:40 -0000 1.88
@@ -3271,7 +3271,7 @@
strarray.argv = he_p.argv;
if (tag->fmt)
- val = tag->fmt(he, RPM_STRING_TYPE, (hPTR_t) strarray.argv[element], buf, tag->pad, (he->c > 1 ? element : -1)); /* NOCAST */
+ val = tag->fmt(he, (hPTR_t) strarray.argv[element], buf, tag->pad, (he->c > 1 ? element : -1)); /* NOCAST */
if (val) {
need = strlen(val);
@@ -3288,7 +3288,7 @@
case RPM_STRING_TYPE:
if (tag->fmt)
- val = tag->fmt(he, RPM_STRING_TYPE, he_p.ptr, buf, tag->pad, -1);
+ val = tag->fmt(he, he_p.ptr, buf, tag->pad, -1);
if (val) {
need = strlen(val);
@@ -3305,7 +3305,7 @@
case RPM_INT64_TYPE:
llVal = he_p.i64p[element];
if (tag->fmt)
- val = tag->fmt(he, RPM_INT64_TYPE, (hPTR_t) &llVal, buf, tag->pad, (he->c > 1 ? element : -1)); /* NOCAST */
+ val = tag->fmt(he, (hPTR_t) &llVal, buf, tag->pad, (he->c > 1 ? element : -1)); /* NOCAST */
if (val) {
need = strlen(val);
} else {
@@ -3336,8 +3336,16 @@
/*@innerbreak@*/ break;
}
- if (tag->fmt)
- val = tag->fmt(he, RPM_INT32_TYPE, (hPTR_t) &intVal, buf, tag->pad, (he->c > 1 ? element : -1)); /* NOCAST */
+ if (tag->fmt) {
+ hRET_t _he_p = { .ptr = NULL };
+ HE_s _he_s = { .tag = 0, .t = 0, .p = &_he_p, .c = 0, .freeData = 0 };
+ HE_t _he = &_he_s;
+ _he->tag = he->tag;
+ _he->t = RPM_INT32_TYPE;
+ (*_he->p).ui32p = &intVal;
+ _he->c = 1;
+ val = tag->fmt(_he, he->p, buf, tag->pad, (he->c > 1 ? element : -1));
+ }
if (val) {
need = strlen(val);
@@ -3356,7 +3364,7 @@
case RPM_BIN_TYPE:
/* XXX HACK ALERT: element field abused as no. bytes of binary data. */
if (tag->fmt)
- val = tag->fmt(he, RPM_BIN_TYPE, he_p.ptr, buf, tag->pad, he->c);
+ val = tag->fmt(he, he_p.ptr, buf, tag->pad, he->c);
if (val) {
need = strlen(val);
@@ -3760,30 +3768,29 @@
/**
* Return octal formatted data.
* @param he tag container
- * @param type tag type
* @param data tag value
* @param formatPrefix sprintf format string
* @param padding no. additional bytes needed by format string
* @param element (unused)
* @return formatted string
*/
-static char * octalFormat(HE_t he, rpmTagType type, hPTR_t data,
+static char * octalFormat(HE_t he, hPTR_t data,
char * formatPrefix, int padding, /*@unused@*/int element)
/*@modifies formatPrefix @*/
{
char * val;
- if (type == RPM_INT32_TYPE) {
+ if (he->t == RPM_INT32_TYPE) {
val = xmalloc(20 + padding);
strcat(formatPrefix, "o");
/*@-formatconst@*/
- sprintf(val, formatPrefix, *((int_32 *) data));
+ sprintf(val, formatPrefix, (*data).i32p[0]);
/*@=formatconst@*/
- } else if (type == RPM_INT64_TYPE) {
+ } else if (he->t == RPM_INT64_TYPE) {
val = xmalloc(40 + padding);
strcat(formatPrefix, "llo");
/*@-formatconst@*/
- sprintf(val, formatPrefix, *((int_64 *) data));
+ sprintf(val, formatPrefix, (*data).i64p[0]);
/*@=formatconst@*/
} else
val = xstrdup(_("(not a number)"));
@@ -3794,30 +3801,29 @@
/**
* Return hex formatted data.
* @param he tag container
- * @param type tag type
* @param data tag value
* @param formatPrefix sprintf format string
* @param padding no. additional bytes needed by format string
* @param element (unused)
* @return formatted string
*/
-static char * hexFormat(HE_t he, rpmTagType type, hPTR_t data,
+static char * hexFormat(HE_t he, hPTR_t data,
char * formatPrefix, int padding, /*@unused@*/int element)
/*@modifies formatPrefix @*/
{
char * val;
- if (type == RPM_INT32_TYPE) {
+ if (he->t == RPM_INT32_TYPE) {
val = xmalloc(20 + padding);
strcat(formatPrefix, "x");
/*@-formatconst@*/
- sprintf(val, formatPrefix, *((int_32 *) data));
+ sprintf(val, formatPrefix, (*data).i32p[0]);
/*@=formatconst@*/
- } else if (type == RPM_INT64_TYPE) {
+ } else if (he->t == RPM_INT64_TYPE) {
val = xmalloc(40 + padding);
strcat(formatPrefix, "llx");
/*@-formatconst@*/
- sprintf(val, formatPrefix, *((int_64 *) data));
+ sprintf(val, formatPrefix, (*data).i64p[0]);
/*@=formatconst@*/
} else
val = xstrdup(_("(not a number)"));
@@ -3828,7 +3834,6 @@
/**
* Return strftime formatted data.
* @param he tag container
- * @param type tag type
* @param data tag value
* @param formatPrefix sprintf format string
* @param padding no. additional bytes needed by format string
@@ -3836,14 +3841,14 @@
* @param strftimeFormat strftime(3) format
* @return formatted string
*/
-static char * realDateFormat(HE_t he, rpmTagType type, hPTR_t data,
+static char * realDateFormat(HE_t he, hPTR_t data,
char * formatPrefix, int padding, /*@unused@*/int element,
const char * strftimeFormat)
/*@modifies formatPrefix @*/
{
char * val;
- if (type != RPM_INT32_TYPE) {
+ if (he->t != RPM_INT32_TYPE) {
val = xstrdup(_("(not a number)"));
} else {
struct tm * tstruct;
@@ -3870,66 +3875,63 @@
/**
* Return date formatted data.
* @param he tag container
- * @param type tag type
* @param data tag value
* @param formatPrefix sprintf format string
* @param padding no. additional bytes needed by format string
* @param element (unused)
* @return formatted string
*/
-static char * dateFormat(HE_t he, rpmTagType type, hPTR_t data,
+static char * dateFormat(HE_t he, hPTR_t data,
char * formatPrefix, int padding, int element)
/*@modifies formatPrefix @*/
{
- return realDateFormat(he, type, data, formatPrefix, padding, element,
+ return realDateFormat(he, data, formatPrefix, padding, element,
_("%c"));
}
/**
* Return day formatted data.
* @param he tag container
- * @param type tag type
* @param data tag value
* @param formatPrefix sprintf format string
* @param padding no. additional bytes needed by format string
* @param element (unused)
* @return formatted string
*/
-static char * dayFormat(HE_t he, rpmTagType type, hPTR_t data,
+static char * dayFormat(HE_t he, hPTR_t data,
char * formatPrefix, int padding, int element)
/*@modifies formatPrefix @*/
{
- return realDateFormat(he, type, data, formatPrefix, padding, element,
+ return realDateFormat(he, data, formatPrefix, padding, element,
_("%a %b %d %Y"));
}
/**
* Return shell escape formatted data.
* @param he tag container
- * @param type tag type
* @param data tag value
* @param formatPrefix sprintf format string
* @param padding no. additional bytes needed by format string
* @param element (unused)
* @return formatted string
*/
-static char * shescapeFormat(HE_t he, rpmTagType type, hPTR_t data,
+static char * shescapeFormat(HE_t he, hPTR_t data,
char * formatPrefix, int padding, /*@unused@*/int element)
/*@modifies formatPrefix @*/
{
char * result, * dst, * src, * buf;
- if (type == RPM_INT32_TYPE) {
+ if (he->t == RPM_INT32_TYPE) {
result = xmalloc(padding + 20);
strcat(formatPrefix, "d");
/*@-formatconst@*/
- sprintf(result, formatPrefix, *((int_32 *) data));
+ sprintf(result, formatPrefix, (*data).i32p[0]);
/*@=formatconst@*/
- } else if (type == RPM_INT64_TYPE) {
+ } else if (he->t == RPM_INT64_TYPE) {
result = xmalloc(padding + 40);
strcat(formatPrefix, "lld");
/*@-formatconst@*/
- sprintf(result, formatPrefix, *((int_64 *) data));
+ sprintf(result, formatPrefix, (*data).i64p[0]);
/*@=formatconst@*/
} else {
buf = alloca(strlen((*data).str) + padding + 2);
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmdb/header.h
============================================================================
$ cvs diff -u -r1.42 -r1.43 header.h
--- rpm/rpmdb/header.h 18 Oct 2007 14:08:48 -0000 1.42
+++ rpm/rpmdb/header.h 18 Oct 2007 15:03:40 -0000 1.43
@@ -248,14 +248,13 @@
* help keep things simple.
*
* @param he tag container
- * @param type tag type
* @param data tag value
* @param formatPrefix
* @param padding
* @param element RPM_BIN_TYPE: no. bytes of data
* @return formatted string
*/
-typedef /*only@*/ char * (*headerTagFormatFunction)(HE_t he, rpmTagType type,
+typedef /*only@*/ char * (*headerTagFormatFunction)(HE_t he,
rpmTagData * data, char * formatPrefix,
int padding, int element)
/*@requires maxSet(data) >= 0 @*/;
@@ .
Received on Thu Oct 18 17:03:41 2007