mirror of
https://github.com/linux-can/can-utils.git
synced 2026-08-05 06:20:00 +02:00
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>
This commit is contained in:
@@ -190,6 +190,7 @@ int main(int argc, char **argv)
|
|||||||
FILE *infile = stdin;
|
FILE *infile = stdin;
|
||||||
FILE *outfile = stdout;
|
FILE *outfile = stdout;
|
||||||
static int maxdev, devno, i, crlf, fdfmt, nortrdlc, d4, opt, mtu;
|
static int maxdev, devno, i, crlf, fdfmt, nortrdlc, d4, opt, mtu;
|
||||||
|
int print_banner = 1;
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "I:O:4nfr?")) != -1) {
|
while ((opt = getopt(argc, argv, "I:O:4nfr?")) != -1) {
|
||||||
switch (opt) {
|
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;
|
start_tv = tv;
|
||||||
fprintf(outfile, "date %s", ctime(&start_tv.tv_sec));
|
fprintf(outfile, "date %s", ctime(&start_tv.tv_sec));
|
||||||
fprintf(outfile, "base hex timestamps absolute%s",
|
fprintf(outfile, "base hex timestamps absolute%s",
|
||||||
|
|||||||
Reference in New Issue
Block a user