[master] f0de32ec0 Convert VRT_synth_page() to take STRANDS

Poul-Henning Kamp phk at FreeBSD.org
Thu Jun 20 20:27:11 UTC 2019


commit f0de32ec0b9353d169566907d3361a429bf2f14e
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Jun 20 20:26:01 2019 +0000

    Convert VRT_synth_page() to take STRANDS

diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index 812883fe9..5e68b07d8 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -675,26 +675,19 @@ VRT_Rollback(VRT_CTX, VCL_HTTP hp)
 /*--------------------------------------------------------------------*/
 
 VCL_VOID
-VRT_synth_page(VRT_CTX, const char *str, ...)
+VRT_synth_page(VRT_CTX, VCL_STRANDS s)
 {
-	va_list ap;
-	const char *p;
 	struct vsb *vsb;
+	int i;
 
 	CAST_OBJ_NOTNULL(vsb, ctx->specific, VSB_MAGIC);
-	va_start(ap, str);
-	p = str;
-	while (p != vrt_magic_string_end) {
-		if (p == NULL)
-			p = "(null)";
-		if (VSB_cat(vsb, p)) {
-			VRT_fail(ctx, "synthetic(): %s",
-				 vstrerror(VSB_error(vsb)));
-			break;
-		}
-		p = va_arg(ap, const char *);
+	AN(s);
+	for (i = 0; i < s->n; i++) {
+		if (s->p[i] != NULL)
+			VSB_cat(vsb, s->p[i]);
+		else
+			VSB_cat(vsb, "(null)");
 	}
-	va_end(ap);
 }
 
 /*--------------------------------------------------------------------*/
diff --git a/include/vrt.h b/include/vrt.h
index a5d6d00ff..0d9b91ac1 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -52,6 +52,7 @@
  * binary/load-time compatible, increment MAJOR version
  *
  * unreleased (planned for 2019-09-15)
+ *	VRT_synth_page now takes STRANDS argument
  *	VRT_hashdata() now takes STRANDS argument
  *	VCL_BOOL VRT_Strands2Bool(VCL_STRANDS) added.
  *	VRT_BundleStrands() moved to vcc_interface.h
@@ -450,7 +451,7 @@ VCL_BLOB VRT_blob(VRT_CTX, const char *, const void *, size_t, unsigned);
 VCL_VOID VRT_Rollback(VRT_CTX, VCL_HTTP);
 
 /* Synthetic pages */
-VCL_VOID VRT_synth_page(VRT_CTX, const char *, ...);
+VCL_VOID VRT_synth_page(VRT_CTX, VCL_STRANDS);
 
 /* Backend related */
 VCL_BACKEND VRT_new_backend(VRT_CTX, const struct vrt_backend *);
diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c
index 83c897df4..c243dbcb7 100644
--- a/lib/libvcc/vcc_action.c
+++ b/lib/libvcc/vcc_action.c
@@ -375,7 +375,7 @@ vcc_act_synthetic(struct vcc *tl, struct token *t, struct symbol *sym)
 	vcc_NextToken(tl);
 
 	Fb(tl, 1, "VRT_synth_page(ctx, ");
-	vcc_Expr(tl, STRING_LIST);
+	vcc_Expr(tl, STRANDS);
 	ERRCHK(tl);
 	Fb(tl, 1, ");\n");
 


More information about the varnish-commit mailing list