Commit 36aa4076 authored by Bernhard Link's avatar Bernhard Link

[refactor] printlistformat: use package_getversion/package_getsource

parent d8d0ce73
...@@ -39,14 +39,12 @@ retvalue listformat_print(const char *listformat, struct package *package) { ...@@ -39,14 +39,12 @@ retvalue listformat_print(const char *listformat, struct package *package) {
const char *p, *q; const char *p, *q;
if (listformat == NULL) { if (listformat == NULL) {
char *version;
r = target->getversion(package->control, &version); r = package_getversion(package);
if (RET_IS_OK(r)) { if (RET_IS_OK(r)) {
printf( "%s: %s %s\n", printf( "%s: %s %s\n",
target->identifier, package->name, target->identifier, package->name,
version); package->version);
free(version);
} else { } else {
printf("Could not retrieve version from %s in %s\n", printf("Could not retrieve version from %s in %s\n",
package->name, target->identifier); package->name, target->identifier);
...@@ -144,27 +142,23 @@ retvalue listformat_print(const char *listformat, struct package *package) { ...@@ -144,27 +142,23 @@ retvalue listformat_print(const char *listformat, struct package *package) {
value = NULL; value = NULL;
v = atoms_components[target->component]; v = atoms_components[target->component];
} else if (q - p == 8 && strncasecmp(p, "{$source", 8) == 0) { } else if (q - p == 8 && strncasecmp(p, "{$source", 8) == 0) {
char *dummy = NULL; r = package_getsource(package);
r = target->getsourceandversion(package->control,
package->name, &value, &dummy);
if (RET_WAS_ERROR(r)) if (RET_WAS_ERROR(r))
return r; return r;
if (RET_IS_OK(r)) { if (RET_IS_OK(r)) {
free(dummy); value = NULL;
v = value; v = package->source;
} else { } else {
value = NULL; value = NULL;
v = ""; v = "";
} }
} else if (q - p == 15 && strncasecmp(p, "{$sourceversion", 15) == 0) { } else if (q - p == 15 && strncasecmp(p, "{$sourceversion", 15) == 0) {
char *dummy = NULL; r = package_getsource(package);
r = target->getsourceandversion(package->control,
package->name, &dummy, &value);
if (RET_WAS_ERROR(r)) if (RET_WAS_ERROR(r))
return r; return r;
if (RET_IS_OK(r)) { if (RET_IS_OK(r)) {
free(dummy); value = NULL;
v = value; v = package->sourceversion;
} else { } else {
value = NULL; value = NULL;
v = ""; v = "";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment