From 9cde2ebe8f908476ea864490f6ab4ee5c5caa4ca Mon Sep 17 00:00:00 2001 From: Oliver Hartkopp Date: Sun, 10 May 2020 14:41:34 +0200 Subject: [PATCH] asc2log: fix date string detection The former check was too complex and did not catch all valid cases. Signed-off-by: Oliver Hartkopp --- asc2log.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/asc2log.c b/asc2log.c index 404d663..8ac7e86 100644 --- a/asc2log.c +++ b/asc2log.c @@ -318,12 +318,9 @@ void eval_canfd(char* buf, struct timeval *date_tvp, char timestamps, int dplace int get_date(struct timeval *tv, char *date) { - char ctmp[14]; - int itmp; - struct tm tms; - if (sscanf(date, "%9s %d %13s %3s %d", ctmp, &itmp, ctmp, ctmp, &itmp) == 5) { + if (strcasestr(date, " pm ") != NULL) { /* assume EN/US date due to existing am/pm field */ if (!setlocale(LC_TIME, "en_US")) { @@ -342,9 +339,6 @@ int get_date(struct timeval *tv, char *date) { } else { /* assume DE date due to non existing am/pm field */ - if (sscanf(date, "%9s %d %13s %d", ctmp, &itmp, ctmp, &itmp) != 4) - return 1; - if (!setlocale(LC_TIME, "de_DE")) { fprintf(stderr, "Setting locale to 'de_DE' failed!\n"); return 1;