summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/formats.c35
1 files changed, 15 insertions, 20 deletions
diff --git a/lib/formats.c b/lib/formats.c
index 4aab74808..fcebef91c 100644
--- a/lib/formats.c
+++ b/lib/formats.c
@@ -67,25 +67,29 @@ static char * stringFormat(rpmtd td, char *formatPrefix)
return val;
}
-/**
- * octalFormat.
- * @param td tag data container
- * @param formatPrefix sprintf format string
- * @return formatted string
- */
-static char * octalFormat(rpmtd td, char * formatPrefix)
+static char * numFormat(rpmtd td, char * formatPrefix, char *format)
{
char * val = NULL;
- if (rpmtdType(td) != RPM_INT32_TYPE) {
+ if (rpmtdClass(td) != RPM_NUMERIC_CLASS) {
val = xstrdup(_("(not a number)"));
} else {
- strcat(formatPrefix, "o");
- rasprintf(&val, formatPrefix, *rpmtdGetUint32(td));
+ strcat(formatPrefix, format);
+ rasprintf(&val, formatPrefix, rpmtdGetNumber(td));
}
return val;
}
+/**
+ * octalFormat.
+ * @param td tag data container
+ * @param formatPrefix sprintf format string
+ * @return formatted string
+ */
+static char * octalFormat(rpmtd td, char * formatPrefix)
+{
+ return numFormat(td, formatPrefix, "o");
+}
/**
* hexFormat.
@@ -95,16 +99,7 @@ static char * octalFormat(rpmtd td, char * formatPrefix)
*/
static char * hexFormat(rpmtd td, char * formatPrefix)
{
- char * val = NULL;
-
- if (rpmtdType(td) != RPM_INT32_TYPE) {
- val = xstrdup(_("(not a number)"));
- } else {
- strcat(formatPrefix, "x");
- rasprintf(&val, formatPrefix, *rpmtdGetUint32(td));
- }
-
- return val;
+ return numFormat(td, formatPrefix, "x");
}
/**