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

Add REAL add/sub/mul/div REAL support

Prompted by someone on #varnish.  OK'd by phk.
parent b9946b4b
......@@ -102,10 +102,18 @@ varnish v1 -vcl {
set req.http.foo = now + 1s;
set req.http.foo = now - 1s;
set req.http.foo = now - now;
set req.http.foo = 1 + 1;
set req.http.foo = 1 - 1;
set req.http.foo = 3 * 2;
set req.http.foo = 3 / 2;
set req.http.foo = 3.6 + 1.4;
set req.http.foo = 3.6 - 1.4;
set req.http.foo = 3.6 * 1.4;
set req.http.foo = 3.6 / 1.4;
set req.ttl = 1s;
}
......
......@@ -942,6 +942,7 @@ vcc_expr_mul(struct vcc *tl, struct expr **e, enum var_type fmt)
case INT: f2 = INT; break;
case DURATION: f2 = REAL; break;
case BYTES: f2 = REAL; break;
case REAL: f2 = REAL; break;
default:
if (tl->t->tok != '*' && tl->t->tok != '/')
return;
......@@ -1049,6 +1050,8 @@ vcc_expr_add(struct vcc *tl, struct expr **e, enum var_type fmt)
/* OK */
} else if ((*e)->fmt == INT && e2->fmt == INT) {
/* OK */
} else if ((*e)->fmt == REAL && e2->fmt == REAL) {
/* OK */
} else if ((*e)->fmt == DURATION && e2->fmt == DURATION) {
/* OK */
} else if (tk->tok == '+' &&
......
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