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
8db663a8
Commit
8db663a8
authored
May 21, 2021
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split number handling into separate function.
parent
0abf0df5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
21 deletions
+33
-21
vcc_expr.c
lib/libvcc/vcc_expr.c
+33
-21
No files found.
lib/libvcc/vcc_expr.c
View file @
8db663a8
...
...
@@ -672,6 +672,38 @@ vcc_Eval_SymFunc(struct vcc *tl, struct expr **e, struct token *t,
}
}
/*--------------------------------------------------------------------
*/
static
void
vcc_number
(
struct
vcc
*
tl
,
struct
expr
**
e
,
vcc_type_t
fmt
,
const
char
*
sign
)
{
VCL_INT
vi
;
struct
expr
*
e1
;
struct
token
*
t
;
assert
(
fmt
!=
VOID
);
if
(
fmt
==
BYTES
)
{
vcc_ByteVal
(
tl
,
&
vi
);
ERRCHK
(
tl
);
e1
=
vcc_mk_expr
(
BYTES
,
"%ju"
,
(
intmax_t
)
vi
);
}
else
{
t
=
tl
->
t
;
vcc_NextToken
(
tl
);
if
(
tl
->
t
->
tok
==
ID
)
{
e1
=
vcc_mk_expr
(
DURATION
,
"(%s%.*s) * %g"
,
sign
,
PF
(
t
),
vcc_DurationUnit
(
tl
));
ERRCHK
(
tl
);
}
else
if
(
fmt
==
REAL
||
t
->
tok
==
FNUM
)
{
e1
=
vcc_mk_expr
(
REAL
,
"%s%.*s"
,
sign
,
PF
(
t
));
}
else
{
e1
=
vcc_mk_expr
(
INT
,
"%s%.*s"
,
sign
,
PF
(
t
));
}
}
e1
->
constant
=
EXPR_CONST
;
*
e
=
e1
;
}
/*--------------------------------------------------------------------
* SYNTAX:
* Expr5:
...
...
@@ -689,7 +721,6 @@ vcc_expr5(struct vcc *tl, struct expr **e, vcc_type_t fmt)
const
char
*
ip
,
*
sign
;
struct
token
*
t
;
struct
symbol
*
sym
;
VCL_INT
vi
;
sign
=
""
;
*
e
=
NULL
;
...
...
@@ -803,26 +834,7 @@ vcc_expr5(struct vcc *tl, struct expr **e, vcc_type_t fmt)
/* FALLTHROUGH */
case
FNUM
:
case
CNUM
:
assert
(
fmt
!=
VOID
);
if
(
fmt
==
BYTES
)
{
vcc_ByteVal
(
tl
,
&
vi
);
ERRCHK
(
tl
);
e1
=
vcc_mk_expr
(
BYTES
,
"%ju"
,
(
intmax_t
)
vi
);
}
else
{
t
=
tl
->
t
;
vcc_NextToken
(
tl
);
if
(
tl
->
t
->
tok
==
ID
)
{
e1
=
vcc_mk_expr
(
DURATION
,
"(%s%.*s) * %g"
,
sign
,
PF
(
t
),
vcc_DurationUnit
(
tl
));
ERRCHK
(
tl
);
}
else
if
(
fmt
==
REAL
||
t
->
tok
==
FNUM
)
{
e1
=
vcc_mk_expr
(
REAL
,
"%s%.*s"
,
sign
,
PF
(
t
));
}
else
{
e1
=
vcc_mk_expr
(
INT
,
"%s%.*s"
,
sign
,
PF
(
t
));
}
}
e1
->
constant
=
EXPR_CONST
;
*
e
=
e1
;
vcc_number
(
tl
,
e
,
fmt
,
sign
);
return
;
case
CBLOB
:
e1
=
vcc_new_expr
(
BLOB
);
...
...
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