Merge branch 'pvs-studio-fix-05-09-2020' of https://github.com/pavel-pimenov/jsoncpp into pvs-studio-fix-05-09-2020
This commit is contained in:
commit
82da440ea1
@ -22,8 +22,6 @@ addons:
|
||||
- clang-8
|
||||
- valgrind
|
||||
matrix:
|
||||
allow_failures:
|
||||
- os: osx
|
||||
include:
|
||||
- name: Mac clang meson static release testing
|
||||
os: osx
|
||||
@ -44,6 +42,8 @@ matrix:
|
||||
CC="clang"
|
||||
LIB_TYPE=static
|
||||
BUILD_TYPE=release
|
||||
PYTHONUSERBASE="$(pwd)/LOCAL"
|
||||
PATH="$PYTHONUSERBASE/bin:$PATH"
|
||||
# before_install and install steps only needed for linux meson builds
|
||||
before_install:
|
||||
- source ./.travis_scripts/travis.before_install.${TRAVIS_OS_NAME}.sh
|
||||
|
@ -353,4 +353,4 @@ def main():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
sys.exit(main())
|
||||
|
@ -1 +0,0 @@
|
||||
# NOTHING TO DO HERE
|
@ -1,10 +1,5 @@
|
||||
set -vex
|
||||
|
||||
wget https://github.com/ninja-build/ninja/releases/download/v1.9.0/ninja-linux.zip
|
||||
unzip -q ninja-linux.zip -d build
|
||||
|
||||
pip3 install meson
|
||||
echo ${PATH}
|
||||
ls /usr/local
|
||||
ls /usr/local/bin
|
||||
export PATH="${PWD}"/build:/usr/local/bin:/usr/bin:${PATH}
|
||||
pip3 install --user meson ninja
|
||||
which meson
|
||||
which ninja
|
||||
|
@ -69,12 +69,15 @@ project(jsoncpp
|
||||
# 2. ./include/json/version.h
|
||||
# 3. ./CMakeLists.txt
|
||||
# IMPORTANT: also update the PROJECT_SOVERSION!!
|
||||
VERSION 1.9.3 # <major>[.<minor>[.<patch>[.<tweak>]]]
|
||||
VERSION 1.9.4 # <major>[.<minor>[.<patch>[.<tweak>]]]
|
||||
LANGUAGES CXX)
|
||||
|
||||
message(STATUS "JsonCpp Version: ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
|
||||
set(PROJECT_SOVERSION 24)
|
||||
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/include/PreventInSourceBuilds.cmake)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/include/PreventInBuildInstalls.cmake)
|
||||
|
||||
option(JSONCPP_WITH_TESTS "Compile and (for jsoncpp_check) run JsonCpp test executables" ON)
|
||||
option(JSONCPP_WITH_POST_BUILD_UNITTEST "Automatically run unit-tests as a post build step" ON)
|
||||
option(JSONCPP_WITH_WARNING_AS_ERROR "Force compilation to fail if a warning occurs" OFF)
|
||||
|
@ -19,7 +19,7 @@ If you wish to install to a directory other than /usr/local, set an environment
|
||||
DESTDIR=/path/to/install/dir
|
||||
|
||||
Then,
|
||||
|
||||
```sh
|
||||
cd jsoncpp/
|
||||
BUILD_TYPE=debug
|
||||
#BUILD_TYPE=release
|
||||
@ -35,6 +35,7 @@ Then,
|
||||
#meson test --no-rebuild --print-errorlogs
|
||||
|
||||
sudo ninja install
|
||||
```
|
||||
|
||||
## Building and testing with other build systems
|
||||
See https://github.com/open-source-parsers/jsoncpp/wiki/Building
|
||||
@ -143,7 +144,9 @@ bool Reader::decodeNumber(Token& token) {
|
||||
```
|
||||
|
||||
Before submitting your code, ensure that you meet the versioning requirements above, follow the style guide of the file you are modifying (or the above rules for new files), and run clang format. Meson exposes clang format with the following command:
|
||||
|
||||
```
|
||||
ninja -v -C build-${LIB_TYPE}/ clang-format
|
||||
```
|
||||
|
||||
For convenience, you can also run the `reformat.sh` script located in the root directory.
|
||||
|
||||
|
11
appveyor.yml
11
appveyor.yml
@ -1,6 +1,7 @@
|
||||
clone_folder: c:\projects\jsoncpp
|
||||
|
||||
environment:
|
||||
|
||||
matrix:
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
CMAKE_GENERATOR: Visual Studio 14 2015
|
||||
@ -13,11 +14,15 @@ environment:
|
||||
|
||||
build_script:
|
||||
- cmake --version
|
||||
- cd c:\projects\jsoncpp
|
||||
- cmake -G "%CMAKE_GENERATOR%" -DCMAKE_INSTALL_PREFIX:PATH=%CD:\=/%/install -DBUILD_SHARED_LIBS:BOOL=ON .
|
||||
# The build script starts in root.
|
||||
- set JSONCPP_FOLDER=%cd%
|
||||
- set JSONCPP_BUILD_FOLDER=%JSONCPP_FOLDER%\build\release
|
||||
- mkdir -p %JSONCPP_BUILD_FOLDER%
|
||||
- cd %JSONCPP_BUILD_FOLDER%
|
||||
- cmake -G "%CMAKE_GENERATOR%" -DCMAKE_INSTALL_PREFIX:PATH=%CD:\=/%/install -DBUILD_SHARED_LIBS:BOOL=ON %JSONCPP_FOLDER%
|
||||
# Use ctest to make a dashboard build:
|
||||
# - ctest -D Experimental(Start|Update|Configure|Build|Test|Coverage|MemCheck|Submit)
|
||||
# NOTE: Testing on window is not yet finished:
|
||||
# NOTE: Testing on windows is not yet finished:
|
||||
# - ctest -C Release -D ExperimentalStart -D ExperimentalConfigure -D ExperimentalBuild -D ExperimentalTest -D ExperimentalSubmit
|
||||
- ctest -C Release -D ExperimentalStart -D ExperimentalConfigure -D ExperimentalBuild -D ExperimentalSubmit
|
||||
# Final step is to verify that installation succeeds
|
||||
|
9
include/PreventInBuildInstalls.cmake
Normal file
9
include/PreventInBuildInstalls.cmake
Normal file
@ -0,0 +1,9 @@
|
||||
string(TOLOWER "${CMAKE_INSTALL_PREFIX}" _PREFIX)
|
||||
string(TOLOWER "${ITK_BINARY_DIR}" _BUILD)
|
||||
if("${_PREFIX}" STREQUAL "${_BUILD}")
|
||||
message(FATAL_ERROR
|
||||
"The current CMAKE_INSTALL_PREFIX points at the build tree:\n"
|
||||
" ${CMAKE_INSTALL_PREFIX}\n"
|
||||
"This is not supported."
|
||||
)
|
||||
endif()
|
45
include/PreventInSourceBuilds.cmake
Normal file
45
include/PreventInSourceBuilds.cmake
Normal file
@ -0,0 +1,45 @@
|
||||
#
|
||||
# This function will prevent in-source builds
|
||||
function(AssureOutOfSourceBuilds)
|
||||
# make sure the user doesn't play dirty with symlinks
|
||||
get_filename_component(srcdir "${CMAKE_SOURCE_DIR}" REALPATH)
|
||||
get_filename_component(bindir "${CMAKE_BINARY_DIR}" REALPATH)
|
||||
|
||||
# disallow in-source builds
|
||||
if("${srcdir}" STREQUAL "${bindir}")
|
||||
message("######################################################")
|
||||
message("# jsoncpp should not be configured & built in the jsoncpp source directory")
|
||||
message("# You must run cmake in a build directory.")
|
||||
message("# For example:")
|
||||
message("# mkdir jsoncpp-Sandbox ; cd jsoncpp-sandbox")
|
||||
message("# git clone https://github.com/open-source-parsers/jsoncpp.git # or download & unpack the source tarball")
|
||||
message("# mkdir jsoncpp-build")
|
||||
message("# this will create the following directory structure")
|
||||
message("#")
|
||||
message("# jsoncpp-Sandbox")
|
||||
message("# +--jsoncpp")
|
||||
message("# +--jsoncpp-build")
|
||||
message("#")
|
||||
message("# Then you can proceed to configure and build")
|
||||
message("# by using the following commands")
|
||||
message("#")
|
||||
message("# cd jsoncpp-build")
|
||||
message("# cmake ../jsoncpp # or ccmake, or cmake-gui ")
|
||||
message("# make")
|
||||
message("#")
|
||||
message("# NOTE: Given that you already tried to make an in-source build")
|
||||
message("# CMake have already created several files & directories")
|
||||
message("# in your source tree. run 'git status' to find them and")
|
||||
message("# remove them by doing:")
|
||||
message("#")
|
||||
message("# cd jsoncpp-Sandbox/jsoncpp")
|
||||
message("# git clean -n -d")
|
||||
message("# git clean -f -d")
|
||||
message("# git checkout --")
|
||||
message("#")
|
||||
message("######################################################")
|
||||
message(FATAL_ERROR "Quitting configuration")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
AssureOutOfSourceBuilds()
|
@ -35,11 +35,10 @@ public:
|
||||
* Release memory which was allocated for N items at pointer P.
|
||||
*
|
||||
* The memory block is filled with zeroes before being released.
|
||||
* The pointer argument is tagged as "volatile" to prevent the
|
||||
* compiler optimizing out this critical step.
|
||||
*/
|
||||
void deallocate(volatile pointer p, size_type n) {
|
||||
std::memset(p, 0, n * sizeof(T));
|
||||
void deallocate(pointer p, size_type n) {
|
||||
// memset_s is used because memset may be optimized away by the compiler
|
||||
memset_s(p, n * sizeof(T), 0, n * sizeof(T));
|
||||
// free using "global operator delete"
|
||||
::operator delete(p);
|
||||
}
|
||||
|
@ -263,10 +263,10 @@ private:
|
||||
CZString(ArrayIndex index);
|
||||
CZString(char const* str, unsigned length, DuplicationPolicy allocate);
|
||||
CZString(CZString const& other);
|
||||
CZString(CZString&& other);
|
||||
CZString(CZString&& other) noexcept;
|
||||
~CZString();
|
||||
CZString& operator=(const CZString& other);
|
||||
CZString& operator=(CZString&& other);
|
||||
CZString& operator=(CZString&& other) noexcept;
|
||||
|
||||
bool operator<(CZString const& other) const;
|
||||
bool operator==(CZString const& other) const;
|
||||
@ -344,13 +344,13 @@ public:
|
||||
Value(bool value);
|
||||
Value(std::nullptr_t ptr) = delete;
|
||||
Value(const Value& other);
|
||||
Value(Value&& other);
|
||||
Value(Value&& other) noexcept;
|
||||
~Value();
|
||||
|
||||
/// \note Overwrite existing comments. To preserve comments, use
|
||||
/// #swapPayload().
|
||||
Value& operator=(const Value& other);
|
||||
Value& operator=(Value&& other);
|
||||
Value& operator=(Value&& other) noexcept;
|
||||
|
||||
/// Swap everything.
|
||||
void swap(Value& other);
|
||||
@ -635,9 +635,9 @@ private:
|
||||
public:
|
||||
Comments() = default;
|
||||
Comments(const Comments& that);
|
||||
Comments(Comments&& that);
|
||||
Comments(Comments&& that) noexcept;
|
||||
Comments& operator=(const Comments& that);
|
||||
Comments& operator=(Comments&& that);
|
||||
Comments& operator=(Comments&& that) noexcept;
|
||||
bool has(CommentPlacement slot) const;
|
||||
String get(CommentPlacement slot) const;
|
||||
void set(CommentPlacement slot, String comment);
|
||||
|
@ -9,10 +9,10 @@
|
||||
// 3. /CMakeLists.txt
|
||||
// IMPORTANT: also update the SOVERSION!!
|
||||
|
||||
#define JSONCPP_VERSION_STRING "1.9.3"
|
||||
#define JSONCPP_VERSION_STRING "1.9.4"
|
||||
#define JSONCPP_VERSION_MAJOR 1
|
||||
#define JSONCPP_VERSION_MINOR 9
|
||||
#define JSONCPP_VERSION_PATCH 3
|
||||
#define JSONCPP_VERSION_PATCH 4
|
||||
#define JSONCPP_VERSION_QUALIFIER
|
||||
#define JSONCPP_VERSION_HEXA \
|
||||
((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | \
|
||||
|
@ -9,7 +9,7 @@ project(
|
||||
# 2. /include/json/version.h
|
||||
# 3. /CMakeLists.txt
|
||||
# IMPORTANT: also update the SOVERSION!!
|
||||
version : '1.9.3',
|
||||
version : '1.9.4',
|
||||
default_options : [
|
||||
'buildtype=release',
|
||||
'cpp_std=c++11',
|
||||
|
1
reformat.sh
Executable file
1
reformat.sh
Executable file
@ -0,0 +1 @@
|
||||
find src -name '*.cpp' -or -name '*.h' | xargs clang-format -i
|
@ -1921,7 +1921,7 @@ bool CharReaderBuilder::validate(Json::Value* invalid) const {
|
||||
if (valid_keys.count(key))
|
||||
continue;
|
||||
if (invalid)
|
||||
(*invalid)[std::move(key)] = *si;
|
||||
(*invalid)[key] = *si;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
@ -259,7 +259,7 @@ Value::CZString::CZString(const CZString& other) {
|
||||
storage_.length_ = other.storage_.length_;
|
||||
}
|
||||
|
||||
Value::CZString::CZString(CZString&& other)
|
||||
Value::CZString::CZString(CZString&& other) noexcept
|
||||
: cstr_(other.cstr_), index_(other.index_) {
|
||||
other.cstr_ = nullptr;
|
||||
}
|
||||
@ -285,7 +285,7 @@ Value::CZString& Value::CZString::operator=(const CZString& other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
Value::CZString& Value::CZString::operator=(CZString&& other) {
|
||||
Value::CZString& Value::CZString::operator=(CZString&& other) noexcept {
|
||||
cstr_ = other.cstr_;
|
||||
index_ = other.index_;
|
||||
other.cstr_ = nullptr;
|
||||
@ -433,7 +433,7 @@ Value::Value(const Value& other) {
|
||||
dupMeta(other);
|
||||
}
|
||||
|
||||
Value::Value(Value&& other) {
|
||||
Value::Value(Value&& other) noexcept {
|
||||
initBasic(nullValue);
|
||||
swap(other);
|
||||
}
|
||||
@ -448,7 +448,7 @@ Value& Value::operator=(const Value& other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
Value& Value::operator=(Value&& other) {
|
||||
Value& Value::operator=(Value&& other) noexcept {
|
||||
other.swap(*this);
|
||||
return *this;
|
||||
}
|
||||
@ -1373,14 +1373,15 @@ bool Value::isObject() const { return type() == objectValue; }
|
||||
Value::Comments::Comments(const Comments& that)
|
||||
: ptr_{cloneUnique(that.ptr_)} {}
|
||||
|
||||
Value::Comments::Comments(Comments&& that) : ptr_{std::move(that.ptr_)} {}
|
||||
Value::Comments::Comments(Comments&& that) noexcept
|
||||
: ptr_{std::move(that.ptr_)} {}
|
||||
|
||||
Value::Comments& Value::Comments::operator=(const Comments& that) {
|
||||
ptr_ = cloneUnique(that.ptr_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Value::Comments& Value::Comments::operator=(Comments&& that) {
|
||||
Value::Comments& Value::Comments::operator=(Comments&& that) noexcept {
|
||||
ptr_ = std::move(that.ptr_);
|
||||
return *this;
|
||||
}
|
||||
|
@ -1215,7 +1215,7 @@ bool StreamWriterBuilder::validate(Json::Value* invalid) const {
|
||||
if (valid_keys.count(key))
|
||||
continue;
|
||||
if (invalid)
|
||||
(*invalid)[std::move(key)] = *si;
|
||||
(*invalid)[key] = *si;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
@ -3916,6 +3916,15 @@ JSONTEST_FIXTURE_LOCAL(MemberTemplateIs, BehavesSameAsNamedIs) {
|
||||
}
|
||||
}
|
||||
|
||||
class VersionTest : public JsonTest::TestCase {};
|
||||
|
||||
JSONTEST_FIXTURE_LOCAL(VersionTest, VersionNumbersMatch) {
|
||||
std::ostringstream vstr;
|
||||
vstr << JSONCPP_VERSION_MAJOR << '.' << JSONCPP_VERSION_MINOR << '.'
|
||||
<< JSONCPP_VERSION_PATCH;
|
||||
JSONTEST_ASSERT_EQUAL(vstr.str(), std::string(JSONCPP_VERSION_STRING));
|
||||
}
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user