|
@@ -289,3 +289,37 @@ pkg_sorter_by_nonambig_name_arch(const void *a, const void *b)
|
|
|
return -1;
|
|
return -1;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * Add a string representation of the source package version to a varbuf.
|
|
|
|
|
+ *
|
|
|
|
|
+ * It parses the Source field (if present), and extracts the optional
|
|
|
|
|
+ * version enclosed in parenthesis. Otherwise it fallsback to use the
|
|
|
|
|
+ * binary package version. It NUL terminates the varbuf.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param vb The varbuf struct to modify.
|
|
|
|
|
+ * @param pkg The package to consider.
|
|
|
|
|
+ * @param pkgbin The binary package instance to consider.
|
|
|
|
|
+ */
|
|
|
|
|
+void
|
|
|
|
|
+varbuf_add_source_version(struct varbuf *vb,
|
|
|
|
|
+ const struct pkginfo *pkg, const struct pkgbin *pkgbin)
|
|
|
|
|
+{
|
|
|
|
|
+ const char *version;
|
|
|
|
|
+ size_t len;
|
|
|
|
|
+
|
|
|
|
|
+ if (pkgbin->source)
|
|
|
|
|
+ version = strchr(pkgbin->source, '(');
|
|
|
|
|
+ else
|
|
|
|
|
+ version = NULL;
|
|
|
|
|
+
|
|
|
|
|
+ if (version == NULL) {
|
|
|
|
|
+ varbufversion(vb, &pkgbin->version, vdew_nonambig);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ version++;
|
|
|
|
|
+
|
|
|
|
|
+ len = strcspn(version, ")");
|
|
|
|
|
+
|
|
|
|
|
+ varbuf_add_buf(vb, version, len);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|