From ca353d26fa21eebd0eef0b8511664c396d81adfd Mon Sep 17 00:00:00 2001 From: Joao Paulo Magalhaes Date: Tue, 21 Oct 2025 17:45:57 +0100 Subject: [PATCH] Dbg prints: fix char sign problem in armv4/armv5 --- src/c4/yml/common.hpp | 11 +++++++++++ src/c4/yml/detail/dbgprint.hpp | 14 +++++++------- src/c4/yml/parse_engine.def.hpp | 15 --------------- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/c4/yml/common.hpp b/src/c4/yml/common.hpp index 2484c51d..f76c9d35 100644 --- a/src/c4/yml/common.hpp +++ b/src/c4/yml/common.hpp @@ -589,6 +589,16 @@ public: (buf) = nullptr; \ } while(false) +namespace detail { +template +struct _charconstant_t // is there a better way to do this? + : public std::conditional::value, + std::integral_constant(unsignedval)>, + std::integral_constant>::type +{}; +#define _RYML_CHCONST(signedval, unsignedval) ::c4::yml::detail::_charconstant_t::value +} // namespace detail + inline csubstr _c4prc(const char &C4_RESTRICT c) // pass by reference! { switch(c) @@ -604,6 +614,7 @@ inline csubstr _c4prc(const char &C4_RESTRICT c) // pass by reference! default: return csubstr(&c, 1); } } + /// @endcond C4_SUPPRESS_WARNING_GCC_POP diff --git a/src/c4/yml/detail/dbgprint.hpp b/src/c4/yml/detail/dbgprint.hpp index cb38a375..04ef42ff 100644 --- a/src/c4/yml/detail/dbgprint.hpp +++ b/src/c4/yml/detail/dbgprint.hpp @@ -125,27 +125,27 @@ inline C4_NO_INLINE void __c4presc(csubstr s, bool keep_newlines=false) case '\v' : _dbg_dumper(s.range(prev, i)); _dbg_dumper("\\v"); prev = i+1; break; case '\a' : _dbg_dumper(s.range(prev, i)); _dbg_dumper("\\a"); prev = i+1; break; case '\x1b': _dbg_dumper(s.range(prev, i)); _dbg_dumper("\\x1b"); prev = i+1; break; - case -0x3e/*0xc2u*/: + case _RYML_CHCONST(-0x3e, 0xc2): if(i+1 < s.len) { - if(s.str[i+1] == -0x60/*0xa0u*/) + if(s.str[i+1] == _RYML_CHCONST(-0x60, 0xa0)) { _dbg_dumper(s.range(prev, i)); _dbg_dumper("\\_"); prev = i+1; } - else if(s.str[i+1] == -0x7b/*0x85u*/) + else if(s.str[i+1] == _RYML_CHCONST(-0x7b,0x85)) { _dbg_dumper(s.range(prev, i)); _dbg_dumper("\\N"); prev = i+1; } } break; - case -0x1e/*0xe2u*/: - if(i+2 < s.len && s.str[i+1] == -0x80/*0x80u*/) + case _RYML_CHCONST(-0x1e, 0xe2): + if(i+2 < s.len && s.str[i+1] == _RYML_CHCONST(-0x80,0x80)) { - if(s.str[i+2] == -0x58/*0xa8u*/) + if(s.str[i+2] == _RYML_CHCONST(-0x58,0xa8)) { _dbg_dumper(s.range(prev, i)); _dbg_dumper("\\L"); prev = i+1; } - else if(s.str[i+2] == -0x57/*0xa9u*/) + else if(s.str[i+2] == _RYML_CHCONST(-0x57,0xa9)) { _dbg_dumper(s.range(prev, i)); _dbg_dumper("\\P"); prev = i+1; } diff --git a/src/c4/yml/parse_engine.def.hpp b/src/c4/yml/parse_engine.def.hpp index e4035978..85aba2a0 100644 --- a/src/c4/yml/parse_engine.def.hpp +++ b/src/c4/yml/parse_engine.def.hpp @@ -2592,21 +2592,6 @@ FilterResult ParseEngine::filter_scalar_squoted_in_place(substr ds #define _c4dbgfdq(...) #endif -/// @cond dev - -namespace detail { -// is there a better way to do this? -template -struct _charconstant_t - : public std::conditional::value, - std::integral_constant(unsignedval)>, - std::integral_constant>::type -{}; -#define _RYML_CHCONST(signedval, unsignedval) ::c4::yml::detail::_charconstant_t::value -} // namespace detail - -/// @endcond - template template void ParseEngine::_filter_nl_dquoted(FilterProcessor &C4_RESTRICT proc)