Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Another fix to the cudf emitter.
Vsevolod Stakhov committed 12 years ago
commit 4331ac7ce98899dd66ed07b96cf705e60b2ed53b
parent b289daa
2 files changed +12 -5
modified libpkg/pkg_cudf.c
@@ -158,6 +158,7 @@ cudf_emit_request_packages(const char *op, struct pkg_jobs *j, FILE *f)
	struct pkg_job_request *req, *tmp;
	const char *origin;
	int column = 0;
+
	bool printed = false;

	if (fprintf(f, "%s: ", op) < 0)
		return (EPKG_FATAL);
@@ -169,11 +170,15 @@ cudf_emit_request_packages(const char *op, struct pkg_jobs *j, FILE *f)
				(req->hh.next != NULL), &column) < 0) {
			return (EPKG_FATAL);
		}
+
		printed = true;
	}
-
	if (fputc('\n', f) < 0)
-
		return (EPKG_FATAL);
+

+
	if (!printed)
+
		if (fputc('\n', f) < 0)
+
			return (EPKG_FATAL);

	column = 0;
+
	printed = false;
	if (fprintf(f, "remove: ") < 0)
		return (EPKG_FATAL);
	HASH_ITER(hh, j->request_delete, req, tmp) {
@@ -184,10 +189,12 @@ cudf_emit_request_packages(const char *op, struct pkg_jobs *j, FILE *f)
				(req->hh.next != NULL), &column) < 0) {
			return (EPKG_FATAL);
		}
+
		printed = true;
	}

-
	if (fputc('\n', f) < 0)
-
		return (EPKG_FATAL);
+
	if (!printed)
+
		if (fputc('\n', f) < 0)
+
			return (EPKG_FATAL);

	return (EPKG_OK);
}
modified libpkg/pkg_jobs.c
@@ -157,7 +157,7 @@ pkg_jobs_add_req(struct pkg_jobs *j, const char *origin, struct pkg *pkg, bool a
{
	struct pkg_job_request *req;

-
	req = malloc(sizeof (struct pkg_job_request));
+
	req = calloc(1, sizeof (struct pkg_job_request));
	if (req == NULL) {
		pkg_emit_errno("malloc", "struct pkg_job_request");
		return;