Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnishevent
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
varnishevent
Commits
312a0c45
Commit
312a0c45
authored
Sep 20, 2015
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
format_tim() parses timestamps by hand, rather than using sscanf()
parent
936275c9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
1 deletion
+27
-1
format.c
src/format.c
+27
-1
No files found.
src/format.c
View file @
312a0c45
...
...
@@ -494,6 +494,32 @@ format_s_backend(const tx_t *tx, const arg_t *args, char **s, size_t *len)
format_slt
(
tx
,
SLT_BerespStatus
,
-
1
,
-
1
,
s
,
len
);
}
static
inline
const
char
*
fmt_parse_unsigned
(
const
char
*
t
,
unsigned
*
num
)
{
unsigned
new
;
*
num
=
0
;
while
(
isdigit
(
*
t
))
{
new
=
*
num
*
10
+
(
*
t
++
-
'0'
);
if
(
new
<
*
num
)
return
NULL
;
*
num
=
new
;
}
return
t
;
}
static
inline
int
fmt_parse_tim
(
const
char
*
ts
,
unsigned
*
secs
,
unsigned
*
usecs
)
{
const
char
*
t
=
fmt_parse_unsigned
(
ts
,
secs
);
if
(
t
==
NULL
||
*
t
!=
'.'
)
return
0
;
t
++
;
if
(
fmt_parse_unsigned
(
t
,
usecs
)
==
NULL
)
return
0
;
return
1
;
}
static
inline
void
format_tim
(
const
tx_t
*
tx
,
int
start_idx
,
const
char
*
fmt
,
char
**
s
,
size_t
*
len
)
...
...
@@ -511,7 +537,7 @@ format_tim(const tx_t *tx, int start_idx, const char *fmt, char **s,
ts
=
get_fld
(
data
,
0
,
len
);
if
(
ts
==
NULL
)
return
;
if
(
sscanf
(
ts
,
"%d.%u"
,
&
secs
,
&
usecs
)
!=
2
)
if
(
!
fmt_parse_tim
(
ts
,
&
secs
,
&
usecs
)
)
return
;
assert
(
usecs
<
1000000
);
t
=
(
time_t
)
secs
;
...
...
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