[master] 938e872 Add STRING + REAL support

Federico G. Schwindt fgsch at lodoss.net
Mon Dec 15 18:50:17 CET 2014


commit 938e8724da75740ee037ffe08bae60bebc83b277
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date:   Sun Dec 14 17:59:42 2014 +0000

    Add STRING + REAL support

diff --git a/bin/varnishtest/tests/v00020.vtc b/bin/varnishtest/tests/v00020.vtc
index f9be7ec..a9e9d3b 100644
--- a/bin/varnishtest/tests/v00020.vtc
+++ b/bin/varnishtest/tests/v00020.vtc
@@ -97,6 +97,7 @@ varnish v1 -vcl {
 	sub vcl_recv {
 		set req.http.foo = "foo" + "bar";
 		set req.http.foo = "foo" + 1;
+		set req.http.foo = "foo" + 1.5;
 		set req.http.foo = "foo" + now;
 
 		set req.http.foo = now + 1s;
diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c
index 49214cc..1e46792 100644
--- a/lib/libvcc/vcc_expr.c
+++ b/lib/libvcc/vcc_expr.c
@@ -785,6 +785,7 @@ vcc_expr4(struct vcc *tl, struct expr **e, enum var_type fmt)
 	const char *ip;
 	const struct symbol *sym;
 	double d;
+	int i;
 
 	*e = NULL;
 	if (tl->t->tok == '(') {
@@ -878,9 +879,15 @@ vcc_expr4(struct vcc *tl, struct expr **e, enum var_type fmt)
 		} else if (fmt == REAL) {
 			e1 = vcc_mk_expr(REAL, "%f", vcc_DoubleVal(tl));
 			ERRCHK(tl);
-		} else {
+		} else if (fmt == INT) {
 			e1 = vcc_mk_expr(INT, "%.*s", PF(tl->t));
 			vcc_NextToken(tl);
+		} else {
+			vcc_NumVal(tl, &d, &i);
+			if (i)
+				e1 = vcc_mk_expr(REAL, "%f", d);
+			else
+				e1 = vcc_mk_expr(INT, "%ld", (long)d);
 		}
 		e1->constant = EXPR_CONST;
 		*e = e1;



More information about the varnish-commit mailing list