danielaparker / jsoncons

A C++, header-only library for constructing JSON and JSON-like data formats, with JSON Pointer, JSON Patch, JSON Schema, JSONPath, JMESPath, CSV, MessagePack, CBOR, BSON, UBJSON
https://danielaparker.github.io/jsoncons
Other
717 stars 163 forks source link

Multiple fixes for float parsing and boolean pretty print with wjson #406

Closed cschreib-ibex closed 1 year ago

cschreib-ibex commented 1 year ago

Fixes #403 #404 #405.

I changed the CSV parser code to no longer call substr; that allowed compilation and tests to pass.

Thanks. Interesting observation about substr.

Regarding the remaining failure, I wouldn't expect the test to work with gcc 4.8, as gcc 4.8 basic_string had issues with stateful allocators. It's probably enough to suppress the test if

(defined(__GNUC__) && (__GNUC__ == 4) && __GNUC_MINOR__ < 9))
cschreib-ibex commented 1 year ago

On the build failures: I noticed them on my test computer as well. I notice the offending test has a guard against _MSC_VER == 1900; I wasn't sure why it was limited to that specific version, but it appears any VS 2022 version is unable to compile this test at the moment. I can change this to _MSC_VER >= 1900?

Edit: reading some more about the actual issue, this is related to basic_string::substr trying to create a new string object to return, and failing because the custom allocator is not default-constructible. It seems odd to me that it should try to default-construct the allocator, instead of propagting it from the parent string, but this is what the standard seems to mandate:

The returned string is constructed as if by basic_string(data()+pos, count), which implies that the returned string's allocator will be default-constructed

So perhaps the test isn't correct?

cschreib-ibex commented 1 year ago

I changed the CSV parser code to no longer call substr; that allowed compilation and tests to pass.

cschreib-ibex commented 1 year ago

As suggested, I re-added the conditional on the "csv_reader constructors", so it is disabled for GCC <= 4.8.