Try to parse timestamps as double, if int64 parse fails
This commit is contained in:
parent
90b96799ac
commit
d3efb829b5
|
@ -409,12 +409,15 @@ static PyObject *Rocket_append_string(Rocket *self, PyObject *args)
|
|||
|
||||
/* Extract timestamp */
|
||||
t64.i = strtoll(buf, &endptr, 10);
|
||||
if (endptr == buf)
|
||||
return raise_str(linenum, buf - linestart + 1,
|
||||
ERR_OTHER, "bad timestamp");
|
||||
if (!isspace(*endptr))
|
||||
return raise_str(linenum, buf - linestart + 1,
|
||||
ERR_OTHER, "timestamp isn't an int");
|
||||
if (endptr == buf || !isspace(*endptr)) {
|
||||
/* Try parsing as a double instead */
|
||||
t64.d = strtod(buf, &endptr);
|
||||
if (endptr == buf)
|
||||
goto bad_timestamp;
|
||||
if (!isspace(*endptr))
|
||||
goto cant_parse_value;
|
||||
t64.i = round(t64.d);
|
||||
}
|
||||
if (t64.i <= last_timestamp)
|
||||
return raise_int(linenum, buf - linestart + 1,
|
||||
ERR_NON_MONOTONIC, t64.i);
|
||||
|
@ -497,6 +500,9 @@ static PyObject *Rocket_append_string(Rocket *self, PyObject *args)
|
|||
err:
|
||||
PyErr_SetFromErrno(PyExc_OSError);
|
||||
return NULL;
|
||||
bad_timestamp:
|
||||
return raise_str(linenum, buf - linestart + 1,
|
||||
ERR_OTHER, "bad timestamp");
|
||||
cant_parse_value:
|
||||
return raise_str(linenum, buf - linestart + 1,
|
||||
ERR_OTHER, "can't parse value");
|
||||
|
|
Loading…
Reference in New Issue
Block a user