1204 Commits

Author SHA1 Message Date
Brad King
056850c44b reader: fix signed overflow when parsing negative value
Clang's ubsan (-fsanitize=undefined) reports:

    runtime error: negation of -9223372036854775808 cannot be represented in
    type 'Json::Value::LargestInt' (aka 'long'); cast to an unsigned type to
    negate this value to itself

Follow its advice and update the code to remove the explicit negation.
2019-01-11 14:04:41 -06:00
Stefano Fiorentino
009a3ad24c issue_836: Check if `removed' is a valid pointer before copy data to it
functions involved:
	- bool Value::removeMember(const char* key, const char* cend, Value* removed)

Signed-off-by: Stefano Fiorentino <stefano.fiore84@gmail.com>
2019-01-11 11:27:59 -06:00
fangguo
7d16e10113 fiexd “Cannot take the address of a bit field.”
```c++
 #include <iostream>

class TestBool
{
public:
    TestBool():addChildValues_(){}
    TestBool(int):addChildValues_(false){}
    bool addChildValues_ : 1;
    bool indented_ : 1;
};


int main()
{
    std::cout << "\n TestBool () addChildValues_ = " << TestBool().addChildValues_;
    std::cout << "\n TestBool false addChildValues_ = " << TestBool(3).addChildValues_;
    return 0;
}
```

```text
root@osssvr-1 # /opt/SUNWspro/prod/bin/CC  testbool.cpp -o testbool   
Error: Cannot take the address of a bit field.
1 Error(s) detected.
```
2018-12-31 07:39:04 +07:00
Orivej Desh
d8723104f3 Update removeMember docs after #693 2018-12-31 07:37:07 +07:00
Mathias L. Baumann
08ddeed927 JsonValue documentation: Rephrase confusing sentence 2018-12-30 15:33:43 -06:00
Hans Johnson
97e05c41f2 COMP: Provide C++11 feature testing during config
Test compiler feature sets early so that required features
are validated before long compilation process is started.
2018-12-30 15:32:57 -06:00
Hans Johnson
b3b92df879 ENH: Provide range for non-warned cmake versions
Allow configuring without cmake policy developer warnings
for a range of cmake versions.

This prevents the need to explicitly enumerate every new
policy for each new cmake version.

===

Moved setting of the CMAKE_CXX_STANDARD to before the project()
directive.
2018-12-30 15:32:57 -06:00
Hans Johnson
892a386018 ENH: Use cmake builtin versioning capabilities
The project directive in cmake 3.1 has a builtin
mechanism for providing consistent versioning
in a package.
2018-12-30 15:32:57 -06:00
Hans Johnson
0417e626c0 STYLE: Convert CMake-language commands to lower case
Ancient CMake versions required upper-case commands.  Later command names
became case-insensitive.  Now the preferred style is lower-case.
2018-12-30 15:32:57 -06:00
Hans Johnson
2cb1ad5d0c STYLE: Replace integer literals which are cast to bool.
Finds and replaces integer literals which are cast to bool.

SRCDIR=/Users/johnsonhj/src/jsoncpp #My local SRC
BLDDIR=/Users/johnsonhj/src/jsoncpp/cmake-build-debug/ #My local BLD

cd /Users/johnsonhj/src/jsoncpp/cmake-build-debug/
run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-bool-literals  -header-filter=.* -fix
2018-12-30 15:31:12 -06:00
Kostiantyn Ponomarenko
4bfa962967 Add Meson related info to README
Add information about how one can get a Meson wrap file.

Signed-off-by: Kostiantyn Ponomarenko <konstantin.ponomarenko@gmail.com>
2018-12-30 15:30:35 -06:00
Hans Johnson
e50bfefef1 COMP: Prefer the C++ headers over the C99 headers
Using the C++11 headers keeps the library cleaner and more
rigorously scoped use of namespaces.
2018-12-30 15:29:22 -06:00
Hans Johnson
5c8e539af4 ENH: MSVS 2013 snprintf compatible substitute
Simplify the backwards compatible snprintf configuration for pre
1900 version of MSVC.  Otherwise prefer C++11 syntax using std::snprintf.
2018-12-30 15:29:22 -06:00
Radoslav Atanasov
ccd077ffce Fix MSVC 15.9 (2017) warning C4866
by changing operator[] param type from JSONCPP_STRING to const JSONCPP_STRING& for CharReaderBuilder and StreamWriterBuilder (as it is already in Value).

https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c4866?view=vs-2017
2018-12-30 15:28:09 -06:00
Hans Johnson
4abf4ec208 PERF: Replace explicit return calls of constructor
Replaces explicit calls to the constructor in a return with a braced
initializer list. This way the return type is not needlessly duplicated in the
function definition and the return statement.

SRCDIR=/Users/johnsonhj/src/jsoncpp #My local SRC
BLDDIR=/Users/johnsonhj/src/jsoncpp/cmake-build-debug/ #My local BLD

cd /Users/johnsonhj/src/jsoncpp/cmake-build-debug/
run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-return-braced-init-list  -header-filter=.* -fix
2018-12-30 15:26:29 -06:00
Christopher Dunn
9026a16ff5
Merge pull request #849 from hjmjohnson/modernize-use-nullptr
COMP: Use nullptr instead of 0 or NULL
2018-12-30 15:23:22 -06:00
Hans Johnson
f64244ed3f COMP: Use nullptr instead of 0 or NULL
The check converts the usage of null pointer constants (eg. NULL, 0) to
use the new C++11 nullptr keyword.

SRCDIR=/Users/johnsonhj/src/jsoncpp #My local SRC
BLDDIR=/Users/johnsonhj/src/jsoncpp/cmake-build-debug/ #My local BLD

cd /Users/johnsonhj/src/jsoncpp/cmake-build-debug/
run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-nullptr  -header-filter=.* -fix
2018-12-12 13:41:06 -06:00
Christopher Dunn
6219eae304
Merge pull request #843 from manang/master
Update json_writer.cpp
2018-12-03 20:20:55 -08:00
manang
b955e0f699
Update json_writer.cpp 2018-12-03 10:26:27 +01:00
Julien Schueller
d501fbe741 Set CMAKE_BUILD_TYPE default on win32 too 2018-12-02 18:37:11 -06:00
Julien Schueller
ec4251b728 Use CMAKE_CROSSCOMPILING_EMULATOR to run tests
Needed when cross-compiling
2018-12-02 18:37:11 -06:00
Julien Schueller
a72266d00b Remove useless BUILD_STATIC_LIBS option 2018-12-02 18:37:11 -06:00
Julien Schueller
010a2d04d3 Unique lib target name 2018-12-02 18:37:11 -06:00
Christopher Dunn
2baad4923e
Merge pull request #804 from yantaozhao/master
allow nullptr when not care the removed array value
2018-07-14 22:11:35 -05:00
YantaoZhao
e32ee4717c allow nullptr when not care the removed array value 2018-07-03 21:29:18 +08:00
Christopher Dunn
80bc776bae
Merge pull request #250 from cdunn2001/travis
in travis, build for osx also
2018-06-24 20:42:46 -05:00
Christopher Dunn
da498591fc In travis-ci, build for osx also
Drop gcc b/c it takes too long to install via addon.

Build only static/release, to save VMs. (No shared to debug.)
2018-06-24 20:35:49 -05:00
pavel.pimenov
745287275c "\n" -> '\n' 2018-06-24 18:51:10 -05:00
Christopher Dunn
c00a3b95c2
Merge pull request #800 from cdunn2001/patch-1
Fixes #798
Closes #799
2018-06-23 18:17:08 -05:00
Christopher Dunn
c59db80002 Try the way I build locally 2018-06-23 18:08:53 -05:00
Christopher Dunn
473afca1e3 Tell meson/ninja versions 2018-06-23 18:08:53 -05:00
Christopher Dunn
59d41de5b1 Try to avoid empty string
- g++ has a problem with ''
- clang++ does not seem to mind it.
2018-06-23 18:08:53 -05:00
Peter Spiess-Knafl
b87f6dbc8a Fix for #798
Add preprocessor definitions for MSVC dllexport/dllimport statements

(cherry picked from commit 2654b6bbbf089bf85d29c9a9ca1283e07cc6fe43)
2018-06-23 16:11:47 -05:00
Kamel CHAOUCHE
ee34ac1fbb Add position independent code feature to CMakeList.txt
Enable Position Independent Code for shared lib
2018-06-22 11:37:18 -05:00
Christopher Dunn
d31a5300e1
Merge pull request #788 from pavel-pimenov/fix-782
Fix #782
2018-06-22 10:29:52 -05:00
pavel.pimenov
86789e7c2f Fix #782 2018-06-05 10:17:36 +03:00
Christopher Dunn
c4103ab390
Merge pull request #784 from Nekto89/cppcheck_fix
Multiple fixes for issues found by Cppcheck
2018-06-03 13:28:53 -05:00
Marian Klymov
a5d7c714b1 Fix typo in previous fix. 2018-06-02 21:52:45 +03:00
Marian Klymov
84ca7d6f0b Apply the formatting specified in .clang-format file. 2018-06-02 20:27:31 +03:00
Marian Klymov
fc20134c92 Fix different names for parameters in declaration and definition 2018-06-02 20:15:26 +03:00
Marian Klymov
091e03979d Reduce scope of variable. 2018-06-02 19:48:10 +03:00
Marian Klymov
a7d0ffc717 Remove unused private function in TestResult class 2018-06-02 19:46:16 +03:00
Marian Klymov
48112c8b62 Make several methods static. 2018-06-02 19:43:31 +03:00
Marian Klymov
c8bb600d27 Pass string as a const reference. 2018-06-02 19:41:57 +03:00
Marian Klymov
85a263e89f Fix improper format specifier in printf
%d in format string requires 'int' but the argument type is 'unsigned int'.
2018-06-02 19:38:12 +03:00
Christopher Dunn
cfab607c0d
Merge pull request #776 from BillyDonahue/apply_clang_format
Reapply clang format
2018-05-22 13:32:58 -05:00
Billy Donahue
b5e1fe89aa Apply the formatting specified in .clang-format file.
$ clang-format --version
  clang-format version 7.0.0 (tags/google/stable/2018-01-11)
  $ clang-format -i --style=file $(find . -name '*.cpp' -o -name '*.h')
2018-05-20 18:38:42 -04:00
Billy Donahue
abd39e791b json_tool missing include 2018-05-20 18:38:42 -04:00
Christopher Dunn
768e31fc68
Merge pull request #773 from BillyDonahue/precision
Improvements in writing precision and json_tool.h helpers.

resolves #772
2018-05-13 22:57:16 -05:00
Billy Donahue
aa1b383666 fix string construction 2018-05-13 18:28:05 -04:00