1018 Commits

Author SHA1 Message Date
Ross Younger
4116912cde Use C++17 fallthrough tag instead of disabling warning
Signed-off-by: Ross Younger <crazyscot@gmail.com>
2019-10-01 20:12:54 +13:00
Milo Yip
d67a69a9cf
Merge pull request #1490 from MalcolmTyrrell/fixCompileErrorInPointerH
Fix vs2017 compile error C2105: '--' needs l-value
2019-09-26 10:08:13 +08:00
Milo Yip
88a1ba9e30 Provide default implementations for move constructor/assignment in GenericMember 2019-09-25 20:20:20 +08:00
Milo Yip
c36b713c47 Disable copy constructor in GenericMember 2019-09-25 18:02:17 +08:00
Etienne Laurin
6102f0bd06 fix template parameter 2019-09-11 17:23:15 +01:00
Etienne Laurin
6fe99777e4 Allow pointer tokens to have non-null-terminated strings 2019-09-11 17:03:35 +01:00
Milo Yip
d87b698d0f Change all GenericMemberIterator from struct to class 2019-06-28 10:37:13 +08:00
ylavic
94fc463801 Add missing curly brackets in STDREGEX's CreatePattern(). 2019-04-29 15:06:52 +02:00
Malcolm Tyrrell
c840a7ae15 Fix vs2017 compile error C2105: '--' needs l-value 2019-04-15 10:00:14 +01:00
Liang ZOU
13687a6e3e
add missing header "ios"
add missing header "ios" for symbol "std:: streamsize"
2019-04-09 10:55:57 +08:00
eisaev
9264a9a7ef
Update allocators.h
Fixed typo
2019-04-03 22:10:30 +05:00
Luka Rahne
40cae03b0d Allow user to define custom RAPIDJSON_NOEXCEPT_ASSERT macro 2019-03-10 20:07:59 +01:00
Milo Yip
3cf4f7c5a0
Merge pull request #727 from mapbox/silence-dereference-null-pointer
Silence false positive clang-tidy warning
2019-03-06 09:33:13 +08:00
Milo Yip
b94c2a1203 Adding swap() for GenericMember 2019-02-08 11:39:25 +08:00
Milo Yip
79a6dabd08
Merge pull request #1439 from ylavic/schema_pointer_allocator
Use the allocator of the Schema for its Pointer.
2019-02-06 19:31:03 +08:00
Léonard Gérard
bf09397285
Correct complexity claim 2019-01-31 22:29:07 -08:00
ylavic
dbb594bdb3 Use the allocator of the Schema for its Pointer.
The Pointer passed to construct the Schema can be from the stack or any
transient storage, so the copy stored in the Schema must have the same
lifetime/allocator as the Schema itself.
2019-01-10 18:42:16 +01:00
Milo Yip
b56eb28575
Merge branch 'master' into pointer_less_than 2018-12-18 09:32:09 +08:00
ylavic
a66cf7924c Allow to (std::)Swap two pointers. 2018-12-17 14:33:32 +01:00
ylavic
eb6ee17d2d Speed up Pointer::operator<().
Speed is more important than alphabetical order (which makes few sense in
JSON in general, and with pointers especially). The use case is indexing
in std containers, i.e. O(log n) with rbtree, so the faster comparison
the better.
2018-12-12 22:32:56 +01:00
ylavic
0e34ed43f4 Rework Pointer::operator<() loop.
I must be too dumb to understand the mess MSVC (32bit only) did with the
previous loop, and to figure out how it might have make it never end.
Anyway, hopefully any compiler can grok this new loop...
2018-12-12 15:15:43 +01:00
ylavic
055f1fa61e Add less than operator to Pointer.
Allows to sort pointers in (std-)containers and/or index by them.
2018-12-10 22:02:25 +01:00
Milo Yip
66eb6067b1
Merge pull request #1425 from ylavic/filereadstream_peek4
Fix off by one in FileReadStream::Peek4()
2018-12-06 23:44:10 +08:00
Milo Yip
b4b0e13b4d
Merge pull request #1424 from ylavic/file_input_streams
Optimize FileReadStream and BasicIStreamWrapper.
2018-12-06 23:43:48 +08:00
ylavic
38d25d7458 Fix FileReadStream::Peek4().
Until Read() reaches EOF, Peek4() must not take off by one in
bufferLast_ into account; otherwise a buffer of size exactly 4 always
returns NULL.
2018-12-06 08:38:21 +01:00
ylavic
8aab3db129 Base buffered BasicIStreamWrapper on the original (better performing) FileReadStream algorithm. 2018-12-06 00:21:05 +01:00
ylavic
2498c5776f Optimize FileReadStream and BasicIStreamWrapper.
On (my) linux, perftest reports:
- ~40% gain for FileReadStream (Take() loop),
- ~10% gain for ReaderParse_DummyHandler_FileReadStream.

With the same logic applied to BasicIStreamWrapper, which thus can now
also be created with a user buffer, performances align with those of
FileReadStream (same buffer size).

The "unbuffered" versions (added for FileReadStream) work solely with
the internal peekBuffer (Ch[4]) and are measured in perftest.  When
performances don't matter much, they can avoid the use of large
stack/heap buffers.
2018-12-05 16:43:54 +01:00
ylavic
be96f4d7fb GenericRegex: don't throw/abort on syntax error (unclosed parenthesis). 2018-12-03 11:42:29 +01:00
Milo Yip
30d92a6399
Merge pull request #1413 from ylavic/schema_regex_leak
Fix a memory leak for invalid std::regex in Schema.
2018-12-03 09:53:39 +08:00
ylavic
3e6956767e Fix a memory leak for invalid std::regex in Schema. 2018-12-01 23:36:45 +01:00
ylavic
b0c96f9baf Use passed in allocator for internal regex parser. 2018-12-01 22:02:48 +01:00
Jean-Claude Monnin
51ca982aa1 Fix warning when NDEBUG is defined [-Wunused-variable]
Because `isPeek()` is side effect free this should not change anything.

The reason this warning is not shown in the unit tests is because the asserts
are always evaluated in the unit test:

#define RAPIDJSON_ASSERT(x) (!(x) ? throw AssertException(RAPIDJSON_STRINGIFY(x)) : (void)0u)
2018-11-21 13:24:06 +01:00
Konstantin Käfer
16872af889 Avoid pointer arithmetic on null pointer to remove undefined behavior
The existing checks triggered undefined behavior when the stack was empty (null pointer). This change avoid this:
* If `stackTop_` and `stackEnd_` are null, it results in a `ptrdiff_t` of `0`
* If `stackTop_` and `stackEnd_` are valid pointers, they produce a `ptrdiff_t` with the remaining size on the stack
2018-10-05 09:26:20 +02:00
Milo Yip
783b819e67
Update rapidjson.h 2018-09-10 13:11:17 +08:00
Milo Yip
8a96a95de2
Merge branch 'master' into fix-noexcept 2018-09-10 11:27:45 +08:00
Milo Yip
08b1a8a41e
Merge pull request #1302 from chwarr/min-max-guard
Guard against min/max being macros in reader.h
2018-09-10 11:22:28 +08:00
Milo Yip
81af404b7f
Merge pull request #1284 from mobileben/noexcept-assert
Handle non-throwing exception specifications that can still throw #1280
2018-09-10 11:21:34 +08:00
Lele Gaifax
11defb7aa4 Wrap all WriteXxx() calls within EndValue(), to ensure a flush after root-level scalar value
This attempts to fix issue #1336.
2018-08-03 12:17:29 +02:00
Milo Yip
6a905f9311
Merge pull request #1331 from JPEWdev/mem-alignment-fix
Fix SIGBUS due to unaligned access
2018-08-01 11:56:25 +08:00
IceTrailer
cd28248611 Fixed parentheses in reader.h which were required to prevent the using of max macro 2018-07-31 22:23:53 +02:00
Veselin Georgiev
748a652f04 Fix SIGBUS due to unaligned access
Update RAPIDJSON_ALIGN() to always align on an 8-byte boundary
unless otherwise overridden.

On some platforms (such as ARM), 64-bit items (such as doubles and
64-bit integers) must be aligned to an 8 byte address, even though the
architecture is only 32-bits. On these platforms, MemoryPoolAllocator
must match the malloc() behavior and return a 8 byte aligned allocation.
This eliminates any alignment issues that may occur at the expense of
additional memory overhead.

Failure to do so caused a SIGBUS signal when calling
GenericValue::SetNull(). The size of the data_ member of the
GenericValue class is 16 bytes in 32-bit mode and its constructor
requires an 8-byte aligned access.

While parsing a JSON formatted string using Document::ParseStream(), a
stack object containing GenericValue items was constructed. Since the
stack was 8-byte aligned, the constructor calls would succeed. When the
lifetime of the object ends, SetObjectRaw() is invoked. This triggered
an allocation with 4-byte alignment to which the previously 8-byte
aligned GenericValue array was copied. After this, any call to a
GenericValue API that triggered the constructor and thus the placement
new operation on the Data type member would trigger a SIGBUS.

Signed-off-by: Veselin Georgiev <veselin.georgiev@garmin.com>
Signed-off-by: Joshua Watt <Joshua.Watt@garmin.com>
2018-07-31 09:02:26 -05:00
Philipp A Hartmann
f54f6b5aa9 Add RAPIDJSON_NOEXCEPT_ASSERT
This is an alternative implementation to #1284 to handle
asserts in noexcept contexts.

Closes #1280.
2018-07-18 12:02:24 +02:00
Philipp A Hartmann
a26267d16d Fix -Wsign-conversion warnings/errors
GCC 8 (incorrectly) warns about sign conversions in (constant)
array size expressions:

error: conversion to 'long unsigned int' from 'int' may
change the sign of the result [-Werror=sign-conversion]
     char schemaBuffer_[128 * 1024];

Make these expressions unsigned by adding a 'u' suffix to
the first operands.
2018-07-15 16:01:02 +02:00
Philipp A Hartmann
fa5963a2f5 Fix -Wclass-memaccess warnings/errors
Recent GCC versions warn about using memcpy/memmove to
write to a class pointer (-Wclass-memaccess).

Avoid the warnings by casting to void* first.

Closes #1086.
Closes #1205.
Closes #1246.
2018-07-15 14:20:38 +02:00
Yolan Romailler
93331cb0cd Removing always true if condition 2018-07-12 15:13:19 +02:00
Christopher Warrington
960b9cfd19 Guard against min/max being macros in reader.h
Sometimes, particularly when Microsoft's windows.h is included, min/max
are defined as macros, interfering with use of
std::numeric_limits::min() and the like.

To guard against this, the function name is wrapped in an extra set of
parenthesis, which inhibits function-style macro expansion.

This is a similar commit to 6e38649ec6, but fixes uses of
std::numeric_limits added after that commit, like those introduced in
2ea43433e2.
2018-07-10 11:08:41 -07:00
Erik Froseth
3e255af03a Detect C++11 features for Developer Studio
This patch enables various C++11 features if the code is compiled with
Developer Studio compiler version 5.14 or higher.
2018-07-03 13:02:45 +02:00
Romain Moret
4595cc488e Rename a few internal preprocessor macros to avoid potential naming conflicts 2018-07-02 13:24:18 +02:00
Milo Yip
c511ce303f
Merge pull request #1250 from StilesCrisis/issue-1249-test
Unit Test: Parsing "0e100" in full precision mode causes UB
2018-06-18 23:54:53 +08:00
abolz
879ae853fe Fix offset computation in BigInteger::operator<< 2018-06-16 09:41:04 +02:00