diff --git a/textproc/nlohmann-json/Makefile b/textproc/nlohmann-json/Makefile index c6165d8553e..bba2883996e 100644 --- a/textproc/nlohmann-json/Makefile +++ b/textproc/nlohmann-json/Makefile @@ -1,10 +1,9 @@ COMMENT = JSON for modern C++ # the "release" contain only json.hpp, and we want tests and CMake config file -V = 3.11.2 +V = 3.12.0 DIST_TUPLE = github nlohmann json v${V} . PKGNAME = nlohmann-json-${V} -REVISION = 0 TEST_DATA_DIR = tests/test_data DIST_TUPLE += github nlohmann json_test_data v3.1.0 ${TEST_DATA_DIR} @@ -29,6 +28,14 @@ NO_BUILD = Yes pre-test: @${MODCMAKE_BUILD_TARGET} +# One test fails due to lack of LC_NUMERIC support in OpenBSD: +# 49: /usr/ports/pobj/nlohmann-json-3.12.0/json-3.12.0/tests/src/unit-locale-cpp.cpp:134: +# 49: TEST CASE: locale-dependent test (LC_NUMERIC=de_DE) +# 49: check if locale is properly set +# 49: +# 49: /usr/ports/pobj/nlohmann-json-3.12.0/json-3.12.0/tests/src/unit-locale-cpp.cpp:142: ERROR: CHECK( std::string(buffer.data()) == "12,34" ) is NOT correct! +# 49: values: CHECK( 12.34 == 12,34 ) + # overwrite target, devel/cmake MODULE cannot pass ctest(1) arguments do-test: # skip known to tail tests diff --git a/textproc/nlohmann-json/distinfo b/textproc/nlohmann-json/distinfo index 1526e41c2ec..2cec33693d3 100644 --- a/textproc/nlohmann-json/distinfo +++ b/textproc/nlohmann-json/distinfo @@ -1,4 +1,4 @@ -SHA256 (nlohmann-json-v3.11.2.tar.gz) = 1p+d62p14lgEZcbExREbicTcL6lOOoX80v/NmhQ9knM= +SHA256 (nlohmann-json-v3.12.0.tar.gz) = S5LrDAbRBoP3RHzpQGy5fNS0U74Y1yeTIPey8CXBAYc= SHA256 (nlohmann-json_test_data-v3.1.0.tar.gz) = iEseIfOM/WpiwVnxt+Co9RaK5dqqOE7U3AwPpmYPIb0= -SIZE (nlohmann-json-v3.11.2.tar.gz) = 8097673 +SIZE (nlohmann-json-v3.12.0.tar.gz) = 9678593 SIZE (nlohmann-json_test_data-v3.1.0.tar.gz) = 115036393 diff --git a/textproc/nlohmann-json/patches/patch-include_nlohmann_detail_conversions_from_json_hpp b/textproc/nlohmann-json/patches/patch-include_nlohmann_detail_conversions_from_json_hpp new file mode 100644 index 00000000000..349fa431a58 --- /dev/null +++ b/textproc/nlohmann-json/patches/patch-include_nlohmann_detail_conversions_from_json_hpp @@ -0,0 +1,17 @@ +https://github.com/nlohmann/json/pull/4736/commits/34868f90149de02432ea758a29227a6ad74f098c + +Index: include/nlohmann/detail/conversions/from_json.hpp +--- include/nlohmann/detail/conversions/from_json.hpp.orig ++++ include/nlohmann/detail/conversions/from_json.hpp +@@ -540,7 +540,10 @@ inline void from_json(const BasicJsonType& j, std_fs:: + JSON_THROW(type_error::create(302, concat("type must be string, but is ", j.type_name()), &j)); + } + const auto& s = *j.template get_ptr(); +-#ifdef JSON_HAS_CPP_20 ++ // Checking for C++20 standard or later can be insufficient in case the ++ // library support for char8_t is either incomplete or was disabled ++ // altogether. Use the __cpp_lib_char8_t feature test instead. ++#if defined(__cpp_lib_char8_t) && (__cpp_lib_char8_t >= 201907L) + p = std_fs::path(std::u8string_view(reinterpret_cast(s.data()), s.size())); + #else + p = std_fs::u8path(s); // accepts UTF-8 encoded std::string in C++17, deprecated in C++20 diff --git a/textproc/nlohmann-json/patches/patch-include_nlohmann_detail_conversions_to_json_hpp b/textproc/nlohmann-json/patches/patch-include_nlohmann_detail_conversions_to_json_hpp new file mode 100644 index 00000000000..bfafe23ec44 --- /dev/null +++ b/textproc/nlohmann-json/patches/patch-include_nlohmann_detail_conversions_to_json_hpp @@ -0,0 +1,43 @@ +https://github.com/nlohmann/json/pull/4736/commits/34868f90149de02432ea758a29227a6ad74f098c + +Index: include/nlohmann/detail/conversions/to_json.hpp +--- include/nlohmann/detail/conversions/to_json.hpp.orig ++++ include/nlohmann/detail/conversions/to_json.hpp +@@ -15,7 +15,8 @@ + + #include // copy + #include // begin, end +-#include // string ++#include // allocator_traits ++#include // basic_string, char_traits + #include // tuple, get + #include // is_same, is_constructible, is_floating_point, is_enum, underlying_type + #include // move, forward, declval, pair +@@ -440,15 +441,21 @@ inline void to_json(BasicJsonType& j, const T& t) + } + + #if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM ++#if defined(__cpp_lib_char8_t) ++template ++inline void to_json(BasicJsonType& j, const std::basic_string& s) ++{ ++ using OtherAllocator = typename std::allocator_traits::template rebind_alloc; ++ j = std::basic_string, OtherAllocator>(s.begin(), s.end(), s.get_allocator()); ++} ++#endif ++ + template + inline void to_json(BasicJsonType& j, const std_fs::path& p) + { +-#ifdef JSON_HAS_CPP_20 +- const std::u8string s = p.u8string(); +- j = std::string(s.begin(), s.end()); +-#else +- j = p.u8string(); // returns std::string in C++17 +-#endif ++ // Returns either a std::string or a std::u8string depending whether library ++ // support for char8_t is enabled. ++ j = p.u8string(); + } + #endif + diff --git a/textproc/nlohmann-json/patches/patch-single_include_nlohmann_json_hpp b/textproc/nlohmann-json/patches/patch-single_include_nlohmann_json_hpp new file mode 100644 index 00000000000..c370f1fa9ad --- /dev/null +++ b/textproc/nlohmann-json/patches/patch-single_include_nlohmann_json_hpp @@ -0,0 +1,55 @@ +https://github.com/nlohmann/json/pull/4736/commits/34868f90149de02432ea758a29227a6ad74f098c + +Index: single_include/nlohmann/json.hpp +--- single_include/nlohmann/json.hpp.orig ++++ single_include/nlohmann/json.hpp +@@ -5325,7 +5325,10 @@ inline void from_json(const BasicJsonType& j, std_fs:: + JSON_THROW(type_error::create(302, concat("type must be string, but is ", j.type_name()), &j)); + } + const auto& s = *j.template get_ptr(); +-#ifdef JSON_HAS_CPP_20 ++ // Checking for C++20 standard or later can be insufficient in case the ++ // library support for char8_t is either incomplete or was disabled ++ // altogether. Use the __cpp_lib_char8_t feature test instead. ++#if defined(__cpp_lib_char8_t) && (__cpp_lib_char8_t >= 201907L) + p = std_fs::path(std::u8string_view(reinterpret_cast(s.data()), s.size())); + #else + p = std_fs::u8path(s); // accepts UTF-8 encoded std::string in C++17, deprecated in C++20 +@@ -5380,7 +5383,8 @@ NLOHMANN_JSON_NAMESPACE_END + + #include // copy + #include // begin, end +-#include // string ++#include // allocator_traits ++#include // basic_string, char_traits + #include // tuple, get + #include // is_same, is_constructible, is_floating_point, is_enum, underlying_type + #include // move, forward, declval, pair +@@ -6087,15 +6091,21 @@ inline void to_json(BasicJsonType& j, const T& t) + } + + #if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM ++#if defined(__cpp_lib_char8_t) ++template ++inline void to_json(BasicJsonType& j, const std::basic_string& s) ++{ ++ using OtherAllocator = typename std::allocator_traits::template rebind_alloc; ++ j = std::basic_string, OtherAllocator>(s.begin(), s.end(), s.get_allocator()); ++} ++#endif ++ + template + inline void to_json(BasicJsonType& j, const std_fs::path& p) + { +-#ifdef JSON_HAS_CPP_20 +- const std::u8string s = p.u8string(); +- j = std::string(s.begin(), s.end()); +-#else +- j = p.u8string(); // returns std::string in C++17 +-#endif ++ // Returns either a std::string or a std::u8string depending whether library ++ // support for char8_t is enabled. ++ j = p.u8string(); + } + #endif + diff --git a/textproc/nlohmann-json/patches/patch-tests_src_unit-deserialization_cpp b/textproc/nlohmann-json/patches/patch-tests_src_unit-deserialization_cpp new file mode 100644 index 00000000000..039f2639b71 --- /dev/null +++ b/textproc/nlohmann-json/patches/patch-tests_src_unit-deserialization_cpp @@ -0,0 +1,18 @@ +https://github.com/nlohmann/json/pull/4736/commits/34868f90149de02432ea758a29227a6ad74f098c + +Index: tests/src/unit-deserialization.cpp +--- tests/src/unit-deserialization.cpp.orig ++++ tests/src/unit-deserialization.cpp +@@ -1134,9 +1134,10 @@ TEST_CASE("deserialization") + } + } + +-// select the types to test - char8_t is only available in C++20 ++// select the types to test - char8_t is only available since C++20 if and only ++// if __cpp_char8_t is defined. + #define TYPE_LIST(...) __VA_ARGS__ +-#ifdef JSON_HAS_CPP_20 ++#if defined(__cpp_char8_t) && (__cpp_char8_t >= 201811L) + #define ASCII_TYPES TYPE_LIST(char, wchar_t, char16_t, char32_t, char8_t) + #else + #define ASCII_TYPES TYPE_LIST(char, wchar_t, char16_t, char32_t) diff --git a/textproc/nlohmann-json/pkg/PLIST b/textproc/nlohmann-json/pkg/PLIST index 9b7c95a3fbb..daa90621cc9 100644 --- a/textproc/nlohmann-json/pkg/PLIST +++ b/textproc/nlohmann-json/pkg/PLIST @@ -23,6 +23,7 @@ include/nlohmann/detail/iterators/iteration_proxy.hpp include/nlohmann/detail/iterators/iterator_traits.hpp include/nlohmann/detail/iterators/json_reverse_iterator.hpp include/nlohmann/detail/iterators/primitive_iterator.hpp +include/nlohmann/detail/json_custom_base_class.hpp include/nlohmann/detail/json_pointer.hpp include/nlohmann/detail/json_ref.hpp include/nlohmann/detail/macro_scope.hpp @@ -44,6 +45,7 @@ include/nlohmann/detail/output/output_adapters.hpp include/nlohmann/detail/output/serializer.hpp include/nlohmann/detail/string_concat.hpp include/nlohmann/detail/string_escape.hpp +include/nlohmann/detail/string_utils.hpp include/nlohmann/detail/value_t.hpp include/nlohmann/json.hpp include/nlohmann/json_fwd.hpp