[4.0] 2ecbcb4 Add STRING + REAL support
Lasse Karstensen
lkarsten at varnish-software.com
Thu Jan 15 16:35:43 CET 2015
commit 2ecbcb468b31c964ad87faf8910f0a9406c0173a
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 3557a4b..c9da0b7 100644
--- a/lib/libvcc/vcc_expr.c
+++ b/lib/libvcc/vcc_expr.c
@@ -672,6 +672,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 == '(') {
@@ -765,9 +766,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