RPM Community Forums

Mailing List Message of <rpm-cvs>

[CVS] RPM: rpm/ CHANGES rpm/rpmdb/ hdrfmt.c header.c header.h

From: Jeff Johnson <jbj@rpm5.org>
Date: Fri 19 Oct 2007 - 21:03:12 CEST
Message-Id: <20071019190312.075A4348469@rpm5.org>
  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:   19-Oct-2007 21:03:12
  Branch: HEAD                             Handle: 2007101920031100

  Modified files:
    rpm                     CHANGES
    rpm/rpmdb               hdrfmt.c header.c header.h

  Log:
    - eliminate padding & formatPrefix, strings is strings now.
    - bury hex dump in intFormat defaults, refactor common code.

  Summary:
    Revision    Changes     Path
    1.1733      +2  -0      rpm/CHANGES
    1.22        +25 -88     rpm/rpmdb/hdrfmt.c
    1.94        +90 -146    rpm/rpmdb/header.c
    1.48        +2  -5      rpm/rpmdb/header.h
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.1732 -r1.1733 CHANGES
  --- rpm/CHANGES	19 Oct 2007 16:49:34 -0000	1.1732
  +++ rpm/CHANGES	19 Oct 2007 19:03:11 -0000	1.1733
  @@ -1,4 +1,6 @@
   4.5 -> 5.0:
  +    - jbj: eliminate padding & formatPrefix, strings is strings now.
  +    - jbj: bury hex dump in intFormat defaults, refactor common code.
       - jbj: hmmm, --yaml is b0rken atm, todo++;
       - jbj: add assert's to control tag container values.
       - jbj: teach formatValue() to create an element tag container.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/hdrfmt.c
  ============================================================================
  $ cvs diff -u -r1.21 -r1.22 hdrfmt.c
  --- rpm/rpmdb/hdrfmt.c	19 Oct 2007 16:49:34 -0000	1.21
  +++ rpm/rpmdb/hdrfmt.c	19 Oct 2007 19:03:11 -0000	1.22
  @@ -71,12 +71,9 @@
   /**
    * Identify type of trigger.
    * @param he		tag container
  - * @param formatPrefix	(unused)
  - * @param padding	(unused)
    * @return		formatted string
    */
  -static /*@only@*/ char * triggertypeFormat(HE_t he,
  -		/*@unused@*/ char * formatPrefix, /*@unused@*/ int padding)
  +static /*@only@*/ char * triggertypeFormat(HE_t he)
   {
       rpmTagData data = { .ptr = he->p.ptr };
       int ix = (he->ix > 0 ? he->ix : 0);
  @@ -104,31 +101,19 @@
   /**
    * Format file permissions for display.
    * @param he		tag container
  - * @param formatPrefix
  - * @param padding
    * @return		formatted string
    */
  -static /*@only@*/ char * permsFormat(HE_t he,
  -		char * formatPrefix, int padding)
  -	/*@modifies formatPrefix @*/
  -	/*@requires maxRead(data) >= 0 @*/
  +static /*@only@*/ char * permsFormat(HE_t he)
   {
       int ix = (he->ix > 0 ? he->ix : 0);
       char * val;
  -    char * buf;
   
   assert(ix == 0);
       if (he->t != RPM_INT64_TYPE) {
   	val = xstrdup(_("(invalid type)"));
       } else {
   	int_32 anint = he->p.i64p[0];
  -	val = xmalloc(15 + padding);
  -	strcat(formatPrefix, "s");
  -	buf = rpmPermsString(anint);
  -	/*@-formatconst@*/
  -	sprintf(val, formatPrefix, buf);
  -	/*@=formatconst@*/
  -	buf = _free(buf);
  +	val = rpmPermsString(anint);
       }
   
       return val;
  @@ -137,24 +122,19 @@
   /**
    * Format file flags for display.
    * @param he		tag container
  - * @param formatPrefix
  - * @param padding
    * @return		formatted string
    */
  -static /*@only@*/ char * fflagsFormat(HE_t he,
  -		char * formatPrefix, int padding)
  -	/*@modifies formatPrefix @*/
  -	/*@requires maxRead(data) >= 0 @*/
  +static /*@only@*/ char * fflagsFormat(HE_t he)
   {
       rpmTagData data = { .ptr = he->p.ptr };
       int ix = (he->ix >= 0 ? he->ix : 0);
       char * val;
  -    char buf[15];
   
   assert(ix == 0);
       if (he->t != RPM_INT64_TYPE) {
   	val = xstrdup(_("(invalid type)"));
       } else {
  +	char buf[15];
   	unsigned anint = data.i64p[ix];
   	buf[0] = '\0';
   	if (anint & RPMFILE_DOC)
  @@ -173,12 +153,7 @@
   	    strcat(buf, "l");
   	if (anint & RPMFILE_README)
   	    strcat(buf, "r");
  -
  -	val = xmalloc(5 + padding);
  -	strcat(formatPrefix, "s");
  -	/*@-formatconst@*/
  -	sprintf(val, formatPrefix, buf);
  -	/*@=formatconst@*/
  +	val = xstrdup(buf);
       }
   
       return val;
  @@ -188,12 +163,9 @@
    * Wrap a pubkey in ascii armor for display.
    * @todo Permit selectable display formats (i.e. binary).
    * @param he		tag container
  - * @param formatPrefix	(unused)
  - * @param padding	(unused)
    * @return		formatted string
    */
  -static /*@only@*/ char * armorFormat(HE_t he,
  -		/*@unused@*/ char * formatPrefix, /*@unused@*/ int padding)
  +static /*@only@*/ char * armorFormat(HE_t he)
   	/*@*/
   {
       rpmTagData data = { .ptr = he->p.ptr };
  @@ -236,7 +208,6 @@
   	/*@notreached@*/ break;
       }
   
  -    /* XXX this doesn't use padding directly, assumes enough slop in retval. */
       val = pgpArmorWrap(atype, s, ns);
       if (atype == PGPARMOR_PUBKEY)
   	s = _free(s);
  @@ -247,12 +218,9 @@
    * Encode binary data in base64 for display.
    * @todo Permit selectable display formats (i.e. binary).
    * @param he		tag container
  - * @param formatPrefix	(unused)
  - * @param padding
    * @return		formatted string
    */
  -static /*@only@*/ char * base64Format(HE_t he,
  -		/*@unused@*/ char * formatPrefix, int padding)
  +static /*@only@*/ char * base64Format(HE_t he)
   	/*@*/
   {
       rpmTagData data = { .ptr = he->p.ptr };
  @@ -279,7 +247,7 @@
   	}
   	/*@=globs@*/
   
  -	val = t = xcalloc(1, nt + padding + 1);
  +	val = t = xcalloc(1, nt + 1);
   	*t = '\0';
   
       /* XXX b64encode accesses uninitialized memory. */
  @@ -350,13 +318,10 @@
   /**
    * Wrap tag data in simple header xml markup.
    * @param he		tag container
  - * @param formatPrefix
  - * @param padding
    * @return		formatted string
    */
  -static /*@only@*/ char * xmlFormat(HE_t he,
  -		char * formatPrefix, int padding)
  -	/*@modifies formatPrefix @*/
  +static /*@only@*/ char * xmlFormat(HE_t he)
  +	/*@*/
   {
       rpmTagData data = { .ptr = he->p.ptr };
       int ix = (he->ix > 0 ? he->ix : 0);
  @@ -396,7 +361,7 @@
       {	int cpl = b64encode_chars_per_line;
   	b64encode_chars_per_line = 0;
   /*@-formatconst@*/
  -	s = base64Format(he, formatPrefix, padding);
  +	s = base64Format(he);
   /*@=formatconst@*/
   	b64encode_chars_per_line = cpl;
   	xtag = "base64";
  @@ -450,13 +415,7 @@
       if (freeit)
   	s = _free(s);
   
  -    nb += padding;
  -    val = xmalloc(nb+1);
  -    strcat(formatPrefix, "s");
  -/*@-formatconst@*/
  -    xx = snprintf(val, nb, formatPrefix, t);
  -/*@=formatconst@*/
  -    val[nb] = '\0';
  +    val = xstrdup(t);
   
       return val;
   }
  @@ -521,13 +480,10 @@
   /**
    * Wrap tag data in simple header yaml markup.
    * @param he		tag container
  - * @param formatPrefix
  - * @param padding
    * @return		formatted string
    */
  -static /*@only@*/ char * yamlFormat(HE_t he,
  -		char * formatPrefix, int padding)
  -	/*@modifies formatPrefix @*/
  +static /*@only@*/ char * yamlFormat(HE_t he)
  +	/*@*/
   {
       rpmTagData data = { .ptr = he->p.ptr };
       int element = he->ix;
  @@ -595,7 +551,7 @@
       {	int cpl = b64encode_chars_per_line;
   	b64encode_chars_per_line = 0;
   /*@-formatconst@*/
  -	s = base64Format(he, formatPrefix, padding);
  +	s = base64Format(he);
   	element = -element; 	/* XXX skip "    " indent. */
   /*@=formatconst@*/
   	b64encode_chars_per_line = cpl;
  @@ -665,13 +621,7 @@
       if (freeit)
   	s = _free(s);
   
  -    nb += padding;
  -    val = xmalloc(nb+1);
  -    strcat(formatPrefix, "s");
  -/*@-formatconst@*/
  -    xx = snprintf(val, nb, formatPrefix, t);
  -/*@=formatconst@*/
  -    val[nb] = '\0';
  +    val = xstrdup(t);
   
       return val;
   }
  @@ -679,12 +629,9 @@
   /**
    * Display signature fingerprint and time.
    * @param he		tag container
  - * @param formatPrefix	(unused)
  - * @param padding
    * @return		formatted string
    */
  -static /*@only@*/ char * pgpsigFormat(HE_t he,
  -		/*@unused@*/ char * formatPrefix, /*@unused@*/ int padding)
  +static /*@only@*/ char * pgpsigFormat(HE_t he)
   	/*@globals fileSystem, internalState @*/
   	/*@modifies fileSystem, internalState @*/
   {
  @@ -788,14 +735,10 @@
   /**
    * Format dependency flags for display.
    * @param he		tag container
  - * @param formatPrefix
  - * @param padding
    * @return		formatted string
    */
  -static /*@only@*/ char * depflagsFormat(HE_t he,
  -		char * formatPrefix, int padding)
  -	/*@modifies formatPrefix @*/
  -	/*@requires maxRead(data) >= 0 @*/
  +static /*@only@*/ char * depflagsFormat(HE_t he)
  +	/*@*/
   {
       rpmTagData data = { .ptr = he->p.ptr };
       int ix = (he->ix > 0 ? he->ix : 0);;
  @@ -814,11 +757,11 @@
   #ifdef	NOTYET	/* XXX appending markers breaks :depflags format. */
   	if (anint & RPMSENSE_SCRIPT_PRE)
   	    t = stpcpy(t, "(pre)");
  -	if (anint & RPMSENSE_SCRIPT_POST)
  +	else if (anint & RPMSENSE_SCRIPT_POST)
   	    t = stpcpy(t, "(post)");
  -	if (anint & RPMSENSE_SCRIPT_PREUN)
  +	else if (anint & RPMSENSE_SCRIPT_PREUN)
   	    t = stpcpy(t, "(preun)");
  -	if (anint & RPMSENSE_SCRIPT_POSTUN)
  +	else if (anint & RPMSENSE_SCRIPT_POSTUN)
   	    t = stpcpy(t, "(postun)");
   #endif
   	if (anint & RPMSENSE_SENSEMASK)
  @@ -833,11 +776,7 @@
   	    *t++ = ' ';
   	*t = '\0';
   
  -	val = xmalloc(5 + padding);
  -	strcat(formatPrefix, "s");
  -	/*@-formatconst@*/
  -	sprintf(val, formatPrefix, buf);
  -	/*@=formatconst@*/
  +	val = xstrdup(buf);
       }
   
       return val;
  @@ -892,7 +831,6 @@
       char * item, * flagsStr;
       char * chptr;
       int i, j, xx;
  -    char buf[5];
   
       he->freeData = 0;
       xx = headerGetEntry(h, RPMTAG_TRIGGERNAME, NULL, &names, &numNames);
  @@ -924,9 +862,8 @@
   
   	    item = xmalloc(strlen(names.argv[j]) + strlen(versions.argv[j]) + 20);
   	    if (flags.i32p[j] & RPMSENSE_SENSEMASK) {
  -		buf[0] = '%', buf[1] = '\0';
   		_he->p.i32p = &flags.i32p[j];
  -		flagsStr = depflagsFormat(_he, buf, 0);
  +		flagsStr = depflagsFormat(_he);
   		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.93 -r1.94 header.c
  --- rpm/rpmdb/header.c	19 Oct 2007 16:49:34 -0000	1.93
  +++ rpm/rpmdb/header.c	19 Oct 2007 19:03:11 -0000	1.94
  @@ -2791,13 +2791,10 @@
   /**
    * Convert tag data representation.
    * @param he		tag container
  - * @param formatPrefix	sprintf format string
  - * @param padding	no. additional bytes needed by format string
    * @param fmt		output radix (NULL or "" assumes %d)
    * @return		formatted string
    */
  -static char * intFormat(HE_t he,
  -		char * formatPrefix, int padding, const char *fmt)
  +static char * intFormat(HE_t he, const char *fmt)
   {
       int ix = (he->ix > 0 ? he->ix : 0);;
       int_64 ival = 0;
  @@ -2834,22 +2831,32 @@
       case RPM_OPENPGP_TYPE:	/* XXX W2DO? */
       case RPM_ASN1_TYPE:		/* XXX W2DO? */
       case RPM_BIN_TYPE:
  -	break;
  +	{   static char hex[] = "0123456789abcdef";
  +	    const char * s = he->p.str;
  +	    int c = he->c;
  +	    char * t;
  +
  +	    nb = 2 * c + 1;
  +	    t = b = alloca(nb+1);
  +	    while (c-- > 0) {
  +		unsigned int i;
  +		i = *s++;
  +		*t++ = hex[ (i >> 4) & 0xf ];
  +		*t++ = hex[ (i     ) & 0xf ];
  +	    }
  +	    *t = '\0';
  +	}   break;
       }
   
       if (istr) {		/* string */
  -	nb = strlen(istr) + 1;
  -	strcat(formatPrefix, "s");
  -	b = alloca(nb);
  -	snprintf(b, nb, formatPrefix, istr);
  -	b[nb-1] = '\0';
  +	b = (char *)istr;	/* NOCAST */
       } else
       if (nb == 0) {	/* number */
  +	char myfmt[] = "%llX";
  +	myfmt[3] = *fmt;
   	nb = 64;
  -	strcat(formatPrefix, "ll");
  -	strcat(formatPrefix, fmt);
   	b = alloca(nb);
  -	snprintf(b, nb, formatPrefix, ival);
  +	snprintf(b, nb, myfmt, ival);
   	b[nb-1] = '\0';
       }
   
  @@ -2859,60 +2866,47 @@
   /**
    * Return octal formatted data.
    * @param he		tag container
  - * @param formatPrefix	sprintf format string
  - * @param padding	no. additional bytes needed by format string
    * @return		formatted string
    */
  -static char * octFormat(HE_t he,
  -		char * formatPrefix, int padding)
  -	/*@modifies formatPrefix @*/
  +static char * octFormat(HE_t he)
  +	/*@*/
   {
  -    return intFormat(he, formatPrefix, padding, "o");
  +    return intFormat(he, "o");
   }
   
   /**
    * Return hex formatted data.
    * @param he		tag container
  - * @param formatPrefix	sprintf format string
  - * @param padding	no. additional bytes needed by format string
    * @return		formatted string
    */
  -static char * hexFormat(HE_t he,
  -		char * formatPrefix, int padding)
  -	/*@modifies formatPrefix @*/
  +static char * hexFormat(HE_t he)
  +	/*@*/
   {
  -    return intFormat(he, formatPrefix, padding, "x");
  +    return intFormat(he, "x");
   }
   
   /**
    * Return decimal formatted data.
    * @param he		tag container
  - * @param formatPrefix	sprintf format string
  - * @param padding	no. additional bytes needed by format string
    * @return		formatted string
    */
  -static char * decFormat(HE_t he,
  -		char * formatPrefix, int padding)
  -	/*@modifies formatPrefix @*/
  +static char * decFormat(HE_t he)
  +	/*@*/
   {
  -    return intFormat(he, formatPrefix, padding, "d");
  +    return intFormat(he, "d");
   }
   
   /**
    * Return strftime formatted data.
    * @param he		tag container
  - * @param formatPrefix	sprintf format string
  - * @param padding	no. additional bytes needed by format string
    * @param strftimeFormat strftime(3) format
    * @return		formatted string
    */
  -static char * realDateFormat(HE_t he,
  -		char * formatPrefix, int padding,
  -		const char * strftimeFormat)
  -	/*@modifies formatPrefix @*/
  +static char * realDateFormat(HE_t he, const char * strftimeFormat)
  +	/*@*/
   {
  -    char * val;
       rpmTagData data = { .ptr = he->p.ptr };
  +    char * val;
   
       if (he->t != RPM_INT32_TYPE) {
   	val = xstrdup(_("(not a number)"));
  @@ -2920,9 +2914,6 @@
   	struct tm * tstruct;
   	char buf[50];
   
  -	val = xmalloc(50 + padding);
  -	strcat(formatPrefix, "s");
  -
   	/* this is important if sizeof(int_32) ! sizeof(time_t) */
   	{   time_t dateint = data.ui32p[0];
   	    tstruct = localtime(&dateint);
  @@ -2930,9 +2921,8 @@
   	buf[0] = '\0';
   	if (tstruct)
   	    (void) strftime(buf, sizeof(buf) - 1, strftimeFormat, tstruct);
  -	/*@-formatconst@*/
  -	sprintf(val, formatPrefix, buf);
  -	/*@=formatconst@*/
  +	buf[sizeof(buf) - 1] = '\0';
  +	val = xstrdup(buf);
       }
   
       return val;
  @@ -2941,82 +2931,73 @@
   /**
    * Return date formatted data.
    * @param he		tag container
  - * @param formatPrefix	sprintf format string
  - * @param padding	no. additional bytes needed by format string
    * @return		formatted string
    */
  -static char * dateFormat(HE_t he,
  -		         char * formatPrefix, int padding)
  -	/*@modifies formatPrefix @*/
  +static char * dateFormat(HE_t he)
  +	/*@*/
   {
  -    return realDateFormat(he, formatPrefix, padding, _("%c"));
  +    return realDateFormat(he, _("%c"));
   }
   
   /**
    * Return day formatted data.
    * @param he		tag container
  - * @param formatPrefix	sprintf format string
  - * @param padding	no. additional bytes needed by format string
    * @return		formatted string
    */
  -static char * dayFormat(HE_t he,
  -		         char * formatPrefix, int padding)
  -	/*@modifies formatPrefix @*/
  +static char * dayFormat(HE_t he)
  +	/*@*/
   {
  -    return realDateFormat(he, formatPrefix, padding, _("%a %b %d %Y"));
  +    return realDateFormat(he, _("%a %b %d %Y"));
   }
   
   /**
    * Return shell escape formatted data.
    * @param he		tag container
  - * @param formatPrefix	sprintf format string
  - * @param padding	no. additional bytes needed by format string
    * @return		formatted string
    */
  -static char * shescapeFormat(HE_t he,
  -		char * formatPrefix, int padding)
  -	/*@modifies formatPrefix @*/
  +static char * shescapeFormat(HE_t he)
  +	/*@*/
   {
  -    char * result, * dst, * src, * buf;
       rpmTagData data = { .ptr = he->p.ptr };
  +    char * val;
  +    size_t nb;
   
  +    /* XXX one of these integer types is unnecessary. */
       if (he->t == RPM_INT32_TYPE) {
  -	result = xmalloc(padding + 20);
  -	strcat(formatPrefix, "d");
  -	/*@-formatconst@*/
  -	sprintf(result, formatPrefix, data.i32p[0]);
  -	/*@=formatconst@*/
  +	nb = 20;
  +	val = xmalloc(nb);
  +	snprintf(val, nb, "%d", data.i32p[0]);
  +	val[nb-1] = '\0';
       } else if (he->t == RPM_INT64_TYPE) {
  -	result = xmalloc(padding + 40);
  -	strcat(formatPrefix, "lld");
  -	/*@-formatconst@*/
  -	sprintf(result, formatPrefix, data.i64p[0]);
  -	/*@=formatconst@*/
  -    } else {
  -	buf = alloca(strlen(data.str) + padding + 2);
  -	strcat(formatPrefix, "s");
  -	/*@-formatconst@*/
  -	sprintf(buf, formatPrefix, data);
  -	/*@=formatconst@*/
  -
  -	result = dst = xmalloc(strlen(buf) * 4 + 3);
  -	*dst++ = '\'';
  -	for (src = buf; *src != '\0'; src++) {
  -	    if (*src == '\'') {
  -		*dst++ = '\'';
  -		*dst++ = '\\';
  -		*dst++ = '\'';
  -		*dst++ = '\'';
  -	    } else {
  -		*dst++ = *src;
  +	nb = 40;
  +	val = xmalloc(40);
  +	snprintf(val, nb, "%lld", data.i64p[0]);
  +	val[nb-1] = '\0';
  +    } else if (he->t == RPM_STRING_TYPE) {
  +	const char * s = data.str;
  +	char * t;
  +	int c;
  +
  +	nb = strlen(data.str) + 1;
  +	/* XXX count no. of escapes instead. */
  +	t = xmalloc(4 * nb + 3);
  +	*t++ = '\'';
  +	while ((c = *s++) != 0) {
  +	    if (c == '\'') {
  +		*t++ = '\'';
  +		*t++ = '\\';
  +		*t++ = '\'';
   	    }
  +	    *t++ = c;
   	}
  -	*dst++ = '\'';
  -	*dst = '\0';
  -
  -    }
  +	*t++ = '\'';
  +	*t = '\0';
  +	nb = strlen(t) + 1;
  +	val = xrealloc(t, nb);
  +    } else
  +	val = xstrdup(_("invalid type"));
   
  -    return result;
  +    return val;
   }
   
   /*@-type@*/ /* FIX: cast? */
  @@ -3429,7 +3410,7 @@
   }
   
   /**
  - * Format a single item value.
  + * Format a single item's value.
    * @param hsa		headerSprintf args
    * @param tag		tag
    * @param element	element index
  @@ -3444,6 +3425,7 @@
       size_t need = 0;
       char * t, * te;
       char buf[20];
  +    
       rpmTagCount countBuf;
   
       HE_t vhe = memset(alloca(sizeof(*vhe)), 0, sizeof(*vhe));
  @@ -3505,35 +3487,21 @@
       switch (he->t) {
       default:
   	val = xstrdup("(unknown type)");
  -	need = tag->pad + strlen(val) + 1;
  -	break;
  +	need = strlen(val) + 1;
  +	goto exit;
  +	/*@notreached@*/ break;
       case RPM_STRING_ARRAY_TYPE:
   	vhe->p.str = he->p.argv[element];
   	vhe->t = RPM_STRING_TYPE;
   	vhe->c = he->c;
   	vhe->ix = -1;
  -	if (tag->fmt)
  -	    val = tag->fmt(vhe, buf, tag->pad);
  -	else
  -	    val = intFormat(vhe, buf, tag->pad, "s");
  -assert(val);
  -	if (val)
  -	    need = tag->pad + strlen(val) + 1;
   	break;
       case RPM_STRING_TYPE:
   	vhe->p.str = he->p.str;
   	vhe->t = RPM_STRING_TYPE;
   	vhe->c = he->c;
   	vhe->ix = -1;
  -	if (tag->fmt)
  -	    val = tag->fmt(vhe, buf, tag->pad);
  -	else
  -	    val = intFormat(vhe, buf, tag->pad, "s");
  -assert(val);
  -	if (val)
  -	    need = tag->pad + strlen(val) + 1;
   	break;
  -
       case RPM_CHAR_TYPE:
       case RPM_INT8_TYPE:
       case RPM_INT16_TYPE:
  @@ -3541,7 +3509,7 @@
       case RPM_INT64_TYPE:
   	switch (he->t) {
   	default:
  -assert(0);
  +assert(0);	/* XXX keep gcc quiet. */
   	    break;
   	case RPM_CHAR_TYPE:	
   	case RPM_INT8_TYPE:
  @@ -3561,14 +3529,6 @@
   	vhe->p.i64p = &ival;
   	vhe->c = he->c;
   	vhe->ix = (he->c > 1 ? 0 : -1);
  -
  -	if (tag->fmt)
  -	    val = tag->fmt(vhe, buf, tag->pad);
  -	else
  -	    val = intFormat(vhe, buf, tag->pad, "d");
  -assert(val);
  -	if (val)
  -	    need = tag->pad + strlen(val) + 1;
   	break;
   
       case RPM_OPENPGP_TYPE:	/* XXX W2DO? */
  @@ -3578,34 +3538,18 @@
   	vhe->p.ptr = he->p.ptr;
   	vhe->c = he->c;
   	vhe->ix = -1;
  -	if (tag->fmt)
  -	    val = tag->fmt(he, buf, tag->pad);
  -
  -	if (val) {
  -	    need = tag->pad + strlen(val) + 1;
  -	} else {
  -#ifdef	NOTYET
  -	    val = memcpy(xmalloc(he->c), he->p.ptr, he->c);
  -#else
  -	    /* XXX format string not used */
  -	    static char hex[] = "0123456789abcdef";
  -	    const char * s = he->p.str;
  -
  -	    need = 2 * he->c + tag->pad;
  -	    val = t = xmalloc(need+1);
  -	    while (he->c-- > 0) {
  -		unsigned int i;
  -		i = *s++;
  -		*t++ = hex[ (i >> 4) & 0xf ];
  -		*t++ = hex[ (i     ) & 0xf ];
  -	    }
  -	    *t = '\0';
  -#endif
  -	}
   	break;
  -
       }
   
  +    if (tag->fmt)
  +	val = tag->fmt(vhe);
  +    else
  +	val = intFormat(vhe, NULL);
  +assert(val);
  +    if (val)
  +	need = strlen(val) + 1;
  +
  +exit:
   /*@-modobserver -observertrans@*/
       if (he->freeData) {
   	he->p.ptr = headerFreeData(he->p.ptr, he->t);
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/header.h
  ============================================================================
  $ cvs diff -u -r1.47 -r1.48 header.h
  --- rpm/rpmdb/header.h	19 Oct 2007 16:49:34 -0000	1.47
  +++ rpm/rpmdb/header.h	19 Oct 2007 19:03:11 -0000	1.48
  @@ -245,13 +245,10 @@
    * HEADER_EXT_TAG format function prototype.
    *
    * @param he		tag container
  - * @param formatPrefix
  - * @param padding
    * @return		formatted string
    */
  -typedef /*only@*/ char * (*headerTagFormatFunction)(HE_t he,
  -				char * formatPrefix, int padding)
  -	/*@requires maxSet(data) >= 0 @*/;
  +typedef /*only@*/ char * (*headerTagFormatFunction)(HE_t he)
  +	/*@modifies he @*/;
   
   /** \ingroup header
    * HEADER_EXT_FORMAT format function prototype.
  @@ .
Received on Fri Oct 19 21:03:12 2007
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.