Discussion:
UCL library bug
Allan Jude
2021-03-18 16:23:33 UTC
Permalink
Hello,
I am using the ucl library to write in a file 64bit values. The data type
is uint64_t or int64_t; on write I use %lu or %ld regarding the type and
I read using %ld only and for small value it works, for values like
18,374,686,479,671,672,848
the ucl type type is recognized as UCL_STRING instead of UCL_INT and I
don't know why this is happening. Is there a bug in the library?
Does it help if you use %lld instead? Or maybe %jd ?
_______________________________________________
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
There is an ENUM called ucl_string_flags that controls how a string is
parsed, it includes options for parsing it as a boolean, as int or
double, or as a timestamp.

We could extend this, and add UCL_STRING_PARSE_UINT or something, then
change ucl_maybe_parse_number() to respect that flag, and then use
strtoumax() instead of strtoimax().

I think the reason it uses strtoimax() by default, is that JSON only
supports signed integers.
--
Allan Jude
Loading...