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
c50ff59c
Commit
c50ff59c
authored
Jun 01, 2021
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch std_conversion onto SF_number functions
parent
c4257032
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
10 deletions
+20
-10
m00015.vtc
bin/varnishtest/tests/m00015.vtc
+1
-1
vmod_std_conversions.c
vmod/vmod_std_conversions.c
+19
-9
No files found.
bin/varnishtest/tests/m00015.vtc
View file @
c50ff59c
...
...
@@ -98,7 +98,7 @@ client c1 {
txreq -hdr "foo: 999999999999.999" \
-hdr "bytes: 999999999999b" \
-hdr "duration: 999999999999.999s" \
-hdr "integer: 999999999999.
999
" \
-hdr "integer: 999999999999.
000
" \
-hdr "time: 999999999999.999"
rxresp
expect resp.http.converted == 999999999999.999
...
...
vmod/vmod_std_conversions.c
View file @
c50ff59c
...
...
@@ -147,8 +147,8 @@ vmod_bytes(VRT_CTX, struct VARGS(bytes) *a)
VCL_INT
v_matchproto_
(
td_std_integer
)
vmod_integer
(
VRT_CTX
,
struct
VARGS
(
integer
)
*
a
)
{
const
char
*
e
;
double
r
;
const
char
*
p
,
*
errtxt
=
NULL
;
double
r
,
tmp
;
int
nargs
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
...
...
@@ -167,9 +167,11 @@ vmod_integer(VRT_CTX, struct VARGS(integer) *a)
return
(
a
->
bytes
);
if
(
a
->
valid_s
&&
a
->
s
!=
NULL
)
{
r
=
VNUMpfx
(
a
->
s
,
&
e
);
if
(
e
!=
NULL
)
r
=
NAN
;
p
=
a
->
s
;
r
=
SF_Parse_Number
(
&
p
,
&
errtxt
);
if
(
!
errno
&&
*
p
==
'\0'
&&
modf
(
r
,
&
tmp
)
==
0
.
0
)
return
(
r
);
r
=
NAN
;
}
if
(
a
->
valid_duration
)
...
...
@@ -190,7 +192,10 @@ vmod_integer(VRT_CTX, struct VARGS(integer) *a)
if
(
a
->
valid_fallback
)
return
(
a
->
fallback
);
VRT_fail
(
ctx
,
"std.integer: conversion failed"
);
if
(
errtxt
!=
NULL
)
VRT_fail
(
ctx
,
"std.integer: conversion failed: %s"
,
errtxt
);
else
VRT_fail
(
ctx
,
"std.integer: conversion failed"
);
return
(
0
);
}
...
...
@@ -234,6 +239,7 @@ VCL_REAL v_matchproto_(td_std_real)
vmod_real
(
VRT_CTX
,
struct
VARGS
(
real
)
*
a
)
{
VCL_REAL
r
;
const
char
*
p
,
*
errtxt
=
NULL
;
int
nargs
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
...
...
@@ -260,15 +266,19 @@ vmod_real(VRT_CTX, struct VARGS(real) *a)
return
((
VCL_REAL
)
a
->
time
);
if
(
a
->
valid_s
&&
a
->
s
!=
NULL
)
{
r
=
VNUM
(
a
->
s
);
if
(
!
isnan
(
r
))
p
=
a
->
s
;
r
=
SF_Parse_Decimal
(
&
p
,
&
errtxt
);
if
(
!
errno
&&
*
p
==
'\0'
)
return
(
r
);
}
if
(
a
->
valid_fallback
)
return
(
a
->
fallback
);
VRT_fail
(
ctx
,
"std.real: conversion failed"
);
if
(
errtxt
!=
NULL
)
VRT_fail
(
ctx
,
"std.real: conversion failed: %s"
,
errtxt
);
else
VRT_fail
(
ctx
,
"std.real: conversion failed"
);
return
(
0
);
}
...
...
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