summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJo-Philipp Wich2019-01-17 21:02:37 +0000
committerJo-Philipp Wich2019-01-17 21:02:37 +0000
commitd217daf1b32d88a48659155b1faf747982175c5d (patch)
treeb2fd4854ca21e8dddbc0c2e2f3308492eb020bb3
parent9dd9a07600593cdbdfc4186bc5105bd6e40dbe1f (diff)
downloadopkg-lede-d217daf1b32d88a48659155b1faf747982175c5d.tar.gz
libopkg: fix replacelist parsing and writing
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r--libopkg/pkg.c6
-rw-r--r--libopkg/pkg_depends.c5
2 files changed, 5 insertions, 6 deletions
diff --git a/libopkg/pkg.c b/libopkg/pkg.c
index 21f239e..e5bfe6f 100644
--- a/libopkg/pkg.c
+++ b/libopkg/pkg.c
@@ -817,11 +817,11 @@ void pkg_formatted_field(FILE * fp, pkg_t * pkg, const char *field)
case 'R':
if (strcasecmp(field, "Replaces") == 0) {
ab_pkg = pkg_get_ptr(pkg, PKG_REPLACES);
- if (ab_pkg && *ab_pkg) {
+ if (ab_pkg && ab_pkg[0]) {
fprintf(fp, "Replaces:");
- for (i = 0; *ab_pkg; i++, ab_pkg++) {
+ for (i = 0; ab_pkg[i]; i++) {
fprintf(fp, "%s %s", i == 0 ? "" : ",",
- (*ab_pkg)->name);
+ ab_pkg[i]->name);
}
fprintf(fp, "\n");
}
diff --git a/libopkg/pkg_depends.c b/libopkg/pkg_depends.c
index 748b599..ae2ac9b 100644
--- a/libopkg/pkg_depends.c
+++ b/libopkg/pkg_depends.c
@@ -668,9 +668,8 @@ void parse_replacelist(pkg_t *pkg, char *list)
abstract_pkg_vec_insert(ab_pkg->provided_by, ab_pkg);
- for (count = 1, item = strtok_r(list, ", ", &tok);
- item;
- count++, item = strtok_r(NULL, ", ", &tok), count++) {
+ for (count = 1, item = strtok_r(list, ", ", &tok); item;
+ count++, item = strtok_r(NULL, ", ", &tok)) {
tmp = realloc(replaces, sizeof(abstract_pkg_t *) * (count + 1));
if (!tmp)