Compare commits

..

56 Commits
1.7.0 ... 1.7.7

Author SHA1 Message Date
Christopher Dunn
d8cd848ede 1.7.7 2016-10-02 11:32:21 -05:00
Christopher Dunn
92259f7147 Bump SOVERSION, separate from MAJOR.MINOR.MICRO 2016-10-02 11:29:12 -05:00
yiqiju
4a431bcdac Fix typo
resolves #538
2016-10-02 10:52:13 -05:00
Christopher Dunn
7d868636de Merge pull request #536 from vriera/master
resolves #537
closes #538
2016-09-27 20:12:01 -05:00
Vicente Olivert Riera
ab0f1e234a Include stdint.h necessary for int64_t and uint64_t
Otherwise failures like these one can happen during the configure phase
of other applications that use jsoncpp, like upmpdcli for instance:

checking jsoncpp/json/json.h usability... yes
checking jsoncpp/json/json.h presence... yes
checking for jsoncpp/json/json.h... yes
configure: error: libjsoncpp not found.

And this is the actual problem that you can see in config.log:

configure:5233: checking for jsoncpp/json/json.h
configure:5233: result: yes
configure:5259: /usr/bin/mipsel-linux-g++ -o conftest conftest.cpp
-lmicrohttpd -lmpdclient -lpthread  -ljsoncpp >&5
In file included from /usr/include/jsoncpp/json/autolink.h:9:0,
                 from /usr/include/jsoncpp/json/json.h:9,
                 from conftest.cpp:26:
/usr/include/jsoncpp/json/config.h:155:9: error: 'int64_t' does not name
a type
 typedef int64_t Int64;
         ^
/usr/include/jsoncpp/json/config.h:156:9: error: 'uint64_t' does not
name a type
 typedef uint64_t UInt64;
         ^

Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>
2016-09-26 11:24:32 +01:00
Christopher Dunn
45a560a8c0 1.7.6 <- 1.7.5 2016-09-25 19:05:56 -05:00
Christopher Dunn
4893a8f667 Merge pull request #535 from kavika13/master
Add RPATH to dynamic library build on OSX

fixes #534 

But we will revert if there are any complaints.
2016-09-25 18:58:14 -05:00
Gergely Nagy
f6d785fda8 Fix poss SEGV
for non-null terminated input.
2016-09-25 18:45:04 -05:00
Merlyn Morgan-Graham
8d54e333ff Add RPATH to dynamic library build on OSX 2016-09-22 22:06:25 -07:00
Christopher Dunn
b063cf4ada Merge pull request #529 from chrox802/chrox802-patch-1
fix a bug about Json::Path
2016-09-07 21:57:56 -05:00
Christopher Dunn
c4ab6d733f Merge pull request #528 from DrMetallius/master
Used macros to disable localeconv() calls
2016-09-07 21:52:18 -05:00
chason
2f97c0147b fix a bug about Json::Path 2016-09-07 19:56:19 +08:00
Alexander Gazarov
52cfe5ae88 Replaced the template-based solution for avoiding calls to localeconv() with a macro-based one (fixes #527) 2016-09-06 14:41:13 +03:00
Christopher Dunn
a304d61a7b 1.7.5 <- 1.7.4 2016-09-01 02:45:08 -05:00
Christopher Dunn
0a97e38ea5 Merge pull request #523 from prezi/fix-android-lconv
Workaround for missing lconv::decimal_point on android
2016-09-01 02:36:34 -05:00
Gida Pataki
894e78bff1 Workaround for missing lconv::decimal_point on android 2016-08-26 23:30:18 +02:00
Christopher Dunn
126bdc2b05 Reject extra chars if strictRoot
resolves #511
2016-08-21 20:32:16 -05:00
Christopher Dunn
094a7d8564 Fix locale for decimal points
resolves #514
2016-08-21 20:13:58 -05:00
Christopher Dunn
b9afdf190d Use int64_t for 64bit ints
resolves #509
2016-08-21 19:58:43 -05:00
Christopher Dunn
80a82ea269 Optional space after comma
resolves #513
2016-08-21 16:35:19 -05:00
Christopher Dunn
f78f685bab Remove needless if.
resolves #516
2016-08-21 16:31:14 -05:00
Christopher Dunn
7d8eddb98c Merge pull request #519 from open-source-parsers/fix-517
Avoid null for stringValue
2016-08-21 16:30:28 -05:00
Christopher Dunn
7e0571b444 Avoid null for stringValue
fixes #517
2016-08-21 16:25:29 -05:00
Christopher Dunn
b14c8c1423 Merge pull request #502 from open-source-parsers/null-object
Allow dtor for nullSingleton
2016-07-20 22:28:44 -07:00
Christopher Dunn
b299d3581f Allow dtor for nullSingleton
re #488 and #490
2016-07-20 11:31:41 -07:00
Christopher Dunn
48d2a69d47 1.7.4 <- 1.7.3 2016-07-09 13:27:28 -05:00
Christopher Dunn
772e257fc9 Merge pull request #493 from zorun/master
Fix compilation errors for downstream projects caused by incorrect pkconfig paths
2016-07-08 17:02:30 -05:00
Baptiste Jonglez
101fcf0806 Fix compilation errors for downstream projects caused by incorrect pkgconfig paths
Recent commit 911e2b0fea ("By default use <prefix> relative paths when
installing") introduced relative install paths in CMake.  But this
interacts badly with commit e6f1cffdd3 from a year ago: now, the paths in
`pkgconfig/jsoncpp.pc` are relative, which is incorrect.

Before 911e2b0fea (1.7.2 on Archlinux), this was correct:

    $ head -4 /usr/lib/pkgconfig/jsoncpp.pc
    prefix=/usr
    exec_prefix=${prefix}
    libdir=/usr/lib
    includedir=/usr/include

After 911e2b0fea (1.7.3 on Archlinux), this is now incorrect:

    $ head -4 /usr/lib/pkgconfig/jsoncpp.pc
    prefix=/usr
    exec_prefix=${prefix}
    libdir=lib
    includedir=include

This change causes hard-to-debug compilation errors for projects that
depend on jsoncpp, for instance:

    CXXLD    libring.la
    /tmp/ring-daemon/src/ring-daemon/src/../libtool: line 7486: cd: lib: No such file or directory
    libtool:   error: cannot determine absolute directory name of 'lib'
    make[3]: *** [Makefile:679: libring.la] Error 1

This is because jsoncpp contributes `-Llib -ljsoncpp` to the LDFLAGS, via
the pkg-config machinery.  Notice the relative path in `-Llib`.

To fix this, simply revert commit e6f1cffdd3 ("Fix custom includedir &
libdir substitution in pkg-config").  The change in 911e2b0fea should have
the same effect.

See #279, #470 for references.
2016-07-08 00:46:04 +02:00
Christopher Dunn
7e4df50d17 Merge pull request #490 from open-source-parsers/null-singleton
Use a Myers Singleton for null
2016-06-27 00:12:23 -05:00
Christopher Dunn
318f30357c 1.7.3 2016-06-26 19:40:43 -05:00
Christopher Dunn
0f288aecdd Use a Myers Singleton for null
Avoid some static initialization problems.

From @marklakata
See #488
2016-06-26 19:36:40 -05:00
Christopher Dunn
e0f9aab0bf Make internal func anon
fixes #489
2016-06-26 17:54:15 -05:00
Christopher Dunn
43203f1d09 Merge pull request #478 from quantumsteve/msvc_override
Use override keyword with Visual Studio.
2016-05-28 10:01:46 -05:00
Steven Hahn
55176b2bdd Use override keyword with Visual Studio. 2016-05-25 18:29:34 -04:00
Christopher Dunn
4356d9bba1 Merge pull request #474 from cdunn2001/fix-warning
Fix some warnings
2016-05-15 23:35:02 -05:00
Christopher Dunn
ea4af18317 Fix int->char conv warn
resolves #473
2016-05-15 23:13:56 -05:00
Christopher Dunn
b999616df8 fix warning 2016-05-15 23:13:47 -05:00
Christopher Dunn
660307d357 Merge pull request #470 from aboseley/relative_install_paths
By default use <prefix> relative paths when installing
2016-05-05 13:59:20 -05:00
Adam Boseley
911e2b0fea By default use <prefix> relative paths when installing
This allows the config file to keep working
when it is installed to a non-standard location
from a make DESTDIR=<location> install
2016-05-04 23:41:18 -07:00
Christopher Dunn
d4a49cf511 Merge pull request #466 from bkuhls/buildroot
CMakeLists.txt: Treat conversion warning as error only with JSONCPP_W…
2016-05-02 20:40:08 -05:00
Christopher Dunn
8bd4f943da Merge pull request #467 from jcfr/generalize-setting-of-JSONCPP_OVERRIDE
json/config.h: Generalize setting of JSONCPP_OVERRIDE to all compilers
2016-04-27 02:45:32 -05:00
Christopher Dunn
4018422a05 Merge pull request #465 from ds283/intel-compiler
Add CMAKE_CXX_FLAGS for Intel compiler
2016-04-27 02:28:41 -05:00
Jean-Christophe Fillion-Robin
ba6fa48d31 json/config.h: Generalize setting of JSONCPP_OVERRIDE to all compilers
This commit has been adapted from InsightSoftwareConsortium/ITK@1c86090
2016-04-25 17:35:12 -04:00
Bernd Kuhls
17fc9b1a80 CMakeLists.txt: Treat conversion warning as error only with JSONCPP_WITH_WARNING_AS_ERROR=On
Fixes errors when building with buildroot:
http://autobuild.buildroot.net/?reason=jsoncpp-1.7.2

Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
2016-04-25 19:47:13 +02:00
ds283
6f22b0e076 Add CMAKE_CXX_FLAGS for Intel compiler 2016-04-25 14:47:05 +01:00
Christopher Dunn
980cdf0fb5 Exclude allocator.h from amalgamated header
Nobody using SecureAllocator really needs the amalgamated header.

resolves #461
2016-04-22 00:45:18 -05:00
Christopher Dunn
45da594e71 Merge pull request #454 from cbeiraod/master
Small fix for strict compilers (using the flag -Werror for instance)
2016-03-26 15:07:55 -05:00
Cristóvão B da Cruz e Silva
c8a7b445ea Small fix for strict compilers (using the flag -Werror for instance) 2016-03-26 18:41:46 +00:00
Christopher Dunn
c8054483f8 1.7.2 <- 1.7.1
This only fixes a clang warning, but we have already
seen more than one report for it.
2016-03-25 15:09:15 -05:00
Christopher Dunn
96d32b37ea Merge pull request #452 from cdunn2001/fix-451
Fix a clang warning
2016-03-24 00:27:13 -05:00
Christopher Dunn
ef2ff8754a Fix a clang warning
Resolves #451.
2016-03-23 22:33:18 -05:00
Christopher Dunn
b58c844579 1.7.1 <- 1.7.0
And 1.7.0 is recalled b/c we accidentally
had SecureAlloc by default.
2016-03-21 21:17:56 -05:00
Christopher Dunn
b803b92d11 Merge pull request #449 from cdunn2001/override-keyword
Use macro for `override`
2016-03-21 21:16:00 -05:00
Christopher Dunn
98e981dff9 Use macro for override
b/c MS VS2010 is supposed to be C++11 but does not fulfull
the entire standard.

Resolves #410.
Re: #430.
2016-03-21 21:00:24 -05:00
Christopher Dunn
1c47796479 JSONCPP_USING_SECURE_MEMORY default is 0
Re: #410
2016-03-21 20:44:16 -05:00
Christopher Dunn
12c67e810d Fix amalgamate.py
Fixes #448.
2016-03-21 20:33:34 -05:00
16 changed files with 161 additions and 83 deletions

View File

@@ -22,16 +22,21 @@ IF(NOT WIN32)
ENDIF()
ENDIF()
# Enable runtime search path support for dynamic libraries on OSX
IF(APPLE)
SET(CMAKE_MACOSX_RPATH 1)
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")
SET(RUNTIME_INSTALL_DIR bin
CACHE PATH "Install dir for executables and dlls")
SET(ARCHIVE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}
SET(ARCHIVE_INSTALL_DIR lib${LIB_SUFFIX}
CACHE PATH "Install dir for static libraries")
SET(LIBRARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}
SET(LIBRARY_INSTALL_DIR lib${LIB_SUFFIX}
CACHE PATH "Install dir for shared libraries")
SET(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include
SET(INCLUDE_INSTALL_DIR include
CACHE PATH "Install dir for headers")
SET(PACKAGE_INSTALL_DIR lib${LIB_SUFFIX}/cmake
CACHE PATH "Install dir for cmake package config files")
@@ -64,11 +69,12 @@ ENDMACRO()
#SET( JSONCPP_VERSION_MAJOR X )
#SET( JSONCPP_VERSION_MINOR Y )
#SET( JSONCPP_VERSION_PATCH Z )
SET( JSONCPP_VERSION 1.7.0 )
SET( JSONCPP_VERSION 1.7.7 )
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_SOVERSION 11 )
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}")
@@ -107,9 +113,16 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
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 -Wall -Wconversion -Wshadow -Wextra -Werror=conversion")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wconversion -Wshadow -Wextra")
# 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} -Werror=conversion -pedantic")
endif ()
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
# using Intel compiler
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wconversion -Wshadow -Wextra -Werror=conversion")
if (JSONCPP_WITH_STRICT_ISO AND NOT JSONCPP_WITH_WARNING_AS_ERROR)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
endif ()

View File

@@ -67,7 +67,7 @@ def amalgamate_source(source_top_dir=None,
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/allocator.h") # Not available here.
header.add_file("include/json/config.h")
header.add_file("include/json/forwards.h")
header.add_file("include/json/features.h")

View File

@@ -6,7 +6,8 @@
#ifndef JSON_CONFIG_H_INCLUDED
#define JSON_CONFIG_H_INCLUDED
#include <stddef.h>
#include <string> //typdef String
#include <string> //typedef String
#include <stdint.h> //typedef int64_t, uint64_t
/// If defined, indicates that json library is embedded in CppTL library.
//# define JSON_IN_CPPTL 1
@@ -77,6 +78,16 @@
#endif // defined(_MSC_VER)
// In c++11 the override keyword allows you to explicity define that a function
// is intended to override the base-class version. This makes the code more
// managable and fixes a set of common hard-to-find bugs.
#if __cplusplus >= 201103L
# define JSONCPP_OVERRIDE override
#elif defined(_MSC_VER) && _MSC_VER > 1600
# define JSONCPP_OVERRIDE override
#else
# define JSONCPP_OVERRIDE
#endif
#ifndef JSON_HAS_RVALUE_REFERENCES
@@ -119,11 +130,15 @@
# define JSON_USE_INT64_DOUBLE_CONVERSION 1
#endif
#include "version.h"
#if !defined(JSON_IS_AMALGAMATION)
#if JSONCPP_USING_SECURE_MEMORY
#include "allocator.h" //typedef Allocator
#endif
# 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;
@@ -138,8 +153,8 @@ typedef unsigned int LargestUInt;
typedef __int64 Int64;
typedef unsigned __int64 UInt64;
#else // if defined(_MSC_VER) // Other platforms, use long long
typedef long long int Int64;
typedef unsigned long long int UInt64;
typedef int64_t Int64;
typedef uint64_t UInt64;
#endif // if defined(_MSC_VER)
typedef Int64 LargestInt;
typedef UInt64 LargestUInt;

View File

@@ -333,9 +333,9 @@ public:
Json::Value settings_;
CharReaderBuilder();
~CharReaderBuilder() override;
~CharReaderBuilder() JSONCPP_OVERRIDE;
CharReader* newCharReader() const override;
CharReader* newCharReader() const JSONCPP_OVERRIDE;
/** \return true if 'settings' are legal and consistent;
* otherwise, indicate bad settings via 'invalid'.

View File

@@ -53,8 +53,8 @@ namespace Json {
class JSON_API Exception : public std::exception {
public:
Exception(JSONCPP_STRING const& msg);
~Exception() throw() override;
char const* what() const throw() override;
~Exception() throw() JSONCPP_OVERRIDE;
char const* what() const throw() JSONCPP_OVERRIDE;
protected:
JSONCPP_STRING msg_;
};
@@ -190,6 +190,8 @@ public:
static const Value& null; ///< We regret this reference to a global instance; prefer the simpler Value().
static const Value& nullRef; ///< just a kludge for binary-compatibility; same as null
static Value const& nullSingleton(); ///< Prefer this to null or nullRef.
/// Minimum signed integer value that can be stored in a Json::Value.
static const LargestInt minLargestInt;
/// Maximum signed integer value that can be stored in a Json::Value.

View File

@@ -3,17 +3,17 @@
#ifndef JSON_VERSION_H_INCLUDED
# define JSON_VERSION_H_INCLUDED
# define JSONCPP_VERSION_STRING "1.7.0"
# define JSONCPP_VERSION_STRING "1.7.7"
# define JSONCPP_VERSION_MAJOR 1
# define JSONCPP_VERSION_MINOR 7
# define JSONCPP_VERSION_PATCH 0
# define JSONCPP_VERSION_PATCH 7
# 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 1
#define JSONCPP_USING_SECURE_MEMORY 0
// If non-zero, the library zeroes any memory that it has allocated before
// it frees its memory.

View File

@@ -112,12 +112,12 @@ public:
Json::Value settings_;
StreamWriterBuilder();
~StreamWriterBuilder() override;
~StreamWriterBuilder() JSONCPP_OVERRIDE;
/**
* \throw std::exception if something goes wrong (e.g. invalid settings)
*/
StreamWriter* newStreamWriter() const override;
StreamWriter* newStreamWriter() const JSONCPP_OVERRIDE;
/** \return true if 'settings' are legal and consistent;
* otherwise, indicate bad settings via 'invalid'.
@@ -158,7 +158,7 @@ class JSON_API FastWriter : public Writer {
public:
FastWriter();
~FastWriter() override {}
~FastWriter() JSONCPP_OVERRIDE {}
void enableYAMLCompatibility();
@@ -172,7 +172,7 @@ public:
void omitEndingLineFeed();
public: // overridden from Writer
JSONCPP_STRING write(const Value& root) override;
JSONCPP_STRING write(const Value& root) JSONCPP_OVERRIDE;
private:
void writeValue(const Value& value);
@@ -210,14 +210,14 @@ private:
class JSON_API StyledWriter : public Writer {
public:
StyledWriter();
~StyledWriter() override {}
~StyledWriter() JSONCPP_OVERRIDE {}
public: // overridden from Writer
/** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
* \param root Value to serialize.
* \return String containing the JSON document that represents the root value.
*/
JSONCPP_STRING write(const Value& root) override;
JSONCPP_STRING write(const Value& root) JSONCPP_OVERRIDE;
private:
void writeValue(const Value& value);

View File

@@ -1,7 +1,7 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=@LIBRARY_INSTALL_DIR@
includedir=@INCLUDE_INSTALL_DIR@
libdir=${exec_prefix}/@LIBRARY_INSTALL_DIR@
includedir=${prefix}/@INCLUDE_INSTALL_DIR@
Name: jsoncpp
Description: A C++ library for interacting with JSON

View File

@@ -58,7 +58,7 @@ static JSONCPP_STRING readInputTestFile(const char* path) {
return JSONCPP_STRING("");
fseek(file, 0, SEEK_END);
long const size = ftell(file);
unsigned long const usize = static_cast<unsigned long const>(size);
unsigned long const usize = static_cast<unsigned long>(size);
fseek(file, 0, SEEK_SET);
JSONCPP_STRING text;
char* buffer = new char[size + 1];

View File

@@ -42,10 +42,15 @@ ENDIF()
IF(BUILD_SHARED_LIBS)
ADD_DEFINITIONS( -DJSON_DLL_BUILD )
ADD_LIBRARY(jsoncpp_lib SHARED ${PUBLIC_HEADERS} ${jsoncpp_sources})
SET_TARGET_PROPERTIES( jsoncpp_lib PROPERTIES VERSION ${JSONCPP_VERSION} SOVERSION ${JSONCPP_VERSION_MAJOR})
SET_TARGET_PROPERTIES( jsoncpp_lib PROPERTIES VERSION ${JSONCPP_VERSION} SOVERSION ${JSONCPP_SOVERSION})
SET_TARGET_PROPERTIES( jsoncpp_lib PROPERTIES OUTPUT_NAME jsoncpp
DEBUG_OUTPUT_NAME jsoncpp${DEBUG_LIBNAME_SUFFIX} )
# Set library's runtime search path on OSX
IF(APPLE)
SET_TARGET_PROPERTIES( jsoncpp_lib PROPERTIES INSTALL_RPATH "@loader_path/." )
ENDIF()
INSTALL( TARGETS jsoncpp_lib ${INSTALL_EXPORT}
RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR}
LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR}
@@ -61,7 +66,7 @@ ENDIF()
IF(BUILD_STATIC_LIBS)
ADD_LIBRARY(jsoncpp_lib_static STATIC ${PUBLIC_HEADERS} ${jsoncpp_sources})
SET_TARGET_PROPERTIES( jsoncpp_lib_static PROPERTIES VERSION ${JSONCPP_VERSION} SOVERSION ${JSONCPP_VERSION_MAJOR})
SET_TARGET_PROPERTIES( jsoncpp_lib_static PROPERTIES VERSION ${JSONCPP_VERSION} SOVERSION ${JSONCPP_SOVERSION})
SET_TARGET_PROPERTIES( jsoncpp_lib_static PROPERTIES OUTPUT_NAME jsoncpp
DEBUG_OUTPUT_NAME jsoncpp${DEBUG_LIBNAME_SUFFIX} )

View File

@@ -401,7 +401,7 @@ Reader::addComment(Location begin, Location end, CommentPlacement placement) {
}
bool Reader::readCStyleComment() {
while (current_ != end_) {
while ((current_ + 1) < end_) {
Char c = getNextChar();
if (c == '*' && *current_ == '/')
break;
@@ -430,25 +430,25 @@ void Reader::readNumber() {
char c = '0'; // stopgap for already consumed character
// integral part
while (c >= '0' && c <= '9')
c = (current_ = p) < end_ ? *p++ : 0;
c = (current_ = p) < end_ ? *p++ : '\0';
// fractional part
if (c == '.') {
c = (current_ = p) < end_ ? *p++ : 0;
c = (current_ = p) < end_ ? *p++ : '\0';
while (c >= '0' && c <= '9')
c = (current_ = p) < end_ ? *p++ : 0;
c = (current_ = p) < end_ ? *p++ : '\0';
}
// exponential part
if (c == 'e' || c == 'E') {
c = (current_ = p) < end_ ? *p++ : 0;
c = (current_ = p) < end_ ? *p++ : '\0';
if (c == '+' || c == '-')
c = (current_ = p) < end_ ? *p++ : 0;
c = (current_ = p) < end_ ? *p++ : '\0';
while (c >= '0' && c <= '9')
c = (current_ = p) < end_ ? *p++ : 0;
c = (current_ = p) < end_ ? *p++ : '\0';
}
}
bool Reader::readString() {
Char c = 0;
Char c = '\0';
while (current_ != end_) {
c = getNextChar();
if (c == '\\')
@@ -520,7 +520,7 @@ bool Reader::readArray(Token& tokenStart) {
currentValue().swapPayload(init);
currentValue().setOffsetStart(tokenStart.start_ - begin_);
skipSpaces();
if (*current_ == ']') // empty array
if (current_ != end_ && *current_ == ']') // empty array
{
Token endArray;
readToken(endArray);
@@ -1068,7 +1068,7 @@ bool OurReader::parse(const char* beginDoc,
Token token;
skipCommentTokens(token);
if (features_.failIfExtra_) {
if (token.type_ != tokenError && token.type_ != tokenEndOfStream) {
if ((features_.strictRoot_ || token.type_ != tokenError) && token.type_ != tokenEndOfStream) {
addError("Extra non-whitespace after JSON value.", token);
return false;
}
@@ -1361,7 +1361,7 @@ OurReader::addComment(Location begin, Location end, CommentPlacement placement)
}
bool OurReader::readCStyleComment() {
while (current_ != end_) {
while ((current_ + 1) < end_) {
Char c = getNextChar();
if (c == '*' && *current_ == '/')
break;
@@ -1394,20 +1394,20 @@ bool OurReader::readNumber(bool checkInf) {
char c = '0'; // stopgap for already consumed character
// integral part
while (c >= '0' && c <= '9')
c = (current_ = p) < end_ ? *p++ : 0;
c = (current_ = p) < end_ ? *p++ : '\0';
// fractional part
if (c == '.') {
c = (current_ = p) < end_ ? *p++ : 0;
c = (current_ = p) < end_ ? *p++ : '\0';
while (c >= '0' && c <= '9')
c = (current_ = p) < end_ ? *p++ : 0;
c = (current_ = p) < end_ ? *p++ : '\0';
}
// exponential part
if (c == 'e' || c == 'E') {
c = (current_ = p) < end_ ? *p++ : 0;
c = (current_ = p) < end_ ? *p++ : '\0';
if (c == '+' || c == '-')
c = (current_ = p) < end_ ? *p++ : 0;
c = (current_ = p) < end_ ? *p++ : '\0';
while (c >= '0' && c <= '9')
c = (current_ = p) < end_ ? *p++ : 0;
c = (current_ = p) < end_ ? *p++ : '\0';
}
return true;
}
@@ -1503,7 +1503,7 @@ bool OurReader::readArray(Token& tokenStart) {
currentValue().swapPayload(init);
currentValue().setOffsetStart(tokenStart.start_ - begin_);
skipSpaces();
if (*current_ == ']') // empty array
if (current_ != end_ && *current_ == ']') // empty array
{
Token endArray;
readToken(endArray);
@@ -1619,6 +1619,7 @@ bool OurReader::decodeDouble(Token& token, Value& decoded) {
Char buffer[bufferSize + 1];
memcpy(buffer, token.start_, ulength);
buffer[length] = 0;
fixNumericLocaleInput(buffer, buffer + length);
count = sscanf(buffer, format, &value);
} else {
JSONCPP_STRING buffer(token.start_, token.end_);
@@ -1907,7 +1908,7 @@ public:
{}
bool parse(
char const* beginDoc, char const* endDoc,
Value* root, JSONCPP_STRING* errs) override {
Value* root, JSONCPP_STRING* errs) JSONCPP_OVERRIDE {
bool ok = reader_.parse(beginDoc, endDoc, *root, collectComments_);
if (errs) {
*errs = reader_.getFormattedErrorMessages();

View File

@@ -6,6 +6,10 @@
#ifndef LIB_JSONCPP_JSON_TOOL_H_INCLUDED
#define LIB_JSONCPP_JSON_TOOL_H_INCLUDED
#ifndef NO_LOCALE_SUPPORT
#include <clocale>
#endif
/* This header provides common string manipulation support, such as UTF-8,
* portable conversion from/to string...
*
@@ -13,6 +17,14 @@
*/
namespace Json {
static char getDecimalPoint() {
#ifdef NO_LOCALE_SUPPORT
return '\0';
#else
struct lconv* lc = localeconv();
return lc ? *(lc->decimal_point) : '\0';
#endif
}
/// Converts a unicode code-point to UTF-8.
static inline JSONCPP_STRING codePointToUTF8(unsigned int cp) {
@@ -63,7 +75,7 @@ typedef char UIntToStringBuffer[uintToStringBufferSize];
static inline void uintToString(LargestUInt value, char*& current) {
*--current = 0;
do {
*--current = static_cast<signed char>(value % 10U + static_cast<unsigned>('0'));
*--current = static_cast<char>(value % 10U + static_cast<unsigned>('0'));
value /= 10;
} while (value != 0);
}
@@ -82,6 +94,18 @@ static inline void fixNumericLocale(char* begin, char* end) {
}
}
static inline void fixNumericLocaleInput(char* begin, char* end) {
char decimalPoint = getDecimalPoint();
if (decimalPoint != '\0' && decimalPoint != '.') {
while (begin < end) {
if (*begin == '.') {
*begin = decimalPoint;
}
++begin;
}
}
}
} // namespace Json {
#endif // LIB_JSONCPP_JSON_TOOL_H_INCLUDED

View File

@@ -31,10 +31,22 @@ namespace Json {
#else
#define ALIGNAS(byte_alignment)
#endif
static const unsigned char ALIGNAS(8) kNull[sizeof(Value)] = { 0 };
const unsigned char& kNullRef = kNull[0];
const Value& Value::null = reinterpret_cast<const Value&>(kNullRef);
const Value& Value::nullRef = null;
//static const unsigned char ALIGNAS(8) kNull[sizeof(Value)] = { 0 };
//const unsigned char& kNullRef = kNull[0];
//const Value& Value::null = reinterpret_cast<const Value&>(kNullRef);
//const Value& Value::nullRef = null;
// static
Value const& Value::nullSingleton()
{
static Value const nullStatic;
return nullStatic;
}
// for backwards compatibility, we'll leave these global references around, but DO NOT
// use them in JSONCPP library code any more!
Value const& Value::null = Value::nullSingleton();
Value const& Value::nullRef = Value::nullSingleton();
const Int Value::minInt = Int(~(UInt(-1) / 2));
const Int Value::maxInt = Int(UInt(-1) / 2);
@@ -157,7 +169,7 @@ static inline void releaseStringValue(char* value, unsigned length) {
static inline void releasePrefixedStringValue(char* value) {
free(value);
}
static inline void releaseStringValue(char* value, unsigned length) {
static inline void releaseStringValue(char* value, unsigned) {
free(value);
}
#endif // JSONCPP_USING_SECURE_MEMORY
@@ -331,6 +343,7 @@ bool Value::CZString::isStaticString() const { return storage_.policy_ == noDupl
* This optimization is used in ValueInternalMap fast allocator.
*/
Value::Value(ValueType vtype) {
static char const empty[] = "";
initBasic(vtype);
switch (vtype) {
case nullValue:
@@ -343,7 +356,8 @@ Value::Value(ValueType vtype) {
value_.real_ = 0.0;
break;
case stringValue:
value_.string_ = 0;
// allocated_ == false, so this is safe.
value_.string_ = const_cast<char*>(static_cast<char const*>(empty));
break;
case arrayValue:
case objectValue:
@@ -488,8 +502,7 @@ Value::~Value() {
JSON_ASSERT_UNREACHABLE;
}
if (comments_)
delete[] comments_;
delete[] comments_;
value_.uint_ = 0;
}
@@ -972,7 +985,7 @@ Value& Value::operator[](ArrayIndex index) {
if (it != value_.map_->end() && (*it).first == key)
return (*it).second;
ObjectValues::value_type defaultValue(key, nullRef);
ObjectValues::value_type defaultValue(key, nullSingleton());
it = value_.map_->insert(it, defaultValue);
return (*it).second;
}
@@ -989,11 +1002,11 @@ const Value& Value::operator[](ArrayIndex index) const {
type_ == nullValue || type_ == arrayValue,
"in Json::Value::operator[](ArrayIndex)const: requires arrayValue");
if (type_ == nullValue)
return nullRef;
return nullSingleton();
CZString key(index);
ObjectValues::const_iterator it = value_.map_->find(key);
if (it == value_.map_->end())
return nullRef;
return nullSingleton();
return (*it).second;
}
@@ -1027,7 +1040,7 @@ Value& Value::resolveReference(const char* key) {
if (it != value_.map_->end() && (*it).first == actualKey)
return (*it).second;
ObjectValues::value_type defaultValue(actualKey, nullRef);
ObjectValues::value_type defaultValue(actualKey, nullSingleton());
it = value_.map_->insert(it, defaultValue);
Value& value = (*it).second;
return value;
@@ -1047,7 +1060,7 @@ Value& Value::resolveReference(char const* key, char const* cend)
if (it != value_.map_->end() && (*it).first == actualKey)
return (*it).second;
ObjectValues::value_type defaultValue(actualKey, nullRef);
ObjectValues::value_type defaultValue(actualKey, nullSingleton());
it = value_.map_->insert(it, defaultValue);
Value& value = (*it).second;
return value;
@@ -1055,7 +1068,7 @@ Value& Value::resolveReference(char const* key, char const* cend)
Value Value::get(ArrayIndex index, const Value& defaultValue) const {
const Value* value = &((*this)[index]);
return value == &nullRef ? defaultValue : *value;
return value == &nullSingleton() ? defaultValue : *value;
}
bool Value::isValidIndex(ArrayIndex index) const { return index < size(); }
@@ -1074,13 +1087,13 @@ Value const* Value::find(char const* key, char const* cend) const
const Value& Value::operator[](const char* key) const
{
Value const* found = find(key, key + strlen(key));
if (!found) return nullRef;
if (!found) return nullSingleton();
return *found;
}
Value const& Value::operator[](JSONCPP_STRING const& key) const
{
Value const* found = find(key.data(), key.data() + key.length());
if (!found) return nullRef;
if (!found) return nullSingleton();
return *found;
}
@@ -1103,7 +1116,7 @@ Value& Value::operator[](const CppTL::ConstString& key) {
Value const& Value::operator[](CppTL::ConstString const& key) const
{
Value const* found = find(key.c_str(), key.end_c_str());
if (!found) return nullRef;
if (!found) return nullSingleton();
return *found;
}
#endif
@@ -1151,7 +1164,7 @@ Value Value::removeMember(const char* key)
JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == objectValue,
"in Json::Value::removeMember(): requires objectValue");
if (type_ == nullValue)
return nullRef;
return nullSingleton();
Value removed; // null
removeMember(key, key + strlen(key), &removed);
@@ -1491,12 +1504,12 @@ void Path::makePath(const JSONCPP_STRING& path, const InArgs& in) {
index = index * 10 + ArrayIndex(*current - '0');
args_.push_back(index);
}
if (current == end || *current++ != ']')
if (current == end || *++current != ']')
invalidPath(path, int(current - path.c_str()));
} else if (*current == '%') {
addPathInArg(path, in, itInArg, PathArgument::kindKey);
++current;
} else if (*current == '.') {
} else if (*current == '.' || *current == ']') {
++current;
} else {
const char* beginName = current;
@@ -1516,7 +1529,7 @@ void Path::addPathInArg(const JSONCPP_STRING& /*path*/,
} else if ((*itInArg)->kind_ != kind) {
// Error: bad argument type
} else {
args_.push_back(**itInArg);
args_.push_back(**itInArg++);
}
}
@@ -1531,16 +1544,19 @@ const Value& Path::resolve(const Value& root) const {
if (arg.kind_ == PathArgument::kindIndex) {
if (!node->isArray() || !node->isValidIndex(arg.index_)) {
// Error: unable to resolve path (array value expected at position...
return Value::null;
}
node = &((*node)[arg.index_]);
} else if (arg.kind_ == PathArgument::kindKey) {
if (!node->isObject()) {
// Error: unable to resolve path (object value expected at position...)
return Value::null;
}
node = &((*node)[arg.key_]);
if (node == &Value::nullRef) {
if (node == &Value::nullSingleton()) {
// Error: unable to resolve path (object has no member named '' at
// position...)
return Value::null;
}
}
}
@@ -1559,7 +1575,7 @@ Value Path::resolve(const Value& root, const Value& defaultValue) const {
if (!node->isObject())
return defaultValue;
node = &((*node)[arg.key_]);
if (node == &Value::nullRef)
if (node == &Value::nullSingleton())
return defaultValue;
}
}

View File

@@ -135,6 +135,7 @@ JSONCPP_STRING valueToString(UInt value) {
#endif // # if defined(JSON_HAS_INT64)
namespace {
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.
@@ -164,6 +165,7 @@ JSONCPP_STRING valueToString(double value, bool useSpecialFloats, unsigned int p
fixNumericLocale(buffer, buffer + len);
return buffer;
}
}
JSONCPP_STRING valueToString(double value) { return valueToString(value, false, 17); }
@@ -351,7 +353,7 @@ void FastWriter::writeValue(const Value& value) {
break;
case stringValue:
{
// Is NULL possible for value.string_?
// Is NULL possible for value.string_? No.
char const* str;
char const* end;
bool ok = value.getString(&str, &end);
@@ -421,7 +423,7 @@ void StyledWriter::writeValue(const Value& value) {
break;
case stringValue:
{
// Is NULL possible for value.string_?
// Is NULL possible for value.string_? No.
char const* str;
char const* end;
bool ok = value.getString(&str, &end);
@@ -638,7 +640,7 @@ void StyledStreamWriter::writeValue(const Value& value) {
break;
case stringValue:
{
// Is NULL possible for value.string_?
// Is NULL possible for value.string_? No.
char const* str;
char const* end;
bool ok = value.getString(&str, &end);
@@ -839,7 +841,7 @@ struct BuiltStyledStreamWriter : public StreamWriter
JSONCPP_STRING const& endingLineFeedSymbol,
bool useSpecialFloats,
unsigned int precision);
int write(Value const& root, JSONCPP_OSTREAM* sout) override;
int write(Value const& root, JSONCPP_OSTREAM* sout) JSONCPP_OVERRIDE;
private:
void writeValue(Value const& value);
void writeArrayValue(Value const& value);
@@ -919,7 +921,7 @@ void BuiltStyledStreamWriter::writeValue(Value const& value) {
break;
case stringValue:
{
// Is NULL is possible for value.string_?
// Is NULL is possible for value.string_? No.
char const* str;
char const* end;
bool ok = value.getString(&str, &end);
@@ -1000,7 +1002,7 @@ void BuiltStyledStreamWriter::writeArrayValue(Value const& value) {
if (!indentation_.empty()) *sout_ << " ";
for (unsigned index = 0; index < size; ++index) {
if (index > 0)
*sout_ << ", ";
*sout_ << ((!indentation_.empty()) ? ", " : ",");
*sout_ << childValues_[index];
}
if (!indentation_.empty()) *sout_ << " ";

View File

@@ -271,8 +271,8 @@ TestResult& checkStringEqual(TestResult& result,
} \
\
public: /* overidden from TestCase */ \
const char* testName() const override { return #FixtureType "/" #name; } \
void runTestCase() override; \
const char* testName() const JSONCPP_OVERRIDE { return #FixtureType "/" #name; } \
void runTestCase() JSONCPP_OVERRIDE; \
}; \
\
void Test##FixtureType##name::runTestCase()

View File

@@ -1 +1 @@
1.7.0
1.7.7