diff -Nru libjsoncpp-1.6.5/amalgamate.py libjsoncpp-1.7.2/amalgamate.py --- libjsoncpp-1.6.5/amalgamate.py 2015-07-23 05:26:13.000000000 +0000 +++ libjsoncpp-1.7.2/amalgamate.py 2016-03-25 20:09:15.000000000 +0000 @@ -67,6 +67,7 @@ header.add_text("/// to prevent private header inclusion.") header.add_text("#define JSON_IS_AMALGAMATION") header.add_file("include/json/version.h") + header.add_file("include/json/allocator.h") header.add_file("include/json/config.h") header.add_file("include/json/forwards.h") header.add_file("include/json/features.h") diff -Nru libjsoncpp-1.6.5/CMakeLists.txt libjsoncpp-1.7.2/CMakeLists.txt --- libjsoncpp-1.6.5/CMakeLists.txt 2015-07-23 05:26:13.000000000 +0000 +++ libjsoncpp-1.7.2/CMakeLists.txt 2016-03-25 20:09:15.000000000 +0000 @@ -7,6 +7,7 @@ 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) +OPTION(JSONCPP_WITH_STRICT_ISO "Issue all the warnings demanded by strict ISO C and ISO C++" ON) OPTION(JSONCPP_WITH_PKGCONFIG_SUPPORT "Generate and install .pc files" ON) OPTION(JSONCPP_WITH_CMAKE_PACKAGE "Generate and install cmake package files" OFF) OPTION(BUILD_SHARED_LIBS "Build jsoncpp_lib as a shared library." OFF) @@ -18,8 +19,8 @@ SET(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel Coverage." FORCE) - ENDIF(NOT CMAKE_BUILD_TYPE) -ENDIF(NOT WIN32) + ENDIF() +ENDIF() SET(DEBUG_LIBNAME_SUFFIX "" CACHE STRING "Optional suffix to append to the library name for a debug build") SET(LIB_SUFFIX "" CACHE STRING "Optional arch-dependent suffix for the library installation directory") @@ -39,7 +40,7 @@ # Set variable named ${VAR_NAME} to value ${VALUE} FUNCTION(set_using_dynamic_name VAR_NAME VALUE) SET( "${VAR_NAME}" "${VALUE}" PARENT_SCOPE) -ENDFUNCTION(set_using_dynamic_name) +ENDFUNCTION() # Extract major, minor, patch from version text # Parse a version string "X.Y.Z" and outputs @@ -55,19 +56,20 @@ set_using_dynamic_name( "${OUPUT_PREFIX}_FOUND" TRUE ) ELSE( ${VERSION_TEXT} MATCHES ${VERSION_REGEX} ) set_using_dynamic_name( "${OUPUT_PREFIX}_FOUND" FALSE ) - ENDIF( ${VERSION_TEXT} MATCHES ${VERSION_REGEX} ) -ENDMACRO(jsoncpp_parse_version) + ENDIF() +ENDMACRO() # Read out version from "version" file #FILE(STRINGS "version" JSONCPP_VERSION) #SET( JSONCPP_VERSION_MAJOR X ) #SET( JSONCPP_VERSION_MINOR Y ) #SET( JSONCPP_VERSION_PATCH Z ) -SET( JSONCPP_VERSION 1.6.5 ) +SET( JSONCPP_VERSION 1.7.2 ) jsoncpp_parse_version( ${JSONCPP_VERSION} JSONCPP_VERSION ) #IF(NOT JSONCPP_VERSION_FOUND) # MESSAGE(FATAL_ERROR "Failed to parse version string properly. Expect X.Y.Z") #ENDIF(NOT JSONCPP_VERSION_FOUND) +SET( JSONCPP_USE_SECURE_MEMORY "0" CACHE STRING "-D...=1 to use memory-wiping allocator for STL" ) MESSAGE(STATUS "JsonCpp Version: ${JSONCPP_VERSION_MAJOR}.${JSONCPP_VERSION_MINOR}.${JSONCPP_VERSION_PATCH}") # File version.h is only regenerated on CMake configure step @@ -83,7 +85,12 @@ # Only enabled in debug because some old versions of VS STL generate # warnings when compiled in release configuration. set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /WX ") - endif( MSVC ) + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") + if (JSONCPP_WITH_STRICT_ISO) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic-errors") + endif () + endif() endmacro() # Include our configuration header @@ -93,35 +100,45 @@ # Only enabled in debug because some old versions of VS STL generate # unreachable code warning when compiled in release configuration. set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /W4 ") -endif( MSVC ) +endif() if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") # using regular Clang or AppleClang - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Werror -Wall -Wconversion -Wshadow -Wno-sign-conversion") -elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wconversion -Wshadow -Werror=conversion -Werror=sign-compare") +elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # using GCC - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Werror -Wall -Wconversion -Wshadow -Wextra -pedantic") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wconversion -Wshadow -Wextra -Werror=conversion") # not yet ready for -Wsign-conversion + + if (JSONCPP_WITH_STRICT_ISO AND NOT JSONCPP_WITH_WARNING_AS_ERROR) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic") + endif () endif() +find_program(CCACHE_FOUND ccache) +if(CCACHE_FOUND) + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) + set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) +endif(CCACHE_FOUND) + IF(JSONCPP_WITH_WARNING_AS_ERROR) UseCompilationWarningAsError() -ENDIF(JSONCPP_WITH_WARNING_AS_ERROR) +ENDIF() IF(JSONCPP_WITH_PKGCONFIG_SUPPORT) CONFIGURE_FILE( "pkg-config/jsoncpp.pc.in" "pkg-config/jsoncpp.pc" @ONLY) - INSTALL(FILES "${CMAKE_BINARY_DIR}/pkg-config/jsoncpp.pc" + INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/pkg-config/jsoncpp.pc" DESTINATION "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/pkgconfig") -ENDIF(JSONCPP_WITH_PKGCONFIG_SUPPORT) +ENDIF() IF(JSONCPP_WITH_CMAKE_PACKAGE) INSTALL(EXPORT jsoncpp DESTINATION ${PACKAGE_INSTALL_DIR}/jsoncpp FILE jsoncppConfig.cmake) -ENDIF(JSONCPP_WITH_CMAKE_PACKAGE) +ENDIF() # Build the different applications ADD_SUBDIRECTORY( src ) diff -Nru libjsoncpp-1.6.5/debian/changelog libjsoncpp-1.7.2/debian/changelog --- libjsoncpp-1.6.5/debian/changelog 2016-02-12 09:57:14.000000000 +0000 +++ libjsoncpp-1.7.2/debian/changelog 2016-03-28 02:49:34.000000000 +0000 @@ -1,3 +1,19 @@ +libjsoncpp (1.7.2-1) unstable; urgency=medium + + * Team upload. + [ Peter Spiess-Knafl ] + * Fix watch file + * Imported Upstream version 1.7.2 (Closes: #811958) + * Removed upstream applied and unused patches + + [ Ghislain Vaillant ] + * Add CI testsuite (Closes: #819378) + * Simplify multiarch handling (Closes: #819376) + - removed multiarch patch + - removed include path patch + + -- Peter Spiess-Knafl Mon, 28 Mar 2016 04:49:21 +0200 + libjsoncpp (1.6.5-4) unstable; urgency=medium * d/libjsoncpp-dev.install: Remove arch specific cmake file (Closes: #814414) diff -Nru libjsoncpp-1.6.5/debian/control libjsoncpp-1.7.2/debian/control --- libjsoncpp-1.6.5/debian/control 2016-02-12 09:57:14.000000000 +0000 +++ libjsoncpp-1.7.2/debian/control 2016-03-28 02:49:34.000000000 +0000 @@ -2,6 +2,7 @@ Priority: extra Maintainer: Peter Spiess-Knafl Uploaders: Cleto Martín +Testsuite: autopkgtest Build-Depends: cmake, debhelper (>= 9), doxygen, python Standards-Version: 3.9.7 Section: libs diff -Nru libjsoncpp-1.6.5/debian/libjsoncpp-dev.install libjsoncpp-1.7.2/debian/libjsoncpp-dev.install --- libjsoncpp-1.6.5/debian/libjsoncpp-dev.install 2016-02-12 09:57:14.000000000 +0000 +++ libjsoncpp-1.7.2/debian/libjsoncpp-dev.install 2016-03-28 02:49:34.000000000 +0000 @@ -1,5 +1,5 @@ -usr/include/jsoncpp/* usr/include/jsoncpp -usr/lib/*/lib*.a -usr/lib/*/lib*.so -usr/lib/*/pkgconfig* -usr/lib/cmake/jsoncpp/jsoncppConfig.cmake +usr/include +usr/lib/*/*.a +usr/lib/*/*.so +usr/lib/*/pkgconfig +usr/lib/*/cmake diff -Nru libjsoncpp-1.6.5/debian/patches/0001-multiarch-path-support.patch libjsoncpp-1.7.2/debian/patches/0001-multiarch-path-support.patch --- libjsoncpp-1.6.5/debian/patches/0001-multiarch-path-support.patch 2016-02-12 09:57:14.000000000 +0000 +++ libjsoncpp-1.7.2/debian/patches/0001-multiarch-path-support.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,62 +0,0 @@ -From: Peter Spiess-Knafl -Date: Sat, 28 Feb 2015 00:42:14 +0100 -Subject: multiarch path support - ---- - src/lib_json/CMakeLists.txt | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - ---- a/src/lib_json/CMakeLists.txt -+++ b/src/lib_json/CMakeLists.txt -@@ -48,8 +48,8 @@ - - INSTALL( TARGETS jsoncpp_lib ${INSTALL_EXPORT} - RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR} -- LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR} -- ARCHIVE DESTINATION ${ARCHIVE_INSTALL_DIR}) -+ LIBRARY DESTINATION "${LIBRARY_INSTALL_DIR}/${CMAKE_LIBRARY_ARCHITECTURE}" -+ ARCHIVE DESTINATION "${ARCHIVE_INSTALL_DIR}/${CMAKE_LIBRARY_ARCHITECTURE}") - - IF(NOT CMAKE_VERSION VERSION_LESS 2.8.11) - TARGET_INCLUDE_DIRECTORIES( jsoncpp_lib PUBLIC -@@ -67,8 +67,8 @@ - - INSTALL( TARGETS jsoncpp_lib_static ${INSTALL_EXPORT} - RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR} -- LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR} -- ARCHIVE DESTINATION ${ARCHIVE_INSTALL_DIR}) -+ LIBRARY DESTINATION "${LIBRARY_INSTALL_DIR}/${CMAKE_LIBRARY_ARCHITECTURE}" -+ ARCHIVE DESTINATION "${ARCHIVE_INSTALL_DIR}/${CMAKE_LIBRARY_ARCHITECTURE}") - - IF(NOT CMAKE_VERSION VERSION_LESS 2.8.11) - TARGET_INCLUDE_DIRECTORIES( jsoncpp_lib_static PUBLIC ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -12,6 +12,8 @@ - OPTION(BUILD_SHARED_LIBS "Build jsoncpp_lib as a shared library." OFF) - OPTION(BUILD_STATIC_LIBS "Build jsoncpp_lib static library." ON) - -+include(GNUInstallDirs) -+ - # Ensures that CMAKE_BUILD_TYPE is visible in cmake-gui on Unix - IF(NOT WIN32) - IF(NOT CMAKE_BUILD_TYPE) -@@ -114,7 +116,7 @@ - "pkg-config/jsoncpp.pc" - @ONLY) - INSTALL(FILES "${CMAKE_BINARY_DIR}/pkg-config/jsoncpp.pc" -- DESTINATION "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/pkgconfig") -+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") - ENDIF(JSONCPP_WITH_PKGCONFIG_SUPPORT) - - IF(JSONCPP_WITH_CMAKE_PACKAGE) ---- a/pkg-config/jsoncpp.pc.in -+++ b/pkg-config/jsoncpp.pc.in -@@ -1,6 +1,6 @@ - prefix=@CMAKE_INSTALL_PREFIX@ - exec_prefix=${prefix} --libdir=@LIBRARY_INSTALL_DIR@ -+libdir=/usr/@CMAKE_INSTALL_LIBDIR@ - includedir=@INCLUDE_INSTALL_DIR@ - - Name: jsoncpp diff -Nru libjsoncpp-1.6.5/debian/patches/0003-fix-arm.patch libjsoncpp-1.7.2/debian/patches/0003-fix-arm.patch --- libjsoncpp-1.6.5/debian/patches/0003-fix-arm.patch 2016-02-12 09:57:14.000000000 +0000 +++ libjsoncpp-1.7.2/debian/patches/0003-fix-arm.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -From 2760c7902a5cc7173aabe4e1f31dcf93e79377d5 Mon Sep 17 00:00:00 2001 -From: Christopher Dunn -Date: Wed, 10 Jun 2015 21:22:24 -0500 -Subject: fix build on armel and armhf - ---- - src/test_lib_json/main.cpp | 3 +++ - 1 file changed, 3 insertions(+) - ---- a/src/test_lib_json/main.cpp -+++ b/src/test_lib_json/main.cpp -@@ -282,7 +282,10 @@ - JSONTEST_ASSERT_EQUAL(0.0, null_.asFloat()); - JSONTEST_ASSERT_STRING_EQUAL("", null_.asString()); - -+#if !defined(__ARMEL__) -+ // See line #165 of include/json/value.h - JSONTEST_ASSERT_EQUAL(Json::Value::null, null_); -+#endif - } - - JSONTEST_FIXTURE(ValueTest, strings) { diff -Nru libjsoncpp-1.6.5/debian/patches/0004-fix-include-path.patch libjsoncpp-1.7.2/debian/patches/0004-fix-include-path.patch --- libjsoncpp-1.6.5/debian/patches/0004-fix-include-path.patch 2016-02-12 09:57:14.000000000 +0000 +++ libjsoncpp-1.7.2/debian/patches/0004-fix-include-path.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -Description: Fix include directory to avoid collisions with libjsonc -Author: Peter Spiess-Knafl -Forwarded: not-needed -Bug-Debian: https://bugs.debian.org/788379 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -30,7 +30,7 @@ - CACHE PATH "Install dir for static libraries") - SET(LIBRARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX} - CACHE PATH "Install dir for shared libraries") --SET(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include -+SET(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/jsoncpp - CACHE PATH "Install dir for headers") - SET(PACKAGE_INSTALL_DIR lib${LIB_SUFFIX}/cmake - CACHE PATH "Install dir for cmake package config files") diff -Nru libjsoncpp-1.6.5/debian/patches/fix-double-parsing.patch libjsoncpp-1.7.2/debian/patches/fix-double-parsing.patch --- libjsoncpp-1.6.5/debian/patches/fix-double-parsing.patch 2016-02-12 09:57:14.000000000 +0000 +++ libjsoncpp-1.7.2/debian/patches/fix-double-parsing.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -Description: Use stringstream to convert real numbers from strings. -Author: Rodney Dawes -Bug-Ubuntu: https://bugs.launchpad.net/bugs/1368420 - -=== modified file 'src/lib_json/json_reader.cpp' ---- a/src/lib_json/json_reader.cpp -+++ b/src/lib_json/json_reader.cpp -@@ -1421,33 +1421,11 @@ - - bool OurReader::decodeDouble(Token& token, Value& decoded) { - double value = 0; -- const int bufferSize = 32; -- int count; -- int length = int(token.end_ - token.start_); - -- // Sanity check to avoid buffer overflow exploits. -- if (length < 0) { -- return addError("Unable to parse token length", token); -- } -+ std::string buffer( token.start_, token.end_ ); -+ std::istringstream is(buffer); - -- // Avoid using a string constant for the format control string given to -- // sscanf, as this can cause hard to debug crashes on OS X. See here for more -- // info: -- // -- // http://developer.apple.com/library/mac/#DOCUMENTATION/DeveloperTools/gcc-4.0.1/gcc/Incompatibilities.html -- char format[] = "%lf"; -- -- if (length <= bufferSize) { -- Char buffer[bufferSize + 1]; -- memcpy(buffer, token.start_, length); -- buffer[length] = 0; -- count = sscanf(buffer, format, &value); -- } else { -- std::string buffer(token.start_, token.end_); -- count = sscanf(buffer.c_str(), format, &value); -- } -- -- if (count != 1) -+ if (!(is >> value)) - return addError("'" + std::string(token.start_, token.end_) + - "' is not a number.", - token); diff -Nru libjsoncpp-1.6.5/debian/patches/series libjsoncpp-1.7.2/debian/patches/series --- libjsoncpp-1.6.5/debian/patches/series 2016-02-12 09:57:14.000000000 +0000 +++ libjsoncpp-1.7.2/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 @@ -1,4 +0,0 @@ -0004-fix-include-path.patch -0001-multiarch-path-support.patch -fix-double-parsing.patch - diff -Nru libjsoncpp-1.6.5/debian/rules libjsoncpp-1.7.2/debian/rules --- libjsoncpp-1.6.5/debian/rules 2016-02-12 09:57:14.000000000 +0000 +++ libjsoncpp-1.7.2/debian/rules 2016-03-28 02:49:34.000000000 +0000 @@ -9,9 +9,8 @@ -DBUILD_SHARED_LIBS=ON \ -DBUILD_STATIC_LIBS=ON \ -DJSONCPP_WITH_CMAKE_PACKAGE=ON \ - -DCMAKE_INSTALL_PREFIX=/usr \ - -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH) \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo + -DLIB_SUFFIX="/$(DEB_TARGET_MULTIARCH)" \ + -DINCLUDE_INSTALL_DIR=/usr/include/jsoncpp override_dh_auto_build-indep: python doxybuild.py --doxygen=/usr/bin/doxygen diff -Nru libjsoncpp-1.6.5/debian/tests/control libjsoncpp-1.7.2/debian/tests/control --- libjsoncpp-1.6.5/debian/tests/control 1970-01-01 00:00:00.000000000 +0000 +++ libjsoncpp-1.7.2/debian/tests/control 2016-03-28 02:49:34.000000000 +0000 @@ -0,0 +1,5 @@ +Tests: testsuite +Depends: build-essential, + cmake, + libjsoncpp-dev, + pkg-config diff -Nru libjsoncpp-1.6.5/debian/tests/testsuite libjsoncpp-1.7.2/debian/tests/testsuite --- libjsoncpp-1.6.5/debian/tests/testsuite 1970-01-01 00:00:00.000000000 +0000 +++ libjsoncpp-1.7.2/debian/tests/testsuite 2016-03-28 02:49:34.000000000 +0000 @@ -0,0 +1,41 @@ +#!/bin/sh +# Copyright 2016 Ghislain Antony Vaillant +# +# This file is part of the autopkgtest testsuite for the libjsoncpp +# source package. + +set -e + +# Presence of $ADTTMP implies that someone will handle cleanup for us, so we +# can avoid duplicating the effort (signal handling, etc.) here. +if [ -z "$ADTTMP" ] +then + echo "Required envvar \"$ADTTMP\"is not set" >&2 + exit 1 +fi + +# Copy testsuite source code. +cp -a ./src/test_lib_json/* "$ADTTMP" +cd "$ADTTMP" + +cat < CMakeLists.txt +cmake_minimum_required(VERSION 2.6.2) +project(jsoncpp_test) + +find_package(jsoncpp REQUIRED) +# Using pkg-config instead of cmake config-mode because the +# packaged jsoncppConfig.cmake does not seem to work beyond detection. +find_package(PkgConfig) +pkg_check_modules(PC_jsoncpp QUIET jsoncpp) +include_directories(\${PC_jsoncpp_INCLUDE_DIRS}) +link_libraries(\${PC_jsoncpp_LIBRARIES}) + +add_executable(jsoncpp_test main.cpp jsontest.cpp jsontest.h) + +EOF + +# Configure, build and execute. +mkdir build && cd build +cmake .. +make VERBOSE=1 -j$(nproc) +./jsoncpp_test diff -Nru libjsoncpp-1.6.5/debian/watch libjsoncpp-1.7.2/debian/watch --- libjsoncpp-1.6.5/debian/watch 2016-02-12 09:57:14.000000000 +0000 +++ libjsoncpp-1.7.2/debian/watch 2016-03-28 02:49:34.000000000 +0000 @@ -1,3 +1,2 @@ version=3 -opts=pgpsigurlmangle=s/archive\/(.+)\.tar\.gz/releases\/download\/$1\/jsoncpp-$1.tar.gz.asc/,filenamemangle=s/.+\/v?(0\.\d\S*)\.tar\.gz/jsoncpp-$1\.tar\.gz/ \ - https://github.com/open-source-parsers/jsoncpp/tags .*/v?(\d\.\d\S*)\.tar\.gz +https://github.com/open-source-parsers/jsoncpp/releases /open-source-parsers/jsoncpp/archive/(.+)\.tar\.gz diff -Nru libjsoncpp-1.6.5/devtools/agent_vmw7.json libjsoncpp-1.7.2/devtools/agent_vmw7.json --- libjsoncpp-1.6.5/devtools/agent_vmw7.json 2015-07-23 05:26:13.000000000 +0000 +++ libjsoncpp-1.7.2/devtools/agent_vmw7.json 2016-03-25 20:09:15.000000000 +0000 @@ -10,12 +10,12 @@ "Visual Studio 10 Win64", "Visual Studio 11", "Visual Studio 11 Win64" - ] + ] }, - {"generator": ["MinGW Makefiles"], + {"generator": ["MinGW Makefiles"], "env_prepend": [{"path": "c:/wut/prg/MinGW/bin"}] } - ] + ] }, {"name": "shared_dll", "variables": [ @@ -25,8 +25,8 @@ }, {"name": "build_type", "build_types": [ - "debug", - "release" + "debug", + "release" ] } ] diff -Nru libjsoncpp-1.6.5/devtools/agent_vmxp.json libjsoncpp-1.7.2/devtools/agent_vmxp.json --- libjsoncpp-1.6.5/devtools/agent_vmxp.json 2015-07-23 05:26:13.000000000 +0000 +++ libjsoncpp-1.7.2/devtools/agent_vmxp.json 2016-03-25 20:09:15.000000000 +0000 @@ -6,9 +6,9 @@ "Visual Studio 6", "Visual Studio 7", "Visual Studio 8 2005" - ] + ] } - ] + ] }, {"name": "shared_dll", "variables": [ @@ -18,8 +18,8 @@ }, {"name": "build_type", "build_types": [ - "debug", - "release" + "debug", + "release" ] } ] diff -Nru libjsoncpp-1.6.5/.gitattributes libjsoncpp-1.7.2/.gitattributes --- libjsoncpp-1.6.5/.gitattributes 1970-01-01 00:00:00.000000000 +0000 +++ libjsoncpp-1.7.2/.gitattributes 2016-03-25 20:09:15.000000000 +0000 @@ -0,0 +1,11 @@ +* text=auto +*.h text +*.cpp text +*.json text +*.in text +*.sh eol=lf +*.bat eol=crlf +*.vcproj eol=crlf +*.vcxproj eol=crlf +*.sln eol=crlf +devtools/agent_vm* eol=crlf diff -Nru libjsoncpp-1.6.5/.gitignore libjsoncpp-1.7.2/.gitignore --- libjsoncpp-1.6.5/.gitignore 2015-07-23 05:26:13.000000000 +0000 +++ libjsoncpp-1.7.2/.gitignore 2016-03-25 20:09:15.000000000 +0000 @@ -34,3 +34,19 @@ cmake_install.cmake pkg-config/jsoncpp.pc jsoncpp_lib_static.dir/ + +# In case someone runs cmake in the root-dir: +/CMakeCache.txt +/Makefile +/include/Makefile +/src/Makefile +/src/jsontestrunner/Makefile +/src/jsontestrunner/jsontestrunner_exe +/src/lib_json/Makefile +/src/test_lib_json/Makefile +/src/test_lib_json/jsoncpp_test + +# eclipse project files +.project +.cproject +/.settings/ diff -Nru libjsoncpp-1.6.5/include/json/allocator.h libjsoncpp-1.7.2/include/json/allocator.h --- libjsoncpp-1.6.5/include/json/allocator.h 1970-01-01 00:00:00.000000000 +0000 +++ libjsoncpp-1.7.2/include/json/allocator.h 2016-03-25 20:09:15.000000000 +0000 @@ -0,0 +1,94 @@ +// Copyright 2007-2010 Baptiste Lepilleur +// Distributed under MIT license, or public domain if desired and +// recognized in your jurisdiction. +// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE + +#ifndef CPPTL_JSON_ALLOCATOR_H_INCLUDED +#define CPPTL_JSON_ALLOCATOR_H_INCLUDED + +#include +#include + +namespace Json { +template +class SecureAllocator { + public: + // Type definitions + using value_type = T; + using pointer = T*; + using const_pointer = const T*; + using reference = T&; + using const_reference = const T&; + using size_type = std::size_t; + using difference_type = std::ptrdiff_t; + + /** + * Allocate memory for N items using the standard allocator. + */ + pointer allocate(size_type n) { + // allocate using "global operator new" + return static_cast(::operator new(n * sizeof(T))); + } + + /** + * 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)); + // free using "global operator delete" + ::operator delete(p); + } + + /** + * Construct an item in-place at pointer P. + */ + template + void construct(pointer p, Args&&... args) { + // construct using "placement new" and "perfect forwarding" + ::new (static_cast(p)) T(std::forward(args)...); + } + + size_type max_size() const { + return size_t(-1) / sizeof(T); + } + + pointer address( reference x ) const { + return std::addressof(x); + } + + const_pointer address( const_reference x ) const { + return std::addressof(x); + } + + /** + * Destroy an item in-place at pointer P. + */ + void destroy(pointer p) { + // destroy using "explicit destructor" + p->~T(); + } + + // Boilerplate + SecureAllocator() {} + template SecureAllocator(const SecureAllocator&) {} + template struct rebind { using other = SecureAllocator; }; +}; + + +template +bool operator==(const SecureAllocator&, const SecureAllocator&) { + return true; +} + +template +bool operator!=(const SecureAllocator&, const SecureAllocator&) { + return false; +} + +} //namespace Json + +#endif // CPPTL_JSON_ALLOCATOR_H_INCLUDED diff -Nru libjsoncpp-1.6.5/include/json/assertions.h libjsoncpp-1.7.2/include/json/assertions.h --- libjsoncpp-1.6.5/include/json/assertions.h 2015-07-23 05:26:13.000000000 +0000 +++ libjsoncpp-1.7.2/include/json/assertions.h 2016-03-25 20:09:15.000000000 +0000 @@ -25,7 +25,7 @@ # define JSON_FAIL_MESSAGE(message) \ { \ - std::ostringstream oss; oss << message; \ + JSONCPP_OSTRINGSTREAM oss; oss << message; \ Json::throwLogicError(oss.str()); \ abort(); \ } @@ -38,7 +38,7 @@ // release builds we abort, for a core-dump or debugger. # define JSON_FAIL_MESSAGE(message) \ { \ - std::ostringstream oss; oss << message; \ + JSONCPP_OSTRINGSTREAM oss; oss << message; \ assert(false && oss.str().c_str()); \ abort(); \ } diff -Nru libjsoncpp-1.6.5/include/json/config.h libjsoncpp-1.7.2/include/json/config.h --- libjsoncpp-1.6.5/include/json/config.h 2015-07-23 05:26:13.000000000 +0000 +++ libjsoncpp-1.7.2/include/json/config.h 2016-03-25 20:09:15.000000000 +0000 @@ -5,6 +5,8 @@ #ifndef JSON_CONFIG_H_INCLUDED #define JSON_CONFIG_H_INCLUDED +#include +#include //typdef String /// If defined, indicates that json library is embedded in CppTL library. //# define JSON_IN_CPPTL 1 @@ -37,12 +39,12 @@ #ifdef JSON_IN_CPPTL #define JSON_API CPPTL_API #elif defined(JSON_DLL_BUILD) -#if defined(_MSC_VER) +#if defined(_MSC_VER) || defined(__MINGW32__) #define JSON_API __declspec(dllexport) #define JSONCPP_DISABLE_DLL_INTERFACE_WARNING #endif // if defined(_MSC_VER) #elif defined(JSON_DLL) -#if defined(_MSC_VER) +#if defined(_MSC_VER) || defined(__MINGW32__) #define JSON_API __declspec(dllimport) #define JSONCPP_DISABLE_DLL_INTERFACE_WARNING #endif // if defined(_MSC_VER) @@ -56,34 +58,83 @@ // Storages, and 64 bits integer support is disabled. // #define JSON_NO_INT64 1 -#if defined(_MSC_VER) && _MSC_VER <= 1200 // MSVC 6 -// Microsoft Visual Studio 6 only support conversion from __int64 to double -// (no conversion from unsigned __int64). -#define JSON_USE_INT64_DOUBLE_CONVERSION 1 -// Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255' -// characters in the debug information) -// All projects I've ever seen with VS6 were using this globally (not bothering -// with pragma push/pop). -#pragma warning(disable : 4786) -#endif // if defined(_MSC_VER) && _MSC_VER < 1200 // MSVC 6 - -#if defined(_MSC_VER) && _MSC_VER >= 1500 // MSVC 2008 -/// Indicates that the following function is deprecated. -#define JSONCPP_DEPRECATED(message) __declspec(deprecated(message)) -#elif defined(__clang__) && defined(__has_feature) -#if __has_feature(attribute_deprecated_with_message) -#define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message))) -#endif -#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)) -#define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message))) -#elif defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) -#define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__)) -#endif +#if defined(_MSC_VER) // MSVC +# if _MSC_VER <= 1200 // MSVC 6 + // Microsoft Visual Studio 6 only support conversion from __int64 to double + // (no conversion from unsigned __int64). +# define JSON_USE_INT64_DOUBLE_CONVERSION 1 + // Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255' + // characters in the debug information) + // All projects I've ever seen with VS6 were using this globally (not bothering + // with pragma push/pop). +# pragma warning(disable : 4786) +# endif // MSVC 6 + +# if _MSC_VER >= 1500 // MSVC 2008 + /// Indicates that the following function is deprecated. +# define JSONCPP_DEPRECATED(message) __declspec(deprecated(message)) +# endif + +#endif // defined(_MSC_VER) + +#if defined(_MSC_VER) && _MSC_VER <= 1600 // MSVC <= 2010 +# define JSONCPP_OVERRIDE +#else +# define JSONCPP_OVERRIDE override +#endif // MSVC <= 2010 + + +#ifndef JSON_HAS_RVALUE_REFERENCES + +#if defined(_MSC_VER) && _MSC_VER >= 1600 // MSVC >= 2010 +#define JSON_HAS_RVALUE_REFERENCES 1 +#endif // MSVC >= 2010 + +#ifdef __clang__ +#if __has_feature(cxx_rvalue_references) +#define JSON_HAS_RVALUE_REFERENCES 1 +#endif // has_feature + +#elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc) +#if defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L) +#define JSON_HAS_RVALUE_REFERENCES 1 +#endif // GXX_EXPERIMENTAL + +#endif // __clang__ || __GNUC__ + +#endif // not defined JSON_HAS_RVALUE_REFERENCES + +#ifndef JSON_HAS_RVALUE_REFERENCES +#define JSON_HAS_RVALUE_REFERENCES 0 +#endif + +#ifdef __clang__ +#elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc) +# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)) +# define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message))) +# elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) +# define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__)) +# endif // GNUC version +#endif // __clang__ || __GNUC__ #if !defined(JSONCPP_DEPRECATED) #define JSONCPP_DEPRECATED(message) #endif // if !defined(JSONCPP_DEPRECATED) +#if __GNUC__ >= 6 +# define JSON_USE_INT64_DOUBLE_CONVERSION 1 +#endif + +#if !defined(JSON_IS_AMALGAMATION) + +# include "version.h" + +# if JSONCPP_USING_SECURE_MEMORY +# include "allocator.h" //typedef Allocator +# endif + +#endif // if !defined(JSON_IS_AMALGAMATION) + namespace Json { typedef int Int; typedef unsigned int UInt; @@ -104,6 +155,19 @@ typedef UInt64 LargestUInt; #define JSON_HAS_INT64 #endif // if defined(JSON_NO_INT64) +#if JSONCPP_USING_SECURE_MEMORY +#define JSONCPP_STRING std::basic_string, Json::SecureAllocator > +#define JSONCPP_OSTRINGSTREAM std::basic_ostringstream, Json::SecureAllocator > +#define JSONCPP_OSTREAM std::basic_ostream> +#define JSONCPP_ISTRINGSTREAM std::basic_istringstream, Json::SecureAllocator > +#define JSONCPP_ISTREAM std::istream +#else +#define JSONCPP_STRING std::string +#define JSONCPP_OSTRINGSTREAM std::ostringstream +#define JSONCPP_OSTREAM std::ostream +#define JSONCPP_ISTRINGSTREAM std::istringstream +#define JSONCPP_ISTREAM std::istream +#endif // if JSONCPP_USING_SECURE_MEMORY } // end namespace Json #endif // JSON_CONFIG_H_INCLUDED diff -Nru libjsoncpp-1.6.5/include/json/reader.h libjsoncpp-1.7.2/include/json/reader.h --- libjsoncpp-1.6.5/include/json/reader.h 2015-07-23 05:26:13.000000000 +0000 +++ libjsoncpp-1.7.2/include/json/reader.h 2016-03-25 20:09:15.000000000 +0000 @@ -42,9 +42,9 @@ * */ struct StructuredError { - size_t offset_start; - size_t offset_limit; - std::string message; + ptrdiff_t offset_start; + ptrdiff_t offset_limit; + JSONCPP_STRING message; }; /** \brief Constructs a Reader allowing all features @@ -99,7 +99,7 @@ /// \brief Parse from input stream. /// \see Json::operator>>(std::istream&, Json::Value&). - bool parse(std::istream& is, Value& root, bool collectComments = true); + bool parse(JSONCPP_ISTREAM& is, Value& root, bool collectComments = true); /** \brief Returns a user friendly string that list errors in the parsed * document. @@ -111,7 +111,7 @@ * \deprecated Use getFormattedErrorMessages() instead (typo fix). */ JSONCPP_DEPRECATED("Use getFormattedErrorMessages() instead.") - std::string getFormatedErrorMessages() const; + JSONCPP_STRING getFormatedErrorMessages() const; /** \brief Returns a user friendly string that list errors in the parsed * document. @@ -121,7 +121,7 @@ * occurred * during parsing. */ - std::string getFormattedErrorMessages() const; + JSONCPP_STRING getFormattedErrorMessages() const; /** \brief Returns a vector of structured erros encounted while parsing. * \return A (possibly empty) vector of StructuredError objects. Currently @@ -138,7 +138,7 @@ * \return \c true if the error was successfully added, \c false if the * Value offset exceeds the document size. */ - bool pushError(const Value& value, const std::string& message); + bool pushError(const Value& value, const JSONCPP_STRING& message); /** \brief Add a semantic error message with extra context. * \param value JSON Value location associated with the error @@ -147,7 +147,7 @@ * \return \c true if the error was successfully added, \c false if either * Value offset exceeds the document size. */ - bool pushError(const Value& value, const std::string& message, const Value& extra); + bool pushError(const Value& value, const JSONCPP_STRING& message, const Value& extra); /** \brief Return whether there are any errors. * \return \c true if there are no errors to report \c false if @@ -183,7 +183,7 @@ class ErrorInfo { public: Token token_; - std::string message_; + JSONCPP_STRING message_; Location extra_; }; @@ -203,7 +203,7 @@ bool decodeNumber(Token& token); bool decodeNumber(Token& token, Value& decoded); bool decodeString(Token& token); - bool decodeString(Token& token, std::string& decoded); + bool decodeString(Token& token, JSONCPP_STRING& decoded); bool decodeDouble(Token& token); bool decodeDouble(Token& token, Value& decoded); bool decodeUnicodeCodePoint(Token& token, @@ -214,9 +214,9 @@ Location& current, Location end, unsigned int& unicode); - bool addError(const std::string& message, Token& token, Location extra = 0); + bool addError(const JSONCPP_STRING& message, Token& token, Location extra = 0); bool recoverFromError(TokenType skipUntilToken); - bool addErrorAndRecover(const std::string& message, + bool addErrorAndRecover(const JSONCPP_STRING& message, Token& token, TokenType skipUntilToken); void skipUntilSpace(); @@ -224,20 +224,20 @@ Char getNextChar(); void getLocationLineAndColumn(Location location, int& line, int& column) const; - std::string getLocationLineAndColumn(Location location) const; + JSONCPP_STRING getLocationLineAndColumn(Location location) const; void addComment(Location begin, Location end, CommentPlacement placement); void skipCommentTokens(Token& token); typedef std::stack Nodes; Nodes nodes_; Errors errors_; - std::string document_; + JSONCPP_STRING document_; Location begin_; Location end_; Location current_; Location lastValueEnd_; Value* lastValue_; - std::string commentsBefore_; + JSONCPP_STRING commentsBefore_; Features features_; bool collectComments_; }; // Reader @@ -266,9 +266,9 @@ */ virtual bool parse( char const* beginDoc, char const* endDoc, - Value* root, std::string* errs) = 0; + Value* root, JSONCPP_STRING* errs) = 0; - class Factory { + class JSON_API Factory { public: virtual ~Factory() {} /** \brief Allocate a CharReader via operator new(). @@ -286,7 +286,7 @@ CharReaderBuilder builder; builder["collectComments"] = false; Value value; - std::string errs; + JSONCPP_STRING errs; bool ok = parseFromStream(builder, std::cin, &value, &errs); \endcode */ @@ -321,6 +321,9 @@ the JSON value in the input string. - `"rejectDupKeys": false or true` - If true, `parse()` returns false when a key is duplicated within an object. + - `"allowSpecialFloats": false or true` + - If true, special float values (NaNs and infinities) are allowed + and their values are lossfree restorable. You can examine 'settings_` yourself to see the defaults. You can also write and read them just like any @@ -330,9 +333,9 @@ Json::Value settings_; CharReaderBuilder(); - virtual ~CharReaderBuilder(); + ~CharReaderBuilder() JSONCPP_OVERRIDE; - virtual CharReader* newCharReader() const; + CharReader* newCharReader() const JSONCPP_OVERRIDE; /** \return true if 'settings' are legal and consistent; * otherwise, indicate bad settings via 'invalid'. @@ -341,7 +344,7 @@ /** A simple way to update a specific setting. */ - Value& operator[](std::string key); + Value& operator[](JSONCPP_STRING key); /** Called by ctor, but you can use this to reset settings_. * \pre 'settings' != NULL (but Json::null is fine) @@ -363,7 +366,7 @@ */ bool JSON_API parseFromStream( CharReader::Factory const&, - std::istream&, + JSONCPP_ISTREAM&, Value* root, std::string* errs); /** \brief Read from 'sin' into 'root'. @@ -390,7 +393,7 @@ \throw std::exception on parse error. \see Json::operator<<() */ -JSON_API std::istream& operator>>(std::istream&, Value&); +JSON_API JSONCPP_ISTREAM& operator>>(JSONCPP_ISTREAM&, Value&); } // namespace Json diff -Nru libjsoncpp-1.6.5/include/json/value.h libjsoncpp-1.7.2/include/json/value.h --- libjsoncpp-1.6.5/include/json/value.h 2015-07-23 05:26:13.000000000 +0000 +++ libjsoncpp-1.7.2/include/json/value.h 2016-03-25 20:09:15.000000000 +0000 @@ -22,6 +22,19 @@ #include #endif +//Conditional NORETURN attribute on the throw functions would: +// a) suppress false positives from static code analysis +// b) possibly improve optimization opportunities. +#if !defined(JSONCPP_NORETURN) +# if defined(_MSC_VER) +# define JSONCPP_NORETURN __declspec(noreturn) +# elif defined(__GNUC__) +# define JSONCPP_NORETURN __attribute__ ((__noreturn__)) +# else +# define JSONCPP_NORETURN +# endif +#endif + // Disable warning C4251: : needs to have dll-interface to // be used by... #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) @@ -39,11 +52,11 @@ */ class JSON_API Exception : public std::exception { public: - Exception(std::string const& msg); - virtual ~Exception() throw(); - virtual char const* what() const throw(); + Exception(JSONCPP_STRING const& msg); + ~Exception() throw() JSONCPP_OVERRIDE; + char const* what() const throw() JSONCPP_OVERRIDE; protected: - std::string const msg_; + JSONCPP_STRING msg_; }; /** Exceptions which the user cannot easily avoid. @@ -54,7 +67,7 @@ */ class JSON_API RuntimeError : public Exception { public: - RuntimeError(std::string const& msg); + RuntimeError(JSONCPP_STRING const& msg); }; /** Exceptions thrown by JSON_ASSERT/JSON_FAIL macros. @@ -65,13 +78,13 @@ */ class JSON_API LogicError : public Exception { public: - LogicError(std::string const& msg); + LogicError(JSONCPP_STRING const& msg); }; /// used internally -void throwRuntimeError(std::string const& msg); +JSONCPP_NORETURN void throwRuntimeError(JSONCPP_STRING const& msg); /// used internally -void throwLogicError(std::string const& msg); +JSONCPP_NORETURN void throwLogicError(JSONCPP_STRING const& msg); /** \brief Type of the value held by a Value object. */ @@ -162,7 +175,7 @@ class JSON_API Value { friend class ValueIteratorBase; public: - typedef std::vector Members; + typedef std::vector Members; typedef ValueIterator iterator; typedef ValueConstIterator const_iterator; typedef Json::UInt UInt; @@ -212,6 +225,9 @@ CZString(ArrayIndex index); CZString(char const* str, unsigned length, DuplicationPolicy allocate); CZString(CZString const& other); +#if JSON_HAS_RVALUE_REFERENCES + CZString(CZString&& other); +#endif ~CZString(); CZString& operator=(CZString other); bool operator<(CZString const& other) const; @@ -287,13 +303,17 @@ * \endcode */ Value(const StaticString& value); - Value(const std::string& value); ///< Copy data() til size(). Embedded zeroes too. + Value(const JSONCPP_STRING& value); ///< Copy data() til size(). Embedded zeroes too. #ifdef JSON_USE_CPPTL Value(const CppTL::ConstString& value); #endif Value(bool value); /// Deep copy. Value(const Value& other); +#if JSON_HAS_RVALUE_REFERENCES + /// Move constructor + Value(Value&& other); +#endif ~Value(); /// Deep copy, then swap(other). @@ -316,7 +336,10 @@ int compare(const Value& other) const; const char* asCString() const; ///< Embedded zeroes could cause you trouble! - std::string asString() const; ///< Embedded zeroes are possible. +#if JSONCPP_USING_SECURE_MEMORY + unsigned getCStringLength() const; //Allows you to understand the length of the CString +#endif + JSONCPP_STRING asString() const; ///< Embedded zeroes are possible. /** Get raw char* of string-value. * \return false if !string. (Seg-fault if str or end are NULL.) */ @@ -420,11 +443,11 @@ const Value& operator[](const char* key) const; /// Access an object value by name, create a null member if it does not exist. /// \param key may contain embedded nulls. - Value& operator[](const std::string& key); + Value& operator[](const JSONCPP_STRING& key); /// Access an object value by name, returns null if there is no member with /// that name. /// \param key may contain embedded nulls. - const Value& operator[](const std::string& key) const; + const Value& operator[](const JSONCPP_STRING& key) const; /** \brief Access an object value by name, create a null member if it does not exist. @@ -455,7 +478,7 @@ /// Return the member named key if it exist, defaultValue otherwise. /// \note deep copy /// \param key may contain embedded nulls. - Value get(const std::string& key, const Value& defaultValue) const; + Value get(const JSONCPP_STRING& key, const Value& defaultValue) const; #ifdef JSON_USE_CPPTL /// Return the member named key if it exist, defaultValue otherwise. /// \note deep copy @@ -480,7 +503,7 @@ /// Same as removeMember(const char*) /// \param key may contain embedded nulls. /// \deprecated - Value removeMember(const std::string& key); + Value removeMember(const JSONCPP_STRING& key); /// Same as removeMember(const char* begin, const char* end, Value* removed), /// but 'key' is null-terminated. bool removeMember(const char* key, Value* removed); @@ -490,8 +513,8 @@ \param key may contain embedded nulls. \return true iff removed (no exceptions) */ - bool removeMember(std::string const& key, Value* removed); - /// Same as removeMember(std::string const& key, Value* removed) + bool removeMember(JSONCPP_STRING const& key, Value* removed); + /// Same as removeMember(JSONCPP_STRING const& key, Value* removed) bool removeMember(const char* begin, const char* end, Value* removed); /** \brief Remove the indexed array element. @@ -506,8 +529,8 @@ bool isMember(const char* key) const; /// Return true if the object has a member named key. /// \param key may contain embedded nulls. - bool isMember(const std::string& key) const; - /// Same as isMember(std::string const& key)const + bool isMember(const JSONCPP_STRING& key) const; + /// Same as isMember(JSONCPP_STRING const& key)const bool isMember(const char* begin, const char* end) const; #ifdef JSON_USE_CPPTL /// Return true if the object has a member named key. @@ -527,17 +550,17 @@ //# endif /// \deprecated Always pass len. - JSONCPP_DEPRECATED("Use setComment(std::string const&) instead.") + JSONCPP_DEPRECATED("Use setComment(JSONCPP_STRING const&) instead.") void setComment(const char* comment, CommentPlacement placement); /// Comments must be //... or /* ... */ void setComment(const char* comment, size_t len, CommentPlacement placement); /// Comments must be //... or /* ... */ - void setComment(const std::string& comment, CommentPlacement placement); + void setComment(const JSONCPP_STRING& comment, CommentPlacement placement); bool hasComment(CommentPlacement placement) const; /// Include delimiters and embedded newlines. - std::string getComment(CommentPlacement placement) const; + JSONCPP_STRING getComment(CommentPlacement placement) const; - std::string toStyledString() const; + JSONCPP_STRING toStyledString() const; const_iterator begin() const; const_iterator end() const; @@ -547,10 +570,10 @@ // Accessors for the [start, limit) range of bytes within the JSON text from // which this value was parsed, if any. - void setOffsetStart(size_t start); - void setOffsetLimit(size_t limit); - size_t getOffsetStart() const; - size_t getOffsetLimit() const; + void setOffsetStart(ptrdiff_t start); + void setOffsetLimit(ptrdiff_t limit); + ptrdiff_t getOffsetStart() const; + ptrdiff_t getOffsetLimit() const; private: void initBasic(ValueType type, bool allocated = false); @@ -591,8 +614,8 @@ // [start, limit) byte offsets in the source JSON text from which this Value // was extracted. - size_t start_; - size_t limit_; + ptrdiff_t start_; + ptrdiff_t limit_; }; /** \brief Experimental and untested: represents an element of the "path" to @@ -605,7 +628,7 @@ PathArgument(); PathArgument(ArrayIndex index); PathArgument(const char* key); - PathArgument(const std::string& key); + PathArgument(const JSONCPP_STRING& key); private: enum Kind { @@ -613,7 +636,7 @@ kindIndex, kindKey }; - std::string key_; + JSONCPP_STRING key_; ArrayIndex index_; Kind kind_; }; @@ -631,7 +654,7 @@ */ class JSON_API Path { public: - Path(const std::string& path, + Path(const JSONCPP_STRING& path, const PathArgument& a1 = PathArgument(), const PathArgument& a2 = PathArgument(), const PathArgument& a3 = PathArgument(), @@ -648,12 +671,12 @@ typedef std::vector InArgs; typedef std::vector Args; - void makePath(const std::string& path, const InArgs& in); - void addPathInArg(const std::string& path, + void makePath(const JSONCPP_STRING& path, const InArgs& in); + void addPathInArg(const JSONCPP_STRING& path, const InArgs& in, InArgs::const_iterator& itInArg, PathArgument::Kind kind); - void invalidPath(const std::string& path, int location); + void invalidPath(const JSONCPP_STRING& path, int location); Args args_; }; @@ -686,7 +709,7 @@ /// Return the member name of the referenced Value, or "" if it is not an /// objectValue. /// \note Avoid `c_str()` on result, as embedded zeroes are possible. - std::string name() const; + JSONCPP_STRING name() const; /// Return the member name of the referenced Value. "" if it is not an /// objectValue. @@ -738,6 +761,7 @@ typedef ValueConstIterator SelfType; ValueConstIterator(); + ValueConstIterator(ValueIterator const& other); private: /*! \internal Use by Value to create an iterator. @@ -787,7 +811,7 @@ typedef ValueIterator SelfType; ValueIterator(); - ValueIterator(const ValueConstIterator& other); + explicit ValueIterator(const ValueConstIterator& other); ValueIterator(const ValueIterator& other); private: diff -Nru libjsoncpp-1.6.5/include/json/version.h libjsoncpp-1.7.2/include/json/version.h --- libjsoncpp-1.6.5/include/json/version.h 2015-07-23 05:26:13.000000000 +0000 +++ libjsoncpp-1.7.2/include/json/version.h 2016-03-25 20:09:15.000000000 +0000 @@ -3,11 +3,18 @@ #ifndef JSON_VERSION_H_INCLUDED # define JSON_VERSION_H_INCLUDED -# define JSONCPP_VERSION_STRING "1.6.5" +# define JSONCPP_VERSION_STRING "1.7.2" # define JSONCPP_VERSION_MAJOR 1 -# define JSONCPP_VERSION_MINOR 6 -# define JSONCPP_VERSION_PATCH 5 +# define JSONCPP_VERSION_MINOR 7 +# define JSONCPP_VERSION_PATCH 2 # define JSONCPP_VERSION_QUALIFIER # define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8)) +#ifdef JSONCPP_USING_SECURE_MEMORY +#undef JSONCPP_USING_SECURE_MEMORY +#endif +#define JSONCPP_USING_SECURE_MEMORY 0 +// If non-zero, the library zeroes any memory that it has allocated before +// it frees its memory. + #endif // JSON_VERSION_H_INCLUDED diff -Nru libjsoncpp-1.6.5/include/json/writer.h libjsoncpp-1.7.2/include/json/writer.h --- libjsoncpp-1.6.5/include/json/writer.h 2015-07-23 05:26:13.000000000 +0000 +++ libjsoncpp-1.7.2/include/json/writer.h 2016-03-25 20:09:15.000000000 +0000 @@ -39,7 +39,7 @@ */ class JSON_API StreamWriter { protected: - std::ostream* sout_; // not owned; will not delete + JSONCPP_OSTREAM* sout_; // not owned; will not delete public: StreamWriter(); virtual ~StreamWriter(); @@ -49,7 +49,7 @@ \return zero on success (For now, we always return zero, so check the stream instead.) \throw std::exception possibly, depending on configuration */ - virtual int write(Value const& root, std::ostream* sout) = 0; + virtual int write(Value const& root, JSONCPP_OSTREAM* sout) = 0; /** \brief A simple abstract factory. */ @@ -66,7 +66,7 @@ /** \brief Write into stringstream, then return string, for convenience. * A StreamWriter will be created from the factory, used, and then deleted. */ -std::string JSON_API writeString(StreamWriter::Factory const& factory, Value const& root); +JSONCPP_STRING JSON_API writeString(StreamWriter::Factory const& factory, Value const& root); /** \brief Build a StreamWriter implementation. @@ -99,6 +99,10 @@ Strictly speaking, this is not valid JSON. But when the output is being fed to a browser's Javascript, it makes for smaller output and the browser can handle the output just fine. + - "useSpecialFloats": false or true + - If true, outputs non-finite floating point values in the following way: + NaN values as "NaN", positive infinity as "Infinity", and negative infinity + as "-Infinity". You can examine 'settings_` yourself to see the defaults. You can also write and read them just like any @@ -108,12 +112,12 @@ Json::Value settings_; StreamWriterBuilder(); - virtual ~StreamWriterBuilder(); + ~StreamWriterBuilder() JSONCPP_OVERRIDE; /** * \throw std::exception if something goes wrong (e.g. invalid settings) */ - virtual StreamWriter* newStreamWriter() const; + StreamWriter* newStreamWriter() const JSONCPP_OVERRIDE; /** \return true if 'settings' are legal and consistent; * otherwise, indicate bad settings via 'invalid'. @@ -121,7 +125,7 @@ bool validate(Json::Value* invalid) const; /** A simple way to update a specific setting. */ - Value& operator[](std::string key); + Value& operator[](JSONCPP_STRING key); /** Called by ctor, but you can use this to reset settings_. * \pre 'settings' != NULL (but Json::null is fine) @@ -138,7 +142,7 @@ public: virtual ~Writer(); - virtual std::string write(const Value& root) = 0; + virtual JSONCPP_STRING write(const Value& root) = 0; }; /** \brief Outputs a Value in JSON format @@ -154,7 +158,7 @@ public: FastWriter(); - virtual ~FastWriter() {} + ~FastWriter() JSONCPP_OVERRIDE {} void enableYAMLCompatibility(); @@ -168,12 +172,12 @@ void omitEndingLineFeed(); public: // overridden from Writer - virtual std::string write(const Value& root); + JSONCPP_STRING write(const Value& root) JSONCPP_OVERRIDE; private: void writeValue(const Value& value); - std::string document_; + JSONCPP_STRING document_; bool yamlCompatiblityEnabled_; bool dropNullPlaceholders_; bool omitEndingLineFeed_; @@ -206,36 +210,36 @@ class JSON_API StyledWriter : public Writer { public: StyledWriter(); - virtual ~StyledWriter() {} + ~StyledWriter() JSONCPP_OVERRIDE {} public: // overridden from Writer /** \brief Serialize a Value in JSON format. * \param root Value to serialize. * \return String containing the JSON document that represents the root value. */ - virtual std::string write(const Value& root); + JSONCPP_STRING write(const Value& root) JSONCPP_OVERRIDE; private: void writeValue(const Value& value); void writeArrayValue(const Value& value); bool isMultineArray(const Value& value); - void pushValue(const std::string& value); + void pushValue(const JSONCPP_STRING& value); void writeIndent(); - void writeWithIndent(const std::string& value); + void writeWithIndent(const JSONCPP_STRING& value); void indent(); void unindent(); void writeCommentBeforeValue(const Value& root); void writeCommentAfterValueOnSameLine(const Value& root); bool hasCommentForValue(const Value& value); - static std::string normalizeEOL(const std::string& text); + static JSONCPP_STRING normalizeEOL(const JSONCPP_STRING& text); - typedef std::vector ChildValues; + typedef std::vector ChildValues; ChildValues childValues_; - std::string document_; - std::string indentString_; - int rightMargin_; - int indentSize_; + JSONCPP_STRING document_; + JSONCPP_STRING indentString_; + unsigned int rightMargin_; + unsigned int indentSize_; bool addChildValues_; }; @@ -267,7 +271,7 @@ */ class JSON_API StyledStreamWriter { public: - StyledStreamWriter(std::string indentation = "\t"); + StyledStreamWriter(JSONCPP_STRING indentation = "\t"); ~StyledStreamWriter() {} public: @@ -277,46 +281,46 @@ * \note There is no point in deriving from Writer, since write() should not * return a value. */ - void write(std::ostream& out, const Value& root); + void write(JSONCPP_OSTREAM& out, const Value& root); private: void writeValue(const Value& value); void writeArrayValue(const Value& value); bool isMultineArray(const Value& value); - void pushValue(const std::string& value); + void pushValue(const JSONCPP_STRING& value); void writeIndent(); - void writeWithIndent(const std::string& value); + void writeWithIndent(const JSONCPP_STRING& value); void indent(); void unindent(); void writeCommentBeforeValue(const Value& root); void writeCommentAfterValueOnSameLine(const Value& root); bool hasCommentForValue(const Value& value); - static std::string normalizeEOL(const std::string& text); + static JSONCPP_STRING normalizeEOL(const JSONCPP_STRING& text); - typedef std::vector ChildValues; + typedef std::vector ChildValues; ChildValues childValues_; - std::ostream* document_; - std::string indentString_; - int rightMargin_; - std::string indentation_; + JSONCPP_OSTREAM* document_; + JSONCPP_STRING indentString_; + unsigned int rightMargin_; + JSONCPP_STRING indentation_; bool addChildValues_ : 1; bool indented_ : 1; }; #if defined(JSON_HAS_INT64) -std::string JSON_API valueToString(Int value); -std::string JSON_API valueToString(UInt value); +JSONCPP_STRING JSON_API valueToString(Int value); +JSONCPP_STRING JSON_API valueToString(UInt value); #endif // if defined(JSON_HAS_INT64) -std::string JSON_API valueToString(LargestInt value); -std::string JSON_API valueToString(LargestUInt value); -std::string JSON_API valueToString(double value); -std::string JSON_API valueToString(bool value); -std::string JSON_API valueToQuotedString(const char* value); +JSONCPP_STRING JSON_API valueToString(LargestInt value); +JSONCPP_STRING JSON_API valueToString(LargestUInt value); +JSONCPP_STRING JSON_API valueToString(double value); +JSONCPP_STRING JSON_API valueToString(bool value); +JSONCPP_STRING JSON_API valueToQuotedString(const char* value); /// \brief Output using the StyledStreamWriter. /// \see Json::operator>>() -JSON_API std::ostream& operator<<(std::ostream&, const Value& root); +JSON_API JSONCPP_OSTREAM& operator<<(JSONCPP_OSTREAM&, const Value& root); } // namespace Json diff -Nru libjsoncpp-1.6.5/makefiles/msvc2010/jsoncpp.sln libjsoncpp-1.7.2/makefiles/msvc2010/jsoncpp.sln --- libjsoncpp-1.6.5/makefiles/msvc2010/jsoncpp.sln 2015-07-23 05:26:13.000000000 +0000 +++ libjsoncpp-1.7.2/makefiles/msvc2010/jsoncpp.sln 2016-03-25 20:09:15.000000000 +0000 @@ -1,42 +1,42 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lib_json", "lib_json.vcxproj", "{1E6C2C1C-6453-4129-AE3F-0EE8E6599C89}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jsontest", "jsontest.vcxproj", "{25AF2DD2-D396-4668-B188-488C33B8E620}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_lib_json", "test_lib_json.vcxproj", "{B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1E6C2C1C-6453-4129-AE3F-0EE8E6599C89}.Debug|Win32.ActiveCfg = Debug|Win32 - {1E6C2C1C-6453-4129-AE3F-0EE8E6599C89}.Debug|Win32.Build.0 = Debug|Win32 - {1E6C2C1C-6453-4129-AE3F-0EE8E6599C89}.Debug|x64.ActiveCfg = Debug|x64 - {1E6C2C1C-6453-4129-AE3F-0EE8E6599C89}.Debug|x64.Build.0 = Debug|x64 - {1E6C2C1C-6453-4129-AE3F-0EE8E6599C89}.Release|Win32.ActiveCfg = Release|Win32 - {1E6C2C1C-6453-4129-AE3F-0EE8E6599C89}.Release|Win32.Build.0 = Release|Win32 - {1E6C2C1C-6453-4129-AE3F-0EE8E6599C89}.Release|x64.ActiveCfg = Release|x64 - {1E6C2C1C-6453-4129-AE3F-0EE8E6599C89}.Release|x64.Build.0 = Release|x64 - {25AF2DD2-D396-4668-B188-488C33B8E620}.Debug|Win32.ActiveCfg = Debug|Win32 - {25AF2DD2-D396-4668-B188-488C33B8E620}.Debug|Win32.Build.0 = Debug|Win32 - {25AF2DD2-D396-4668-B188-488C33B8E620}.Debug|x64.ActiveCfg = Debug|Win32 - {25AF2DD2-D396-4668-B188-488C33B8E620}.Release|Win32.ActiveCfg = Release|Win32 - {25AF2DD2-D396-4668-B188-488C33B8E620}.Release|Win32.Build.0 = Release|Win32 - {25AF2DD2-D396-4668-B188-488C33B8E620}.Release|x64.ActiveCfg = Release|Win32 - {B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}.Debug|Win32.ActiveCfg = Debug|Win32 - {B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}.Debug|Win32.Build.0 = Debug|Win32 - {B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}.Debug|x64.ActiveCfg = Debug|Win32 - {B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}.Release|Win32.ActiveCfg = Release|Win32 - {B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}.Release|Win32.Build.0 = Release|Win32 - {B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}.Release|x64.ActiveCfg = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lib_json", "lib_json.vcxproj", "{1E6C2C1C-6453-4129-AE3F-0EE8E6599C89}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jsontest", "jsontest.vcxproj", "{25AF2DD2-D396-4668-B188-488C33B8E620}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_lib_json", "test_lib_json.vcxproj", "{B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1E6C2C1C-6453-4129-AE3F-0EE8E6599C89}.Debug|Win32.ActiveCfg = Debug|Win32 + {1E6C2C1C-6453-4129-AE3F-0EE8E6599C89}.Debug|Win32.Build.0 = Debug|Win32 + {1E6C2C1C-6453-4129-AE3F-0EE8E6599C89}.Debug|x64.ActiveCfg = Debug|x64 + {1E6C2C1C-6453-4129-AE3F-0EE8E6599C89}.Debug|x64.Build.0 = Debug|x64 + {1E6C2C1C-6453-4129-AE3F-0EE8E6599C89}.Release|Win32.ActiveCfg = Release|Win32 + {1E6C2C1C-6453-4129-AE3F-0EE8E6599C89}.Release|Win32.Build.0 = Release|Win32 + {1E6C2C1C-6453-4129-AE3F-0EE8E6599C89}.Release|x64.ActiveCfg = Release|x64 + {1E6C2C1C-6453-4129-AE3F-0EE8E6599C89}.Release|x64.Build.0 = Release|x64 + {25AF2DD2-D396-4668-B188-488C33B8E620}.Debug|Win32.ActiveCfg = Debug|Win32 + {25AF2DD2-D396-4668-B188-488C33B8E620}.Debug|Win32.Build.0 = Debug|Win32 + {25AF2DD2-D396-4668-B188-488C33B8E620}.Debug|x64.ActiveCfg = Debug|Win32 + {25AF2DD2-D396-4668-B188-488C33B8E620}.Release|Win32.ActiveCfg = Release|Win32 + {25AF2DD2-D396-4668-B188-488C33B8E620}.Release|Win32.Build.0 = Release|Win32 + {25AF2DD2-D396-4668-B188-488C33B8E620}.Release|x64.ActiveCfg = Release|Win32 + {B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}.Debug|Win32.ActiveCfg = Debug|Win32 + {B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}.Debug|Win32.Build.0 = Debug|Win32 + {B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}.Debug|x64.ActiveCfg = Debug|Win32 + {B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}.Release|Win32.ActiveCfg = Release|Win32 + {B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}.Release|Win32.Build.0 = Release|Win32 + {B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}.Release|x64.ActiveCfg = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff -Nru libjsoncpp-1.6.5/makefiles/msvc2010/jsontest.vcxproj libjsoncpp-1.7.2/makefiles/msvc2010/jsontest.vcxproj --- libjsoncpp-1.6.5/makefiles/msvc2010/jsontest.vcxproj 2015-07-23 05:26:13.000000000 +0000 +++ libjsoncpp-1.7.2/makefiles/msvc2010/jsontest.vcxproj 2016-03-25 20:09:15.000000000 +0000 @@ -1,96 +1,96 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {25AF2DD2-D396-4668-B188-488C33B8E620} - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - <_ProjectFileVersion>10.0.40219.1 - ../../build/vs71/debug/jsontest\ - ../../build/vs71/debug/jsontest\ - true - ../../build/vs71/release/jsontest\ - ../../build/vs71/release/jsontest\ - false - - - - Disabled - ../../include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - - - Level3 - EditAndContinue - - - $(OutDir)jsontest.exe - true - $(OutDir)jsontest.pdb - Console - MachineX86 - - - - - ../../include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreaded - - - Level3 - ProgramDatabase - - - $(OutDir)jsontest.exe - true - Console - true - true - MachineX86 - - - - - - - - {1e6c2c1c-6453-4129-ae3f-0ee8e6599c89} - - - - - + + + + + Debug + Win32 + + + Release + Win32 + + + + {25AF2DD2-D396-4668-B188-488C33B8E620} + Win32Proj + + + + Application + MultiByte + + + Application + MultiByte + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + ../../build/vs71/debug/jsontest\ + ../../build/vs71/debug/jsontest\ + true + ../../build/vs71/release/jsontest\ + ../../build/vs71/release/jsontest\ + false + + + + Disabled + ../../include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + + + Level3 + EditAndContinue + + + $(OutDir)jsontest.exe + true + $(OutDir)jsontest.pdb + Console + MachineX86 + + + + + ../../include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreaded + + + Level3 + ProgramDatabase + + + $(OutDir)jsontest.exe + true + Console + true + true + MachineX86 + + + + + + + + {1e6c2c1c-6453-4129-ae3f-0ee8e6599c89} + + + + + \ No newline at end of file diff -Nru libjsoncpp-1.6.5/makefiles/msvc2010/lib_json.vcxproj libjsoncpp-1.7.2/makefiles/msvc2010/lib_json.vcxproj --- libjsoncpp-1.6.5/makefiles/msvc2010/lib_json.vcxproj 2015-07-23 05:26:13.000000000 +0000 +++ libjsoncpp-1.7.2/makefiles/msvc2010/lib_json.vcxproj 2016-03-25 20:09:15.000000000 +0000 @@ -1,143 +1,143 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - - - - - - - - - - - {1E6C2C1C-6453-4129-AE3F-0EE8E6599C89} - Win32Proj - jsoncpp - - - - StaticLibrary - true - Unicode - - - StaticLibrary - true - Unicode - - - StaticLibrary - false - true - Unicode - - - StaticLibrary - false - true - Unicode - - - - - - - - - - - - - - - - - - - - - NotUsing - Level3 - Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - ../../include - MultiThreadedDebug - - - Windows - true - - - - - NotUsing - Level3 - Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - ../../include - MultiThreadedDebug - - - Windows - true - - - - - Level3 - NotUsing - MaxSpeed - true - true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - ../../include - MultiThreaded - - - Windows - true - true - true - - - - - Level3 - NotUsing - MaxSpeed - true - true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - ../../include - MultiThreaded - - - Windows - true - true - true - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + + + + + + + {1E6C2C1C-6453-4129-AE3F-0EE8E6599C89} + Win32Proj + jsoncpp + + + + StaticLibrary + true + Unicode + + + StaticLibrary + true + Unicode + + + StaticLibrary + false + true + Unicode + + + StaticLibrary + false + true + Unicode + + + + + + + + + + + + + + + + + + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + ../../include + MultiThreadedDebug + + + Windows + true + + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + ../../include + MultiThreadedDebug + + + Windows + true + + + + + Level3 + NotUsing + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + ../../include + MultiThreaded + + + Windows + true + true + true + + + + + Level3 + NotUsing + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + ../../include + MultiThreaded + + + Windows + true + true + true + + + + + \ No newline at end of file diff -Nru libjsoncpp-1.6.5/makefiles/msvc2010/test_lib_json.vcxproj libjsoncpp-1.7.2/makefiles/msvc2010/test_lib_json.vcxproj --- libjsoncpp-1.6.5/makefiles/msvc2010/test_lib_json.vcxproj 2015-07-23 05:26:13.000000000 +0000 +++ libjsoncpp-1.7.2/makefiles/msvc2010/test_lib_json.vcxproj 2016-03-25 20:09:15.000000000 +0000 @@ -1,109 +1,109 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {B7A96B78-2782-40D2-8F37-A2DEF2B9C26D} - test_lib_json - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - <_ProjectFileVersion>10.0.40219.1 - ../../build/vs71/debug/test_lib_json\ - ../../build/vs71/debug/test_lib_json\ - true - ../../build/vs71/release/test_lib_json\ - ../../build/vs71/release/test_lib_json\ - false - - - - Disabled - ../../include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - - - Level3 - EditAndContinue - - - $(OutDir)test_lib_json.exe - true - $(OutDir)test_lib_json.pdb - Console - MachineX86 - - - Running all unit tests - $(TargetPath) - - - - - ../../include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreaded - - - Level3 - ProgramDatabase - - - $(OutDir)test_lib_json.exe - true - Console - true - true - MachineX86 - - - Running all unit tests - $(TargetPath) - - - - - - - - - - - - {1e6c2c1c-6453-4129-ae3f-0ee8e6599c89} - - - - - + + + + + Debug + Win32 + + + Release + Win32 + + + + {B7A96B78-2782-40D2-8F37-A2DEF2B9C26D} + test_lib_json + Win32Proj + + + + Application + MultiByte + + + Application + MultiByte + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + ../../build/vs71/debug/test_lib_json\ + ../../build/vs71/debug/test_lib_json\ + true + ../../build/vs71/release/test_lib_json\ + ../../build/vs71/release/test_lib_json\ + false + + + + Disabled + ../../include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + + + Level3 + EditAndContinue + + + $(OutDir)test_lib_json.exe + true + $(OutDir)test_lib_json.pdb + Console + MachineX86 + + + Running all unit tests + $(TargetPath) + + + + + ../../include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreaded + + + Level3 + ProgramDatabase + + + $(OutDir)test_lib_json.exe + true + Console + true + true + MachineX86 + + + Running all unit tests + $(TargetPath) + + + + + + + + + + + + {1e6c2c1c-6453-4129-ae3f-0ee8e6599c89} + + + + + \ No newline at end of file diff -Nru libjsoncpp-1.6.5/src/CMakeLists.txt libjsoncpp-1.7.2/src/CMakeLists.txt --- libjsoncpp-1.6.5/src/CMakeLists.txt 2015-07-23 05:26:13.000000000 +0000 +++ libjsoncpp-1.7.2/src/CMakeLists.txt 2016-03-25 20:09:15.000000000 +0000 @@ -2,4 +2,4 @@ IF(JSONCPP_WITH_TESTS) ADD_SUBDIRECTORY(jsontestrunner) ADD_SUBDIRECTORY(test_lib_json) -ENDIF(JSONCPP_WITH_TESTS) +ENDIF() diff -Nru libjsoncpp-1.6.5/src/jsontestrunner/CMakeLists.txt libjsoncpp-1.7.2/src/jsontestrunner/CMakeLists.txt --- libjsoncpp-1.6.5/src/jsontestrunner/CMakeLists.txt 2015-07-23 05:26:13.000000000 +0000 +++ libjsoncpp-1.7.2/src/jsontestrunner/CMakeLists.txt 2016-03-25 20:09:15.000000000 +0000 @@ -9,7 +9,7 @@ TARGET_LINK_LIBRARIES(jsontestrunner_exe jsoncpp_lib) ELSE(BUILD_SHARED_LIBS) TARGET_LINK_LIBRARIES(jsontestrunner_exe jsoncpp_lib_static) -ENDIF(BUILD_SHARED_LIBS) +ENDIF() SET_TARGET_PROPERTIES(jsontestrunner_exe PROPERTIES OUTPUT_NAME jsontestrunner_exe) @@ -22,4 +22,4 @@ DEPENDS jsontestrunner_exe jsoncpp_test ) ADD_CUSTOM_TARGET(jsoncpp_check DEPENDS jsoncpp_readerwriter_tests) -ENDIF(PYTHONINTERP_FOUND) +ENDIF() diff -Nru libjsoncpp-1.6.5/src/jsontestrunner/main.cpp libjsoncpp-1.7.2/src/jsontestrunner/main.cpp --- libjsoncpp-1.6.5/src/jsontestrunner/main.cpp 2015-07-23 05:26:13.000000000 +0000 +++ libjsoncpp-1.7.2/src/jsontestrunner/main.cpp 2016-03-25 20:09:15.000000000 +0000 @@ -17,14 +17,14 @@ struct Options { - std::string path; + JSONCPP_STRING path; Json::Features features; bool parseOnly; - typedef std::string (*writeFuncType)(Json::Value const&); + typedef JSONCPP_STRING (*writeFuncType)(Json::Value const&); writeFuncType write; }; -static std::string normalizeFloatingPointStr(double value) { +static JSONCPP_STRING normalizeFloatingPointStr(double value) { char buffer[32]; #if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__) sprintf_s(buffer, sizeof(buffer), "%.16g", value); @@ -32,18 +32,18 @@ snprintf(buffer, sizeof(buffer), "%.16g", value); #endif buffer[sizeof(buffer) - 1] = 0; - std::string s(buffer); - std::string::size_type index = s.find_last_of("eE"); - if (index != std::string::npos) { - std::string::size_type hasSign = + JSONCPP_STRING s(buffer); + JSONCPP_STRING::size_type index = s.find_last_of("eE"); + if (index != JSONCPP_STRING::npos) { + JSONCPP_STRING::size_type hasSign = (s[index + 1] == '+' || s[index + 1] == '-') ? 1 : 0; - std::string::size_type exponentStartIndex = index + 1 + hasSign; - std::string normalized = s.substr(0, exponentStartIndex); - std::string::size_type indexDigit = + JSONCPP_STRING::size_type exponentStartIndex = index + 1 + hasSign; + JSONCPP_STRING normalized = s.substr(0, exponentStartIndex); + JSONCPP_STRING::size_type indexDigit = s.find_first_not_of('0', exponentStartIndex); - std::string exponent = "0"; + JSONCPP_STRING exponent = "0"; if (indexDigit != - std::string::npos) // There is an exponent different from 0 + JSONCPP_STRING::npos) // There is an exponent different from 0 { exponent = s.substr(indexDigit); } @@ -52,17 +52,18 @@ return s; } -static std::string readInputTestFile(const char* path) { +static JSONCPP_STRING readInputTestFile(const char* path) { FILE* file = fopen(path, "rb"); if (!file) - return std::string(""); + return JSONCPP_STRING(""); fseek(file, 0, SEEK_END); - long size = ftell(file); + long const size = ftell(file); + unsigned long const usize = static_cast(size); fseek(file, 0, SEEK_SET); - std::string text; + JSONCPP_STRING text; char* buffer = new char[size + 1]; buffer[size] = 0; - if (fread(buffer, 1, size, file) == (unsigned long)size) + if (fread(buffer, 1, usize, file) == usize) text = buffer; fclose(file); delete[] buffer; @@ -70,7 +71,7 @@ } static void -printValueTree(FILE* fout, Json::Value& value, const std::string& path = ".") { +printValueTree(FILE* fout, Json::Value& value, const JSONCPP_STRING& path = ".") { if (value.hasComment(Json::commentBefore)) { fprintf(fout, "%s\n", value.getComment(Json::commentBefore).c_str()); } @@ -104,8 +105,8 @@ break; case Json::arrayValue: { fprintf(fout, "%s=[]\n", path.c_str()); - int size = value.size(); - for (int index = 0; index < size; ++index) { + Json::ArrayIndex size = value.size(); + for (Json::ArrayIndex index = 0; index < size; ++index) { static char buffer[16]; #if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__) sprintf_s(buffer, sizeof(buffer), "[%d]", index); @@ -119,11 +120,11 @@ fprintf(fout, "%s={}\n", path.c_str()); Json::Value::Members members(value.getMemberNames()); std::sort(members.begin(), members.end()); - std::string suffix = *(path.end() - 1) == '.' ? "" : "."; + JSONCPP_STRING suffix = *(path.end() - 1) == '.' ? "" : "."; for (Json::Value::Members::iterator it = members.begin(); it != members.end(); ++it) { - const std::string& name = *it; + const JSONCPP_STRING name = *it; printValueTree(fout, value[name], path + suffix + name); } } break; @@ -136,15 +137,15 @@ } } -static int parseAndSaveValueTree(const std::string& input, - const std::string& actual, - const std::string& kind, +static int parseAndSaveValueTree(const JSONCPP_STRING& input, + const JSONCPP_STRING& actual, + const JSONCPP_STRING& kind, const Json::Features& features, bool parseOnly, Json::Value* root) { Json::Reader reader(features); - bool parsingSuccessful = reader.parse(input, *root); + bool parsingSuccessful = reader.parse(input.data(), input.data() + input.size(), *root); if (!parsingSuccessful) { printf("Failed to parse %s file: \n%s\n", kind.c_str(), @@ -162,36 +163,36 @@ } return 0; } -// static std::string useFastWriter(Json::Value const& root) { +// static JSONCPP_STRING useFastWriter(Json::Value const& root) { // Json::FastWriter writer; // writer.enableYAMLCompatibility(); // return writer.write(root); // } -static std::string useStyledWriter( +static JSONCPP_STRING useStyledWriter( Json::Value const& root) { Json::StyledWriter writer; return writer.write(root); } -static std::string useStyledStreamWriter( +static JSONCPP_STRING useStyledStreamWriter( Json::Value const& root) { Json::StyledStreamWriter writer; - std::ostringstream sout; + JSONCPP_OSTRINGSTREAM sout; writer.write(sout, root); return sout.str(); } -static std::string useBuiltStyledStreamWriter( +static JSONCPP_STRING useBuiltStyledStreamWriter( Json::Value const& root) { Json::StreamWriterBuilder builder; return Json::writeString(builder, root); } static int rewriteValueTree( - const std::string& rewritePath, + const JSONCPP_STRING& rewritePath, const Json::Value& root, Options::writeFuncType write, - std::string* rewrite) + JSONCPP_STRING* rewrite) { *rewrite = write(root); FILE* fout = fopen(rewritePath.c_str(), "wt"); @@ -204,13 +205,13 @@ return 0; } -static std::string removeSuffix(const std::string& path, - const std::string& extension) { +static JSONCPP_STRING removeSuffix(const JSONCPP_STRING& path, + const JSONCPP_STRING& extension) { if (extension.length() >= path.length()) - return std::string(""); - std::string suffix = path.substr(path.length() - extension.length()); + return JSONCPP_STRING(""); + JSONCPP_STRING suffix = path.substr(path.length() - extension.length()); if (suffix != extension) - return std::string(""); + return JSONCPP_STRING(""); return path.substr(0, path.length() - extension.length()); } @@ -237,18 +238,18 @@ return printUsage(argv); } int index = 1; - if (std::string(argv[index]) == "--json-checker") { + if (JSONCPP_STRING(argv[index]) == "--json-checker") { opts->features = Json::Features::strictMode(); opts->parseOnly = true; ++index; } - if (std::string(argv[index]) == "--json-config") { + if (JSONCPP_STRING(argv[index]) == "--json-config") { printConfig(); return 3; } - if (std::string(argv[index]) == "--json-writer") { + if (JSONCPP_STRING(argv[index]) == "--json-writer") { ++index; - std::string const writerName(argv[index++]); + JSONCPP_STRING const writerName(argv[index++]); if (writerName == "StyledWriter") { opts->write = &useStyledWriter; } else if (writerName == "StyledStreamWriter") { @@ -270,22 +271,22 @@ { int exitCode = 0; - std::string input = readInputTestFile(opts.path.c_str()); + JSONCPP_STRING input = readInputTestFile(opts.path.c_str()); if (input.empty()) { printf("Failed to read input or empty input: %s\n", opts.path.c_str()); return 3; } - std::string basePath = removeSuffix(opts.path, ".json"); + JSONCPP_STRING basePath = removeSuffix(opts.path, ".json"); if (!opts.parseOnly && basePath.empty()) { printf("Bad input path. Path does not end with '.expected':\n%s\n", opts.path.c_str()); return 3; } - std::string const actualPath = basePath + ".actual"; - std::string const rewritePath = basePath + ".rewrite"; - std::string const rewriteActualPath = basePath + ".actual-rewrite"; + JSONCPP_STRING const actualPath = basePath + ".actual"; + JSONCPP_STRING const rewritePath = basePath + ".rewrite"; + JSONCPP_STRING const rewriteActualPath = basePath + ".actual-rewrite"; Json::Value root; exitCode = parseAndSaveValueTree( @@ -294,7 +295,7 @@ if (exitCode || opts.parseOnly) { return exitCode; } - std::string rewrite; + JSONCPP_STRING rewrite; exitCode = rewriteValueTree(rewritePath, root, opts.write, &rewrite); if (exitCode) { return exitCode; @@ -310,12 +311,12 @@ } int main(int argc, const char* argv[]) { Options opts; + try { int exitCode = parseCommandLine(argc, argv, &opts); if (exitCode != 0) { printf("Failed to parse command-line."); return exitCode; } - try { return runTest(opts); } catch (const std::exception& e) { diff -Nru libjsoncpp-1.6.5/src/lib_json/CMakeLists.txt libjsoncpp-1.7.2/src/lib_json/CMakeLists.txt --- libjsoncpp-1.6.5/src/lib_json/CMakeLists.txt 2015-07-23 05:26:13.000000000 +0000 +++ libjsoncpp-1.7.2/src/lib_json/CMakeLists.txt 2016-03-25 20:09:15.000000000 +0000 @@ -37,7 +37,7 @@ SET(INSTALL_EXPORT EXPORT jsoncpp) ELSE(JSONCPP_WITH_CMAKE_PACKAGE) SET(INSTALL_EXPORT) -ENDIF(JSONCPP_WITH_CMAKE_PACKAGE) +ENDIF() IF(BUILD_SHARED_LIBS) ADD_DEFINITIONS( -DJSON_DLL_BUILD ) @@ -55,7 +55,7 @@ TARGET_INCLUDE_DIRECTORIES( jsoncpp_lib PUBLIC $ $) - ENDIF(NOT CMAKE_VERSION VERSION_LESS 2.8.11) + ENDIF() ENDIF() @@ -75,6 +75,6 @@ $ $ ) - ENDIF(NOT CMAKE_VERSION VERSION_LESS 2.8.11) + ENDIF() ENDIF() diff -Nru libjsoncpp-1.6.5/src/lib_json/json_reader.cpp libjsoncpp-1.7.2/src/lib_json/json_reader.cpp --- libjsoncpp-1.6.5/src/lib_json/json_reader.cpp 2015-07-23 05:26:13.000000000 +0000 +++ libjsoncpp-1.7.2/src/lib_json/json_reader.cpp 2016-03-25 20:09:15.000000000 +0000 @@ -17,10 +17,27 @@ #include #include #include +#include -#if defined(_MSC_VER) && _MSC_VER < 1500 // VC++ 8.0 and below +#if defined(_MSC_VER) +#if !defined(WINCE) && defined(__STDC_SECURE_LIB__) && _MSC_VER >= 1500 // VC++ 9.0 and above +#define snprintf sprintf_s +#elif _MSC_VER >= 1900 // VC++ 14.0 and above +#define snprintf std::snprintf +#else #define snprintf _snprintf #endif +#elif defined(__ANDROID__) || defined(__QNXNTO__) +#define snprintf snprintf +#elif __cplusplus >= 201103L +#if !defined(__MINGW32__) && !defined(__CYGWIN__) +#define snprintf std::snprintf +#endif +#endif + +#if defined(__QNXNTO__) +#define sscanf std::sscanf +#endif #if defined(_MSC_VER) && _MSC_VER >= 1400 // VC++ 8.0 // Disable warning about strdup being deprecated. @@ -32,7 +49,7 @@ namespace Json { -#if __cplusplus >= 201103L +#if __cplusplus >= 201103L || (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520) typedef std::unique_ptr CharReaderPtr; #else typedef std::auto_ptr CharReaderPtr; @@ -81,7 +98,8 @@ bool Reader::parse(const std::string& document, Value& root, bool collectComments) { - document_ = document; + JSONCPP_STRING documentCopy(document.data(), document.data() + document.capacity()); + std::swap(documentCopy, document_); const char* begin = document_.c_str(); const char* end = begin + document_.length(); return parse(begin, end, root, collectComments); @@ -93,11 +111,11 @@ // Those would allow streamed input from a file, if parse() were a // template function. - // Since std::string is reference-counted, this at least does not + // Since JSONCPP_STRING is reference-counted, this at least does not // create an extra copy. - std::string doc; + JSONCPP_STRING doc; std::getline(sin, doc, (char)EOF); - return parse(doc, root, collectComments); + return parse(doc.data(), doc.data() + doc.size(), root, collectComments); } bool Reader::parse(const char* beginDoc, @@ -351,9 +369,9 @@ return true; } -static std::string normalizeEOL(Reader::Location begin, Reader::Location end) { - std::string normalized; - normalized.reserve(end - begin); +static JSONCPP_STRING normalizeEOL(Reader::Location begin, Reader::Location end) { + JSONCPP_STRING normalized; + normalized.reserve(static_cast(end - begin)); Reader::Location current = begin; while (current != end) { char c = *current++; @@ -373,7 +391,7 @@ void Reader::addComment(Location begin, Location end, CommentPlacement placement) { assert(collectComments_); - const std::string& normalized = normalizeEOL(begin, end); + const JSONCPP_STRING& normalized = normalizeEOL(begin, end); if (placement == commentAfterOnSameLine) { assert(lastValue_ != 0); lastValue_->setComment(normalized, placement); @@ -443,7 +461,7 @@ bool Reader::readObject(Token& tokenStart) { Token tokenName; - std::string name; + JSONCPP_STRING name; Value init(objectValue); currentValue().swapPayload(init); currentValue().setOffsetStart(tokenStart.start_ - begin_); @@ -463,7 +481,7 @@ Value numberName; if (!decodeNumber(tokenName, numberName)) return recoverFromError(tokenObjectEnd); - name = numberName.asString(); + name = JSONCPP_STRING(numberName.asCString()); } else { break; } @@ -555,7 +573,7 @@ ++current; // TODO: Help the compiler do the div and mod at compile time or get rid of them. Value::LargestUInt maxIntegerValue = - isNegative ? Value::LargestUInt(-Value::minLargestInt) + isNegative ? Value::LargestUInt(Value::maxLargestInt) + 1 : Value::maxLargestUInt; Value::LargestUInt threshold = maxIntegerValue / 10; Value::LargestUInt value = 0; @@ -563,7 +581,7 @@ Char c = *current++; if (c < '0' || c > '9') return decodeDouble(token, decoded); - Value::UInt digit(c - '0'); + Value::UInt digit(static_cast(c - '0')); if (value >= threshold) { // We've hit or exceeded the max value divided by 10 (rounded down). If // a) we've only just touched the limit, b) this is the last digit, and @@ -576,7 +594,9 @@ } value = value * 10 + digit; } - if (isNegative) + if (isNegative && value == maxIntegerValue) + decoded = Value::minLargestInt; + else if (isNegative) decoded = -Value::LargestInt(value); else if (value <= Value::LargestUInt(Value::maxInt)) decoded = Value::LargestInt(value); @@ -597,10 +617,10 @@ bool Reader::decodeDouble(Token& token, Value& decoded) { double value = 0; - std::string buffer(token.start_, token.end_); - std::istringstream is(buffer); + JSONCPP_STRING buffer(token.start_, token.end_); + JSONCPP_ISTRINGSTREAM is(buffer); if (!(is >> value)) - return addError("'" + std::string(token.start_, token.end_) + + return addError("'" + JSONCPP_STRING(token.start_, token.end_) + "' is not a number.", token); decoded = value; @@ -608,7 +628,7 @@ } bool Reader::decodeString(Token& token) { - std::string decoded_string; + JSONCPP_STRING decoded_string; if (!decodeString(token, decoded_string)) return false; Value decoded(decoded_string); @@ -618,8 +638,8 @@ return true; } -bool Reader::decodeString(Token& token, std::string& decoded) { - decoded.reserve(token.end_ - token.start_ - 2); +bool Reader::decodeString(Token& token, JSONCPP_STRING& decoded) { + decoded.reserve(static_cast(token.end_ - token.start_ - 2)); Location current = token.start_ + 1; // skip '"' Location end = token.end_ - 1; // do not include '"' while (current != end) { @@ -703,13 +723,13 @@ bool Reader::decodeUnicodeEscapeSequence(Token& token, Location& current, Location end, - unsigned int& unicode) { + unsigned int& ret_unicode) { if (end - current < 4) return addError( "Bad unicode escape sequence in string: four digits expected.", token, current); - unicode = 0; + int unicode = 0; for (int index = 0; index < 4; ++index) { Char c = *current++; unicode *= 16; @@ -725,11 +745,12 @@ token, current); } + ret_unicode = static_cast(unicode); return true; } bool -Reader::addError(const std::string& message, Token& token, Location extra) { +Reader::addError(const JSONCPP_STRING& message, Token& token, Location extra) { ErrorInfo info; info.token_ = token; info.message_ = message; @@ -739,7 +760,7 @@ } bool Reader::recoverFromError(TokenType skipUntilToken) { - int errorCount = int(errors_.size()); + size_t const errorCount = errors_.size(); Token skip; for (;;) { if (!readToken(skip)) @@ -751,7 +772,7 @@ return false; } -bool Reader::addErrorAndRecover(const std::string& message, +bool Reader::addErrorAndRecover(const JSONCPP_STRING& message, Token& token, TokenType skipUntilToken) { addError(message, token); @@ -789,29 +810,21 @@ ++line; } -std::string Reader::getLocationLineAndColumn(Location location) const { +JSONCPP_STRING Reader::getLocationLineAndColumn(Location location) const { int line, column; getLocationLineAndColumn(location, line, column); char buffer[18 + 16 + 16 + 1]; -#if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__) -#if defined(WINCE) - _snprintf(buffer, sizeof(buffer), "Line %d, Column %d", line, column); -#else - sprintf_s(buffer, sizeof(buffer), "Line %d, Column %d", line, column); -#endif -#else snprintf(buffer, sizeof(buffer), "Line %d, Column %d", line, column); -#endif return buffer; } // Deprecated. Preserved for backward compatibility -std::string Reader::getFormatedErrorMessages() const { +JSONCPP_STRING Reader::getFormatedErrorMessages() const { return getFormattedErrorMessages(); } -std::string Reader::getFormattedErrorMessages() const { - std::string formattedMessage; +JSONCPP_STRING Reader::getFormattedErrorMessages() const { + JSONCPP_STRING formattedMessage; for (Errors::const_iterator itError = errors_.begin(); itError != errors_.end(); ++itError) { @@ -841,8 +854,8 @@ return allErrors; } -bool Reader::pushError(const Value& value, const std::string& message) { - size_t length = end_ - begin_; +bool Reader::pushError(const Value& value, const JSONCPP_STRING& message) { + ptrdiff_t const length = end_ - begin_; if(value.getOffsetStart() > length || value.getOffsetLimit() > length) return false; @@ -858,8 +871,8 @@ return true; } -bool Reader::pushError(const Value& value, const std::string& message, const Value& extra) { - size_t length = end_ - begin_; +bool Reader::pushError(const Value& value, const JSONCPP_STRING& message, const Value& extra) { + ptrdiff_t const length = end_ - begin_; if(value.getOffsetStart() > length || value.getOffsetLimit() > length || extra.getOffsetLimit() > length) @@ -884,7 +897,6 @@ class OurFeatures { public: static OurFeatures all(); - OurFeatures(); bool allowComments_; bool strictRoot_; bool allowDroppedNullPlaceholders_; @@ -892,20 +904,13 @@ bool allowSingleQuotes_; bool failIfExtra_; bool rejectDupKeys_; + bool allowSpecialFloats_; int stackLimit_; }; // OurFeatures // exact copy of Implementation of class Features // //////////////////////////////// -OurFeatures::OurFeatures() - : allowComments_(true), strictRoot_(false) - , allowDroppedNullPlaceholders_(false), allowNumericKeys_(false) - , allowSingleQuotes_(false) - , failIfExtra_(false) -{ -} - OurFeatures OurFeatures::all() { return OurFeatures(); } // Implementation of class Reader @@ -917,9 +922,9 @@ typedef char Char; typedef const Char* Location; struct StructuredError { - size_t offset_start; - size_t offset_limit; - std::string message; + ptrdiff_t offset_start; + ptrdiff_t offset_limit; + JSONCPP_STRING message; }; OurReader(OurFeatures const& features); @@ -927,10 +932,10 @@ const char* endDoc, Value& root, bool collectComments = true); - std::string getFormattedErrorMessages() const; + JSONCPP_STRING getFormattedErrorMessages() const; std::vector getStructuredErrors() const; - bool pushError(const Value& value, const std::string& message); - bool pushError(const Value& value, const std::string& message, const Value& extra); + bool pushError(const Value& value, const JSONCPP_STRING& message); + bool pushError(const Value& value, const JSONCPP_STRING& message, const Value& extra); bool good() const; private: @@ -948,6 +953,9 @@ tokenTrue, tokenFalse, tokenNull, + tokenNaN, + tokenPosInf, + tokenNegInf, tokenArraySeparator, tokenMemberSeparator, tokenComment, @@ -964,7 +972,7 @@ class ErrorInfo { public: Token token_; - std::string message_; + JSONCPP_STRING message_; Location extra_; }; @@ -978,14 +986,14 @@ bool readCppStyleComment(); bool readString(); bool readStringSingleQuote(); - void readNumber(); + bool readNumber(bool checkInf); bool readValue(); bool readObject(Token& token); bool readArray(Token& token); bool decodeNumber(Token& token); bool decodeNumber(Token& token, Value& decoded); bool decodeString(Token& token); - bool decodeString(Token& token, std::string& decoded); + bool decodeString(Token& token, JSONCPP_STRING& decoded); bool decodeDouble(Token& token); bool decodeDouble(Token& token, Value& decoded); bool decodeUnicodeCodePoint(Token& token, @@ -996,9 +1004,9 @@ Location& current, Location end, unsigned int& unicode); - bool addError(const std::string& message, Token& token, Location extra = 0); + bool addError(const JSONCPP_STRING& message, Token& token, Location extra = 0); bool recoverFromError(TokenType skipUntilToken); - bool addErrorAndRecover(const std::string& message, + bool addErrorAndRecover(const JSONCPP_STRING& message, Token& token, TokenType skipUntilToken); void skipUntilSpace(); @@ -1006,20 +1014,20 @@ Char getNextChar(); void getLocationLineAndColumn(Location location, int& line, int& column) const; - std::string getLocationLineAndColumn(Location location) const; + JSONCPP_STRING getLocationLineAndColumn(Location location) const; void addComment(Location begin, Location end, CommentPlacement placement); void skipCommentTokens(Token& token); typedef std::stack Nodes; Nodes nodes_; Errors errors_; - std::string document_; + JSONCPP_STRING document_; Location begin_; Location end_; Location current_; Location lastValueEnd_; Value* lastValue_; - std::string commentsBefore_; + JSONCPP_STRING commentsBefore_; int stackDepth_; OurFeatures const features_; @@ -1030,7 +1038,9 @@ OurReader::OurReader(OurFeatures const& features) : errors_(), document_(), begin_(), end_(), current_(), lastValueEnd_(), - lastValue_(), commentsBefore_(), features_(features), collectComments_() { + lastValue_(), commentsBefore_(), + stackDepth_(0), + features_(features), collectComments_() { } bool OurReader::parse(const char* beginDoc, @@ -1132,6 +1142,30 @@ currentValue().setOffsetLimit(token.end_ - begin_); } break; + case tokenNaN: + { + Value v(std::numeric_limits::quiet_NaN()); + currentValue().swapPayload(v); + currentValue().setOffsetStart(token.start_ - begin_); + currentValue().setOffsetLimit(token.end_ - begin_); + } + break; + case tokenPosInf: + { + Value v(std::numeric_limits::infinity()); + currentValue().swapPayload(v); + currentValue().setOffsetStart(token.start_ - begin_); + currentValue().setOffsetLimit(token.end_ - begin_); + } + break; + case tokenNegInf: + { + Value v(-std::numeric_limits::infinity()); + currentValue().swapPayload(v); + currentValue().setOffsetStart(token.start_ - begin_); + currentValue().setOffsetLimit(token.end_ - begin_); + } + break; case tokenArraySeparator: case tokenObjectEnd: case tokenArrayEnd: @@ -1212,9 +1246,16 @@ case '7': case '8': case '9': - case '-': token.type_ = tokenNumber; - readNumber(); + readNumber(false); + break; + case '-': + if (readNumber(true)) { + token.type_ = tokenNumber; + } else { + token.type_ = tokenNegInf; + ok = features_.allowSpecialFloats_ && match("nfinity", 7); + } break; case 't': token.type_ = tokenTrue; @@ -1228,6 +1269,22 @@ token.type_ = tokenNull; ok = match("ull", 3); break; + case 'N': + if (features_.allowSpecialFloats_) { + token.type_ = tokenNaN; + ok = match("aN", 2); + } else { + ok = false; + } + break; + case 'I': + if (features_.allowSpecialFloats_) { + token.type_ = tokenPosInf; + ok = match("nfinity", 7); + } else { + ok = false; + } + break; case ',': token.type_ = tokenArraySeparator; break; @@ -1294,7 +1351,7 @@ void OurReader::addComment(Location begin, Location end, CommentPlacement placement) { assert(collectComments_); - const std::string& normalized = normalizeEOL(begin, end); + const JSONCPP_STRING& normalized = normalizeEOL(begin, end); if (placement == commentAfterOnSameLine) { assert(lastValue_ != 0); lastValue_->setComment(normalized, placement); @@ -1328,8 +1385,12 @@ return true; } -void OurReader::readNumber() { +bool OurReader::readNumber(bool checkInf) { const char *p = current_; + if (checkInf && p != end_ && *p == 'I') { + current_ = ++p; + return false; + } char c = '0'; // stopgap for already consumed character // integral part while (c >= '0' && c <= '9') @@ -1348,6 +1409,7 @@ while (c >= '0' && c <= '9') c = (current_ = p) < end_ ? *p++ : 0; } + return true; } bool OurReader::readString() { Char c = 0; @@ -1376,7 +1438,7 @@ bool OurReader::readObject(Token& tokenStart) { Token tokenName; - std::string name; + JSONCPP_STRING name; Value init(objectValue); currentValue().swapPayload(init); currentValue().setOffsetStart(tokenStart.start_ - begin_); @@ -1408,7 +1470,7 @@ } if (name.length() >= (1U<<30)) throwRuntimeError("keylength >= 2^30"); if (features_.rejectDupKeys_ && currentValue().isMember(name)) { - std::string msg = "Duplicate key: '" + name + "'"; + JSONCPP_STRING msg = "Duplicate key: '" + name + "'"; return addErrorAndRecover( msg, tokenName, tokenObjectEnd); } @@ -1502,7 +1564,7 @@ Char c = *current++; if (c < '0' || c > '9') return decodeDouble(token, decoded); - Value::UInt digit(c - '0'); + Value::UInt digit(static_cast(c - '0')); if (value >= threshold) { // We've hit or exceeded the max value divided by 10 (rounded down). If // a) we've only just touched the limit, b) this is the last digit, and @@ -1538,12 +1600,13 @@ double value = 0; const int bufferSize = 32; int count; - int length = int(token.end_ - token.start_); + ptrdiff_t const length = token.end_ - token.start_; // Sanity check to avoid buffer overflow exploits. if (length < 0) { return addError("Unable to parse token length", token); } + size_t const ulength = static_cast(length); // Avoid using a string constant for the format control string given to // sscanf, as this can cause hard to debug crashes on OS X. See here for more @@ -1554,16 +1617,16 @@ if (length <= bufferSize) { Char buffer[bufferSize + 1]; - memcpy(buffer, token.start_, length); + memcpy(buffer, token.start_, ulength); buffer[length] = 0; count = sscanf(buffer, format, &value); } else { - std::string buffer(token.start_, token.end_); + JSONCPP_STRING buffer(token.start_, token.end_); count = sscanf(buffer.c_str(), format, &value); } if (count != 1) - return addError("'" + std::string(token.start_, token.end_) + + return addError("'" + JSONCPP_STRING(token.start_, token.end_) + "' is not a number.", token); decoded = value; @@ -1571,7 +1634,7 @@ } bool OurReader::decodeString(Token& token) { - std::string decoded_string; + JSONCPP_STRING decoded_string; if (!decodeString(token, decoded_string)) return false; Value decoded(decoded_string); @@ -1581,8 +1644,8 @@ return true; } -bool OurReader::decodeString(Token& token, std::string& decoded) { - decoded.reserve(token.end_ - token.start_ - 2); +bool OurReader::decodeString(Token& token, JSONCPP_STRING& decoded) { + decoded.reserve(static_cast(token.end_ - token.start_ - 2)); Location current = token.start_ + 1; // skip '"' Location end = token.end_ - 1; // do not include '"' while (current != end) { @@ -1666,13 +1729,13 @@ bool OurReader::decodeUnicodeEscapeSequence(Token& token, Location& current, Location end, - unsigned int& unicode) { + unsigned int& ret_unicode) { if (end - current < 4) return addError( "Bad unicode escape sequence in string: four digits expected.", token, current); - unicode = 0; + int unicode = 0; for (int index = 0; index < 4; ++index) { Char c = *current++; unicode *= 16; @@ -1688,11 +1751,12 @@ token, current); } + ret_unicode = static_cast(unicode); return true; } bool -OurReader::addError(const std::string& message, Token& token, Location extra) { +OurReader::addError(const JSONCPP_STRING& message, Token& token, Location extra) { ErrorInfo info; info.token_ = token; info.message_ = message; @@ -1702,7 +1766,7 @@ } bool OurReader::recoverFromError(TokenType skipUntilToken) { - int errorCount = int(errors_.size()); + size_t errorCount = errors_.size(); Token skip; for (;;) { if (!readToken(skip)) @@ -1714,7 +1778,7 @@ return false; } -bool OurReader::addErrorAndRecover(const std::string& message, +bool OurReader::addErrorAndRecover(const JSONCPP_STRING& message, Token& token, TokenType skipUntilToken) { addError(message, token); @@ -1752,24 +1816,16 @@ ++line; } -std::string OurReader::getLocationLineAndColumn(Location location) const { +JSONCPP_STRING OurReader::getLocationLineAndColumn(Location location) const { int line, column; getLocationLineAndColumn(location, line, column); char buffer[18 + 16 + 16 + 1]; -#if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__) -#if defined(WINCE) - _snprintf(buffer, sizeof(buffer), "Line %d, Column %d", line, column); -#else - sprintf_s(buffer, sizeof(buffer), "Line %d, Column %d", line, column); -#endif -#else snprintf(buffer, sizeof(buffer), "Line %d, Column %d", line, column); -#endif return buffer; } -std::string OurReader::getFormattedErrorMessages() const { - std::string formattedMessage; +JSONCPP_STRING OurReader::getFormattedErrorMessages() const { + JSONCPP_STRING formattedMessage; for (Errors::const_iterator itError = errors_.begin(); itError != errors_.end(); ++itError) { @@ -1799,8 +1855,8 @@ return allErrors; } -bool OurReader::pushError(const Value& value, const std::string& message) { - size_t length = end_ - begin_; +bool OurReader::pushError(const Value& value, const JSONCPP_STRING& message) { + ptrdiff_t length = end_ - begin_; if(value.getOffsetStart() > length || value.getOffsetLimit() > length) return false; @@ -1816,8 +1872,8 @@ return true; } -bool OurReader::pushError(const Value& value, const std::string& message, const Value& extra) { - size_t length = end_ - begin_; +bool OurReader::pushError(const Value& value, const JSONCPP_STRING& message, const Value& extra) { + ptrdiff_t length = end_ - begin_; if(value.getOffsetStart() > length || value.getOffsetLimit() > length || extra.getOffsetLimit() > length) @@ -1849,9 +1905,9 @@ : collectComments_(collectComments) , reader_(features) {} - virtual bool parse( + bool parse( char const* beginDoc, char const* endDoc, - Value* root, std::string* errs) { + Value* root, JSONCPP_STRING* errs) JSONCPP_OVERRIDE { bool ok = reader_.parse(beginDoc, endDoc, *root, collectComments_); if (errs) { *errs = reader_.getFormattedErrorMessages(); @@ -1878,9 +1934,10 @@ features.stackLimit_ = settings_["stackLimit"].asInt(); features.failIfExtra_ = settings_["failIfExtra"].asBool(); features.rejectDupKeys_ = settings_["rejectDupKeys"].asBool(); + features.allowSpecialFloats_ = settings_["allowSpecialFloats"].asBool(); return new OurCharReader(collectComments, features); } -static void getValidReaderKeys(std::set* valid_keys) +static void getValidReaderKeys(std::set* valid_keys) { valid_keys->clear(); valid_keys->insert("collectComments"); @@ -1892,25 +1949,26 @@ valid_keys->insert("stackLimit"); valid_keys->insert("failIfExtra"); valid_keys->insert("rejectDupKeys"); + valid_keys->insert("allowSpecialFloats"); } bool CharReaderBuilder::validate(Json::Value* invalid) const { Json::Value my_invalid; if (!invalid) invalid = &my_invalid; // so we do not need to test for NULL Json::Value& inv = *invalid; - std::set valid_keys; + std::set valid_keys; getValidReaderKeys(&valid_keys); Value::Members keys = settings_.getMemberNames(); size_t n = keys.size(); for (size_t i = 0; i < n; ++i) { - std::string const& key = keys[i]; + JSONCPP_STRING const& key = keys[i]; if (valid_keys.find(key) == valid_keys.end()) { inv[key] = settings_[key]; } } return 0u == inv.size(); } -Value& CharReaderBuilder::operator[](std::string key) +Value& CharReaderBuilder::operator[](JSONCPP_STRING key) { return settings_[key]; } @@ -1923,8 +1981,10 @@ (*settings)["allowDroppedNullPlaceholders"] = false; (*settings)["allowNumericKeys"] = false; (*settings)["allowSingleQuotes"] = false; + (*settings)["stackLimit"] = 1000; (*settings)["failIfExtra"] = true; (*settings)["rejectDupKeys"] = true; + (*settings)["allowSpecialFloats"] = false; //! [CharReaderBuilderStrictMode] } // static @@ -1940,6 +2000,7 @@ (*settings)["stackLimit"] = 1000; (*settings)["failIfExtra"] = false; (*settings)["rejectDupKeys"] = false; + (*settings)["allowSpecialFloats"] = false; //! [CharReaderBuilderDefaults] } @@ -1947,12 +2008,12 @@ // global functions bool parseFromStream( - CharReader::Factory const& fact, std::istream& sin, - Value* root, std::string* errs) + CharReader::Factory const& fact, JSONCPP_ISTREAM& sin, + Value* root, JSONCPP_STRING* errs) { - std::ostringstream ssin; + JSONCPP_OSTRINGSTREAM ssin; ssin << sin.rdbuf(); - std::string doc = ssin.str(); + JSONCPP_STRING doc = ssin.str(); char const* begin = doc.data(); char const* end = begin + doc.size(); // Note that we do not actually need a null-terminator. @@ -1960,16 +2021,16 @@ return reader->parse(begin, end, root, errs); } -std::istream& operator>>(std::istream& sin, Value& root) { +JSONCPP_ISTREAM& operator>>(JSONCPP_ISTREAM& sin, Value& root) { CharReaderBuilder b; - std::string errs; + JSONCPP_STRING errs; bool ok = parseFromStream(b, sin, &root, &errs); if (!ok) { fprintf(stderr, "Error from reader: %s", errs.c_str()); - throwRuntimeError("reader error"); + throwRuntimeError(errs); } return sin; } diff -Nru libjsoncpp-1.6.5/src/lib_json/json_tool.h libjsoncpp-1.7.2/src/lib_json/json_tool.h --- libjsoncpp-1.6.5/src/lib_json/json_tool.h 2015-07-23 05:26:13.000000000 +0000 +++ libjsoncpp-1.7.2/src/lib_json/json_tool.h 2016-03-25 20:09:15.000000000 +0000 @@ -15,8 +15,8 @@ namespace Json { /// Converts a unicode code-point to UTF-8. -static inline std::string codePointToUTF8(unsigned int cp) { - std::string result; +static inline JSONCPP_STRING codePointToUTF8(unsigned int cp) { + JSONCPP_STRING result; // based on description from http://en.wikipedia.org/wiki/UTF-8 @@ -63,7 +63,7 @@ static inline void uintToString(LargestUInt value, char*& current) { *--current = 0; do { - *--current = static_cast(value % 10U + static_cast('0')); + *--current = static_cast(value % 10U + static_cast('0')); value /= 10; } while (value != 0); } diff -Nru libjsoncpp-1.6.5/src/lib_json/json_value.cpp libjsoncpp-1.7.2/src/lib_json/json_value.cpp --- libjsoncpp-1.6.5/src/lib_json/json_value.cpp 2015-07-23 05:26:13.000000000 +0000 +++ libjsoncpp-1.7.2/src/lib_json/json_value.cpp 2016-03-25 20:09:15.000000000 +0000 @@ -55,11 +55,14 @@ #if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) template static inline bool InRange(double d, T min, U max) { + // The casts can lose precision, but we are looking only for + // an approximate range. Might fail on edge cases though. ~cdunn + //return d >= static_cast(min) && d <= static_cast(max); return d >= min && d <= max; } #else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) static inline double integerToDouble(Json::UInt64 value) { - return static_cast(Int64(value / 2)) * 2.0 + Int64(value & 1); + return static_cast(Int64(value / 2)) * 2.0 + static_cast(Int64(value & 1)); } template static inline double integerToDouble(T value) { @@ -80,10 +83,11 @@ * @return Pointer on the duplicate instance of string. */ static inline char* duplicateStringValue(const char* value, - size_t length) { + size_t length) +{ // Avoid an integer overflow in the call to malloc below by limiting length // to a sane value. - if (length >= (size_t)Value::maxInt) + if (length >= static_cast(Value::maxInt)) length = Value::maxInt - 1; char* newString = static_cast(malloc(length + 1)); @@ -105,7 +109,7 @@ { // Avoid an integer overflow in the call to malloc below by limiting length // to a sane value. - JSON_ASSERT_MESSAGE(length <= (unsigned)Value::maxInt - sizeof(unsigned) - 1U, + JSON_ASSERT_MESSAGE(length <= static_cast(Value::maxInt) - sizeof(unsigned) - 1U, "in Json::Value::duplicateAndPrefixStringValue(): " "length too big for prefixing"); unsigned actualLength = length + static_cast(sizeof(unsigned)) + 1U; @@ -134,7 +138,29 @@ } /** Free the string duplicated by duplicateStringValue()/duplicateAndPrefixStringValue(). */ -static inline void releaseStringValue(char* value) { free(value); } +#if JSONCPP_USING_SECURE_MEMORY +static inline void releasePrefixedStringValue(char* value) { + unsigned length = 0; + char const* valueDecoded; + decodePrefixedString(true, value, &length, &valueDecoded); + size_t const size = sizeof(unsigned) + length + 1U; + memset(value, 0, size); + free(value); +} +static inline void releaseStringValue(char* value, unsigned length) { + // length==0 => we allocated the strings memory + size_t size = (length==0) ? strlen(value) : length; + memset(value, 0, size); + free(value); +} +#else // !JSONCPP_USING_SECURE_MEMORY +static inline void releasePrefixedStringValue(char* value) { + free(value); +} +static inline void releaseStringValue(char* value, unsigned length) { + free(value); +} +#endif // JSONCPP_USING_SECURE_MEMORY } // namespace Json @@ -152,7 +178,7 @@ namespace Json { -Exception::Exception(std::string const& msg) +Exception::Exception(JSONCPP_STRING const& msg) : msg_(msg) {} Exception::~Exception() throw() @@ -161,17 +187,17 @@ { return msg_.c_str(); } -RuntimeError::RuntimeError(std::string const& msg) +RuntimeError::RuntimeError(JSONCPP_STRING const& msg) : Exception(msg) {} -LogicError::LogicError(std::string const& msg) +LogicError::LogicError(JSONCPP_STRING const& msg) : Exception(msg) {} -void throwRuntimeError(std::string const& msg) +JSONCPP_NORETURN void throwRuntimeError(JSONCPP_STRING const& msg) { throw RuntimeError(msg); } -void throwLogicError(std::string const& msg) +JSONCPP_NORETURN void throwLogicError(JSONCPP_STRING const& msg) { throw LogicError(msg); } @@ -184,16 +210,17 @@ // ////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////// -Value::CommentInfo::CommentInfo() : comment_(0) {} +Value::CommentInfo::CommentInfo() : comment_(0) +{} Value::CommentInfo::~CommentInfo() { if (comment_) - releaseStringValue(comment_); + releaseStringValue(comment_, 0u); } void Value::CommentInfo::setComment(const char* text, size_t len) { if (comment_) { - releaseStringValue(comment_); + releaseStringValue(comment_, 0u); comment_ = 0; } JSON_ASSERT(text != 0); @@ -218,28 +245,34 @@ Value::CZString::CZString(ArrayIndex aindex) : cstr_(0), index_(aindex) {} Value::CZString::CZString(char const* str, unsigned ulength, DuplicationPolicy allocate) - : cstr_(str) -{ + : cstr_(str) { // allocate != duplicate storage_.policy_ = allocate & 0x3; storage_.length_ = ulength & 0x3FFFFFFF; } -Value::CZString::CZString(const CZString& other) - : cstr_(other.storage_.policy_ != noDuplication && other.cstr_ != 0 - ? duplicateStringValue(other.cstr_, other.storage_.length_) - : other.cstr_) -{ - storage_.policy_ = (other.cstr_ +Value::CZString::CZString(const CZString& other) { + cstr_ = (other.storage_.policy_ != noDuplication && other.cstr_ != 0 + ? duplicateStringValue(other.cstr_, other.storage_.length_) + : other.cstr_); + storage_.policy_ = static_cast(other.cstr_ ? (static_cast(other.storage_.policy_) == noDuplication ? noDuplication : duplicate) - : static_cast(other.storage_.policy_)); + : static_cast(other.storage_.policy_)) & 3U; storage_.length_ = other.storage_.length_; } +#if JSON_HAS_RVALUE_REFERENCES +Value::CZString::CZString(CZString&& other) + : cstr_(other.cstr_), index_(other.index_) { + other.cstr_ = nullptr; +} +#endif + Value::CZString::~CZString() { - if (cstr_ && storage_.policy_ == duplicate) - releaseStringValue(const_cast(cstr_)); + if (cstr_ && storage_.policy_ == duplicate) { + releaseStringValue(const_cast(cstr_), storage_.length_ + 1u); //+1 for null terminating character for sake of completeness but not actually necessary + } } void Value::CZString::swap(CZString& other) { @@ -259,6 +292,7 @@ unsigned this_len = this->storage_.length_; unsigned other_len = other.storage_.length_; unsigned min_len = std::min(this_len, other_len); + JSON_ASSERT(this->cstr_ && other.cstr_); int comp = memcmp(this->cstr_, other.cstr_, min_len); if (comp < 0) return true; if (comp > 0) return false; @@ -272,6 +306,7 @@ unsigned this_len = this->storage_.length_; unsigned other_len = other.storage_.length_; if (this_len != other_len) return false; + JSON_ASSERT(this->cstr_ && other.cstr_); int comp = memcmp(this->cstr_, other.cstr_, this_len); return comp == 0; } @@ -358,7 +393,7 @@ duplicateAndPrefixStringValue(beginValue, static_cast(endValue - beginValue)); } -Value::Value(const std::string& value) { +Value::Value(const JSONCPP_STRING& value) { initBasic(stringValue, true); value_.string_ = duplicateAndPrefixStringValue(value.data(), static_cast(value.length())); @@ -425,6 +460,14 @@ } } +#if JSON_HAS_RVALUE_REFERENCES +// Move constructor +Value::Value(Value&& other) { + initBasic(nullValue); + swap(other); +} +#endif + Value::~Value() { switch (type_) { case nullValue: @@ -435,7 +478,7 @@ break; case stringValue: if (allocated_) - releaseStringValue(value_.string_); + releasePrefixedStringValue(value_.string_); break; case arrayValue: case objectValue: @@ -447,6 +490,8 @@ if (comments_) delete[] comments_; + + value_.uint_ = 0; } Value& Value::operator=(Value other) { @@ -509,6 +554,7 @@ decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str); decodePrefixedString(other.allocated_, other.value_.string_, &other_len, &other_str); unsigned min_len = std::min(this_len, other_len); + JSON_ASSERT(this_str && other_str); int comp = memcmp(this_str, other_str, min_len); if (comp < 0) return true; if (comp > 0) return false; @@ -564,6 +610,7 @@ decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str); decodePrefixedString(other.allocated_, other.value_.string_, &other_len, &other_str); if (this_len != other_len) return false; + JSON_ASSERT(this_str && other_str); int comp = memcmp(this_str, other_str, this_len); return comp == 0; } @@ -589,6 +636,18 @@ return this_str; } +#if JSONCPP_USING_SECURE_MEMORY +unsigned Value::getCStringLength() const { + JSON_ASSERT_MESSAGE(type_ == stringValue, + "in Json::Value::asCString(): requires stringValue"); + if (value_.string_ == 0) return 0; + unsigned this_len; + char const* this_str; + decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str); + return this_len; +} +#endif + bool Value::getString(char const** str, char const** cend) const { if (type_ != stringValue) return false; if (value_.string_ == 0) return false; @@ -598,7 +657,7 @@ return true; } -std::string Value::asString() const { +JSONCPP_STRING Value::asString() const { switch (type_) { case nullValue: return ""; @@ -608,7 +667,7 @@ unsigned this_len; char const* this_str; decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str); - return std::string(this_str, this_len); + return JSONCPP_STRING(this_str, this_len); } case booleanValue: return value_.bool_ ? "true" : "false"; @@ -768,7 +827,8 @@ #if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) return static_cast(value_.uint_); #else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) - return integerToDouble(value_.uint_); + // This can fail (silently?) if the value is bigger than MAX_FLOAT. + return static_cast(integerToDouble(value_.uint_)); #endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) case realValue: return static_cast(value_.real_); @@ -897,7 +957,7 @@ for (ArrayIndex index = newSize; index < oldSize; ++index) { value_.map_->erase(index); } - assert(size() == newSize); + JSON_ASSERT(size() == newSize); } } @@ -1017,7 +1077,7 @@ if (!found) return nullRef; return *found; } -Value const& Value::operator[](std::string const& key) const +Value const& Value::operator[](JSONCPP_STRING const& key) const { Value const* found = find(key.data(), key.data() + key.length()); if (!found) return nullRef; @@ -1028,7 +1088,7 @@ return resolveReference(key, key + strlen(key)); } -Value& Value::operator[](const std::string& key) { +Value& Value::operator[](const JSONCPP_STRING& key) { return resolveReference(key.data(), key.data() + key.length()); } @@ -1059,7 +1119,7 @@ { return get(key, key + strlen(key), defaultValue); } -Value Value::get(std::string const& key, Value const& defaultValue) const +Value Value::get(JSONCPP_STRING const& key, Value const& defaultValue) const { return get(key.data(), key.data() + key.length(), defaultValue); } @@ -1082,7 +1142,7 @@ { return removeMember(key, key + strlen(key), removed); } -bool Value::removeMember(std::string const& key, Value* removed) +bool Value::removeMember(JSONCPP_STRING const& key, Value* removed) { return removeMember(key.data(), key.data() + key.length(), removed); } @@ -1097,7 +1157,7 @@ removeMember(key, key + strlen(key), &removed); return removed; // still null if removeMember() did nothing } -Value Value::removeMember(const std::string& key) +Value Value::removeMember(const JSONCPP_STRING& key) { return removeMember(key.c_str()); } @@ -1141,7 +1201,7 @@ { return isMember(key, key + strlen(key)); } -bool Value::isMember(std::string const& key) const +bool Value::isMember(JSONCPP_STRING const& key) const { return isMember(key.data(), key.data() + key.length()); } @@ -1163,7 +1223,7 @@ ObjectValues::const_iterator it = value_.map_->begin(); ObjectValues::const_iterator itEnd = value_.map_->end(); for (; it != itEnd; ++it) { - members.push_back(std::string((*it).first.data(), + members.push_back(JSONCPP_STRING((*it).first.data(), (*it).first.length())); } return members; @@ -1305,7 +1365,7 @@ setComment(comment, strlen(comment), placement); } -void Value::setComment(const std::string& comment, CommentPlacement placement) { +void Value::setComment(const JSONCPP_STRING& comment, CommentPlacement placement) { setComment(comment.c_str(), comment.length(), placement); } @@ -1313,21 +1373,21 @@ return comments_ != 0 && comments_[placement].comment_ != 0; } -std::string Value::getComment(CommentPlacement placement) const { +JSONCPP_STRING Value::getComment(CommentPlacement placement) const { if (hasComment(placement)) return comments_[placement].comment_; return ""; } -void Value::setOffsetStart(size_t start) { start_ = start; } +void Value::setOffsetStart(ptrdiff_t start) { start_ = start; } -void Value::setOffsetLimit(size_t limit) { limit_ = limit; } +void Value::setOffsetLimit(ptrdiff_t limit) { limit_ = limit; } -size_t Value::getOffsetStart() const { return start_; } +ptrdiff_t Value::getOffsetStart() const { return start_; } -size_t Value::getOffsetLimit() const { return limit_; } +ptrdiff_t Value::getOffsetLimit() const { return limit_; } -std::string Value::toStyledString() const { +JSONCPP_STRING Value::toStyledString() const { StyledWriter writer; return writer.write(*this); } @@ -1395,13 +1455,13 @@ PathArgument::PathArgument(const char* key) : key_(key), index_(), kind_(kindKey) {} -PathArgument::PathArgument(const std::string& key) +PathArgument::PathArgument(const JSONCPP_STRING& key) : key_(key.c_str()), index_(), kind_(kindKey) {} // class Path // ////////////////////////////////////////////////////////////////// -Path::Path(const std::string& path, +Path::Path(const JSONCPP_STRING& path, const PathArgument& a1, const PathArgument& a2, const PathArgument& a3, @@ -1416,7 +1476,7 @@ makePath(path, in); } -void Path::makePath(const std::string& path, const InArgs& in) { +void Path::makePath(const JSONCPP_STRING& path, const InArgs& in) { const char* current = path.c_str(); const char* end = current + path.length(); InArgs::const_iterator itInArg = in.begin(); @@ -1442,12 +1502,12 @@ const char* beginName = current; while (current != end && !strchr("[.", *current)) ++current; - args_.push_back(std::string(beginName, current)); + args_.push_back(JSONCPP_STRING(beginName, current)); } } } -void Path::addPathInArg(const std::string& /*path*/, +void Path::addPathInArg(const JSONCPP_STRING& /*path*/, const InArgs& in, InArgs::const_iterator& itInArg, PathArgument::Kind kind) { @@ -1460,7 +1520,7 @@ } } -void Path::invalidPath(const std::string& /*path*/, int /*location*/) { +void Path::invalidPath(const JSONCPP_STRING& /*path*/, int /*location*/) { // Error: invalid path. } diff -Nru libjsoncpp-1.6.5/src/lib_json/json_valueiterator.inl libjsoncpp-1.7.2/src/lib_json/json_valueiterator.inl --- libjsoncpp-1.6.5/src/lib_json/json_valueiterator.inl 2015-07-23 05:26:13.000000000 +0000 +++ libjsoncpp-1.7.2/src/lib_json/json_valueiterator.inl 2016-03-25 20:09:15.000000000 +0000 @@ -92,12 +92,12 @@ return Value::UInt(-1); } -std::string ValueIteratorBase::name() const { +JSONCPP_STRING ValueIteratorBase::name() const { char const* keey; char const* end; keey = memberName(&end); - if (!keey) return std::string(); - return std::string(keey, end); + if (!keey) return JSONCPP_STRING(); + return JSONCPP_STRING(keey, end); } char const* ValueIteratorBase::memberName() const { @@ -129,6 +129,9 @@ const Value::ObjectValues::iterator& current) : ValueIteratorBase(current) {} +ValueConstIterator::ValueConstIterator(ValueIterator const& other) + : ValueIteratorBase(other) {} + ValueConstIterator& ValueConstIterator:: operator=(const ValueIteratorBase& other) { copy(other); @@ -149,7 +152,9 @@ : ValueIteratorBase(current) {} ValueIterator::ValueIterator(const ValueConstIterator& other) - : ValueIteratorBase(other) {} + : ValueIteratorBase(other) { + throwRuntimeError("ConstIterator to Iterator should never be allowed."); +} ValueIterator::ValueIterator(const ValueIterator& other) : ValueIteratorBase(other) {} diff -Nru libjsoncpp-1.6.5/src/lib_json/json_writer.cpp libjsoncpp-1.7.2/src/lib_json/json_writer.cpp --- libjsoncpp-1.6.5/src/lib_json/json_writer.cpp 2015-07-23 05:26:13.000000000 +0000 +++ libjsoncpp-1.7.2/src/lib_json/json_writer.cpp 2016-03-25 20:09:15.000000000 +0000 @@ -20,20 +20,47 @@ #include #define isfinite _finite #elif defined(__sun) && defined(__SVR4) //Solaris +#if !defined(isfinite) #include #define isfinite finite +#endif +#elif defined(_AIX) +#if !defined(isfinite) +#include +#define isfinite finite +#endif +#elif defined(__hpux) +#if !defined(isfinite) +#if defined(__ia64) && !defined(finite) +#define isfinite(x) ((sizeof(x) == sizeof(float) ? \ + _Isfinitef(x) : _IsFinite(x))) +#else +#include +#define isfinite finite +#endif +#endif #else #include +#if !(defined(__QNXNTO__)) // QNX already defines isfinite #define isfinite std::isfinite #endif +#endif -#if defined(_MSC_VER) && _MSC_VER < 1500 // VC++ 8.0 and below +#if defined(_MSC_VER) +#if !defined(WINCE) && defined(__STDC_SECURE_LIB__) && _MSC_VER >= 1500 // VC++ 9.0 and above +#define snprintf sprintf_s +#elif _MSC_VER >= 1900 // VC++ 14.0 and above +#define snprintf std::snprintf +#else #define snprintf _snprintf -#elif defined(__ANDROID__) +#endif +#elif defined(__ANDROID__) || defined(__QNXNTO__) #define snprintf snprintf #elif __cplusplus >= 201103L +#if !defined(__MINGW32__) && !defined(__CYGWIN__) #define snprintf std::snprintf #endif +#endif #if defined(__BORLANDC__) #include @@ -48,7 +75,7 @@ namespace Json { -#if __cplusplus >= 201103L +#if __cplusplus >= 201103L || (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520) typedef std::unique_ptr StreamWriterPtr; #else typedef std::auto_ptr StreamWriterPtr; @@ -72,20 +99,23 @@ return false; } -std::string valueToString(LargestInt value) { +JSONCPP_STRING valueToString(LargestInt value) { UIntToStringBuffer buffer; char* current = buffer + sizeof(buffer); - bool isNegative = value < 0; - if (isNegative) - value = -value; - uintToString(LargestUInt(value), current); - if (isNegative) + if (value == Value::minLargestInt) { + uintToString(LargestUInt(Value::maxLargestInt) + 1, current); + *--current = '-'; + } else if (value < 0) { + uintToString(LargestUInt(-value), current); *--current = '-'; + } else { + uintToString(LargestUInt(value), current); + } assert(current >= buffer); return current; } -std::string valueToString(LargestUInt value) { +JSONCPP_STRING valueToString(LargestUInt value) { UIntToStringBuffer buffer; char* current = buffer + sizeof(buffer); uintToString(value, current); @@ -95,68 +125,63 @@ #if defined(JSON_HAS_INT64) -std::string valueToString(Int value) { +JSONCPP_STRING valueToString(Int value) { return valueToString(LargestInt(value)); } -std::string valueToString(UInt value) { +JSONCPP_STRING valueToString(UInt value) { return valueToString(LargestUInt(value)); } #endif // # if defined(JSON_HAS_INT64) -std::string valueToString(double value) { +JSONCPP_STRING valueToString(double value, bool useSpecialFloats, unsigned int precision) { // Allocate a buffer that is more than large enough to store the 16 digits of // precision requested below. char buffer[32]; int len = -1; -// Print into the buffer. We need not request the alternative representation -// that always has a decimal point because JSON doesn't distingish the -// concepts of reals and integers. -#if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__) // Use secure version with - // visual studio 2005 to - // avoid warning. -#if defined(WINCE) - len = _snprintf(buffer, sizeof(buffer), "%.17g", value); -#else - len = sprintf_s(buffer, sizeof(buffer), "%.17g", value); -#endif -#else + char formatString[6]; + sprintf(formatString, "%%.%dg", precision); + + // Print into the buffer. We need not request the alternative representation + // that always has a decimal point because JSON doesn't distingish the + // concepts of reals and integers. if (isfinite(value)) { - len = snprintf(buffer, sizeof(buffer), "%.17g", value); + len = snprintf(buffer, sizeof(buffer), formatString, value); } else { // IEEE standard states that NaN values will not compare to themselves if (value != value) { - len = snprintf(buffer, sizeof(buffer), "null"); + len = snprintf(buffer, sizeof(buffer), useSpecialFloats ? "NaN" : "null"); } else if (value < 0) { - len = snprintf(buffer, sizeof(buffer), "-1e+9999"); + len = snprintf(buffer, sizeof(buffer), useSpecialFloats ? "-Infinity" : "-1e+9999"); } else { - len = snprintf(buffer, sizeof(buffer), "1e+9999"); + len = snprintf(buffer, sizeof(buffer), useSpecialFloats ? "Infinity" : "1e+9999"); } // For those, we do not need to call fixNumLoc, but it is fast. } -#endif assert(len >= 0); fixNumericLocale(buffer, buffer + len); return buffer; } -std::string valueToString(bool value) { return value ? "true" : "false"; } +JSONCPP_STRING valueToString(double value) { return valueToString(value, false, 17); } -std::string valueToQuotedString(const char* value) { +JSONCPP_STRING valueToString(bool value) { return value ? "true" : "false"; } + +JSONCPP_STRING valueToQuotedString(const char* value) { if (value == NULL) return ""; // Not sure how to handle unicode... if (strpbrk(value, "\"\\\b\f\n\r\t") == NULL && !containsControlCharacter(value)) - return std::string("\"") + value + "\""; + return JSONCPP_STRING("\"") + value + "\""; // We have to walk value and escape any special characters. - // Appending to std::string is not efficient, but this should be rare. + // Appending to JSONCPP_STRING is not efficient, but this should be rare. // (Note: forward slashes are *not* rare, but I am not escaping them.) - std::string::size_type maxsize = + JSONCPP_STRING::size_type maxsize = strlen(value) * 2 + 3; // allescaped+quotes+NULL - std::string result; + JSONCPP_STRING result; result.reserve(maxsize); // to avoid lots of mallocs result += "\""; for (const char* c = value; *c != 0; ++c) { @@ -192,7 +217,7 @@ // sequence from occurring. default: if (isControlCharacter(*c)) { - std::ostringstream oss; + JSONCPP_OSTRINGSTREAM oss; oss << "\\u" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << static_cast(*c); result += oss.str(); @@ -221,19 +246,19 @@ } return NULL; } -static std::string valueToQuotedStringN(const char* value, unsigned length) { +static JSONCPP_STRING valueToQuotedStringN(const char* value, unsigned length) { if (value == NULL) return ""; // Not sure how to handle unicode... if (strnpbrk(value, "\"\\\b\f\n\r\t", length) == NULL && !containsControlCharacter0(value, length)) - return std::string("\"") + value + "\""; + return JSONCPP_STRING("\"") + value + "\""; // We have to walk value and escape any special characters. - // Appending to std::string is not efficient, but this should be rare. + // Appending to JSONCPP_STRING is not efficient, but this should be rare. // (Note: forward slashes are *not* rare, but I am not escaping them.) - std::string::size_type maxsize = + JSONCPP_STRING::size_type maxsize = length * 2 + 3; // allescaped+quotes+NULL - std::string result; + JSONCPP_STRING result; result.reserve(maxsize); // to avoid lots of mallocs result += "\""; char const* end = value + length; @@ -270,7 +295,7 @@ // sequence from occurring. default: if ((isControlCharacter(*c)) || (*c == 0)) { - std::ostringstream oss; + JSONCPP_OSTRINGSTREAM oss; oss << "\\u" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << static_cast(*c); result += oss.str(); @@ -301,7 +326,7 @@ void FastWriter::omitEndingLineFeed() { omitEndingLineFeed_ = true; } -std::string FastWriter::write(const Value& root) { +JSONCPP_STRING FastWriter::write(const Value& root) { document_ = ""; writeValue(root); if (!omitEndingLineFeed_) @@ -338,8 +363,8 @@ break; case arrayValue: { document_ += '['; - int size = value.size(); - for (int index = 0; index < size; ++index) { + ArrayIndex size = value.size(); + for (ArrayIndex index = 0; index < size; ++index) { if (index > 0) document_ += ','; writeValue(value[index]); @@ -351,7 +376,7 @@ document_ += '{'; for (Value::Members::iterator it = members.begin(); it != members.end(); ++it) { - const std::string& name = *it; + const JSONCPP_STRING& name = *it; if (it != members.begin()) document_ += ','; document_ += valueToQuotedStringN(name.data(), static_cast(name.length())); @@ -369,7 +394,7 @@ StyledWriter::StyledWriter() : rightMargin_(74), indentSize_(3), addChildValues_() {} -std::string StyledWriter::write(const Value& root) { +JSONCPP_STRING StyledWriter::write(const Value& root) { document_ = ""; addChildValues_ = false; indentString_ = ""; @@ -419,7 +444,7 @@ indent(); Value::Members::iterator it = members.begin(); for (;;) { - const std::string& name = *it; + const JSONCPP_STRING& name = *it; const Value& childValue = value[name]; writeCommentBeforeValue(childValue); writeWithIndent(valueToQuotedString(name.c_str())); @@ -483,26 +508,25 @@ } bool StyledWriter::isMultineArray(const Value& value) { - int size = value.size(); + ArrayIndex const size = value.size(); bool isMultiLine = size * 3 >= rightMargin_; childValues_.clear(); - for (int index = 0; index < size && !isMultiLine; ++index) { + for (ArrayIndex index = 0; index < size && !isMultiLine; ++index) { const Value& childValue = value[index]; - isMultiLine = - isMultiLine || ((childValue.isArray() || childValue.isObject()) && + isMultiLine = ((childValue.isArray() || childValue.isObject()) && childValue.size() > 0); } if (!isMultiLine) // check if line length > max line length { childValues_.reserve(size); addChildValues_ = true; - int lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]' - for (int index = 0; index < size; ++index) { + ArrayIndex lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]' + for (ArrayIndex index = 0; index < size; ++index) { if (hasCommentForValue(value[index])) { isMultiLine = true; } writeValue(value[index]); - lineLength += int(childValues_[index].length()); + lineLength += static_cast(childValues_[index].length()); } addChildValues_ = false; isMultiLine = isMultiLine || lineLength >= rightMargin_; @@ -510,7 +534,7 @@ return isMultiLine; } -void StyledWriter::pushValue(const std::string& value) { +void StyledWriter::pushValue(const JSONCPP_STRING& value) { if (addChildValues_) childValues_.push_back(value); else @@ -528,15 +552,15 @@ document_ += indentString_; } -void StyledWriter::writeWithIndent(const std::string& value) { +void StyledWriter::writeWithIndent(const JSONCPP_STRING& value) { writeIndent(); document_ += value; } -void StyledWriter::indent() { indentString_ += std::string(indentSize_, ' '); } +void StyledWriter::indent() { indentString_ += JSONCPP_STRING(indentSize_, ' '); } void StyledWriter::unindent() { - assert(int(indentString_.size()) >= indentSize_); + assert(indentString_.size() >= indentSize_); indentString_.resize(indentString_.size() - indentSize_); } @@ -546,8 +570,8 @@ document_ += "\n"; writeIndent(); - const std::string& comment = root.getComment(commentBefore); - std::string::const_iterator iter = comment.begin(); + const JSONCPP_STRING& comment = root.getComment(commentBefore); + JSONCPP_STRING::const_iterator iter = comment.begin(); while (iter != comment.end()) { document_ += *iter; if (*iter == '\n' && @@ -580,11 +604,11 @@ // Class StyledStreamWriter // ////////////////////////////////////////////////////////////////// -StyledStreamWriter::StyledStreamWriter(std::string indentation) +StyledStreamWriter::StyledStreamWriter(JSONCPP_STRING indentation) : document_(NULL), rightMargin_(74), indentation_(indentation), addChildValues_() {} -void StyledStreamWriter::write(std::ostream& out, const Value& root) { +void StyledStreamWriter::write(JSONCPP_OSTREAM& out, const Value& root) { document_ = &out; addChildValues_ = false; indentString_ = ""; @@ -637,7 +661,7 @@ indent(); Value::Members::iterator it = members.begin(); for (;;) { - const std::string& name = *it; + const JSONCPP_STRING& name = *it; const Value& childValue = value[name]; writeCommentBeforeValue(childValue); writeWithIndent(valueToQuotedString(name.c_str())); @@ -703,26 +727,25 @@ } bool StyledStreamWriter::isMultineArray(const Value& value) { - int size = value.size(); + ArrayIndex const size = value.size(); bool isMultiLine = size * 3 >= rightMargin_; childValues_.clear(); - for (int index = 0; index < size && !isMultiLine; ++index) { + for (ArrayIndex index = 0; index < size && !isMultiLine; ++index) { const Value& childValue = value[index]; - isMultiLine = - isMultiLine || ((childValue.isArray() || childValue.isObject()) && + isMultiLine = ((childValue.isArray() || childValue.isObject()) && childValue.size() > 0); } if (!isMultiLine) // check if line length > max line length { childValues_.reserve(size); addChildValues_ = true; - int lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]' - for (int index = 0; index < size; ++index) { + ArrayIndex lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]' + for (ArrayIndex index = 0; index < size; ++index) { if (hasCommentForValue(value[index])) { isMultiLine = true; } writeValue(value[index]); - lineLength += int(childValues_[index].length()); + lineLength += static_cast(childValues_[index].length()); } addChildValues_ = false; isMultiLine = isMultiLine || lineLength >= rightMargin_; @@ -730,7 +753,7 @@ return isMultiLine; } -void StyledStreamWriter::pushValue(const std::string& value) { +void StyledStreamWriter::pushValue(const JSONCPP_STRING& value) { if (addChildValues_) childValues_.push_back(value); else @@ -745,7 +768,7 @@ *document_ << '\n' << indentString_; } -void StyledStreamWriter::writeWithIndent(const std::string& value) { +void StyledStreamWriter::writeWithIndent(const JSONCPP_STRING& value) { if (!indented_) writeIndent(); *document_ << value; indented_ = false; @@ -763,8 +786,8 @@ return; if (!indented_) writeIndent(); - const std::string& comment = root.getComment(commentBefore); - std::string::const_iterator iter = comment.begin(); + const JSONCPP_STRING& comment = root.getComment(commentBefore); + JSONCPP_STRING::const_iterator iter = comment.begin(); while (iter != comment.end()) { *document_ << *iter; if (*iter == '\n' && @@ -809,44 +832,50 @@ struct BuiltStyledStreamWriter : public StreamWriter { BuiltStyledStreamWriter( - std::string const& indentation, + JSONCPP_STRING const& indentation, CommentStyle::Enum cs, - std::string const& colonSymbol, - std::string const& nullSymbol, - std::string const& endingLineFeedSymbol); - virtual int write(Value const& root, std::ostream* sout); + JSONCPP_STRING const& colonSymbol, + JSONCPP_STRING const& nullSymbol, + JSONCPP_STRING const& endingLineFeedSymbol, + bool useSpecialFloats, + unsigned int precision); + int write(Value const& root, JSONCPP_OSTREAM* sout) JSONCPP_OVERRIDE; private: void writeValue(Value const& value); void writeArrayValue(Value const& value); bool isMultineArray(Value const& value); - void pushValue(std::string const& value); + void pushValue(JSONCPP_STRING const& value); void writeIndent(); - void writeWithIndent(std::string const& value); + void writeWithIndent(JSONCPP_STRING const& value); void indent(); void unindent(); void writeCommentBeforeValue(Value const& root); void writeCommentAfterValueOnSameLine(Value const& root); static bool hasCommentForValue(const Value& value); - typedef std::vector ChildValues; + typedef std::vector ChildValues; ChildValues childValues_; - std::string indentString_; - int rightMargin_; - std::string indentation_; + JSONCPP_STRING indentString_; + unsigned int rightMargin_; + JSONCPP_STRING indentation_; CommentStyle::Enum cs_; - std::string colonSymbol_; - std::string nullSymbol_; - std::string endingLineFeedSymbol_; + JSONCPP_STRING colonSymbol_; + JSONCPP_STRING nullSymbol_; + JSONCPP_STRING endingLineFeedSymbol_; bool addChildValues_ : 1; bool indented_ : 1; + bool useSpecialFloats_ : 1; + unsigned int precision_; }; BuiltStyledStreamWriter::BuiltStyledStreamWriter( - std::string const& indentation, + JSONCPP_STRING const& indentation, CommentStyle::Enum cs, - std::string const& colonSymbol, - std::string const& nullSymbol, - std::string const& endingLineFeedSymbol) + JSONCPP_STRING const& colonSymbol, + JSONCPP_STRING const& nullSymbol, + JSONCPP_STRING const& endingLineFeedSymbol, + bool useSpecialFloats, + unsigned int precision) : rightMargin_(74) , indentation_(indentation) , cs_(cs) @@ -855,9 +884,11 @@ , endingLineFeedSymbol_(endingLineFeedSymbol) , addChildValues_(false) , indented_(false) + , useSpecialFloats_(useSpecialFloats) + , precision_(precision) { } -int BuiltStyledStreamWriter::write(Value const& root, std::ostream* sout) +int BuiltStyledStreamWriter::write(Value const& root, JSONCPP_OSTREAM* sout) { sout_ = sout; addChildValues_ = false; @@ -884,7 +915,7 @@ pushValue(valueToString(value.asLargestUInt())); break; case realValue: - pushValue(valueToString(value.asDouble())); + pushValue(valueToString(value.asDouble(), useSpecialFloats_, precision_)); break; case stringValue: { @@ -911,7 +942,7 @@ indent(); Value::Members::iterator it = members.begin(); for (;;) { - std::string const& name = *it; + JSONCPP_STRING const& name = *it; Value const& childValue = value[name]; writeCommentBeforeValue(childValue); writeWithIndent(valueToQuotedStringN(name.data(), static_cast(name.length()))); @@ -979,26 +1010,25 @@ } bool BuiltStyledStreamWriter::isMultineArray(Value const& value) { - int size = value.size(); + ArrayIndex const size = value.size(); bool isMultiLine = size * 3 >= rightMargin_; childValues_.clear(); - for (int index = 0; index < size && !isMultiLine; ++index) { + for (ArrayIndex index = 0; index < size && !isMultiLine; ++index) { Value const& childValue = value[index]; - isMultiLine = - isMultiLine || ((childValue.isArray() || childValue.isObject()) && + isMultiLine = ((childValue.isArray() || childValue.isObject()) && childValue.size() > 0); } if (!isMultiLine) // check if line length > max line length { childValues_.reserve(size); addChildValues_ = true; - int lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]' - for (int index = 0; index < size; ++index) { + ArrayIndex lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]' + for (ArrayIndex index = 0; index < size; ++index) { if (hasCommentForValue(value[index])) { isMultiLine = true; } writeValue(value[index]); - lineLength += int(childValues_[index].length()); + lineLength += static_cast(childValues_[index].length()); } addChildValues_ = false; isMultiLine = isMultiLine || lineLength >= rightMargin_; @@ -1006,7 +1036,7 @@ return isMultiLine; } -void BuiltStyledStreamWriter::pushValue(std::string const& value) { +void BuiltStyledStreamWriter::pushValue(JSONCPP_STRING const& value) { if (addChildValues_) childValues_.push_back(value); else @@ -1025,7 +1055,7 @@ } } -void BuiltStyledStreamWriter::writeWithIndent(std::string const& value) { +void BuiltStyledStreamWriter::writeWithIndent(JSONCPP_STRING const& value) { if (!indented_) writeIndent(); *sout_ << value; indented_ = false; @@ -1044,8 +1074,8 @@ return; if (!indented_) writeIndent(); - const std::string& comment = root.getComment(commentBefore); - std::string::const_iterator iter = comment.begin(); + const JSONCPP_STRING& comment = root.getComment(commentBefore); + JSONCPP_STRING::const_iterator iter = comment.begin(); while (iter != comment.end()) { *sout_ << *iter; if (*iter == '\n' && @@ -1095,10 +1125,12 @@ {} StreamWriter* StreamWriterBuilder::newStreamWriter() const { - std::string indentation = settings_["indentation"].asString(); - std::string cs_str = settings_["commentStyle"].asString(); + JSONCPP_STRING indentation = settings_["indentation"].asString(); + JSONCPP_STRING cs_str = settings_["commentStyle"].asString(); bool eyc = settings_["enableYAMLCompatibility"].asBool(); bool dnp = settings_["dropNullPlaceholders"].asBool(); + bool usf = settings_["useSpecialFloats"].asBool(); + unsigned int pre = settings_["precision"].asUInt(); CommentStyle::Enum cs = CommentStyle::All; if (cs_str == "All") { cs = CommentStyle::All; @@ -1107,47 +1139,50 @@ } else { throwRuntimeError("commentStyle must be 'All' or 'None'"); } - std::string colonSymbol = " : "; + JSONCPP_STRING colonSymbol = " : "; if (eyc) { colonSymbol = ": "; } else if (indentation.empty()) { colonSymbol = ":"; } - std::string nullSymbol = "null"; + JSONCPP_STRING nullSymbol = "null"; if (dnp) { nullSymbol = ""; } - std::string endingLineFeedSymbol = ""; + if (pre > 17) pre = 17; + JSONCPP_STRING endingLineFeedSymbol = ""; return new BuiltStyledStreamWriter( indentation, cs, - colonSymbol, nullSymbol, endingLineFeedSymbol); + colonSymbol, nullSymbol, endingLineFeedSymbol, usf, pre); } -static void getValidWriterKeys(std::set* valid_keys) +static void getValidWriterKeys(std::set* valid_keys) { valid_keys->clear(); valid_keys->insert("indentation"); valid_keys->insert("commentStyle"); valid_keys->insert("enableYAMLCompatibility"); valid_keys->insert("dropNullPlaceholders"); + valid_keys->insert("useSpecialFloats"); + valid_keys->insert("precision"); } bool StreamWriterBuilder::validate(Json::Value* invalid) const { Json::Value my_invalid; if (!invalid) invalid = &my_invalid; // so we do not need to test for NULL Json::Value& inv = *invalid; - std::set valid_keys; + std::set valid_keys; getValidWriterKeys(&valid_keys); Value::Members keys = settings_.getMemberNames(); size_t n = keys.size(); for (size_t i = 0; i < n; ++i) { - std::string const& key = keys[i]; + JSONCPP_STRING const& key = keys[i]; if (valid_keys.find(key) == valid_keys.end()) { inv[key] = settings_[key]; } } return 0u == inv.size(); } -Value& StreamWriterBuilder::operator[](std::string key) +Value& StreamWriterBuilder::operator[](JSONCPP_STRING key) { return settings_[key]; } @@ -1159,17 +1194,19 @@ (*settings)["indentation"] = "\t"; (*settings)["enableYAMLCompatibility"] = false; (*settings)["dropNullPlaceholders"] = false; + (*settings)["useSpecialFloats"] = false; + (*settings)["precision"] = 17; //! [StreamWriterBuilderDefaults] } -std::string writeString(StreamWriter::Factory const& builder, Value const& root) { - std::ostringstream sout; +JSONCPP_STRING writeString(StreamWriter::Factory const& builder, Value const& root) { + JSONCPP_OSTRINGSTREAM sout; StreamWriterPtr const writer(builder.newStreamWriter()); writer->write(root, &sout); return sout.str(); } -std::ostream& operator<<(std::ostream& sout, Value const& root) { +JSONCPP_OSTREAM& operator<<(JSONCPP_OSTREAM& sout, Value const& root) { StreamWriterBuilder builder; StreamWriterPtr const writer(builder.newStreamWriter()); writer->write(root, &sout); diff -Nru libjsoncpp-1.6.5/src/lib_json/version.h.in libjsoncpp-1.7.2/src/lib_json/version.h.in --- libjsoncpp-1.6.5/src/lib_json/version.h.in 2015-07-23 05:26:13.000000000 +0000 +++ libjsoncpp-1.7.2/src/lib_json/version.h.in 2016-03-25 20:09:15.000000000 +0000 @@ -10,4 +10,11 @@ # define JSONCPP_VERSION_QUALIFIER # define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8)) +#ifdef JSONCPP_USING_SECURE_MEMORY +#undef JSONCPP_USING_SECURE_MEMORY +#endif +#define JSONCPP_USING_SECURE_MEMORY @JSONCPP_USE_SECURE_MEMORY@ +// If non-zero, the library zeroes any memory that it has allocated before +// it frees its memory. + #endif // JSON_VERSION_H_INCLUDED diff -Nru libjsoncpp-1.6.5/src/test_lib_json/CMakeLists.txt libjsoncpp-1.7.2/src/test_lib_json/CMakeLists.txt --- libjsoncpp-1.6.5/src/test_lib_json/CMakeLists.txt 2015-07-23 05:26:13.000000000 +0000 +++ libjsoncpp-1.7.2/src/test_lib_json/CMakeLists.txt 2016-03-25 20:09:15.000000000 +0000 @@ -12,7 +12,7 @@ TARGET_LINK_LIBRARIES(jsoncpp_test jsoncpp_lib) ELSE(BUILD_SHARED_LIBS) TARGET_LINK_LIBRARIES(jsoncpp_test jsoncpp_lib_static) -ENDIF(BUILD_SHARED_LIBS) +ENDIF() # another way to solve issue #90 #set_target_properties(jsoncpp_test PROPERTIES COMPILE_FLAGS -ffloat-store) @@ -32,7 +32,7 @@ ADD_CUSTOM_COMMAND( TARGET jsoncpp_test POST_BUILD COMMAND $) - ENDIF(BUILD_SHARED_LIBS) -ENDIF(JSONCPP_WITH_POST_BUILD_UNITTEST) + ENDIF() +ENDIF() SET_TARGET_PROPERTIES(jsoncpp_test PROPERTIES OUTPUT_NAME jsoncpp_test) diff -Nru libjsoncpp-1.6.5/src/test_lib_json/jsontest.cpp libjsoncpp-1.7.2/src/test_lib_json/jsontest.cpp --- libjsoncpp-1.6.5/src/test_lib_json/jsontest.cpp 2015-07-23 05:26:13.000000000 +0000 +++ libjsoncpp-1.7.2/src/test_lib_json/jsontest.cpp 2016-03-25 20:09:15.000000000 +0000 @@ -81,7 +81,7 @@ predicateStackTail_ = &rootPredicateNode_; } -void TestResult::setTestName(const std::string& name) { name_ = name; } +void TestResult::setTestName(const JSONCPP_STRING& name) { name_ = name; } TestResult& TestResult::addFailure(const char* file, unsigned int line, const char* expr) { @@ -163,7 +163,7 @@ Failures::const_iterator itEnd = failures_.end(); for (Failures::const_iterator it = failures_.begin(); it != itEnd; ++it) { const Failure& failure = *it; - std::string indent(failure.nestingLevel_ * 2, ' '); + JSONCPP_STRING indent(failure.nestingLevel_ * 2, ' '); if (failure.file_) { printf("%s%s(%d): ", indent.c_str(), failure.file_, failure.line_); } @@ -173,19 +173,19 @@ printf("\n"); } if (!failure.message_.empty()) { - std::string reindented = indentText(failure.message_, indent + " "); + JSONCPP_STRING reindented = indentText(failure.message_, indent + " "); printf("%s\n", reindented.c_str()); } } } -std::string TestResult::indentText(const std::string& text, - const std::string& indent) { - std::string reindented; - std::string::size_type lastIndex = 0; +JSONCPP_STRING TestResult::indentText(const JSONCPP_STRING& text, + const JSONCPP_STRING& indent) { + JSONCPP_STRING reindented; + JSONCPP_STRING::size_type lastIndex = 0; while (lastIndex < text.size()) { - std::string::size_type nextIndex = text.find('\n', lastIndex); - if (nextIndex == std::string::npos) { + JSONCPP_STRING::size_type nextIndex = text.find('\n', lastIndex); + if (nextIndex == JSONCPP_STRING::npos) { nextIndex = text.size() - 1; } reindented += indent; @@ -195,7 +195,7 @@ return reindented; } -TestResult& TestResult::addToLastFailure(const std::string& message) { +TestResult& TestResult::addToLastFailure(const JSONCPP_STRING& message) { if (messageTarget_ != 0) { messageTarget_->message_ += message; } @@ -240,9 +240,9 @@ return static_cast(tests_.size()); } -std::string Runner::testNameAt(unsigned int index) const { +JSONCPP_STRING Runner::testNameAt(unsigned int index) const { TestCase* test = tests_[index](); - std::string name = test->testName(); + JSONCPP_STRING name = test->testName(); delete test; return name; } @@ -303,7 +303,7 @@ } } -bool Runner::testIndex(const std::string& testName, +bool Runner::testIndex(const JSONCPP_STRING& testName, unsigned int& indexOut) const { unsigned int count = testCount(); for (unsigned int index = 0; index < count; ++index) { @@ -323,10 +323,10 @@ } int Runner::runCommandLine(int argc, const char* argv[]) const { - // typedef std::deque TestNames; + // typedef std::deque TestNames; Runner subrunner; for (int index = 1; index < argc; ++index) { - std::string opt = argv[index]; + JSONCPP_STRING opt = argv[index]; if (opt == "--list-tests") { listTests(); return 0; @@ -426,9 +426,23 @@ // Assertion functions // ////////////////////////////////////////////////////////////////// +JSONCPP_STRING ToJsonString(const char* toConvert) { + return JSONCPP_STRING(toConvert); +} + +JSONCPP_STRING ToJsonString(JSONCPP_STRING in) { + return in; +} + +#if JSONCPP_USING_SECURE_MEMORY +JSONCPP_STRING ToJsonString(std::string in) { + return JSONCPP_STRING(in.data(), in.data() + in.length()); +} +#endif + TestResult& checkStringEqual(TestResult& result, - const std::string& expected, - const std::string& actual, + const JSONCPP_STRING& expected, + const JSONCPP_STRING& actual, const char* file, unsigned int line, const char* expr) { diff -Nru libjsoncpp-1.6.5/src/test_lib_json/jsontest.h libjsoncpp-1.7.2/src/test_lib_json/jsontest.h --- libjsoncpp-1.6.5/src/test_lib_json/jsontest.h 2015-07-23 05:26:13.000000000 +0000 +++ libjsoncpp-1.7.2/src/test_lib_json/jsontest.h 2016-03-25 20:09:15.000000000 +0000 @@ -32,8 +32,8 @@ public: const char* file_; unsigned int line_; - std::string expr_; - std::string message_; + JSONCPP_STRING expr_; + JSONCPP_STRING message_; unsigned int nestingLevel_; }; @@ -65,7 +65,7 @@ /// \internal Implementation detail for predicate macros PredicateContext* predicateStackTail_; - void setTestName(const std::string& name); + void setTestName(const JSONCPP_STRING& name); /// Adds an assertion failure. TestResult& @@ -82,7 +82,7 @@ // Generic operator that will work with anything ostream can deal with. template TestResult& operator<<(const T& value) { - std::ostringstream oss; + JSONCPP_OSTRINGSTREAM oss; oss.precision(16); oss.setf(std::ios_base::floatfield); oss << value; @@ -96,19 +96,19 @@ TestResult& operator<<(Json::UInt64 value); private: - TestResult& addToLastFailure(const std::string& message); + TestResult& addToLastFailure(const JSONCPP_STRING& message); unsigned int getAssertionNestingLevel() const; /// Adds a failure or a predicate context void addFailureInfo(const char* file, unsigned int line, const char* expr, unsigned int nestingLevel); - static std::string indentText(const std::string& text, - const std::string& indent); + static JSONCPP_STRING indentText(const JSONCPP_STRING& text, + const JSONCPP_STRING& indent); typedef std::deque Failures; Failures failures_; - std::string name_; + JSONCPP_STRING name_; PredicateContext rootPredicateNode_; PredicateContext::Id lastUsedPredicateId_; /// Failure which is the target of the messages added using operator << @@ -155,7 +155,7 @@ unsigned int testCount() const; /// Returns the name of the test case at the specified index - std::string testNameAt(unsigned int index) const; + JSONCPP_STRING testNameAt(unsigned int index) const; /// Runs the test case at the specified index using the specified TestResult void runTestAt(unsigned int index, TestResult& result) const; @@ -168,7 +168,7 @@ private: void listTests() const; - bool testIndex(const std::string& testName, unsigned int& index) const; + bool testIndex(const JSONCPP_STRING& testName, unsigned int& index) const; static void preventDialogOnCrash(); private: @@ -191,9 +191,15 @@ return result; } +JSONCPP_STRING ToJsonString(const char* toConvert); +JSONCPP_STRING ToJsonString(JSONCPP_STRING in); +#if JSONCPP_USING_SECURE_MEMORY +JSONCPP_STRING ToJsonString(std::string in); +#endif + TestResult& checkStringEqual(TestResult& result, - const std::string& expected, - const std::string& actual, + const JSONCPP_STRING& expected, + const JSONCPP_STRING& actual, const char* file, unsigned int line, const char* expr); @@ -235,8 +241,8 @@ /// \brief Asserts that two values are equals. #define JSONTEST_ASSERT_STRING_EQUAL(expected, actual) \ JsonTest::checkStringEqual(*result_, \ - std::string(expected), \ - std::string(actual), \ + JsonTest::ToJsonString(expected), \ + JsonTest::ToJsonString(actual), \ __FILE__, \ __LINE__, \ #expected " == " #actual) @@ -265,8 +271,8 @@ } \ \ public: /* overidden from TestCase */ \ - virtual const char* testName() const { return #FixtureType "/" #name; } \ - virtual void runTestCase(); \ + const char* testName() const JSONCPP_OVERRIDE { return #FixtureType "/" #name; } \ + void runTestCase() JSONCPP_OVERRIDE; \ }; \ \ void Test##FixtureType##name::runTestCase() diff -Nru libjsoncpp-1.6.5/src/test_lib_json/main.cpp libjsoncpp-1.7.2/src/test_lib_json/main.cpp --- libjsoncpp-1.6.5/src/test_lib_json/main.cpp 2015-07-23 05:26:13.000000000 +0000 +++ libjsoncpp-1.7.2/src/test_lib_json/main.cpp 2016-03-25 20:09:15.000000000 +0000 @@ -7,6 +7,10 @@ #include #include #include +#include +#include +#include +#include // Make numeric limits more convenient to talk about. // Assumes int type in 32 bits. @@ -35,7 +39,7 @@ #else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) static inline double uint64ToDouble(Json::UInt64 value) { return static_cast(Json::Int64(value / 2)) * 2.0 + - Json::Int64(value & 1); + static_cast(Json::Int64(value & 1)); } #endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) @@ -98,21 +102,21 @@ /// Normalize the representation of floating-point number by stripped leading /// 0 in exponent. - static std::string normalizeFloatingPointStr(const std::string& s); + static JSONCPP_STRING normalizeFloatingPointStr(const JSONCPP_STRING& s); }; -std::string ValueTest::normalizeFloatingPointStr(const std::string& s) { - std::string::size_type index = s.find_last_of("eE"); - if (index != std::string::npos) { - std::string::size_type hasSign = +JSONCPP_STRING ValueTest::normalizeFloatingPointStr(const JSONCPP_STRING& s) { + JSONCPP_STRING::size_type index = s.find_last_of("eE"); + if (index != JSONCPP_STRING::npos) { + JSONCPP_STRING::size_type hasSign = (s[index + 1] == '+' || s[index + 1] == '-') ? 1 : 0; - std::string::size_type exponentStartIndex = index + 1 + hasSign; - std::string normalized = s.substr(0, exponentStartIndex); - std::string::size_type indexDigit = + JSONCPP_STRING::size_type exponentStartIndex = index + 1 + hasSign; + JSONCPP_STRING normalized = s.substr(0, exponentStartIndex); + JSONCPP_STRING::size_type indexDigit = s.find_first_not_of('0', exponentStartIndex); - std::string exponent = "0"; + JSONCPP_STRING exponent = "0"; if (indexDigit != - std::string::npos) // There is an exponent different from 0 + JSONCPP_STRING::npos) // There is an exponent different from 0 { exponent = s.substr(indexDigit); } @@ -643,7 +647,7 @@ JSONTEST_ASSERT_EQUAL((1 << 20), val.asFloat()); JSONTEST_ASSERT_EQUAL(true, val.asBool()); JSONTEST_ASSERT_STRING_EQUAL("1048576", - normalizeFloatingPointStr(val.asString())); + normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString()))); // -2^20 val = Json::Value(-(1 << 20)); @@ -884,7 +888,7 @@ JSONTEST_ASSERT_EQUAL((Json::Int64(1) << 40), val.asFloat()); JSONTEST_ASSERT_EQUAL(true, val.asBool()); JSONTEST_ASSERT_STRING_EQUAL("1099511627776", - normalizeFloatingPointStr(val.asString())); + normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString()))); // -2^40 val = Json::Value(-(Json::Int64(1) << 40)); @@ -959,7 +963,7 @@ val.asFloat()); JSONTEST_ASSERT_EQUAL(true, val.asBool()); JSONTEST_ASSERT_STRING_EQUAL("9.2233720368547758e+18", - normalizeFloatingPointStr(val.asString())); + normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString()))); // int64 min val = Json::Value(Json::Int64(kint64min)); @@ -1007,7 +1011,7 @@ JSONTEST_ASSERT_EQUAL(-9223372036854775808.0, val.asFloat()); JSONTEST_ASSERT_EQUAL(true, val.asBool()); JSONTEST_ASSERT_STRING_EQUAL("-9.2233720368547758e+18", - normalizeFloatingPointStr(val.asString())); + normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString()))); // 10^19 const Json::UInt64 ten_to_19 = static_cast(1e19); @@ -1054,7 +1058,7 @@ JSONTEST_ASSERT_EQUAL(1e19, val.asFloat()); JSONTEST_ASSERT_EQUAL(true, val.asBool()); JSONTEST_ASSERT_STRING_EQUAL("1e+19", - normalizeFloatingPointStr(val.asString())); + normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString()))); // uint64 max val = Json::Value(Json::UInt64(kuint64max)); @@ -1098,7 +1102,7 @@ JSONTEST_ASSERT_EQUAL(18446744073709551616.0, val.asFloat()); JSONTEST_ASSERT_EQUAL(true, val.asBool()); JSONTEST_ASSERT_STRING_EQUAL("1.8446744073709552e+19", - normalizeFloatingPointStr(val.asString())); + normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString()))); #endif } @@ -1188,7 +1192,7 @@ #endif JSONTEST_ASSERT_EQUAL(true, val.asBool()); JSONTEST_ASSERT_EQUAL("2147483647.5", - normalizeFloatingPointStr(val.asString())); + normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString()))); // A bit under int32 min val = Json::Value(kint32min - 0.5); @@ -1212,11 +1216,11 @@ JSONTEST_ASSERT_EQUAL(-2147483648.5, val.asDouble()); JSONTEST_ASSERT_EQUAL(float(-2147483648.5), val.asFloat()); #ifdef JSON_HAS_INT64 - JSONTEST_ASSERT_EQUAL(-Json::Int64(1) << 31, val.asLargestInt()); + JSONTEST_ASSERT_EQUAL(-(Json::Int64(1) << 31), val.asLargestInt()); #endif JSONTEST_ASSERT_EQUAL(true, val.asBool()); JSONTEST_ASSERT_EQUAL("-2147483648.5", - normalizeFloatingPointStr(val.asString())); + normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString()))); // A bit over uint32 max val = Json::Value(kuint32max + 0.5); @@ -1246,29 +1250,29 @@ #endif JSONTEST_ASSERT_EQUAL(true, val.asBool()); JSONTEST_ASSERT_EQUAL("4294967295.5", - normalizeFloatingPointStr(val.asString())); + normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString()))); val = Json::Value(1.2345678901234); JSONTEST_ASSERT_STRING_EQUAL("1.2345678901234001", - normalizeFloatingPointStr(val.asString())); + normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString()))); // A 16-digit floating point number. val = Json::Value(2199023255552000.0f); - JSONTEST_ASSERT_EQUAL(float(2199023255552000), val.asFloat()); + JSONTEST_ASSERT_EQUAL(float(2199023255552000.0f), val.asFloat()); JSONTEST_ASSERT_STRING_EQUAL("2199023255552000", - normalizeFloatingPointStr(val.asString())); + normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString()))); // A very large floating point number. val = Json::Value(3.402823466385289e38); JSONTEST_ASSERT_EQUAL(float(3.402823466385289e38), val.asFloat()); JSONTEST_ASSERT_STRING_EQUAL("3.402823466385289e+38", - normalizeFloatingPointStr(val.asString())); + normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString()))); // An even larger floating point number. val = Json::Value(1.2345678e300); JSONTEST_ASSERT_EQUAL(double(1.2345678e300), val.asDouble()); JSONTEST_ASSERT_STRING_EQUAL("1.2345678e+300", - normalizeFloatingPointStr(val.asString())); + normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString()))); } void ValueTest::checkConstMemberCount(const Json::Value& value, @@ -1534,7 +1538,7 @@ JSONTEST_FIXTURE(ValueTest, StaticString) { char mutant[] = "hello"; Json::StaticString ss(mutant); - std::string regular(mutant); + JSONCPP_STRING regular(mutant); mutant[1] = 'a'; JSONTEST_ASSERT_STRING_EQUAL("hallo", ss.c_str()); JSONTEST_ASSERT_STRING_EQUAL("hello", regular.c_str()); @@ -1556,15 +1560,15 @@ JSONTEST_FIXTURE(ValueTest, CommentBefore) { Json::Value val; // fill val - val.setComment(std::string("// this comment should appear before"), Json::commentBefore); + val.setComment(JSONCPP_STRING("// this comment should appear before"), Json::commentBefore); Json::StreamWriterBuilder wbuilder; wbuilder.settings_["commentStyle"] = "All"; { char const expected[] = "// this comment should appear before\nnull"; - std::string result = Json::writeString(wbuilder, val); + JSONCPP_STRING result = Json::writeString(wbuilder, val); JSONTEST_ASSERT_STRING_EQUAL(expected, result); - std::string res2 = val.toStyledString(); - std::string exp2 = "\n"; + JSONCPP_STRING res2 = val.toStyledString(); + JSONCPP_STRING exp2 = "\n"; exp2 += expected; exp2 += "\n"; JSONTEST_ASSERT_STRING_EQUAL(exp2, res2); @@ -1573,10 +1577,10 @@ val.swapPayload(other); { char const expected[] = "// this comment should appear before\n\"hello\""; - std::string result = Json::writeString(wbuilder, val); + JSONCPP_STRING result = Json::writeString(wbuilder, val); JSONTEST_ASSERT_STRING_EQUAL(expected, result); - std::string res2 = val.toStyledString(); - std::string exp2 = "\n"; + JSONCPP_STRING res2 = val.toStyledString(); + JSONCPP_STRING exp2 = "\n"; exp2 += expected; exp2 += "\n"; JSONTEST_ASSERT_STRING_EQUAL(exp2, res2); @@ -1587,10 +1591,10 @@ // Assignment over-writes comments. { char const expected[] = "\"hello\""; - std::string result = Json::writeString(wbuilder, val); + JSONCPP_STRING result = Json::writeString(wbuilder, val); JSONTEST_ASSERT_STRING_EQUAL(expected, result); - std::string res2 = val.toStyledString(); - std::string exp2 = ""; + JSONCPP_STRING res2 = val.toStyledString(); + JSONCPP_STRING exp2 = ""; exp2 += expected; exp2 += "\n"; JSONTEST_ASSERT_STRING_EQUAL(exp2, res2); @@ -1599,7 +1603,7 @@ JSONTEST_FIXTURE(ValueTest, zeroes) { char const cstr[] = "h\0i"; - std::string binary(cstr, sizeof(cstr)); // include trailing 0 + JSONCPP_STRING binary(cstr, sizeof(cstr)); // include trailing 0 JSONTEST_ASSERT_EQUAL(4U, binary.length()); Json::StreamWriterBuilder b; { @@ -1627,7 +1631,7 @@ JSONTEST_FIXTURE(ValueTest, zeroesInKeys) { char const cstr[] = "h\0i"; - std::string binary(cstr, sizeof(cstr)); // include trailing 0 + JSONCPP_STRING binary(cstr, sizeof(cstr)); // include trailing 0 JSONTEST_ASSERT_EQUAL(4U, binary.length()); { Json::Value root; @@ -1651,6 +1655,63 @@ } } +JSONTEST_FIXTURE(ValueTest, specialFloats) { + Json::StreamWriterBuilder b; + b.settings_["useSpecialFloats"] = true; + + Json::Value v = std::numeric_limits::quiet_NaN(); + JSONCPP_STRING expected = "NaN"; + JSONCPP_STRING result = Json::writeString(b, v); + JSONTEST_ASSERT_STRING_EQUAL(expected, result); + + v = std::numeric_limits::infinity(); + expected = "Infinity"; + result = Json::writeString(b, v); + JSONTEST_ASSERT_STRING_EQUAL(expected, result); + + v = -std::numeric_limits::infinity(); + expected = "-Infinity"; + result = Json::writeString(b, v); + JSONTEST_ASSERT_STRING_EQUAL(expected, result); +} + +JSONTEST_FIXTURE(ValueTest, precision) { + Json::StreamWriterBuilder b; + b.settings_["precision"] = 5; + + Json::Value v = 100.0/3; + JSONCPP_STRING expected = "33.333"; + JSONCPP_STRING result = Json::writeString(b, v); + JSONTEST_ASSERT_STRING_EQUAL(expected, result); + + v = 0.25000000; + expected = "0.25"; + result = Json::writeString(b, v); + JSONTEST_ASSERT_STRING_EQUAL(expected, result); + + v = 0.2563456; + expected = "0.25635"; + result = Json::writeString(b, v); + JSONTEST_ASSERT_STRING_EQUAL(expected, result); + + b.settings_["precision"] = 1; + expected = "0.3"; + result = Json::writeString(b, v); + JSONTEST_ASSERT_STRING_EQUAL(expected, result); + + b.settings_["precision"] = 17; + v = 1234857476305.256345694873740545068; + expected = "1234857476305.2563"; + result = Json::writeString(b, v); + JSONTEST_ASSERT_STRING_EQUAL(expected, result); + + b.settings_["precision"] = 24; + v = 0.256345694873740545068; + expected = "0.25634569487374054"; + result = Json::writeString(b, v); + JSONTEST_ASSERT_STRING_EQUAL(expected, result); +} + struct WriterTest : JsonTest::TestCase {}; JSONTEST_FIXTURE(WriterTest, dropNullPlaceholders) { @@ -1674,15 +1735,15 @@ } JSONTEST_FIXTURE(StreamWriterTest, writeZeroes) { - std::string binary("hi", 3); // include trailing 0 + JSONCPP_STRING binary("hi", 3); // include trailing 0 JSONTEST_ASSERT_EQUAL(3, binary.length()); - std::string expected("\"hi\\u0000\""); // unicoded zero + JSONCPP_STRING expected("\"hi\\u0000\""); // unicoded zero Json::StreamWriterBuilder b; { Json::Value root; root = binary; JSONTEST_ASSERT_STRING_EQUAL(binary, root.asString()); - std::string out = Json::writeString(b, root); + JSONCPP_STRING out = Json::writeString(b, root); JSONTEST_ASSERT_EQUAL(expected.size(), out.size()); JSONTEST_ASSERT_STRING_EQUAL(expected, out); } @@ -1690,7 +1751,7 @@ Json::Value root; root["top"] = binary; JSONTEST_ASSERT_STRING_EQUAL(binary, root["top"].asString()); - std::string out = Json::writeString(b, root["top"]); + JSONCPP_STRING out = Json::writeString(b, root["top"]); JSONTEST_ASSERT_STRING_EQUAL(expected, out); } } @@ -1791,7 +1852,7 @@ JSONTEST_FIXTURE(CharReaderTest, parseWithNoErrors) { Json::CharReaderBuilder b; Json::CharReader* reader(b.newCharReader()); - std::string errs; + JSONCPP_STRING errs; Json::Value root; char const doc[] = "{ \"property\" : \"value\" }"; bool ok = reader->parse( @@ -1805,7 +1866,7 @@ JSONTEST_FIXTURE(CharReaderTest, parseWithNoErrorsTestingOffsets) { Json::CharReaderBuilder b; Json::CharReader* reader(b.newCharReader()); - std::string errs; + JSONCPP_STRING errs; Json::Value root; char const doc[] = "{ \"property\" : [\"value\", \"value2\"], \"obj\" : " @@ -1822,7 +1883,7 @@ JSONTEST_FIXTURE(CharReaderTest, parseWithOneError) { Json::CharReaderBuilder b; Json::CharReader* reader(b.newCharReader()); - std::string errs; + JSONCPP_STRING errs; Json::Value root; char const doc[] = "{ \"property\" :: \"value\" }"; @@ -1839,7 +1900,7 @@ JSONTEST_FIXTURE(CharReaderTest, parseChineseWithOneError) { Json::CharReaderBuilder b; Json::CharReader* reader(b.newCharReader()); - std::string errs; + JSONCPP_STRING errs; Json::Value root; char const doc[] = "{ \"pr佐藤erty\" :: \"value\" }"; @@ -1856,7 +1917,7 @@ JSONTEST_FIXTURE(CharReaderTest, parseWithDetailError) { Json::CharReaderBuilder b; Json::CharReader* reader(b.newCharReader()); - std::string errs; + JSONCPP_STRING errs; Json::Value root; char const doc[] = "{ \"property\" : \"v\\alue\" }"; @@ -1878,7 +1939,7 @@ { b.settings_["stackLimit"] = 2; Json::CharReader* reader(b.newCharReader()); - std::string errs; + JSONCPP_STRING errs; bool ok = reader->parse( doc, doc + std::strlen(doc), &root, &errs); @@ -1890,7 +1951,7 @@ { b.settings_["stackLimit"] = 1; Json::CharReader* reader(b.newCharReader()); - std::string errs; + JSONCPP_STRING errs; JSONTEST_ASSERT_THROWS(reader->parse( doc, doc + std::strlen(doc), &root, &errs)); @@ -1908,7 +1969,7 @@ { b.strictMode(&b.settings_); Json::CharReader* reader(b.newCharReader()); - std::string errs; + JSONCPP_STRING errs; bool ok = reader->parse( doc, doc + std::strlen(doc), &root, &errs); @@ -1924,7 +1985,7 @@ struct CharReaderFailIfExtraTest : JsonTest::TestCase {}; JSONTEST_FIXTURE(CharReaderFailIfExtraTest, issue164) { - // This is interpretted as a string value followed by a colon. + // This is interpreted as a string value followed by a colon. Json::CharReaderBuilder b; Json::Value root; char const doc[] = @@ -1932,7 +1993,7 @@ { b.settings_["failIfExtra"] = false; Json::CharReader* reader(b.newCharReader()); - std::string errs; + JSONCPP_STRING errs; bool ok = reader->parse( doc, doc + std::strlen(doc), &root, &errs); @@ -1944,7 +2005,7 @@ { b.settings_["failIfExtra"] = true; Json::CharReader* reader(b.newCharReader()); - std::string errs; + JSONCPP_STRING errs; bool ok = reader->parse( doc, doc + std::strlen(doc), &root, &errs); @@ -1959,7 +2020,7 @@ b.settings_["failIfExtra"] = false; b.strictMode(&b.settings_); Json::CharReader* reader(b.newCharReader()); - std::string errs; + JSONCPP_STRING errs; bool ok = reader->parse( doc, doc + std::strlen(doc), &root, &errs); @@ -1979,7 +2040,7 @@ "1:2:3"; b.settings_["failIfExtra"] = true; Json::CharReader* reader(b.newCharReader()); - std::string errs; + JSONCPP_STRING errs; bool ok = reader->parse( doc, doc + std::strlen(doc), &root, &errs); @@ -1999,7 +2060,7 @@ "{ \"property\" : \"value\" } //trailing\n//comment\n"; b.settings_["failIfExtra"] = true; Json::CharReader* reader(b.newCharReader()); - std::string errs; + JSONCPP_STRING errs; bool ok = reader->parse( doc, doc + std::strlen(doc), &root, &errs); @@ -2016,7 +2077,7 @@ "[ \"property\" , \"value\" ] //trailing\n//comment\n"; b.settings_["failIfExtra"] = true; Json::CharReader* reader(b.newCharReader()); - std::string errs; + JSONCPP_STRING errs; bool ok = reader->parse( doc, doc + std::strlen(doc), &root, &errs); @@ -2032,7 +2093,7 @@ " true /*trailing\ncomment*/"; b.settings_["failIfExtra"] = true; Json::CharReader* reader(b.newCharReader()); - std::string errs; + JSONCPP_STRING errs; bool ok = reader->parse( doc, doc + std::strlen(doc), &root, &errs); @@ -2047,7 +2108,7 @@ Json::CharReaderBuilder b; b.settings_["allowDroppedNullPlaceholders"] = true; Json::Value root; - std::string errs; + JSONCPP_STRING errs; Json::CharReader* reader(b.newCharReader()); { char const doc[] = "{\"a\":,\"b\":true}"; @@ -2199,7 +2260,7 @@ Json::CharReaderBuilder b; b.settings_["allowSingleQuotes"] = true; Json::Value root; - std::string errs; + JSONCPP_STRING errs; Json::CharReader* reader(b.newCharReader()); { char const doc[] = "{'a':true,\"b\":true}"; @@ -2232,7 +2293,7 @@ Json::CharReaderBuilder b; b.settings_["allowSingleQuotes"] = true; Json::Value root; - std::string errs; + JSONCPP_STRING errs; Json::CharReader* reader(b.newCharReader()); { char const doc[] = "{'a':true,\"b\":true}"; @@ -2259,6 +2320,81 @@ delete reader; } +struct CharReaderAllowSpecialFloatsTest : JsonTest::TestCase {}; + +JSONTEST_FIXTURE(CharReaderAllowSpecialFloatsTest, issue209) { + Json::CharReaderBuilder b; + b.settings_["allowSpecialFloats"] = true; + Json::Value root; + JSONCPP_STRING errs; + Json::CharReader* reader(b.newCharReader()); + { + char const doc[] = "{\"a\":NaN,\"b\":Infinity,\"c\":-Infinity}"; + bool ok = reader->parse( + doc, doc + std::strlen(doc), + &root, &errs); + JSONTEST_ASSERT(ok); + JSONTEST_ASSERT_STRING_EQUAL("", errs); + JSONTEST_ASSERT_EQUAL(3u, root.size()); + double n = root["a"].asDouble(); + JSONTEST_ASSERT(n != n); + JSONTEST_ASSERT_EQUAL(std::numeric_limits::infinity(), root.get("b", 0.0)); + JSONTEST_ASSERT_EQUAL(-std::numeric_limits::infinity(), root.get("c", 0.0)); + } + + struct TestData { + int line; + bool ok; + JSONCPP_STRING in; + }; + const TestData test_data[] = { + {__LINE__, 1, "{\"a\":9}"}, + {__LINE__, 0, "{\"a\":0Infinity}"}, + {__LINE__, 0, "{\"a\":1Infinity}"}, + {__LINE__, 0, "{\"a\":9Infinity}"}, + {__LINE__, 0, "{\"a\":0nfinity}"}, + {__LINE__, 0, "{\"a\":1nfinity}"}, + {__LINE__, 0, "{\"a\":9nfinity}"}, + {__LINE__, 0, "{\"a\":nfinity}"}, + {__LINE__, 0, "{\"a\":.nfinity}"}, + {__LINE__, 0, "{\"a\":9nfinity}"}, + {__LINE__, 0, "{\"a\":-nfinity}"}, + {__LINE__, 1, "{\"a\":Infinity}"}, + {__LINE__, 0, "{\"a\":.Infinity}"}, + {__LINE__, 0, "{\"a\":_Infinity}"}, + {__LINE__, 0, "{\"a\":_nfinity}"}, + {__LINE__, 1, "{\"a\":-Infinity}"} + }; + for (size_t tdi = 0; tdi < sizeof(test_data) / sizeof(*test_data); ++tdi) { + const TestData& td = test_data[tdi]; + bool ok = reader->parse(&*td.in.begin(), + &*td.in.begin() + td.in.size(), + &root, &errs); + JSONTEST_ASSERT(td.ok == ok) + << "line:" << td.line << "\n" + << " expected: {" + << "ok:" << td.ok + << ", in:\'" << td.in << "\'" + << "}\n" + << " actual: {" + << "ok:" << ok + << "}\n"; + } + + { + char const doc[] = "{\"posInf\": Infinity, \"NegInf\": -Infinity}"; + bool ok = reader->parse( + doc, doc + std::strlen(doc), + &root, &errs); + JSONTEST_ASSERT(ok); + JSONTEST_ASSERT_STRING_EQUAL("", errs); + JSONTEST_ASSERT_EQUAL(2u, root.size()); + JSONTEST_ASSERT_EQUAL(std::numeric_limits::infinity(), root["posInf"].asDouble()); + JSONTEST_ASSERT_EQUAL(-std::numeric_limits::infinity(), root["NegInf"].asDouble()); + } + delete reader; +} + struct BuilderTest : JsonTest::TestCase {}; JSONTEST_FIXTURE(BuilderTest, settings) { @@ -2289,7 +2425,7 @@ json["k1"] = "a"; json["k2"] = "b"; int dist = 0; - std::string str; + JSONCPP_STRING str; for (Json::ValueIterator it = json.begin(); it != json.end(); ++it) { dist = it - json.begin(); str = it->asString().c_str(); @@ -2334,6 +2470,46 @@ JSONTEST_ASSERT(it == json.end()); } +JSONTEST_FIXTURE(IteratorTest, const) { + Json::Value const v; + JSONTEST_ASSERT_THROWS( + Json::Value::iterator it(v.begin()) // Compile, but throw. + ); + + Json::Value value; + + for(int i = 9; i < 12; ++i) + { + JSONCPP_OSTRINGSTREAM out; + out << std::setw(2) << i; + JSONCPP_STRING str = out.str(); + value[str] = str; + } + + JSONCPP_OSTRINGSTREAM out; + //in old code, this will get a compile error + Json::Value::const_iterator iter = value.begin(); + for(; iter != value.end(); ++iter) + { + out << *iter << ','; + } + JSONCPP_STRING expected = "\" 9\",\"10\",\"11\","; + JSONTEST_ASSERT_STRING_EQUAL(expected, out.str()); +} + +struct RValueTest : JsonTest::TestCase {}; + +JSONTEST_FIXTURE(RValueTest, moveConstruction) { +#if JSON_HAS_RVALUE_REFERENCES + Json::Value json; + json["key"] = "value"; + Json::Value moved = std::move(json); + JSONTEST_ASSERT(moved != json); // Possibly not nullValue; definitely not equal. + JSONTEST_ASSERT_EQUAL(Json::objectValue, moved.type()); + JSONTEST_ASSERT_EQUAL(Json::stringValue, moved["key"].type()); +#endif +} + int main(int argc, const char* argv[]) { JsonTest::Runner runner; JSONTEST_REGISTER_FIXTURE(runner, ValueTest, checkNormalizeFloatingPointStr); @@ -2362,6 +2538,8 @@ //JSONTEST_REGISTER_FIXTURE(runner, ValueTest, nulls); JSONTEST_REGISTER_FIXTURE(runner, ValueTest, zeroes); JSONTEST_REGISTER_FIXTURE(runner, ValueTest, zeroesInKeys); + JSONTEST_REGISTER_FIXTURE(runner, ValueTest, specialFloats); + JSONTEST_REGISTER_FIXTURE(runner, ValueTest, precision); JSONTEST_REGISTER_FIXTURE(runner, WriterTest, dropNullPlaceholders); JSONTEST_REGISTER_FIXTURE(runner, StreamWriterTest, dropNullPlaceholders); @@ -2396,11 +2574,16 @@ JSONTEST_REGISTER_FIXTURE(runner, CharReaderAllowZeroesTest, issue176); + JSONTEST_REGISTER_FIXTURE(runner, CharReaderAllowSpecialFloatsTest, issue209); + JSONTEST_REGISTER_FIXTURE(runner, BuilderTest, settings); JSONTEST_REGISTER_FIXTURE(runner, IteratorTest, distance); JSONTEST_REGISTER_FIXTURE(runner, IteratorTest, names); JSONTEST_REGISTER_FIXTURE(runner, IteratorTest, indexes); + JSONTEST_REGISTER_FIXTURE(runner, IteratorTest, const); + + JSONTEST_REGISTER_FIXTURE(runner, RValueTest, moveConstruction); return runner.runCommandLine(argc, argv); } diff -Nru libjsoncpp-1.6.5/travis.sh libjsoncpp-1.7.2/travis.sh --- libjsoncpp-1.6.5/travis.sh 2015-07-23 05:26:13.000000000 +0000 +++ libjsoncpp-1.7.2/travis.sh 2016-03-25 20:09:15.000000000 +0000 @@ -19,6 +19,8 @@ cmake -DJSONCPP_WITH_CMAKE_PACKAGE=$CMAKE_PKG -DBUILD_SHARED_LIBS=$SHARED_LIB -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_VERBOSE_MAKEFILE=$VERBOSE_MAKE . make +cmake -DJSONCPP_WITH_CMAKE_PACKAGE=$CMAKE_PKG -DBUILD_SHARED_LIBS=$SHARED_LIB -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_VERBOSE_MAKEFILE=$VERBOSE_MAKE -DJSONCPP_USE_SECURE_MEMORY=1 . +make # Python is not available in Travis for osx. # https://github.com/travis-ci/travis-ci/issues/2320 diff -Nru libjsoncpp-1.6.5/version libjsoncpp-1.7.2/version --- libjsoncpp-1.6.5/version 2015-07-23 05:26:13.000000000 +0000 +++ libjsoncpp-1.7.2/version 2016-03-25 20:09:15.000000000 +0000 @@ -1 +1 @@ -1.6.5 +1.7.2