[master] 5e1e35a Fix incorrect representation when using reals

Federico G. Schwindt fgsch at lodoss.net
Mon Jun 30 14:23:26 CEST 2014


commit 5e1e35a5ff5f984e2a8a85c9b1d6b5e44b5caa07
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date:   Mon Jun 30 13:18:11 2014 +0100

    Fix incorrect representation when using reals
    
    Fixes #1532

diff --git a/bin/varnishtest/tests/r01532.vtc b/bin/varnishtest/tests/r01532.vtc
new file mode 100644
index 0000000..c189f55
--- /dev/null
+++ b/bin/varnishtest/tests/r01532.vtc
@@ -0,0 +1,20 @@
+varnishtest "Incorrect representation when using reals - #1532"
+
+server s1 {
+	rxreq
+	txresp
+} -start
+
+varnish v1 -vcl+backend {
+	import ${vmod_std};
+
+	sub vcl_deliver {
+		set resp.http.x-foo = std.real2time(1140618699.00);
+	}
+} -start
+
+client c1 {
+	txreq
+	rxresp
+	expect resp.http.x-foo == "Wed, 22 Feb 2006 14:31:39 GMT"
+} -run
diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c
index 8e4e234..0d39073 100644
--- a/lib/libvcc/vcc_expr.c
+++ b/lib/libvcc/vcc_expr.c
@@ -749,7 +749,7 @@ vcc_expr4(struct vcc *tl, struct expr **e, enum var_type fmt)
 			e1 = vcc_mk_expr(BYTES, "%.1f", d);
 			ERRCHK(tl);
 		} else if (fmt == REAL) {
-			e1 = vcc_mk_expr(REAL, "%g", vcc_DoubleVal(tl));
+			e1 = vcc_mk_expr(REAL, "%f", vcc_DoubleVal(tl));
 			ERRCHK(tl);
 		} else {
 			e1 = vcc_mk_expr(INT, "%.*s", PF(tl->t));



More information about the varnish-commit mailing list