Commit 41ad2c65 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Teach VCC to do modules on INT, this is handy in vcl_synth{}:

    sub vcl_synth {
        if (resp.status == 12404) {
            [...]       // this specific 404
        } else if (resp.status % 1000 == 404) {
            [...]       // all other 404's
        }
    }
parent 6483ae21
......@@ -56,6 +56,13 @@ varnish v1 -errvcl {BOOL + BOOL not possible.} {
}
}
varnish v1 -errvcl {Operator % only possible on INT} {
sub vcl_recv {
if (req.ttl % 1000) {
}
}
}
varnish v1 -vcl {
backend b { .host = "${localhost}"; }
sub vcl_recv {
......
......@@ -123,6 +123,7 @@ varnish v1 -vcl+backend {
}
set resp.status = 22302;
set resp.reason = "Wrong Postcode";
set resp.http.residual = resp.status % 10000;
return (deliver);
}
} -start
......@@ -159,6 +160,7 @@ client c1 {
txreq -url "/synth"
rxresp
expect resp.status == 302
expect resp.http.residual == 2302
expect resp.reason == "Wrong Postcode"
} -run
......
......@@ -911,13 +911,20 @@ vcc_expr_mul(struct vcc *tl, struct expr **e, vcc_type_t fmt)
struct expr *e2;
vcc_type_t f2;
struct token *tk;
char buf[24];
*e = NULL;
vcc_expr4(tl, e, fmt);
ERRCHK(tl);
AN(*e);
while (tl->t->tok == '*' || tl->t->tok == '/') {
while (tl->t->tok == '*' || tl->t->tok == '/' || tl->t->tok == '%') {
if (tl->t->tok == '%' && ((*e)->fmt != INT)) {
VSB_printf(tl->sb,
"Operator %% only possible on INT.\n");
vcc_ErrWhere(tl, tl->t);
return;
}
f2 = (*e)->fmt->multype;
if (f2 == NULL) {
VSB_printf(tl->sb,
......@@ -936,10 +943,8 @@ vcc_expr_mul(struct vcc *tl, struct expr **e, vcc_type_t fmt)
vcc_ErrWhere(tl, tk);
return;
}
if (tk->tok == '*')
*e = vcc_expr_edit(tl, (*e)->fmt, "(\v1*\v2)", *e, e2);
else
*e = vcc_expr_edit(tl, (*e)->fmt, "(\v1/\v2)", *e, e2);
bprintf(buf, "(\v1%c\v2)", tk->tok);
*e = vcc_expr_edit(tl, (*e)->fmt, buf, *e, e2);
}
}
......
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