log2asc: fix logfiles where the timestamp starts with zero
The ASC file banner, e.g.
date Thu Jan 1 01:00:00 1970
base hex timestamps absolute
no internal events logged
should be printed when the first timestamp from the logfile has been
processed. But for logfiles starting with zero (e.g. candump -tz option)
this banner is printed every time the timestamps seconds equals zero.
As it was obviously not a good idea to stick the condition for printing
the banner based on some assumption about the timestamp a new variable
'print_banner' has been introduced.
Reported-by: https://github.com/CaSchmidt
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
pull/438/head
parent
9e08e2272b
commit
58083ad34a
|
|
@ -190,6 +190,7 @@ int main(int argc, char **argv)
|
|||
FILE *infile = stdin;
|
||||
FILE *outfile = stdout;
|
||||
static int maxdev, devno, i, crlf, fdfmt, nortrdlc, d4, opt, mtu;
|
||||
int print_banner = 1;
|
||||
|
||||
while ((opt = getopt(argc, argv, "I:O:4nfr?")) != -1) {
|
||||
switch (opt) {
|
||||
|
|
@ -272,7 +273,8 @@ int main(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
if (!start_tv.tv_sec) { /* print banner */
|
||||
if (print_banner) { /* print banner */
|
||||
print_banner = 0;
|
||||
start_tv = tv;
|
||||
fprintf(outfile, "date %s", ctime(&start_tv.tv_sec));
|
||||
fprintf(outfile, "base hex timestamps absolute%s",
|
||||
|
|
|
|||
Loading…
Reference in New Issue