From d8fdf4e1e50fab430b99f6d25a7635d49f5ef97c Mon Sep 17 00:00:00 2001 From: Mark Gillard Date: Sun, 24 May 2020 13:42:15 +0300 Subject: [PATCH] fixed weird overflow with BOMs in char8 mode --- include/toml++/toml_utf8_streams.h | 4 ++-- tests/tests.h | 10 +--------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/include/toml++/toml_utf8_streams.h b/include/toml++/toml_utf8_streams.h index 61817f3..8da3e14 100644 --- a/include/toml++/toml_utf8_streams.h +++ b/include/toml++/toml_utf8_streams.h @@ -79,13 +79,13 @@ namespace toml::impl using stream_traits = typename std::remove_pointer_t::traits_type; const auto initial_pos = source->tellg(); size_t bom_pos{}; - char bom[3]; + Char bom[3]; for (; bom_pos < 3_sz && *source; bom_pos++) { const auto next = source->get(); if (next == stream_traits::eof()) break; - bom[bom_pos] = static_cast(next); + bom[bom_pos] = static_cast(next); } if (!*source || bom_pos < 3_sz || memcmp(utf8_byte_order_mark.data(), bom, 3_sz) != 0) source->seekg(initial_pos); diff --git a/tests/tests.h b/tests/tests.h index 2a58565..3f6705f 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -36,15 +36,7 @@ TOML_POP_WARNINGS #define FILE_LINE_ARGS std::string_view{ __FILE__ }, __LINE__ #define S(str) TOML_STRING_PREFIX(str) - -// some tests include a byte-order-mark "just because", but there's some weird interplay -// when using char8 mode that I can't figure out. Char8 mode is 'experimental' so I don't mind -// that BOMs might cause failures in this mode- it's a 'buyer beware' feature! -#if !TOML_CHAR_8_STRINGS - #define BOM_PREFIX "\xEF\xBB\xBF" -#else - #define BOM_PREFIX -#endif +#define BOM_PREFIX "\xEF\xBB\xBF" TOML_PUSH_WARNINGS TOML_DISABLE_FLOAT_WARNINGS