Attached.
Comments? OK?
From 65080bc212609fed77ac01b3821895cc700d4186 Mon Sep 17 00:00:00 2001
From: "Federico G. Schwindt" <[email protected]>
Date: Sun, 14 Dec 2014 17:59:42 +0000
Subject: [PATCH] Add STRING + REAL support
---
bin/varnishtest/tests/v00020.vtc | 1 +
lib/libvcc/vcc_expr.c | 9 ++++++++-
2 files changed, 9 insertions(+), 1 deletion(-)
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 7f1a83e..bd78637 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, "%d", (int)d);
}
e1->constant = EXPR_CONST;
*e = e1;
--
2.1.3
_______________________________________________
varnish-dev mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev