json-schema-validator: Updrade to 2.2.0

Upgrade and add important patches to the release

Signed-off-by: Parian Golchin <par.golchin@gmail.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Parian Golchin 2023-08-22 20:03:28 +02:00 committed by Khem Raj
parent 0324259cd6
commit 0697d52777
6 changed files with 159 additions and 62 deletions

View File

@ -0,0 +1,29 @@
From 35939115142db6cd366ab11b29692a0179338ddf Mon Sep 17 00:00:00 2001
From: Parian Golchin <Parian.Golchin@iris-sensing.com>
Date: Fri, 18 Aug 2023 15:54:25 +0200
Subject: [PATCH 1/3] Set Json_validator Install off if it finds it via linking
Upstream-Status: Inappropriate [newer version of cmake in main branch]
Signed-off-by: Parian Golchin <Parian.Golchin@iris-sensing.com>
---
CMakeLists.txt | 3 +++
1 file changed, 3 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f636734..9e4587f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -55,6 +55,9 @@ option(JSON_VALIDATOR_BUILD_EXAMPLES "Build examples" ${JSON_VALIDATOR_IS_TOP_LE
if(NOT TARGET nlohmann_json::nlohmann_json)
find_package(nlohmann_json REQUIRED)
+else()
+ message(STATUS "Found nlohmann_json::nlohmann_json-target - linking with it")
+ set(JSON_VALIDATOR_INSTALL OFF)
endif()
target_link_libraries(
--
2.25.1

View File

@ -1,46 +0,0 @@
From e0b1ad02c678513412aba95a1b2fb4005c3c0452 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Sat, 19 Mar 2022 22:40:49 -0700
Subject: [PATCH] cmake: Use GNUInstallDirs
This helps it make it platform independent, some platforms e.g.
ppc64/linux use /usr/lib64 for system libraries
Upstream-Status: Submitted [https://github.com/pboettch/json-schema-validator/pull/197]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
CMakeLists.txt | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c4cc218..594dc5f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -122,11 +122,13 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
endif()
endif()
+include(GNUInstallDirs)
+
if(JSON_VALIDATOR_INSTALL)
install(TARGETS nlohmann_json_schema_validator
EXPORT ${PROJECT_NAME}Targets
- LIBRARY DESTINATION lib
- ARCHIVE DESTINATION lib
+ LIBRARY DESTINATION ${LIBDIR}
+ ARCHIVE DESTINATION ${LIBDIR}
RUNTIME DESTINATION bin)
install(FILES src/nlohmann/json-schema.hpp
@@ -155,7 +157,7 @@ if(JSON_VALIDATOR_INSTALL)
# Set Up the Project Targets and Config Files for CMake
# Set the install path to the cmake config files
- set(INSTALL_CMAKE_DIR ${CMAKE_INSTALL_PREFIX}/lib/cmake/${PROJECT_NAME})
+ set(INSTALL_CMAKE_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
# Create the ConfigVersion file
include(CMakePackageConfigHelpers) # write_basic_package_version_file
--
2.35.1

View File

@ -0,0 +1,71 @@
From 2065015da40cf79dd8ec9e3f186538e17c3b592f Mon Sep 17 00:00:00 2001
From: Robert Joslyn <robert.joslyn@redrectangle.org>
Date: Wed, 30 Nov 2022 13:07:29 -0800
Subject: [PATCH 2/3] Fix assumed signed char
The code assumes that char is signed, but whether char is signed or
unsigned is implementation defined. On some architectures like PowerPC,
GCC treats char as unsigned resulting in compile errors:
smtp-address-validator.cpp:213:1: error: narrowing conversion of '-32' from 'int' to 'char' [-Wnarrowing]
Fix this by specifying signed char.
Upstream-Status: Accepted [https://github.com/pboettch/json-schema-validator/commit/491ac44026e08f31790f5cacffa62e168bb35e32]
Signed-off-by: Parian Golchin <Parian.Golchin@iris-sensing.com>
---
src/smtp-address-validator.cpp | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/smtp-address-validator.cpp b/src/smtp-address-validator.cpp
index a63ead0..3903b51 100644
--- a/src/smtp-address-validator.cpp
+++ b/src/smtp-address-validator.cpp
@@ -63,7 +63,7 @@ static const short _address_key_offsets[] = {
1363, 1365, 1367, 1368, 1370, 1388, 0
};
-static const char _address_trans_keys[] = {
+static const signed char _address_trans_keys[] = {
-32, -19, -16, -12, 34, 45, 61, 63,
-62, -33, -31, -17, -15, -13, 33, 39,
42, 43, 47, 57, 65, 90, 94, 126,
@@ -711,7 +711,7 @@ bool is_address(const char* p, const char* pe)
{
int _klen;
unsigned int _trans = 0;
- const char * _keys;
+ const signed char * _keys;
const signed char * _acts;
unsigned int _nacts;
_resume: {}
@@ -728,9 +728,9 @@ bool is_address(const char* p, const char* pe)
_klen = (int)_address_single_lengths[cs];
if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_upper = _keys + _klen - 1;
- const char *_mid;
+ const signed char *_lower = _keys;
+ const signed char *_upper = _keys + _klen - 1;
+ const signed char *_mid;
while ( 1 ) {
if ( _upper < _lower ) {
_keys += _klen;
@@ -752,9 +752,9 @@ bool is_address(const char* p, const char* pe)
_klen = (int)_address_range_lengths[cs];
if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_upper = _keys + (_klen<<1) - 2;
- const char *_mid;
+ const signed char *_lower = _keys;
+ const signed char *_upper = _keys + (_klen<<1) - 2;
+ const signed char *_mid;
while ( 1 ) {
if ( _upper < _lower ) {
_trans += (unsigned int)_klen;
--
2.25.1

View File

@ -0,0 +1,41 @@
From fa49c29942763285c51b7d2dea417d9f51e4961f Mon Sep 17 00:00:00 2001
From: Sven Fink <sven.fink@wipotec.com>
Date: Fri, 13 Jan 2023 09:15:42 +0100
Subject: [PATCH 3/3] For root value, use empty pointer
Upstream-Status: Accepted [https://github.com/pboettch/json-schema-validator/commit/59c9d6200bf3cd54b4fc717ec1660c91eddb4d1a]
Signed-off-by: Parian Golchin <Parian.Golchin@iris-sensing.com>
---
src/json-validator.cpp | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/json-validator.cpp b/src/json-validator.cpp
index 7f34553..3c73d98 100644
--- a/src/json-validator.cpp
+++ b/src/json-validator.cpp
@@ -553,6 +553,9 @@ class type_schema : public schema
else_->validate(ptr, instance, patch, e);
}
}
+ if (instance.is_null()) {
+ patch.add(nlohmann::json::json_pointer{}, default_value_);
+ }
}
protected:
@@ -1134,6 +1137,11 @@ public:
propertyNames_ = schema::make(attr.value(), root, {"propertyNames"}, uris);
sch.erase(attr);
}
+
+ attr = sch.find("default");
+ if (attr != sch.end()) {
+ set_default_value(*attr);
+ }
}
};
--
2.25.1

View File

@ -1,16 +0,0 @@
SUMMARY = "JSON schema validator for JSON for Modern C++"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=c441d022da1b1663c70181a32225d006"
SRC_URI = "git://github.com/pboettch/json-schema-validator;branch=master;protocol=https \
file://0001-cmake-Use-GNUInstallDirs.patch \
"
SRCREV = "27fc1d094503623dfe39365ba82581507524545c"
S = "${WORKDIR}/git"
DEPENDS += "nlohmann-json"
inherit cmake
EXTRA_OECMAKE = "-DBUILD_SHARED_LIBS=ON -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF"

View File

@ -0,0 +1,18 @@
SUMMARY = "JSON schema validator for JSON for Modern C++"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=c441d022da1b1663c70181a32225d006"
SRC_URI = "git://github.com/pboettch/json-schema-validator;branch=main;protocol=https \
file://0001-Set-Json_validator-Install-off-if-it-finds-it-via-li.patch \
file://0002-Fix-assumed-signed-char.patch \
file://0003-For-root-value-use-empty-pointer.patch \
"
SRCREV = "6b17782d6a5d1dee5d2c4fc5d25ffb1123913431"
S = "${WORKDIR}/git"
DEPENDS += "nlohmann-json"
inherit cmake
EXTRA_OECMAKE = "-DBUILD_SHARED_LIBS=ON -DJSON_VALIDATOR_BUILD_TESTS=OFF -DJSON_VALIDATOR_BUILD_EXAMPLES=OFF"