From dc36a219e5572f034080b894fec6893a02ddeafa Mon Sep 17 00:00:00 2001 From: Moritz Geier Date: Mon, 22 Apr 2024 15:17:52 +0200 Subject: [PATCH 1/2] Fix: iterator is extended over end of string if no match occurs with `dfa_match` --- include/ctpg/ctpg.hpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/ctpg/ctpg.hpp b/include/ctpg/ctpg.hpp index 9ff5905..a01c606 100644 --- a/include/ctpg/ctpg.hpp +++ b/include/ctpg/ctpg.hpp @@ -2940,7 +2940,6 @@ class parser< } ps.current_term_idx = res.term_idx; - ps.current_end_it = ps.current_it + res.len; if (ps.current_term_idx == uninitialized16) { @@ -2949,6 +2948,7 @@ class parser< } else { + ps.current_end_it = ps.current_it + res.len; trace_recognized_term(ps); } @@ -3487,7 +3487,13 @@ namespace regex constexpr bool match(match_options opts, const Buffer& buf, Stream& s) const { auto res = dfa_match(sm, opts, source_point{}, buf.begin(), buf.end(), s); - auto end = buf.begin() + res.len; + + Buffer::iterator end; + if (res.len == uninitialized16) + end = buf.end(); + else + end = buf.begin() + res.len; + if (res.term_idx == 0 && end == buf.end()) return true; else From 2471e94855a21a8837e2eb2287311ff6807026a4 Mon Sep 17 00:00:00 2001 From: Moritz Geier Date: Fri, 26 Apr 2024 07:30:03 +0200 Subject: [PATCH 2/2] FIX: Fixed occational compilation error --- include/ctpg/ctpg.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/ctpg/ctpg.hpp b/include/ctpg/ctpg.hpp index a01c606..36d85c9 100644 --- a/include/ctpg/ctpg.hpp +++ b/include/ctpg/ctpg.hpp @@ -3488,7 +3488,7 @@ namespace regex { auto res = dfa_match(sm, opts, source_point{}, buf.begin(), buf.end(), s); - Buffer::iterator end; + typename Buffer::iterator end; if (res.len == uninitialized16) end = buf.end(); else