mirror of
https://github.com/marzer/tomlplusplus.git
synced 2024-09-04 05:59:37 +00:00
fixed #187
also: - fixed #188 - fixed #189 - updated conformance tests - version bump
This commit is contained in:
parent
d00464a7bc
commit
8f31ec8aed
@ -21,13 +21,18 @@ template:
|
|||||||
|
|
||||||
-->
|
-->
|
||||||
|
|
||||||
## Unreleased
|
## v3.3.0
|
||||||
|
|
||||||
|
[Released](https://github.com/marzer/tomlplusplus/releases/tag/v3.3.0) 2023-01-29
|
||||||
|
|
||||||
#### Fixes:
|
#### Fixes:
|
||||||
|
|
||||||
- fixed null pointer dereference in parser when exceptions are disabled (#169) (@ncaklovic)
|
- fixed null pointer dereference in parser when exceptions are disabled (#169) (@ncaklovic)
|
||||||
- fixed spurious warnings in MSVC 19.34
|
- fixed spurious warnings in MSVC 19.34
|
||||||
- fixed `toml::parse_file()` on windows for non-ASCII paths
|
- fixed `toml::parse_file()` on windows for non-ASCII paths
|
||||||
|
- fixed a spurious table redefinition error (#187) (@jorisvr)
|
||||||
|
- fixed UB edge-case in integer parsing (#188) (@jorisvr)
|
||||||
|
- fixed some build issues with Apple-flavoured Clang (#189) (@eddelbuettel)
|
||||||
|
|
||||||
#### Additions:
|
#### Additions:
|
||||||
|
|
||||||
|
@ -2262,14 +2262,21 @@ TOML_IMPL_NAMESPACE_START
|
|||||||
}
|
}
|
||||||
|
|
||||||
// range check
|
// range check
|
||||||
if TOML_UNLIKELY(result > static_cast<uint64_t>((std::numeric_limits<int64_t>::max)()) + (sign < 0 ? 1ull : 0ull))
|
static constexpr auto i64_max = static_cast<uint64_t>((std::numeric_limits<int64_t>::max)());
|
||||||
|
if TOML_UNLIKELY(result > i64_max + (sign < 0 ? 1u : 0u))
|
||||||
set_error_and_return_default("'"sv,
|
set_error_and_return_default("'"sv,
|
||||||
traits::full_prefix,
|
traits::full_prefix,
|
||||||
std::string_view{ digits, length },
|
std::string_view{ digits, length },
|
||||||
"' is not representable in 64 bits"sv);
|
"' is not representable in 64 bits"sv);
|
||||||
|
|
||||||
if constexpr (traits::is_signed)
|
if constexpr (traits::is_signed)
|
||||||
|
{
|
||||||
|
// avoid signed multiply UB when parsing INT64_MIN
|
||||||
|
if TOML_UNLIKELY(sign < 0 && result == i64_max + 1u)
|
||||||
|
return (std::numeric_limits<int64_t>::min)();
|
||||||
|
|
||||||
return static_cast<int64_t>(result) * sign;
|
return static_cast<int64_t>(result) * sign;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return static_cast<int64_t>(result);
|
return static_cast<int64_t>(result);
|
||||||
}
|
}
|
||||||
@ -3252,13 +3259,28 @@ TOML_IMPL_NAMESPACE_START
|
|||||||
|
|
||||||
else if (auto tbl = matching_node.as_table(); !is_arr && tbl && !implicit_tables.empty())
|
else if (auto tbl = matching_node.as_table(); !is_arr && tbl && !implicit_tables.empty())
|
||||||
{
|
{
|
||||||
if (auto found = impl::find(implicit_tables.begin(), implicit_tables.end(), tbl);
|
if (auto found = impl::find(implicit_tables.begin(), implicit_tables.end(), tbl); found)
|
||||||
found && (tbl->empty() || tbl->is_homogeneous<table>()))
|
|
||||||
{
|
{
|
||||||
implicit_tables.erase(implicit_tables.cbegin() + (found - implicit_tables.data()));
|
bool ok = true;
|
||||||
tbl->source_.begin = header_begin_pos;
|
if (!tbl->empty())
|
||||||
tbl->source_.end = header_end_pos;
|
{
|
||||||
return tbl;
|
for (auto& [_, child] : *tbl)
|
||||||
|
{
|
||||||
|
if (!child.is_table() && !child.is_array_of_tables())
|
||||||
|
{
|
||||||
|
ok = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ok)
|
||||||
|
{
|
||||||
|
implicit_tables.erase(implicit_tables.cbegin() + (found - implicit_tables.data()));
|
||||||
|
tbl->source_.begin = header_begin_pos;
|
||||||
|
tbl->source_.end = header_end_pos;
|
||||||
|
return tbl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -515,7 +515,7 @@
|
|||||||
__pragma(warning(push)) \
|
__pragma(warning(push)) \
|
||||||
static_assert(true)
|
static_assert(true)
|
||||||
|
|
||||||
#if TOML_HAS_INCLUDE(<CodeAnalysis / Warnings.h>)
|
#if TOML_HAS_INCLUDE(<CodeAnalysis/Warnings.h>)
|
||||||
#pragma warning(push, 0)
|
#pragma warning(push, 0)
|
||||||
#include <CodeAnalysis/Warnings.h>
|
#include <CodeAnalysis/Warnings.h>
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define TOML_LIB_MAJOR 3
|
#define TOML_LIB_MAJOR 3
|
||||||
#define TOML_LIB_MINOR 2
|
#define TOML_LIB_MINOR 3
|
||||||
#define TOML_LIB_PATCH 0
|
#define TOML_LIB_PATCH 0
|
||||||
|
|
||||||
#define TOML_LANG_MAJOR 1
|
#define TOML_LANG_MAJOR 1
|
||||||
|
@ -7,9 +7,6 @@
|
|||||||
|
|
||||||
#define INCLUDE_TOMLPLUSPLUS_H // old guard name used pre-v3
|
#define INCLUDE_TOMLPLUSPLUS_H // old guard name used pre-v3
|
||||||
|
|
||||||
//# Note: these would be included transitively as with any normal C++ project but
|
|
||||||
//# they're listed explicitly here because this file is used as the source for generate_single_header.py.
|
|
||||||
|
|
||||||
#include "impl/preprocessor.h"
|
#include "impl/preprocessor.h"
|
||||||
|
|
||||||
TOML_PUSH_WARNINGS;
|
TOML_PUSH_WARNINGS;
|
||||||
@ -24,12 +21,12 @@ TOML_DISABLE_SUGGEST_ATTR_WARNINGS;
|
|||||||
#pragma warning(disable : 4251) // dll exports for std lib types
|
#pragma warning(disable : 4251) // dll exports for std lib types
|
||||||
#endif
|
#endif
|
||||||
#elif TOML_CLANG
|
#elif TOML_CLANG
|
||||||
#pragma clang diagnostic ignored "-Wheader-hygiene"
|
TOML_PRAGMA_CLANG(diagnostic ignored "-Wheader-hygiene")
|
||||||
#if TOML_CLANG >= 12
|
#if TOML_CLANG >= 12
|
||||||
#pragma clang diagnostic ignored "-Wc++20-extensions"
|
TOML_PRAGMA_CLANG(diagnostic ignored "-Wc++20-extensions")
|
||||||
#endif
|
#endif
|
||||||
#if TOML_CLANG == 13 && !defined(__APPLE__)
|
#if TOML_CLANG == 13
|
||||||
#pragma clang diagnostic ignored "-Wreserved-identifier"
|
TOML_PRAGMA_CLANG(diagnostic ignored "-Wreserved-identifier")
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -167,122 +167,285 @@ namespace
|
|||||||
|
|
||||||
TEST_CASE("conformance - iarna/invalid")
|
TEST_CASE("conformance - iarna/invalid")
|
||||||
{
|
{
|
||||||
parsing_should_fail(FILE_LINE_ARGS, array_of_tables_1); // array-of-tables-1
|
SECTION("array-of-tables-1")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, array_of_tables_1); // array-of-tables-1
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, array_of_tables_2); // array-of-tables-2
|
SECTION("array-of-tables-2")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, array_of_tables_2); // array-of-tables-2
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, bare_key_1); // bare-key-1
|
SECTION("bare-key-1")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, bare_key_1); // bare-key-1
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, bare_key_2); // bare-key-2
|
SECTION("bare-key-2")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, bare_key_2); // bare-key-2
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, bare_key_3); // bare-key-3
|
SECTION("bare-key-3")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, bare_key_3); // bare-key-3
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, comment_control_1); // comment-control-1
|
SECTION("comment-control-1")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, comment_control_1); // comment-control-1
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, comment_control_2); // comment-control-2
|
SECTION("comment-control-2")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, comment_control_2); // comment-control-2
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, comment_control_3); // comment-control-3
|
SECTION("comment-control-3")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, comment_control_3); // comment-control-3
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, comment_control_4); // comment-control-4
|
SECTION("comment-control-4")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, comment_control_4); // comment-control-4
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, inline_table_imutable_1); // inline-table-imutable-1
|
SECTION("inline-table-imutable-1")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, inline_table_imutable_1); // inline-table-imutable-1
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, inline_table_imutable_2); // inline-table-imutable-2
|
SECTION("inline-table-imutable-2")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, inline_table_imutable_2); // inline-table-imutable-2
|
||||||
|
}
|
||||||
|
|
||||||
#if !TOML_LANG_UNRELEASED
|
#if !TOML_LANG_UNRELEASED
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, inline_table_trailing_comma); // inline-table-trailing-comma
|
SECTION("inline-table-trailing-comma")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, inline_table_trailing_comma); // inline-table-trailing-comma
|
||||||
|
}
|
||||||
|
|
||||||
#endif // !TOML_LANG_UNRELEASED
|
#endif // !TOML_LANG_UNRELEASED
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, int_0_padded); // int-0-padded
|
SECTION("int-0-padded")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, int_0_padded); // int-0-padded
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, int_signed_bin); // int-signed-bin
|
SECTION("int-signed-bin")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, int_signed_bin); // int-signed-bin
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, int_signed_hex); // int-signed-hex
|
SECTION("int-signed-hex")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, int_signed_hex); // int-signed-hex
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, int_signed_oct); // int-signed-oct
|
SECTION("int-signed-oct")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, int_signed_oct); // int-signed-oct
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, key_value_pair_1); // key-value-pair-1
|
SECTION("key-value-pair-1")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, key_value_pair_1); // key-value-pair-1
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, key_value_pair_2); // key-value-pair-2
|
SECTION("key-value-pair-2")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, key_value_pair_2); // key-value-pair-2
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, multiple_dot_key); // multiple-dot-key
|
SECTION("multiple-dot-key")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, multiple_dot_key); // multiple-dot-key
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, multiple_key); // multiple-key
|
SECTION("multiple-key")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, multiple_key); // multiple-key
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, no_key_name); // no-key-name
|
SECTION("no-key-name")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, no_key_name); // no-key-name
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, string_basic_control_1); // string-basic-control-1
|
SECTION("string-basic-control-1")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, string_basic_control_1); // string-basic-control-1
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, string_basic_control_2); // string-basic-control-2
|
SECTION("string-basic-control-2")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, string_basic_control_2); // string-basic-control-2
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, string_basic_control_3); // string-basic-control-3
|
SECTION("string-basic-control-3")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, string_basic_control_3); // string-basic-control-3
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, string_basic_control_4); // string-basic-control-4
|
SECTION("string-basic-control-4")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, string_basic_control_4); // string-basic-control-4
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_control_1); // string-basic-multiline-control-1
|
SECTION("string-basic-multiline-control-1")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_control_1); // string-basic-multiline-control-1
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_control_2); // string-basic-multiline-control-2
|
SECTION("string-basic-multiline-control-2")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_control_2); // string-basic-multiline-control-2
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_control_3); // string-basic-multiline-control-3
|
SECTION("string-basic-multiline-control-3")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_control_3); // string-basic-multiline-control-3
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_control_4); // string-basic-multiline-control-4
|
SECTION("string-basic-multiline-control-4")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_control_4); // string-basic-multiline-control-4
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS,
|
SECTION("string-basic-multiline-invalid-backslash")
|
||||||
string_basic_multiline_invalid_backslash); // string-basic-multiline-invalid-backslash
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS,
|
||||||
|
string_basic_multiline_invalid_backslash); // string-basic-multiline-invalid-backslash
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(
|
SECTION("string-basic-multiline-out-of-range-unicode-escape-1")
|
||||||
FILE_LINE_ARGS,
|
{
|
||||||
string_basic_multiline_out_of_range_unicode_escape_1); // string-basic-multiline-out-of-range-unicode-escape-1
|
parsing_should_fail(
|
||||||
|
FILE_LINE_ARGS,
|
||||||
|
string_basic_multiline_out_of_range_unicode_escape_1); // string-basic-multiline-out-of-range-unicode-escape-1
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(
|
SECTION("string-basic-multiline-out-of-range-unicode-escape-2")
|
||||||
FILE_LINE_ARGS,
|
{
|
||||||
string_basic_multiline_out_of_range_unicode_escape_2); // string-basic-multiline-out-of-range-unicode-escape-2
|
parsing_should_fail(
|
||||||
|
FILE_LINE_ARGS,
|
||||||
|
string_basic_multiline_out_of_range_unicode_escape_2); // string-basic-multiline-out-of-range-unicode-escape-2
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_quotes); // string-basic-multiline-quotes
|
SECTION("string-basic-multiline-quotes")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_quotes); // string-basic-multiline-quotes
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_unknown_escape); // string-basic-multiline-unknown-escape
|
SECTION("string-basic-multiline-unknown-escape")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS,
|
||||||
|
string_basic_multiline_unknown_escape); // string-basic-multiline-unknown-escape
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS,
|
SECTION("string-basic-out-of-range-unicode-escape-1")
|
||||||
string_basic_out_of_range_unicode_escape_1); // string-basic-out-of-range-unicode-escape-1
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS,
|
||||||
|
string_basic_out_of_range_unicode_escape_1); // string-basic-out-of-range-unicode-escape-1
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS,
|
SECTION("string-basic-out-of-range-unicode-escape-2")
|
||||||
string_basic_out_of_range_unicode_escape_2); // string-basic-out-of-range-unicode-escape-2
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS,
|
||||||
|
string_basic_out_of_range_unicode_escape_2); // string-basic-out-of-range-unicode-escape-2
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, string_basic_unknown_escape); // string-basic-unknown-escape
|
SECTION("string-basic-unknown-escape")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, string_basic_unknown_escape); // string-basic-unknown-escape
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, string_literal_control_1); // string-literal-control-1
|
SECTION("string-literal-control-1")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, string_literal_control_1); // string-literal-control-1
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, string_literal_control_2); // string-literal-control-2
|
SECTION("string-literal-control-2")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, string_literal_control_2); // string-literal-control-2
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, string_literal_control_3); // string-literal-control-3
|
SECTION("string-literal-control-3")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, string_literal_control_3); // string-literal-control-3
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, string_literal_control_4); // string-literal-control-4
|
SECTION("string-literal-control-4")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, string_literal_control_4); // string-literal-control-4
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_control_1); // string-literal-multiline-control-1
|
SECTION("string-literal-multiline-control-1")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_control_1); // string-literal-multiline-control-1
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_control_2); // string-literal-multiline-control-2
|
SECTION("string-literal-multiline-control-2")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_control_2); // string-literal-multiline-control-2
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_control_3); // string-literal-multiline-control-3
|
SECTION("string-literal-multiline-control-3")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_control_3); // string-literal-multiline-control-3
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_control_4); // string-literal-multiline-control-4
|
SECTION("string-literal-multiline-control-4")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_control_4); // string-literal-multiline-control-4
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_quotes); // string-literal-multiline-quotes
|
SECTION("string-literal-multiline-quotes")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_quotes); // string-literal-multiline-quotes
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, table_1); // table-1
|
SECTION("table-1")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, table_1); // table-1
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, table_2); // table-2
|
SECTION("table-2")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, table_2); // table-2
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, table_3); // table-3
|
SECTION("table-3")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, table_3); // table-3
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, table_4); // table-4
|
SECTION("table-4")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, table_4); // table-4
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, table_invalid_1); // table-invalid-1
|
SECTION("table-invalid-1")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, table_invalid_1); // table-invalid-1
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, table_invalid_2); // table-invalid-2
|
SECTION("table-invalid-2")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, table_invalid_2); // table-invalid-2
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, table_invalid_3); // table-invalid-3
|
SECTION("table-invalid-3")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, table_invalid_3); // table-invalid-3
|
||||||
|
}
|
||||||
|
|
||||||
parsing_should_fail(FILE_LINE_ARGS, table_invalid_4); // table-invalid-4
|
SECTION("table-invalid-4")
|
||||||
|
{
|
||||||
|
parsing_should_fail(FILE_LINE_ARGS, table_invalid_4); // table-invalid-4
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -382,4 +382,15 @@ b = []
|
|||||||
parse_expected_value(FILE_LINE_ARGS, "6.9342"sv, 6.9342);
|
parse_expected_value(FILE_LINE_ARGS, "6.9342"sv, 6.9342);
|
||||||
parse_expected_value(FILE_LINE_ARGS, "-995.9214"sv, -995.9214);
|
parse_expected_value(FILE_LINE_ARGS, "-995.9214"sv, -995.9214);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SECTION("tomlplusplus/issues/187") // https://github.com/marzer/tomlplusplus/issues/187
|
||||||
|
{
|
||||||
|
parsing_should_succeed(FILE_LINE_ARGS, R"(
|
||||||
|
[[a.b]]
|
||||||
|
x = 1
|
||||||
|
|
||||||
|
[a]
|
||||||
|
y = 2
|
||||||
|
)"sv);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
46
toml.hpp
46
toml.hpp
@ -541,7 +541,7 @@
|
|||||||
__pragma(warning(push)) \
|
__pragma(warning(push)) \
|
||||||
static_assert(true)
|
static_assert(true)
|
||||||
|
|
||||||
#if TOML_HAS_INCLUDE(<CodeAnalysis / Warnings.h>)
|
#if TOML_HAS_INCLUDE(<CodeAnalysis/Warnings.h>)
|
||||||
#pragma warning(push, 0)
|
#pragma warning(push, 0)
|
||||||
#include <CodeAnalysis/Warnings.h>
|
#include <CodeAnalysis/Warnings.h>
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
@ -1115,12 +1115,12 @@ TOML_DISABLE_SUGGEST_ATTR_WARNINGS;
|
|||||||
#pragma warning(disable : 4251) // dll exports for std lib types
|
#pragma warning(disable : 4251) // dll exports for std lib types
|
||||||
#endif
|
#endif
|
||||||
#elif TOML_CLANG
|
#elif TOML_CLANG
|
||||||
#pragma clang diagnostic ignored "-Wheader-hygiene"
|
TOML_PRAGMA_CLANG(diagnostic ignored "-Wheader-hygiene")
|
||||||
#if TOML_CLANG >= 12
|
#if TOML_CLANG >= 12
|
||||||
#pragma clang diagnostic ignored "-Wc++20-extensions"
|
TOML_PRAGMA_CLANG(diagnostic ignored "-Wc++20-extensions")
|
||||||
#endif
|
#endif
|
||||||
#if TOML_CLANG == 13 && !defined(__APPLE__)
|
#if TOML_CLANG == 13
|
||||||
#pragma clang diagnostic ignored "-Wreserved-identifier"
|
TOML_PRAGMA_CLANG(diagnostic ignored "-Wreserved-identifier")
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -14262,14 +14262,21 @@ TOML_IMPL_NAMESPACE_START
|
|||||||
}
|
}
|
||||||
|
|
||||||
// range check
|
// range check
|
||||||
if TOML_UNLIKELY(result > static_cast<uint64_t>((std::numeric_limits<int64_t>::max)()) + (sign < 0 ? 1ull : 0ull))
|
static constexpr auto i64_max = static_cast<uint64_t>((std::numeric_limits<int64_t>::max)());
|
||||||
|
if TOML_UNLIKELY(result > i64_max + (sign < 0 ? 1u : 0u))
|
||||||
set_error_and_return_default("'"sv,
|
set_error_and_return_default("'"sv,
|
||||||
traits::full_prefix,
|
traits::full_prefix,
|
||||||
std::string_view{ digits, length },
|
std::string_view{ digits, length },
|
||||||
"' is not representable in 64 bits"sv);
|
"' is not representable in 64 bits"sv);
|
||||||
|
|
||||||
if constexpr (traits::is_signed)
|
if constexpr (traits::is_signed)
|
||||||
|
{
|
||||||
|
// avoid signed multiply UB when parsing INT64_MIN
|
||||||
|
if TOML_UNLIKELY(sign < 0 && result == i64_max + 1u)
|
||||||
|
return (std::numeric_limits<int64_t>::min)();
|
||||||
|
|
||||||
return static_cast<int64_t>(result) * sign;
|
return static_cast<int64_t>(result) * sign;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return static_cast<int64_t>(result);
|
return static_cast<int64_t>(result);
|
||||||
}
|
}
|
||||||
@ -15251,13 +15258,28 @@ TOML_IMPL_NAMESPACE_START
|
|||||||
|
|
||||||
else if (auto tbl = matching_node.as_table(); !is_arr && tbl && !implicit_tables.empty())
|
else if (auto tbl = matching_node.as_table(); !is_arr && tbl && !implicit_tables.empty())
|
||||||
{
|
{
|
||||||
if (auto found = impl::find(implicit_tables.begin(), implicit_tables.end(), tbl);
|
if (auto found = impl::find(implicit_tables.begin(), implicit_tables.end(), tbl); found)
|
||||||
found && (tbl->empty() || tbl->is_homogeneous<table>()))
|
|
||||||
{
|
{
|
||||||
implicit_tables.erase(implicit_tables.cbegin() + (found - implicit_tables.data()));
|
bool ok = true;
|
||||||
tbl->source_.begin = header_begin_pos;
|
if (!tbl->empty())
|
||||||
tbl->source_.end = header_end_pos;
|
{
|
||||||
return tbl;
|
for (auto& [_, child] : *tbl)
|
||||||
|
{
|
||||||
|
if (!child.is_table() && !child.is_array_of_tables())
|
||||||
|
{
|
||||||
|
ok = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ok)
|
||||||
|
{
|
||||||
|
implicit_tables.erase(implicit_tables.cbegin() + (found - implicit_tables.data()));
|
||||||
|
tbl->source_.begin = header_begin_pos;
|
||||||
|
tbl->source_.end = header_end_pos;
|
||||||
|
return tbl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -470,6 +470,10 @@ def load_burnsushi_tests(tests):
|
|||||||
))
|
))
|
||||||
add_condition(tests['valid']['burntsushi'], 'TOML_LANG_UNRELEASED', (
|
add_condition(tests['valid']['burntsushi'], 'TOML_LANG_UNRELEASED', (
|
||||||
'string-escape-esc', # \e in strings
|
'string-escape-esc', # \e in strings
|
||||||
|
'datetime-no-seconds', # omitting seconds from date-times
|
||||||
|
'inline-table-newline',
|
||||||
|
'key-unicode',
|
||||||
|
'string-hex-escape'
|
||||||
))
|
))
|
||||||
|
|
||||||
tests['invalid']['burntsushi'] = load_tests(Path(root_dir, 'invalid'), False)
|
tests['invalid']['burntsushi'] = load_tests(Path(root_dir, 'invalid'), False)
|
||||||
@ -575,6 +579,8 @@ def write_test_file(name, all_tests):
|
|||||||
write('')
|
write('')
|
||||||
write(f'#if {condition}');
|
write(f'#if {condition}');
|
||||||
for test in tests:
|
for test in tests:
|
||||||
|
write('')
|
||||||
|
write(f'\tSECTION("{test.name()}") {{')
|
||||||
write('')
|
write('')
|
||||||
expected = test.expected()
|
expected = test.expected()
|
||||||
if isinstance(expected, bool):
|
if isinstance(expected, bool):
|
||||||
@ -589,6 +595,9 @@ def write_test_file(name, all_tests):
|
|||||||
write(f'\t\tconst auto expected = {s};')
|
write(f'\t\tconst auto expected = {s};')
|
||||||
write('\t\tREQUIRE(tbl == expected);')
|
write('\t\tREQUIRE(tbl == expected);')
|
||||||
write('\t});')
|
write('\t});')
|
||||||
|
write('')
|
||||||
|
write('\t}')
|
||||||
|
write('')
|
||||||
if condition != '':
|
if condition != '':
|
||||||
write('')
|
write('')
|
||||||
write(f'#endif // {condition}');
|
write(f'#endif // {condition}');
|
||||||
|
Loading…
Reference in New Issue
Block a user