print-null-string.patch (1804B)
1 diff --git a/include/fmt/format.h b/include/fmt/format.h 2 --- a/include/fmt/format.h 3 +++ b/include/fmt/format.h 4 @@ -2294,17 +2294,17 @@ FMT_CONSTEXPR auto write(OutputIt out, b 5 const format_specs& specs, locale_ref) -> OutputIt { 6 return write<Char>(out, s, specs); 7 } 8 template <typename Char, typename OutputIt> 9 FMT_CONSTEXPR auto write(OutputIt out, const Char* s, const format_specs& specs, 10 locale_ref) -> OutputIt { 11 if (specs.type() == presentation_type::pointer) 12 return write_ptr<Char>(out, bit_cast<uintptr_t>(s), &specs); 13 - if (!s) report_error("string pointer is null"); 14 + if (!s) return write_bytes<Char>(out, "(null)", specs); 15 return write<Char>(out, basic_string_view<Char>(s), specs, {}); 16 } 17 18 template <typename Char, typename OutputIt, typename T, 19 FMT_ENABLE_IF(is_integral<T>::value && 20 !std::is_same<T, bool>::value && 21 !std::is_same<T, Char>::value)> 22 FMT_CONSTEXPR auto write(OutputIt out, T value) -> OutputIt { 23 @@ -3573,18 +3573,17 @@ FMT_CONSTEXPR auto write(OutputIt out, C 24 auto it = reserve(out, 1); 25 *it++ = value; 26 return base_iterator(out, it); 27 } 28 29 template <typename Char, typename OutputIt> 30 FMT_CONSTEXPR20 auto write(OutputIt out, const Char* value) -> OutputIt { 31 if (value) return write(out, basic_string_view<Char>(value)); 32 - report_error("string pointer is null"); 33 - return out; 34 + return write_bytes<Char>(out, "(null)"); 35 } 36 37 template <typename Char, typename OutputIt, typename T, 38 FMT_ENABLE_IF(std::is_same<T, void>::value)> 39 auto write(OutputIt out, const T* value, const format_specs& specs = {}, 40 locale_ref = {}) -> OutputIt { 41 return write_ptr<Char>(out, bit_cast<uintptr_t>(value), &specs); 42 }