Commit 2ecbcb46 authored by Federico G. Schwindt's avatar Federico G. Schwindt Committed by Lasse Karstensen

Add STRING + REAL support

parent 7ecfc0b1
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment