Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
f176f05c
Commit
f176f05c
authored
Sep 09, 2016
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow automatic promotion from INT to REAL.
Fixes #2084
parent
a630df00
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
2 deletions
+32
-2
r02084.vtc
bin/varnishtest/tests/r02084.vtc
+27
-0
vcc_expr.c
lib/libvcc/vcc_expr.c
+5
-2
No files found.
bin/varnishtest/tests/r02084.vtc
0 → 100644
View file @
f176f05c
varnishtest "REAL - INT types"
server s1 {
rxreq
txresp
} -start
varnish v1 -vcl+backend {
import std;
sub vcl_deliver {
set resp.http.add = 10.0 + std.integer(req.http.foo, 0);
set resp.http.sub = 10.0 - std.integer(req.http.foo, 0);
set resp.http.mul = 10.0 * std.integer(req.http.foo, 0);
set resp.http.div = 10.0 / std.integer(req.http.foo, 0);
}
} -start
client c1 {
txreq -hdr "foo: 3"
rxresp
expect resp.http.add == 13.000
expect resp.http.sub == 7.000
expect resp.http.mul == 30.000
expect resp.http.div == 3.333
} -run
lib/libvcc/vcc_expr.c
View file @
f176f05c
...
...
@@ -910,14 +910,13 @@ vcc_expr_mul(struct vcc *tl, struct expr **e, vcc_type_t fmt)
vcc_NextToken
(
tl
);
vcc_expr4
(
tl
,
&
e2
,
f2
);
ERRCHK
(
tl
);
if
(
e2
->
fmt
->
multype
==
NULL
)
{
if
(
e2
->
fmt
!=
REAL
&&
e2
->
fmt
!=
INT
)
{
VSB_printf
(
tl
->
sb
,
"%s %.*s %s not possible.
\n
"
,
f2
->
name
,
PF
(
tk
),
e2
->
fmt
->
name
);
vcc_ErrWhere
(
tl
,
tk
);
return
;
}
assert
(
e2
->
fmt
==
f2
);
if
(
tk
->
tok
==
'*'
)
*
e
=
vcc_expr_edit
(
f3
,
"(
\v
1*
\v
2)"
,
*
e
,
e2
);
else
...
...
@@ -1017,6 +1016,10 @@ vcc_expr_add(struct vcc *tl, struct expr **e, vcc_type_t fmt)
ADD_OK
(
"-"
,
INT
,
INT
,
INT
);
ADD_OK
(
"+"
,
REAL
,
REAL
,
REAL
);
ADD_OK
(
"-"
,
REAL
,
REAL
,
REAL
);
ADD_OK
(
"+"
,
REAL
,
INT
,
REAL
);
ADD_OK
(
"-"
,
REAL
,
INT
,
REAL
);
ADD_OK
(
"+"
,
INT
,
REAL
,
REAL
);
ADD_OK
(
"-"
,
INT
,
REAL
,
REAL
);
#undef ADD_OK
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment