Commit 50515b22 authored by Federico G. Schwindt's avatar Federico G. Schwindt

Handle integers in boolean expressions

Zero is false, all other values are true.
parent cd29edae
......@@ -127,6 +127,16 @@ varnish v1 -vcl {
}
}
varnish v1 -vcl {
import std;
backend b { .host = "127.0.0.1"; }
sub vcl_recv {
if (std.integer("1", 1)) {
}
}
}
# XXX: not the most clear error message
varnish v1 -errvcl {STRING - STRING not possible.} {
backend b { .host = "127.0.0.1"; }
......
......@@ -1200,7 +1200,9 @@ vcc_expr_cmp(struct vcc *tl, struct expr **e, vcc_type_t fmt)
default:
break;
}
if (fmt == BOOL && ((*e)->fmt == STRING || (*e)->fmt == BACKEND)) {
if (fmt == BOOL &&
((*e)->fmt == STRING || (*e)->fmt == BACKEND ||
(*e)->fmt == INT)) {
*e = vcc_expr_edit(BOOL, "(\v1 != 0)", *e, NULL);
return;
}
......
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