From 86208ed9e9033a752b61116eac11905a1a6d107b Mon Sep 17 00:00:00 2001 From: yhirose Date: Sun, 30 Apr 2023 10:29:55 +0900 Subject: [PATCH] Fix #269 and #273 --- peglib.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/peglib.h b/peglib.h index 7152e4e..76c9287 100644 --- a/peglib.h +++ b/peglib.h @@ -1003,6 +1003,9 @@ public: size_t len = static_cast(-1); if (!for_label_) { c.cut_stack.push_back(false); } + auto se = scope_exit([&]() { + if (!for_label_) { c.cut_stack.pop_back(); } + }); size_t id = 0; for (const auto &ope : opes_) { @@ -1030,8 +1033,6 @@ public: id++; } - if (!for_label_) { c.cut_stack.pop_back(); } - return len; }