Skip to content

Commit

Permalink
update rapidjson to current state
Browse files Browse the repository at this point in the history
  • Loading branch information
christoph-cullmann committed Mar 29, 2024
1 parent 68c78b8 commit e713a55
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions 3rdparty/rapidjson/allocators.h
Original file line number Diff line number Diff line change
Expand Up @@ -497,9 +497,9 @@ class StdAllocator :
#endif

/* implicit */
StdAllocator(const BaseAllocator& allocator) RAPIDJSON_NOEXCEPT :
StdAllocator(const BaseAllocator& baseAllocator) RAPIDJSON_NOEXCEPT :
allocator_type(),
baseAllocator_(allocator)
baseAllocator_(baseAllocator)
{ }

~StdAllocator() RAPIDJSON_NOEXCEPT
Expand Down
4 changes: 2 additions & 2 deletions 3rdparty/rapidjson/document.h
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ class GenericValue {
return false;
for (ConstMemberIterator lhsMemberItr = MemberBegin(); lhsMemberItr != MemberEnd(); ++lhsMemberItr) {
typename RhsType::ConstMemberIterator rhsMemberItr = rhs.FindMember(lhsMemberItr->name);
if (rhsMemberItr == rhs.MemberEnd() || lhsMemberItr->value != rhsMemberItr->value)
if (rhsMemberItr == rhs.MemberEnd() || (!(lhsMemberItr->value == rhsMemberItr->value)))
return false;
}
return true;
Expand All @@ -1042,7 +1042,7 @@ class GenericValue {
if (data_.a.size != rhs.data_.a.size)
return false;
for (SizeType i = 0; i < data_.a.size; i++)
if ((*this)[i] != rhs[i])
if (!((*this)[i] == rhs[i]))
return false;
return true;

Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/rapidjson/internal/regex.h
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ class GenericRegexSearch {
RAPIDJSON_ASSERT(regex_.IsValid());
if (!allocator_)
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator)();
stateSet_ = static_cast<unsigned*>(allocator_->Malloc(GetStateSetSize()));
stateSet_ = static_cast<uint32_t*>(allocator_->Malloc(GetStateSetSize()));
state0_.template Reserve<SizeType>(regex_.stateCount_);
state1_.template Reserve<SizeType>(regex_.stateCount_);
}
Expand Down
28 changes: 14 additions & 14 deletions 3rdparty/rapidjson/schema.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,9 @@

#if !defined(RAPIDJSON_SCHEMA_USE_INTERNALREGEX)
#define RAPIDJSON_SCHEMA_USE_INTERNALREGEX 1
#else
#define RAPIDJSON_SCHEMA_USE_INTERNALREGEX 0
#endif

#if !RAPIDJSON_SCHEMA_USE_INTERNALREGEX && defined(RAPIDJSON_SCHEMA_USE_STDREGEX) && (__cplusplus >=201103L || (defined(_MSC_VER) && _MSC_VER >= 1800))
#define RAPIDJSON_SCHEMA_USE_STDREGEX 1
#else
#if !defined(RAPIDJSON_SCHEMA_USE_STDREGEX) || !(__cplusplus >=201103L || (defined(_MSC_VER) && _MSC_VER >= 1800))
#define RAPIDJSON_SCHEMA_USE_STDREGEX 0
#endif

Expand Down Expand Up @@ -179,8 +175,6 @@ RAPIDJSON_MULTILINEMACRO_END
#endif

//! Combination of validate flags
/*! \see
*/
enum ValidateFlag {
kValidateNoFlags = 0, //!< No flags are set.
kValidateContinueOnErrorFlag = 1, //!< Don't stop after first validation error.
Expand Down Expand Up @@ -369,7 +363,9 @@ class Hasher {
uint64_t h = Hash(0, kObjectType);
uint64_t* kv = stack_.template Pop<uint64_t>(memberCount * 2);
for (SizeType i = 0; i < memberCount; i++)
h ^= Hash(kv[i * 2], kv[i * 2 + 1]); // Use xor to achieve member order insensitive
// Issue #2205
// Hasing the key to avoid key=value cases with bug-prone zero-value hash
h ^= Hash(Hash(0, kv[i * 2]), kv[i * 2 + 1]); // Use xor to achieve member order insensitive
*stack_.template Push<uint64_t>() = h;
return true;
}
Expand Down Expand Up @@ -407,7 +403,7 @@ class Hasher {

bool WriteBuffer(Type type, const void* data, size_t len) {
// FNV-1a from http://isthe.com/chongo/tech/comp/fnv/
uint64_t h = Hash(RAPIDJSON_UINT64_C2(0x84222325, 0xcbf29ce4), type);
uint64_t h = Hash(RAPIDJSON_UINT64_C2(0xcbf29ce4, 0x84222325), type);
const unsigned char* d = static_cast<const unsigned char*>(data);
for (size_t i = 0; i < len; i++)
h = Hash(h, d[i]);
Expand Down Expand Up @@ -1645,9 +1641,13 @@ class Schema {

bool CheckDoubleMultipleOf(Context& context, double d) const {
double a = std::abs(d), b = std::abs(multipleOf_.GetDouble());
double q = std::floor(a / b);
double r = a - q * b;
if (r > 0.0) {
double q = a / b;
double qRounded = std::floor(q + 0.5);
double scaledEpsilon = (q + qRounded) * std::numeric_limits<double>::epsilon();
double difference = std::abs(qRounded - q);
bool isMultiple = (difference <= scaledEpsilon)
|| (difference < std::numeric_limits<double>::min());
if (!isMultiple) {
context.error_handler.NotMultipleOf(d, multipleOf_);
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorMultipleOf);
}
Expand Down Expand Up @@ -2560,7 +2560,7 @@ class GenericSchemaValidator :
// If reporting all errors, the stack will be empty, so return "errors".
const Ch* GetInvalidSchemaKeyword() const {
if (!schemaStack_.Empty()) return CurrentContext().invalidKeyword;
if (GetContinueOnErrors() && !error_.ObjectEmpty()) return (const Ch*)GetErrorsString();
if (GetContinueOnErrors() && !error_.ObjectEmpty()) return static_cast<const Ch*>(GetErrorsString());
return 0;
}

Expand Down Expand Up @@ -2902,7 +2902,7 @@ class GenericSchemaValidator :
ISchemaValidator* sv = new (GetStateAllocator().Malloc(sizeof(GenericSchemaValidator))) GenericSchemaValidator(*schemaDocument_, root, documentStack_.template Bottom<char>(), documentStack_.GetSize(),
depth_ + 1,
&GetStateAllocator());
sv->SetValidateFlags(inheritContinueOnErrors ? GetValidateFlags() : GetValidateFlags() & ~(unsigned)kValidateContinueOnErrorFlag);
sv->SetValidateFlags(inheritContinueOnErrors ? GetValidateFlags() : GetValidateFlags() & ~static_cast<unsigned>(kValidateContinueOnErrorFlag));
return sv;
}

Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/rapidjson/writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ class Writer {

bool WriteDouble(double d) {
if (internal::Double(d).IsNanOrInf()) {
if (!(writeFlags & kWriteNanAndInfFlag))
if (!(writeFlags & kWriteNanAndInfFlag) && !(writeFlags & kWriteNanAndInfNullFlag))
return false;
if (writeFlags & kWriteNanAndInfNullFlag) {
PutReserve(*os_, 4);
Expand Down

0 comments on commit e713a55

Please sign in to comment.