Skip to content

Commit f049a1e

Browse files
llyyrkasper93
authored andcommitted
m_option: fix scientific notation timestamp parsing
Fixes: a173b47
1 parent 7a59a12 commit f049a1e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

options/m_option.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2673,8 +2673,10 @@ static int parse_timestring(struct bstr str, double *time, char endchar)
26732673
bool neg = bstr_eatstart0(&str, "-");
26742674
if (!neg)
26752675
bstr_eatstart0(&str, "+");
2676-
if (bstrchr(str, '-') >= 0 || bstrchr(str, '+') >= 0)
2677-
return 0; /* the timestamp shouldn't contain anymore +/- after this point */
2676+
bool sci = bstr_find0(str, "e-") >= 0 || bstr_find0(str, "e+") >= 0;
2677+
/* non-scientific notation timestamps shouldn't contain anymore +/- after this point */
2678+
if (!sci && (bstrchr(str, '-') >= 0 || bstrchr(str, '+') >= 0))
2679+
return 0;
26782680
if (bstr_sscanf(str, "%u:%u:%lf%n", &h, &m, &s, &len) >= 3) {
26792681
if (m >= 60 || s >= 60)
26802682
return 0; /* minutes or seconds are out of range */

0 commit comments

Comments
 (0)