[master] 50515b2 Handle integers in boolean expressions

Federico Schwindt fgsch at lodoss.net
Wed Sep 14 00:50:09 CEST 2016


Bah, the message should read:

Handle integers in boolean statements

I haven't updated the documentation as I want to talk to Dridi first.

On Tue, Sep 13, 2016 at 11:47 PM, Federico G. Schwindt <fgsch at lodoss.net>
wrote:

>
> commit 50515b2214d38d1eba0331aa0b88e9e6b6687da7
> Author: Federico G. Schwindt <fgsch at lodoss.net>
> Date:   Tue Sep 13 23:40:04 2016 +0100
>
>     Handle integers in boolean expressions
>
>     Zero is false, all other values are true.
>
> diff --git a/bin/varnishtest/tests/v00020.vtc b/bin/varnishtest/tests/
> v00020.vtc
> index cd0ab28..3fd7e69 100644
> --- a/bin/varnishtest/tests/v00020.vtc
> +++ b/bin/varnishtest/tests/v00020.vtc
> @@ -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"; }
> diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c
> index 4ced132..7d594cf 100644
> --- a/lib/libvcc/vcc_expr.c
> +++ b/lib/libvcc/vcc_expr.c
> @@ -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;
>         }
>
> _______________________________________________
> varnish-commit mailing list
> varnish-commit at varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-commit/attachments/20160913/02f7f2f8/attachment-0001.html>


More information about the varnish-commit mailing list