Hello community, here is the log from the commit of package jsoncpp for openSUSE:Factory checked in at 2015-03-18 13:04:45 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/jsoncpp (Old) and /work/SRC/openSUSE:Factory/.jsoncpp.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "jsoncpp" Changes: -------- --- /work/SRC/openSUSE:Factory/jsoncpp/jsoncpp.changes 2015-03-09 10:09:57.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.jsoncpp.new/jsoncpp.changes 2015-03-18 13:04:47.000000000 +0100 @@ -1,0 +2,45 @@ +Sun Mar 15 19:40:03 UTC 2015 - mplus...@suse.com + +- Update to 1.6.0 + * Added Json::Exception, plus derived types: + Json::RuntimeError + Json::LogicError + * Clarified when exceptions are thrown. + * If you are trapping std::exception, nothing will change for you. + * Fixed deprecation macro. (Thx to @Dani-Hub.) + * Fixed compilation error for gcc-4.8. (Thx to @connormanning.) + * Fixed CharReader::Factory base. (Thx to Tengiz Sharafiev.) + +------------------------------------------------------------------- +Mon Mar 9 09:05:55 UTC 2015 - mplus...@suse.com + +- Create and install cmake files +- Define libname to make maintenance easier +- Use graphviz-gd so that we can generate png files in + documentation +- Update to 1.5.4 + * Support embedded 0s in strings (since UTF-8 allows them). + + If you use c-string methods, or std::string::c_str(), you + can still have problems. + + Note that this support has a price: keys are now limited to + 1 billion characters (2^30). + * Add feature to allow single-quotes in input JSON (since + JavaScript allows them). + * Propagate rarely-used StaticString thru copy-ctor. + * Let JSON_ASSERT throw std::logic_error instead of + std::runtime_error. + * Skip Python tests by default, and run C++ unit-tests only for + changes. + * Ignore cmake-generated files for in-source builds. + * Add tests. Fix other tests. + * Remove unused code (JSON_VALUE_USE_INTERNAL_MAP). + * Add rejectDupKeys feature. + + Now part of strictMode. + * Fix minor build issues for VisualStudio. + * Fix compile error for VS2013, plus warnings. + * Add operator[] to Builders. + * In Builders, fix ::validate() (which was always returning + true). + * Fix UTF-8 zeroes bugs in previous patch-versions. + +------------------------------------------------------------------- Old: ---- 1.5.2.tar.gz New: ---- 1.6.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ jsoncpp.spec ++++++ --- /var/tmp/diff_new_pack.GHZWby/_old 2015-03-18 13:04:48.000000000 +0100 +++ /var/tmp/diff_new_pack.GHZWby/_new 2015-03-18 13:04:48.000000000 +0100 @@ -16,8 +16,9 @@ # +%define libname lib%{name}1 Name: jsoncpp -Version: 1.5.2 +Version: 1.6.0 Release: 0 Summary: C++ library that allows manipulating with JSON License: MIT @@ -28,7 +29,7 @@ BuildRequires: doxygen BuildRequires: fdupes BuildRequires: gcc-c++ -BuildRequires: graphviz +BuildRequires: graphviz-gd BuildRequires: pkg-config BuildRequires: python BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -45,7 +46,7 @@ %package devel Summary: Development files for %{name} Group: Development/Languages/C and C++ -Requires: lib%{name}1 = %{version} +Requires: %{libname} = %{version} %description devel JSON is a lightweight data-interchange format. It can represent numbers, @@ -70,11 +71,11 @@ existing comment in unserialization/serialization steps, making it a convenient format to store user input files. -%package -n lib%{name}1 +%package -n %{libname} Summary: Shared library for %{name} Group: System/Libraries -%description -n lib%{name}1 +%description -n %{libname} JSON is a lightweight data-interchange format. It can represent numbers, strings, ordered sequences of values, and collections of name/value pairs. @@ -91,7 +92,8 @@ # path needs to be exported otherwise unit tests will fail export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:%{_builddir}/%{name}-%{version}/build/src/lib_json -%cmake -DJSONCPP_LIB_BUILD_SHARED=ON +%cmake \ + -DJSONCPP_WITH_CMAKE_PACKAGE=ON make %{?_smp_mflags} @@ -100,11 +102,11 @@ %fdupes -s dist/doxygen rm -rf %{buildroot}%{_libdir}/lib%{name}.a -%post -n lib%{name}1 -p /sbin/ldconfig +%post -n %{libname} -p /sbin/ldconfig -%postun -n lib%{name}1 -p /sbin/ldconfig +%postun -n %{libname} -p /sbin/ldconfig -%files -n lib%{name}1 +%files -n %{libname} %defattr(-,root,root) %doc LICENSE %{_libdir}/lib%{name}.so.* @@ -113,6 +115,7 @@ %defattr(-,root,root) %doc AUTHORS LICENSE NEWS.txt README.md %{_libdir}/pkgconfig/%{name}.pc +%{_libdir}/cmake/%{name} %{_libdir}/lib%{name}.so %{_includedir}/json/ ++++++ 1.5.2.tar.gz -> 1.6.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsoncpp-1.5.2/.gitignore new/jsoncpp-1.6.0/.gitignore --- old/jsoncpp-1.5.2/.gitignore 2015-03-05 16:18:44.000000000 +0100 +++ new/jsoncpp-1.6.0/.gitignore 2015-03-15 19:49:24.000000000 +0100 @@ -10,6 +10,7 @@ /libs/ /doc/doxyfile /dist/ +#/version #/include/json/version.h # MSVC project files: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsoncpp-1.5.2/CMakeLists.txt new/jsoncpp-1.6.0/CMakeLists.txt --- old/jsoncpp-1.5.2/CMakeLists.txt 2015-03-05 16:18:44.000000000 +0100 +++ new/jsoncpp-1.6.0/CMakeLists.txt 2015-03-15 19:49:24.000000000 +0100 @@ -1,3 +1,5 @@ +# vim: et ts=4 sts=4 sw=4 tw=0 + CMAKE_MINIMUM_REQUIRED(VERSION 2.8.5) PROJECT(jsoncpp) ENABLE_TESTING() @@ -54,17 +56,24 @@ ENDMACRO(jsoncpp_parse_version) # Read out version from "version" file -FILE(STRINGS "version" JSONCPP_VERSION) - +#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.0 ) 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) +#IF(NOT JSONCPP_VERSION_FOUND) +# MESSAGE(FATAL_ERROR "Failed to parse version string properly. Expect X.Y.Z") +#ENDIF(NOT JSONCPP_VERSION_FOUND) MESSAGE(STATUS "JsonCpp Version: ${JSONCPP_VERSION_MAJOR}.${JSONCPP_VERSION_MINOR}.${JSONCPP_VERSION_PATCH}") # File version.h is only regenerated on CMake configure step CONFIGURE_FILE( "${PROJECT_SOURCE_DIR}/src/lib_json/version.h.in" - "${PROJECT_SOURCE_DIR}/include/json/version.h" ) + "${PROJECT_SOURCE_DIR}/include/json/version.h" + NEWLINE_STYLE UNIX ) +CONFIGURE_FILE( "${PROJECT_SOURCE_DIR}/version.in" + "${PROJECT_SOURCE_DIR}/version" + NEWLINE_STYLE UNIX ) macro(UseCompilationWarningAsError) if ( MSVC ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsoncpp-1.5.2/README.md new/jsoncpp-1.6.0/README.md --- old/jsoncpp-1.5.2/README.md 2015-03-05 16:18:44.000000000 +0100 +++ new/jsoncpp-1.6.0/README.md 2015-03-15 19:49:24.000000000 +0100 @@ -16,7 +16,7 @@ ## A note on backward-compatibility * `1.y.z` is built with C++11. -* `0.8.z` can be used with older compilers. +* `0.y.z` can be used with older compilers. * Major versions maintain binary-compatibility. Using JsonCpp in your project diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsoncpp-1.5.2/include/json/assertions.h new/jsoncpp-1.6.0/include/json/assertions.h --- old/jsoncpp-1.5.2/include/json/assertions.h 2015-03-05 16:18:44.000000000 +0100 +++ new/jsoncpp-1.6.0/include/json/assertions.h 2015-03-15 19:49:24.000000000 +0100 @@ -13,18 +13,30 @@ #include "config.h" #endif // if !defined(JSON_IS_AMALGAMATION) +/** It should not be possible for a maliciously designed file to + * cause an abort() or seg-fault, so these macros are used only + * for pre-condition violations and internal logic errors. + */ #if JSON_USE_EXCEPTION -#include <stdexcept> -#define JSON_ASSERT(condition) \ - if (!(condition)) {throw std::logic_error( "assert json failed" );} // @todo <= add detail about condition in exception -#define JSON_FAIL_MESSAGE(message) do{std::ostringstream oss; oss << message; throw std::logic_error(oss.str());}while(0) -//#define JSON_FAIL_MESSAGE(message) throw std::logic_error(message) + +// @todo <= add detail about condition in exception +# define JSON_ASSERT(condition) \ + {if (!(condition)) {Json::throwLogicError( "assert json failed" );}} + +# define JSON_FAIL_MESSAGE(message) \ + { \ + std::ostringstream oss; oss << message; \ + Json::throwLogicError(oss.str()); \ + abort(); \ + } + #else // JSON_USE_EXCEPTION -#define JSON_ASSERT(condition) assert(condition); + +# define JSON_ASSERT(condition) assert(condition) // The call to assert() will show the failure message in debug builds. In -// release bugs we abort, for a core-dump or debugger. -#define JSON_FAIL_MESSAGE(message) \ +// release builds we abort, for a core-dump or debugger. +# define JSON_FAIL_MESSAGE(message) \ { \ std::ostringstream oss; oss << message; \ assert(false && oss.str().c_str()); \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsoncpp-1.5.2/include/json/config.h new/jsoncpp-1.6.0/include/json/config.h --- old/jsoncpp-1.5.2/include/json/config.h 2015-03-05 16:18:44.000000000 +0100 +++ new/jsoncpp-1.6.0/include/json/config.h 2015-03-15 19:49:24.000000000 +0100 @@ -70,6 +70,14 @@ #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(JSONCPP_DEPRECATED) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsoncpp-1.5.2/include/json/reader.h new/jsoncpp-1.6.0/include/json/reader.h --- old/jsoncpp-1.5.2/include/json/reader.h 2015-03-05 16:18:44.000000000 +0100 +++ new/jsoncpp-1.6.0/include/json/reader.h 2015-03-15 19:49:24.000000000 +0100 @@ -110,7 +110,7 @@ * during parsing. * \deprecated Use getFormattedErrorMessages() instead (typo fix). */ - JSONCPP_DEPRECATED("Use getFormattedErrorMessages instead") + JSONCPP_DEPRECATED("Use getFormattedErrorMessages() instead.") std::string getFormatedErrorMessages() const; /** \brief Returns a user friendly string that list errors in the parsed @@ -270,6 +270,7 @@ class Factory { public: + virtual ~Factory() {} /** \brief Allocate a CharReader via operator new(). * \throw std::exception if something goes wrong (e.g. invalid settings) */ @@ -279,8 +280,6 @@ /** \brief Build a CharReader implementation. - \deprecated This is experimental and will be altered before the next release. - Usage: \code using namespace Json; @@ -320,6 +319,8 @@ - `"failIfExtra": false or true` - If true, `parse()` returns false when extra non-whitespace trails the JSON value in the input string. + - `"rejectDupKeys": false or true` + - If true, `parse()` returns false when a key is duplicated within an object. You can examine 'settings_` yourself to see the defaults. You can also write and read them just like any @@ -360,7 +361,7 @@ * Someday we might have a real StreamReader, but for now this * is convenient. */ -bool parseFromStream( +bool JSON_API parseFromStream( CharReader::Factory const&, std::istream&, Value* root, std::string* errs); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsoncpp-1.5.2/include/json/value.h new/jsoncpp-1.6.0/include/json/value.h --- old/jsoncpp-1.5.2/include/json/value.h 2015-03-05 16:18:44.000000000 +0100 +++ new/jsoncpp-1.6.0/include/json/value.h 2015-03-15 19:49:24.000000000 +0100 @@ -11,6 +11,7 @@ #endif // if !defined(JSON_IS_AMALGAMATION) #include <string> #include <vector> +#include <exception> #ifndef JSON_USE_CPPTL_SMALLMAP #include <map> @@ -32,6 +33,31 @@ */ namespace Json { +/** Base class for all exceptions we throw. + * + * We use nothing but these internally. Of course, STL can throw others. + */ +class JSON_API Exception; +/** Exceptions which the user cannot easily avoid. + * + * E.g. out-of-memory (when we use malloc), stack-overflow, malicious input + * + * \remark derived from Json::Exception + */ +class JSON_API RuntimeError; +/** Exceptions thrown by JSON_ASSERT/JSON_FAIL macros. + * + * These are precondition-violations (user bugs) and internal errors (our bugs). + * + * \remark derived from Json::Exception + */ +class JSON_API LogicError; + +/// used internally +void throwRuntimeError(std::string const& msg); +/// used internally +void throwLogicError(std::string const& msg); + /** \brief Type of the value held by a Value object. */ enum ValueType { @@ -74,14 +100,14 @@ */ class JSON_API StaticString { public: - explicit StaticString(const char* czstring) : str_(czstring) {} + explicit StaticString(const char* czstring) : c_str_(czstring) {} - operator const char*() const { return str_; } + operator const char*() const { return c_str_; } - const char* c_str() const { return str_; } + const char* c_str() const { return c_str_; } private: - const char* str_; + const char* c_str_; }; /** \brief Represents a <a HREF="http://www.json.org">JSON</a> value. @@ -255,7 +281,8 @@ Value(const Value& other); ~Value(); - // Deep copy, then swap(other). + /// Deep copy, then swap(other). + /// \note Over-write existing comments. To preserve comments, use #swapPayload(). Value& operator=(Value other); /// Swap everything. void swap(Value& other); @@ -404,15 +431,19 @@ const Value& operator[](const CppTL::ConstString& key) const; #endif /// Return the member named key if it exist, defaultValue otherwise. + /// \note deep copy Value get(const char* key, const Value& defaultValue) const; /// Return the member named key if it exist, defaultValue otherwise. + /// \note deep copy /// \param key may contain embedded nulls. Value get(const char* key, const char* end, const Value& defaultValue) const; /// 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; #ifdef JSON_USE_CPPTL /// Return the member named key if it exist, defaultValue otherwise. + /// \note deep copy Value get(const CppTL::ConstString& key, const Value& defaultValue) const; #endif /// Most general and efficient version of isMember()const, get()const, @@ -636,16 +667,22 @@ /// Value. Value key() const; - /// Return the index of the referenced Value. -1 if it is not an arrayValue. + /// Return the index of the referenced Value, or -1 if it is not an arrayValue. UInt index() const; + /// 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; + /// Return the member name of the referenced Value. "" if it is not an /// objectValue. /// \deprecated This cannot be used for UTF-8 strings, since there can be embedded nulls. + JSONCPP_DEPRECATED("Use `key = name();` instead.") char const* memberName() const; /// Return the member name of the referenced Value, or NULL if it is not an /// objectValue. - /// Better version than memberName(). Allows embedded nulls. + /// \note Better version than memberName(). Allows embedded nulls. char const* memberName(char const** end) const; protected: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsoncpp-1.5.2/include/json/version.h new/jsoncpp-1.6.0/include/json/version.h --- old/jsoncpp-1.5.2/include/json/version.h 2015-03-05 16:18:44.000000000 +0100 +++ new/jsoncpp-1.6.0/include/json/version.h 2015-03-15 19:49:24.000000000 +0100 @@ -4,10 +4,10 @@ #ifndef JSON_VERSION_H_INCLUDED # define JSON_VERSION_H_INCLUDED -# define JSONCPP_VERSION_STRING "1.5.2" +# define JSONCPP_VERSION_STRING "1.6.0" # define JSONCPP_VERSION_MAJOR 1 -# define JSONCPP_VERSION_MINOR 5 -# define JSONCPP_VERSION_PATCH 2 +# define JSONCPP_VERSION_MINOR 6 +# define JSONCPP_VERSION_PATCH 0 # define JSONCPP_VERSION_QUALIFIER # define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsoncpp-1.5.2/include/json/writer.h new/jsoncpp-1.6.0/include/json/writer.h --- old/jsoncpp-1.5.2/include/json/writer.h 2015-03-05 16:18:44.000000000 +0100 +++ new/jsoncpp-1.6.0/include/json/writer.h 2015-03-15 19:49:24.000000000 +0100 @@ -46,7 +46,7 @@ /** Write Value into document as configured in sub-class. Do not take ownership of sout, but maintain a reference during function. \pre sout != NULL - \return zero on success + \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; @@ -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 writeString(StreamWriter::Factory const& factory, Value const& root); +std::string JSON_API writeString(StreamWriter::Factory const& factory, Value const& root); /** \brief Build a StreamWriter implementation. @@ -132,7 +132,7 @@ }; /** \brief Abstract class for writers. - * \deprecated Use StreamWriter. + * \deprecated Use StreamWriter. (And really, this is an implementation detail.) */ class JSON_API Writer { public: @@ -151,6 +151,7 @@ * \deprecated Use StreamWriterBuilder. */ class JSON_API FastWriter : public Writer { + public: FastWriter(); virtual ~FastWriter() {} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsoncpp-1.5.2/src/jsontestrunner/CMakeLists.txt new/jsoncpp-1.6.0/src/jsontestrunner/CMakeLists.txt --- old/jsoncpp-1.5.2/src/jsontestrunner/CMakeLists.txt 2015-03-05 16:18:44.000000000 +0100 +++ new/jsoncpp-1.6.0/src/jsontestrunner/CMakeLists.txt 2015-03-15 19:49:24.000000000 +0100 @@ -1,4 +1,4 @@ -FIND_PACKAGE(PythonInterp 2.6 REQUIRED) +FIND_PACKAGE(PythonInterp 2.6) IF(JSONCPP_LIB_BUILD_SHARED) ADD_DEFINITIONS( -DJSON_DLL ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsoncpp-1.5.2/src/lib_json/json_reader.cpp new/jsoncpp-1.6.0/src/lib_json/json_reader.cpp --- old/jsoncpp-1.5.2/src/lib_json/json_reader.cpp 2015-03-05 16:18:44.000000000 +0100 +++ new/jsoncpp-1.6.0/src/lib_json/json_reader.cpp 2015-03-15 19:49:24.000000000 +0100 @@ -17,7 +17,6 @@ #include <sstream> #include <memory> #include <set> -#include <stdexcept> #if defined(_MSC_VER) && _MSC_VER < 1500 // VC++ 8.0 and below #define snprintf _snprintf @@ -148,7 +147,7 @@ // But this deprecated class has a security problem: Bad input can // cause a seg-fault. This seems like a fair, binary-compatible way // to prevent the problem. - if (stackDepth_g >= stackLimit_g) throw std::runtime_error("Exceeded stackLimit in readValue()."); + if (stackDepth_g >= stackLimit_g) throwRuntimeError("Exceeded stackLimit in readValue()."); ++stackDepth_g; Token token; @@ -916,6 +915,7 @@ bool allowNumericKeys_; bool allowSingleQuotes_; bool failIfExtra_; + bool rejectDupKeys_; int stackLimit_; }; // OurFeatures @@ -1106,7 +1106,7 @@ } bool OurReader::readValue() { - if (stackDepth_ >= features_.stackLimit_) throw std::runtime_error("Exceeded stackLimit in readValue()."); + if (stackDepth_ >= features_.stackLimit_) throwRuntimeError("Exceeded stackLimit in readValue()."); ++stackDepth_; Token token; skipCommentTokens(token); @@ -1430,7 +1430,12 @@ return addErrorAndRecover( "Missing ':' after object member name", colon, tokenObjectEnd); } - if (name.length() >= (1U<<30)) throw std::runtime_error("keylength >= 2^30"); + if (name.length() >= (1U<<30)) throwRuntimeError("keylength >= 2^30"); + if (features_.rejectDupKeys_ && currentValue().isMember(name)) { + std::string msg = "Duplicate key: '" + name + "'"; + return addErrorAndRecover( + msg, tokenName, tokenObjectEnd); + } Value& value = currentValue()[name]; nodes_.push(&value); bool ok = readValue(); @@ -1896,6 +1901,7 @@ features.allowSingleQuotes_ = settings_["allowSingleQuotes"].asBool(); features.stackLimit_ = settings_["stackLimit"].asInt(); features.failIfExtra_ = settings_["failIfExtra"].asBool(); + features.rejectDupKeys_ = settings_["rejectDupKeys"].asBool(); return new OurCharReader(collectComments, features); } static void getValidReaderKeys(std::set<std::string>* valid_keys) @@ -1909,6 +1915,7 @@ valid_keys->insert("allowSingleQuotes"); valid_keys->insert("stackLimit"); valid_keys->insert("failIfExtra"); + valid_keys->insert("rejectDupKeys"); } bool CharReaderBuilder::validate(Json::Value* invalid) const { @@ -1941,6 +1948,7 @@ (*settings)["allowNumericKeys"] = false; (*settings)["allowSingleQuotes"] = false; (*settings)["failIfExtra"] = true; + (*settings)["rejectDupKeys"] = true; //! [CharReaderBuilderStrictMode] } // static @@ -1955,6 +1963,7 @@ (*settings)["allowSingleQuotes"] = false; (*settings)["stackLimit"] = 1000; (*settings)["failIfExtra"] = false; + (*settings)["rejectDupKeys"] = false; //! [CharReaderBuilderDefaults] } @@ -1984,7 +1993,7 @@ "Error from reader: %s", errs.c_str()); - JSON_FAIL_MESSAGE("reader error"); + throwRuntimeError("reader error"); } return sin; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsoncpp-1.5.2/src/lib_json/json_value.cpp new/jsoncpp-1.6.0/src/lib_json/json_value.cpp --- old/jsoncpp-1.5.2/src/lib_json/json_value.cpp 2015-03-05 16:18:44.000000000 +0100 +++ new/jsoncpp-1.6.0/src/lib_json/json_value.cpp 2015-03-15 19:49:24.000000000 +0100 @@ -52,9 +52,6 @@ const LargestInt Value::maxLargestInt = LargestInt(LargestUInt(-1) / 2); const LargestUInt Value::maxLargestUInt = LargestUInt(-1); -/// Unknown size marker -static const size_t unknown = (size_t)-1; - #if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) template <typename T, typename U> static inline bool InRange(double d, T min, U max) { @@ -83,19 +80,18 @@ * @return Pointer on the duplicate instance of string. */ static inline char* duplicateStringValue(const char* value, - size_t length = unknown) { - if (length == unknown) - length = strlen(value); - + 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) length = Value::maxInt - 1; char* newString = static_cast<char*>(malloc(length + 1)); - JSON_ASSERT_MESSAGE(newString != 0, - "in Json::Value::duplicateStringValue(): " - "Failed to allocate string value buffer"); + if (newString == NULL) { + throwRuntimeError( + "in Json::Value::duplicateStringValue(): " + "Failed to allocate string value buffer"); + } memcpy(newString, value, length); newString[length] = 0; return newString; @@ -114,9 +110,11 @@ "length too big for prefixing"); unsigned actualLength = length + sizeof(unsigned) + 1U; char* newString = static_cast<char*>(malloc(actualLength)); - JSON_ASSERT_MESSAGE(newString != 0, - "in Json::Value::duplicateAndPrefixStringValue(): " - "Failed to allocate string value buffer"); + if (newString == 0) { + throwRuntimeError( + "in Json::Value::duplicateAndPrefixStringValue(): " + "Failed to allocate string value buffer"); + } *reinterpret_cast<unsigned*>(newString) = length; memcpy(newString + sizeof(unsigned), value, length); newString[actualLength - 1U] = 0; // to avoid buffer over-run accidents by users later @@ -154,6 +152,47 @@ namespace Json { +class JSON_API Exception : public std::exception { +public: + Exception(std::string const& msg); + virtual ~Exception() throw(); + virtual char const* what() const throw(); +protected: + std::string const msg_; +}; +class JSON_API RuntimeError : public Exception { +public: + RuntimeError(std::string const& msg); +}; +class JSON_API LogicError : public Exception { +public: + LogicError(std::string const& msg); +}; + +Exception::Exception(std::string const& msg) + : msg_(msg) +{} +Exception::~Exception() throw() +{} +char const* Exception::what() const throw() +{ + return msg_.c_str(); +} +RuntimeError::RuntimeError(std::string const& msg) + : Exception(msg) +{} +LogicError::LogicError(std::string const& msg) + : Exception(msg) +{} +void throwRuntimeError(std::string const& msg) +{ + throw RuntimeError(msg); +} +void throwLogicError(std::string const& msg) +{ + throw LogicError(msg); +} + // ////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////// @@ -196,15 +235,16 @@ Value::CZString::CZString(ArrayIndex index) : cstr_(0), index_(index) {} Value::CZString::CZString(char const* str, unsigned length, DuplicationPolicy allocate) - : cstr_(allocate == duplicate ? duplicateStringValue(str) : str) + : cstr_(str) { + // allocate != duplicate storage_.policy_ = allocate; storage_.length_ = length; } Value::CZString::CZString(const CZString& other) : cstr_(other.storage_.policy_ != noDuplication && other.cstr_ != 0 - ? duplicateStringValue(other.cstr_) + ? duplicateStringValue(other.cstr_, other.storage_.length_) : other.cstr_) { storage_.policy_ = (other.cstr_ @@ -1028,8 +1068,8 @@ Value Value::get(char const* key, char const* end, Value const& defaultValue) const { - const Value* value = &((*this)[key]); - return value == &nullRef ? defaultValue : *value; + Value const* found = find(key, end); + return !found ? defaultValue : *found; } Value Value::get(char const* key, Value const& defaultValue) const { @@ -1037,7 +1077,7 @@ } Value Value::get(std::string const& key, Value const& defaultValue) const { - return get(key.c_str(), defaultValue); + return get(key.data(), key.data() + key.length(), defaultValue); } @@ -1104,7 +1144,7 @@ #ifdef JSON_USE_CPPTL Value Value::get(const CppTL::ConstString& key, const Value& defaultValue) const { - return get(key.c_str(), defaultValue); + return get(key.c_str(), key.end_c_str(), defaultValue); } #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsoncpp-1.5.2/src/lib_json/json_valueiterator.inl new/jsoncpp-1.6.0/src/lib_json/json_valueiterator.inl --- old/jsoncpp-1.5.2/src/lib_json/json_valueiterator.inl 2015-03-05 16:18:44.000000000 +0100 +++ new/jsoncpp-1.6.0/src/lib_json/json_valueiterator.inl 2015-03-15 19:49:24.000000000 +0100 @@ -92,6 +92,14 @@ return Value::UInt(-1); } +std::string ValueIteratorBase::name() const { + char const* key; + char const* end; + key = memberName(&end); + if (!key) return std::string(); + return std::string(key, end); +} + char const* ValueIteratorBase::memberName() const { const char* name = (*current_).first.data(); return name ? name : ""; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsoncpp-1.5.2/src/lib_json/json_writer.cpp new/jsoncpp-1.6.0/src/lib_json/json_writer.cpp --- old/jsoncpp-1.5.2/src/lib_json/json_writer.cpp 2015-03-05 16:18:44.000000000 +0100 +++ new/jsoncpp-1.6.0/src/lib_json/json_writer.cpp 2015-03-15 19:49:24.000000000 +0100 @@ -12,16 +12,25 @@ #include <sstream> #include <utility> #include <set> -#include <stdexcept> -#include <assert.h> -#include <math.h> -#include <stdio.h> -#include <string.h> +#include <cassert> +#include <cstring> +#include <cstdio> -#if defined(_MSC_VER) && _MSC_VER < 1500 // VC++ 8.0 and below +#if defined(_MSC_VER) && _MSC_VER >= 1200 && _MSC_VER < 1800 // Between VC++ 6.0 and VC++ 11.0 #include <float.h> #define isfinite _finite +#elif defined(__sun) && defined(__SVR4) //Solaris +#include <ieeefp.h> +#define isfinite finite +#else +#include <cmath> +#define isfinite std::isfinite +#endif + +#if defined(_MSC_VER) && _MSC_VER < 1500 // VC++ 8.0 and below #define snprintf _snprintf +#else +#define snprintf std::snprintf #endif #if defined(_MSC_VER) && _MSC_VER >= 1400 // VC++ 8.0 @@ -29,11 +38,6 @@ #pragma warning(disable : 4996) #endif -#if defined(__sun) && defined(__SVR4) //Solaris -#include <ieeefp.h> -#define isfinite finite -#endif - namespace Json { #if __cplusplus >= 201103L @@ -1080,7 +1084,7 @@ } else if (cs_str == "None") { cs = CommentStyle::None; } else { - throw std::runtime_error("commentStyle must be 'All' or 'None'"); + throwRuntimeError("commentStyle must be 'All' or 'None'"); } std::string colonSymbol = " : "; if (eyc) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsoncpp-1.5.2/src/test_lib_json/CMakeLists.txt new/jsoncpp-1.6.0/src/test_lib_json/CMakeLists.txt --- old/jsoncpp-1.5.2/src/test_lib_json/CMakeLists.txt 2015-03-05 16:18:44.000000000 +0100 +++ new/jsoncpp-1.6.0/src/test_lib_json/CMakeLists.txt 2015-03-15 19:49:24.000000000 +0100 @@ -1,3 +1,4 @@ +# vim: et ts=4 sts=4 sw=4 tw=0 IF(JSONCPP_LIB_BUILD_SHARED) ADD_DEFINITIONS( -DJSON_DLL ) @@ -22,9 +23,19 @@ # Run unit tests in post-build # (default cmake workflow hides away the test result into a file, resulting in poor dev workflow?!?) IF(JSONCPP_WITH_POST_BUILD_UNITTEST) - ADD_CUSTOM_COMMAND( TARGET jsoncpp_test - POST_BUILD - COMMAND $<TARGET_FILE:jsoncpp_test>) + IF(JSONCPP_LIB_BUILD_SHARED) + # First, copy the shared lib, for Microsoft. + # Then, run the test executable. + ADD_CUSTOM_COMMAND( TARGET jsoncpp_test + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:jsoncpp_lib> $<TARGET_FILE_DIR:jsoncpp_test> + COMMAND $<TARGET_FILE:jsoncpp_test>) + ELSE(JSONCPP_LIB_BUILD_SHARED) + # Just run the test executable. + ADD_CUSTOM_COMMAND( TARGET jsoncpp_test + POST_BUILD + COMMAND $<TARGET_FILE:jsoncpp_test>) + ENDIF(JSONCPP_LIB_BUILD_SHARED) ENDIF(JSONCPP_WITH_POST_BUILD_UNITTEST) SET_TARGET_PROPERTIES(jsoncpp_test PROPERTIES OUTPUT_NAME jsoncpp_test) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsoncpp-1.5.2/src/test_lib_json/main.cpp new/jsoncpp-1.6.0/src/test_lib_json/main.cpp --- old/jsoncpp-1.5.2/src/test_lib_json/main.cpp 2015-03-05 16:18:44.000000000 +0100 +++ new/jsoncpp-1.6.0/src/test_lib_json/main.cpp 2015-03-15 19:49:24.000000000 +0100 @@ -6,7 +6,6 @@ #include "jsontest.h" #include <json/config.h> #include <json/json.h> -#include <stdexcept> #include <cstring> // Make numeric limits more convenient to talk about. @@ -1541,9 +1540,53 @@ } } +JSONTEST_FIXTURE(ValueTest, CommentBefore) { + Json::Value val; // fill val + val.setComment("// 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); + JSONTEST_ASSERT_STRING_EQUAL(expected, result); + std::string res2 = val.toStyledString(); + std::string exp2 = "\n"; + exp2 += expected; + exp2 += "\n"; + JSONTEST_ASSERT_STRING_EQUAL(exp2, res2); + } + Json::Value other = "hello"; + val.swapPayload(other); + { + char const expected[] = "// this comment should appear before\n\"hello\""; + std::string result = Json::writeString(wbuilder, val); + JSONTEST_ASSERT_STRING_EQUAL(expected, result); + std::string res2 = val.toStyledString(); + std::string exp2 = "\n"; + exp2 += expected; + exp2 += "\n"; + JSONTEST_ASSERT_STRING_EQUAL(exp2, res2); + JSONTEST_ASSERT_STRING_EQUAL("null\n", other.toStyledString()); + } + val = "hello"; + // val.setComment("// this comment should appear before", Json::CommentPlacement::commentBefore); + // Assignment over-writes comments. + { + char const expected[] = "\"hello\""; + std::string result = Json::writeString(wbuilder, val); + JSONTEST_ASSERT_STRING_EQUAL(expected, result); + std::string res2 = val.toStyledString(); + std::string exp2 = ""; + exp2 += expected; + exp2 += "\n"; + JSONTEST_ASSERT_STRING_EQUAL(exp2, res2); + } +} + JSONTEST_FIXTURE(ValueTest, zeroes) { - std::string binary("hi", 3); // include trailing 0 - JSONTEST_ASSERT_EQUAL(3, binary.length()); + char const cstr[] = "h\0i"; + std::string binary(cstr, sizeof(cstr)); // include trailing 0 + JSONTEST_ASSERT_EQUAL(4U, binary.length()); Json::StreamWriterBuilder b; { Json::Value root; @@ -1557,11 +1600,11 @@ JSONTEST_ASSERT_STRING_EQUAL(binary, root[top].asString()); Json::Value removed; bool did; - did = root.removeMember(top, top + 3U, + did = root.removeMember(top, top + sizeof(top) - 1U, &removed); JSONTEST_ASSERT(did); JSONTEST_ASSERT_STRING_EQUAL(binary, removed.asString()); - did = root.removeMember(top, top + 3U, + did = root.removeMember(top, top + sizeof(top) - 1U, &removed); JSONTEST_ASSERT(!did); JSONTEST_ASSERT_STRING_EQUAL(binary, removed.asString()); // still @@ -1569,15 +1612,16 @@ } JSONTEST_FIXTURE(ValueTest, zeroesInKeys) { - std::string binary("hi", 3); // include trailing 0 - JSONTEST_ASSERT_EQUAL(3, binary.length()); - Json::StreamWriterBuilder b; + char const cstr[] = "h\0i"; + std::string binary(cstr, sizeof(cstr)); // include trailing 0 + JSONTEST_ASSERT_EQUAL(4U, binary.length()); { Json::Value root; root[binary] = "there"; JSONTEST_ASSERT_STRING_EQUAL("there", root[binary].asString()); - JSONTEST_ASSERT(!root.isMember("hi")); + JSONTEST_ASSERT(!root.isMember("h")); JSONTEST_ASSERT(root.isMember(binary)); + JSONTEST_ASSERT_STRING_EQUAL("there", root.get(binary, Json::Value::nullRef).asString()); Json::Value removed; bool did; did = root.removeMember(binary.data(), binary.data() + binary.length(), @@ -1588,6 +1632,8 @@ &removed); JSONTEST_ASSERT(!did); JSONTEST_ASSERT_STRING_EQUAL("there", removed.asString()); // still + JSONTEST_ASSERT(!root.isMember(binary)); + JSONTEST_ASSERT_STRING_EQUAL("", root.get(binary, Json::Value::nullRef).asString()); } } @@ -1838,6 +1884,29 @@ } } +struct CharReaderStrictModeTest : JsonTest::TestCase {}; + +JSONTEST_FIXTURE(CharReaderStrictModeTest, dupKeys) { + Json::CharReaderBuilder b; + Json::Value root; + char const doc[] = + "{ \"property\" : \"value\", \"key\" : \"val1\", \"key\" : \"val2\" }"; + { + b.strictMode(&b.settings_); + Json::CharReader* reader(b.newCharReader()); + std::string errs; + bool ok = reader->parse( + doc, doc + std::strlen(doc), + &root, &errs); + JSONTEST_ASSERT(!ok); + JSONTEST_ASSERT_STRING_EQUAL( + "* Line 1, Column 41\n" + " Duplicate key: 'key'\n", + errs); + JSONTEST_ASSERT_EQUAL("val1", root["key"]); // so far + delete reader; + } +} struct CharReaderFailIfExtraTest : JsonTest::TestCase {}; JSONTEST_FIXTURE(CharReaderFailIfExtraTest, issue164) { @@ -2203,7 +2272,7 @@ Json::Value json; json["k1"] = "a"; json["k2"] = "b"; - int dist; + int dist = 0; std::string str; for (Json::ValueIterator it = json.begin(); it != json.end(); ++it) { dist = it - json.begin(); @@ -2213,6 +2282,42 @@ JSONTEST_ASSERT_STRING_EQUAL("b", str); } +JSONTEST_FIXTURE(IteratorTest, names) { + Json::Value json; + json["k1"] = "a"; + json["k2"] = "b"; + Json::ValueIterator it = json.begin(); + JSONTEST_ASSERT(it != json.end()); + JSONTEST_ASSERT_EQUAL(Json::Value("k1"), it.key()); + JSONTEST_ASSERT_STRING_EQUAL("k1", it.name()); + JSONTEST_ASSERT_EQUAL(-1, it.index()); + ++it; + JSONTEST_ASSERT(it != json.end()); + JSONTEST_ASSERT_EQUAL(Json::Value("k2"), it.key()); + JSONTEST_ASSERT_STRING_EQUAL("k2", it.name()); + JSONTEST_ASSERT_EQUAL(-1, it.index()); + ++it; + JSONTEST_ASSERT(it == json.end()); +} + +JSONTEST_FIXTURE(IteratorTest, indexes) { + Json::Value json; + json[0] = "a"; + json[1] = "b"; + Json::ValueIterator it = json.begin(); + JSONTEST_ASSERT(it != json.end()); + JSONTEST_ASSERT_EQUAL(Json::Value(Json::ArrayIndex(0)), it.key()); + JSONTEST_ASSERT_STRING_EQUAL("", it.name()); + JSONTEST_ASSERT_EQUAL(0, it.index()); + ++it; + JSONTEST_ASSERT(it != json.end()); + JSONTEST_ASSERT_EQUAL(Json::Value(Json::ArrayIndex(1)), it.key()); + JSONTEST_ASSERT_STRING_EQUAL("", it.name()); + JSONTEST_ASSERT_EQUAL(1, it.index()); + ++it; + JSONTEST_ASSERT(it == json.end()); +} + int main(int argc, const char* argv[]) { JsonTest::Runner runner; JSONTEST_REGISTER_FIXTURE(runner, ValueTest, checkNormalizeFloatingPointStr); @@ -2236,6 +2341,8 @@ JSONTEST_REGISTER_FIXTURE(runner, ValueTest, offsetAccessors); JSONTEST_REGISTER_FIXTURE(runner, ValueTest, typeChecksThrowExceptions); JSONTEST_REGISTER_FIXTURE(runner, ValueTest, StaticString); + JSONTEST_REGISTER_FIXTURE(runner, ValueTest, CommentBefore); + //JSONTEST_REGISTER_FIXTURE(runner, ValueTest, nulls); JSONTEST_REGISTER_FIXTURE(runner, ValueTest, zeroes); JSONTEST_REGISTER_FIXTURE(runner, ValueTest, zeroesInKeys); @@ -2258,6 +2365,8 @@ JSONTEST_REGISTER_FIXTURE(runner, CharReaderTest, parseWithDetailError); JSONTEST_REGISTER_FIXTURE(runner, CharReaderTest, parseWithStackLimit); + JSONTEST_REGISTER_FIXTURE(runner, CharReaderStrictModeTest, dupKeys); + JSONTEST_REGISTER_FIXTURE(runner, CharReaderFailIfExtraTest, issue164); JSONTEST_REGISTER_FIXTURE(runner, CharReaderFailIfExtraTest, issue107); JSONTEST_REGISTER_FIXTURE(runner, CharReaderFailIfExtraTest, commentAfterObject); @@ -2273,6 +2382,8 @@ JSONTEST_REGISTER_FIXTURE(runner, BuilderTest, settings); JSONTEST_REGISTER_FIXTURE(runner, IteratorTest, distance); + JSONTEST_REGISTER_FIXTURE(runner, IteratorTest, names); + JSONTEST_REGISTER_FIXTURE(runner, IteratorTest, indexes); return runner.runCommandLine(argc, argv); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsoncpp-1.5.2/version new/jsoncpp-1.6.0/version --- old/jsoncpp-1.5.2/version 2015-03-05 16:18:44.000000000 +0100 +++ new/jsoncpp-1.6.0/version 2015-03-15 19:49:24.000000000 +0100 @@ -1 +1 @@ -1.5.2 +1.6.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsoncpp-1.5.2/version.in new/jsoncpp-1.6.0/version.in --- old/jsoncpp-1.5.2/version.in 1970-01-01 01:00:00.000000000 +0100 +++ new/jsoncpp-1.6.0/version.in 2015-03-15 19:49:24.000000000 +0100 @@ -0,0 +1 @@ +@JSONCPP_VERSION@ -- To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org For additional commands, e-mail: opensuse-commit+h...@opensuse.org