head 1.1; access; symbols pkgsrc-2026Q1:1.1.0.8 pkgsrc-2026Q1-base:1.1 pkgsrc-2025Q4:1.1.0.6 pkgsrc-2025Q4-base:1.1 pkgsrc-2025Q3:1.1.0.4 pkgsrc-2025Q3-base:1.1 pkgsrc-2025Q2:1.1.0.2 pkgsrc-2025Q2-base:1.1; locks; strict; comment @// @; 1.1 date 2025.04.27.20.07.25; author wiz; state Exp; branches; next ; commitid WmI80Rd64H3BdJSF; desc @@ 1.1 log @nlohmann-json: add post-release patches from upstream Fixes build of openrct2. Bump PKGREVISION. @ text @$NetBSD$ https://github.com/nlohmann/json/pull/4736 https://github.com/nlohmann/json/pull/4763 --- single_include/nlohmann/json.hpp.orig 2025-04-11 08:42:28.000000000 +0000 +++ single_include/nlohmann/json.hpp @@@@ -4497,6 +4497,10 @@@@ NLOHMANN_JSON_NAMESPACE_END #pragma clang diagnostic ignored "-Wweak-vtables" #endif +#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM + #include // u8string_view +#endif + NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { @@@@ -5325,7 +5329,10 @@@@ inline void from_json(const BasicJsonTyp 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 +5387,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 +6095,21 @@@@ inline void to_json(BasicJsonType& j, co } #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 @