566 Commits

Author SHA1 Message Date
Philipp A. Hartmann
f6a07692f9 Fix warnings on GCC 6 and later (closes #666)
* document.h
  * suppress -Wterminate on GCC 6.x and later
  * simplify warning handling
* schema.h
  * drop RAPIDJSON_NOEXCEPT from GenericSchemaDocument constructor
    (calls RAPIDJSON_NEW anyway)
  * simplify warning handling
    (avoids RAPIDJSON_POP mismatch on Clang)
* encodingtest.cpp, istreamwrappertest.cpp
  * work around -Wdangling-else
* readertest.cpp
  * suppress -Wdangling-else
2016-06-23 21:42:16 +02:00
Eli Fidler
8c4059766e test for no-double-promotion instead of just checking compiler version 2016-06-14 07:01:41 -07:00
Eli Fidler
c52cec7e51 fix undefined double to uint64_t cast
note that std::numeric_limits<uint64_t>::max() and
std::numeric_limits<int64_t>::max() aren't exactly representable in a
double, so we need to be strictly less to be definitely lossless

UBSAN gave during Value.IsLosslessDouble test:
include/rapidjson/document.h:955:42: runtime error: value 1.84467e+19 is outside the range of representable values of type 'unsigned long'
2016-06-14 07:01:41 -07:00
Eli Fidler
df9b45a656 avoid division by zero, which is undefined behavior
UBSAN gave:
runtime error: division by zero
2016-06-14 07:01:41 -07:00
Eli Fidler
760ea4316c avoid signed-integer underflow, which is undefined behavior
maybe these tests should just be deleted?

UBSAN gave:
runtime error: signed integer overflow: -9223372036854775808 - 1 cannot be represented in type 'long'
runtime error: signed integer overflow: -9223372036854775808 - 2 cannot be represented in type 'long'
2016-06-14 07:01:41 -07:00
Eli Fidler
be1eedf808 avoid signed-integer overflow, which is undefined behavior
UBSAN gave for test/unittest/itoatest.cpp:87:
runtime error: signed integer overflow: 4611686018427387904 * 2 cannot be represented in type 'long'
2016-06-14 07:01:41 -07:00
Eli Fidler
fe550f3866 avoid array index out-of-bounds
UBSAN gave "runtime error: index 13 out of bounds for type 'const uint32_t [10]'"
2016-06-13 07:24:26 -07:00
Eli Fidler
5c77c9248c with recent clang, this triggers -Wunevaluated-expression
specifically, "expression with side effects has no effect in an unevaluated context"
2016-06-13 07:24:26 -07:00
Eli Fidler
035271091f with recent clang, when expected is false, this code triggers -Wunreachable-code
clang advises: "note: silence by adding parentheses to mark code as explicitly dead"
2016-06-13 07:24:26 -07:00
Eli Fidler
13e3aa9b00 we do need to avoid the double-promotion warning on clang, since we're compiling with -Werror 2016-06-13 07:24:26 -07:00
Michael Thon
135da7ab34 Allow options for writing and parsing NaN/Infinity
This adds kWriteNanAndInfFlag to Writer to allow writing of nan,
inf and -inf doubles as "NaN", "Infinity" and "-Infinity",
respectively, and kParseNanAndInfFlag to Reader to allow parsing
of "NaN", "Inf", "Infinity", "-Inf" and "-Infinity". This is part
of issue #36, adding optional support for relaxed JSON syntax.
2016-05-20 23:54:55 +02:00
Milo Yip
c8a1d51753 Add reproduction test case 2016-04-19 15:05:15 +08:00
Milo Yip
be352d9548 Fix a bug in regex
Due to dereferencing a pointer which may be invalidated
2016-04-17 11:59:09 +08:00
Milo Yip
ed6fdb6d78 Improve coverage for SchemaValidator:::AppendToken() 2016-04-17 09:09:25 +08:00
Milo Yip
954f80872d Improve schema minimum/maximum/multipleOf coverage 2016-04-17 01:55:55 +08:00
Milo Yip
26e69ffde9 Fix a bug in schema minimum/maximum keywords for 64-bit integer 2016-04-17 00:48:02 +08:00
Milo Yip
ecd8fa3437 Improve coverage of regex 2016-04-16 23:04:40 +08:00
Milo Yip
c71825f80e Improve Value::IsFloat() coverage 2016-04-16 22:14:38 +08:00
Milo Yip
bdfa0447ec Add test cases for ScanCopyUnescapedString 2016-04-16 21:44:33 +08:00
Milo Yip
a6f9cb85ab Third trial on writer coverage 2016-04-16 16:11:34 +08:00
Milo Yip
3da4afd259 Another trial on writer coverage 2016-04-16 15:19:34 +08:00
Milo Yip
8fcc65bf58 Adjust ScanWriteUnescapedString test case 2016-04-15 19:51:50 +08:00
Milo Yip
8f9ff88c29 Add Writer. ScanWriteUnescapedString to try to improve coverage 2016-04-15 17:03:23 +08:00
Milo Yip
a8970be543 Improve UTF8::Encode() coverage via writing to AutoUTF 2016-04-15 14:15:08 +08:00
Milo Yip
1bfa188d18 Improve encodings coverage 2016-04-15 13:50:24 +08:00
Milo Yip
47e21a054c Temp revert cmake for OS X 2016-04-07 00:46:39 +08:00
Milo Yip
49c29d057d Fix VC warning C4189 2016-04-06 01:16:00 +08:00
Milo Yip
c843a2655b Try to fix all /W4 warnings in VC2015 2016-04-04 15:01:34 +08:00
Milo Yip
2418d7cd91 Fix cmake 2016-03-31 15:02:03 +08:00
Milo Yip
d7df1f26ba Add /W4 and /WX for VC 2016-03-31 14:20:24 +08:00
Jarred Nicholls
926d7ffcc8 Later clang compilers will warn on float -> double promotion because it can add precision. In the context of RapidJSON – especially with its float methods on GenericValue – I think this warning holds no water and should be ignored.
Trim whitespace off the end of various lines.

Added an additional NumberStream specialization that will always perform a TakePush() even when just Take() is called. This supports RawNumber parsing by pushing onto our StackStream particular parts of the number that currently aren't captured because of full precision double parsing, such as the negative sign, scientific number exponents, etc.

RawNumber parsing fails with input streams that don't have copy optimization, such as the BasicIStreamWrapper stream. To work around this, instead do the Transcode copy operation by reading from a UTF8 StringStream instead of the original InputStream. Since the NumberStream downcasts all input Ch into chars, we know we're dealing with UTF8/ASCII compatible stack characters during the Transcoding.
2016-03-29 15:44:30 -04:00
Nicholas Fraser
68217548f3 Added trailing comma support to iterative parser
This also fixes cases where the iterative parser should have produced
kParseErrorValueInvalid rather than kParseErrorUnspecifiedSyntaxError
when expecting a value (after a colon in an object, after a comma in an
array, and at the start of an array.)
2016-03-20 12:52:48 -04:00
Nicholas Fraser
7c0e9d941d Added additional tests for trailing commas 2016-03-20 11:39:00 -04:00
Nicholas Fraser
3e21bb429d Added optional support for trailing commas
This adds kParseTrailingCommasFlag to allow a trailing comma at the
end of maps and arrays. This is part of issue #36, adding optional
support for relaxed JSON syntax.
2016-03-20 01:10:33 -04:00
Konstantin Trushin
305882489c do potentially precision-losing conversions explicitly 2016-03-13 14:07:39 +03:00
Cory Omand
7a79e91ecd PrettyWriter formatting options.
This change adds PrettyWriter::SetFormatOptions with a corresponding
bitfield enum PrettyFormatOptions. This allows options affecting the
format of the PrettyWriter to be set. The first option to be provided
is kFormatSingleLineArray, which instructs the PrettyWriter to write
arrays on a single line, rather than breaking them up onto a line
per element.
2016-03-08 15:33:04 -08:00
Milo Yip
7886965e34 Fix a bug in dtoa
This previously affects Writer:: SetMaxDecimalPlaces()
2016-03-08 10:03:31 +08:00
Milo Yip
01b2d463f7 Fix #573 2016-03-05 10:34:00 +08:00
Milo Yip
a62777487d Normalize line endings but not JSON files 2016-03-04 11:52:18 +08:00
Milo Yip
7fb84d304b Revert "Normalize all the line endings"
This reverts commit 6047e3ce128954ec594e9a893ef2125c9f9b61c7.
2016-03-04 11:51:30 +08:00
Milo Yip
6047e3ce12 Normalize all the line endings 2016-03-04 09:46:11 +08:00
Milo Yip
d9cf99baf6 Normalize all line endings 2016-03-04 09:44:01 +08:00
Sergey Kosarevsky
ae785ffb52 Don't use nullptr 2016-03-02 02:21:38 +01:00
Sergey Kosarevsky
57eae5595e Added new unit test for kParseNumbersAsStringsFlag 2016-03-02 02:08:59 +01:00
Sergey Kosarevsky
1ffb335915 Added RawNumber() to fix unit tests 2016-02-29 18:05:05 +01:00
Sergey Kosarevsky
3dba370486 Added IterativeParsingReaderHandler::RawNumber() 2016-02-29 17:51:32 +01:00
Milo Yip
ae840f66c5 Remerge #504 2016-02-23 14:21:03 +08:00
Milo Yip
494f9deb9b Merge pull request #555 from miloyip/appveyor_vs2015
Add VS2010 and VS2015 to AppVeyor CI
2016-02-21 17:16:28 +08:00
Milo Yip
770f3a47b1 Bypass a VC2010 problem on IsLosslessDouble() 2016-02-21 14:57:08 +08:00
Milo Yip
a907ca490e Fix another VC2010 compilation error 2016-02-21 14:14:49 +08:00