diff options
author | Spartan322 <Megacake1234@gmail.com> | 2024-07-21 03:02:30 +0200 |
---|---|---|
committer | Spartan322 <Megacake1234@gmail.com> | 2024-07-22 02:49:25 +0200 |
commit | a07c64148eb60b886f92caa46a9c687240ec420c (patch) | |
tree | e43aae271fe5aa75f1b0c918c1428e7f766a14f8 /src/openvic-dataloader/AbstractSyntaxTree.hpp | |
parent | ba8addc72595607206da654bc79c994121b7a3ae (diff) |
Add backslash identifier support to v2scriptadd/backslash-identifier
Add buffer::char_type size multiplier to max file size of string intern buffer
Fix list grammar segfaults
Fix diagnostic logger intern segfaults from buffer reallocation
Fix non-string-supported CSV parser not supporting Victoria 2 CSV escaping behavior
Diffstat (limited to 'src/openvic-dataloader/AbstractSyntaxTree.hpp')
-rw-r--r-- | src/openvic-dataloader/AbstractSyntaxTree.hpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/openvic-dataloader/AbstractSyntaxTree.hpp b/src/openvic-dataloader/AbstractSyntaxTree.hpp index ade1c82..f9f5796 100644 --- a/src/openvic-dataloader/AbstractSyntaxTree.hpp +++ b/src/openvic-dataloader/AbstractSyntaxTree.hpp @@ -3,6 +3,7 @@ #include <concepts> #include <cstdio> #include <string_view> +#include <type_traits> #include <utility> #include <openvic-dataloader/NodeLocation.hpp> @@ -51,12 +52,12 @@ namespace ovdl { using node_type = typename file_type::node_type; explicit BasicAbstractSyntaxTree(file_type&& file) - : AbstractSyntaxTree(file.size()), + : AbstractSyntaxTree(file.size() * file.visit_buffer([](auto&& buffer) -> size_t { return sizeof(typename std::decay_t<decltype(buffer)>::char_type); })), _file { std::move(file) } {} template<typename Encoding, typename MemoryResource = void> explicit BasicAbstractSyntaxTree(lexy::buffer<Encoding, MemoryResource>&& buffer) - : AbstractSyntaxTree(buffer.size()), + : AbstractSyntaxTree(buffer.size() * sizeof(Encoding::char_type)), _file { std::move(buffer) } {} void set_location(const node_type* n, NodeLocation loc) { |