summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2022-01-21 23:44:50 +0330
committerLinus Groh <mail@linusgroh.de>2022-01-22 00:35:49 +0000
commitbc20e4f71d41f2ebcc56351daecb826544b15df5 (patch)
tree51b5023266fe69b8d9c64e07bbaa343a49b127fd /Userland
parent97dde091702fac122ff2f5178e3773f170758f1b (diff)
downloadserenity-bc20e4f71d41f2ebcc56351daecb826544b15df5.zip
LibRegex: Add some more information to Compare::Reference debug output
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibRegex/RegexByteCode.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/Userland/Libraries/LibRegex/RegexByteCode.cpp b/Userland/Libraries/LibRegex/RegexByteCode.cpp
index 050f067ae0..e0e6cbe175 100644
--- a/Userland/Libraries/LibRegex/RegexByteCode.cpp
+++ b/Userland/Libraries/LibRegex/RegexByteCode.cpp
@@ -900,6 +900,21 @@ Vector<String> OpCode_Compare::variable_arguments_to_string(Optional<MatchInput>
} else if (compare_type == CharacterCompareType::Reference) {
auto ref = m_bytecode->at(offset++);
result.empend(String::formatted("number={}", ref));
+ if (input.has_value()) {
+ if (state().capture_group_matches.size() > input->match_index) {
+ auto& match = state().capture_group_matches[input->match_index];
+ if (match.size() > ref) {
+ auto& group = match[ref];
+ result.empend(String::formatted("left={}", group.left_column));
+ result.empend(String::formatted("right={}", group.left_column + group.view.length_in_code_units()));
+ result.empend(String::formatted("contents='{}'", group.view));
+ } else {
+ result.empend(String::formatted("(invalid ref, max={})", match.size() - 1));
+ }
+ } else {
+ result.empend(String::formatted("(invalid index {}, max={})", input->match_index, state().capture_group_matches.size() - 1));
+ }
+ }
} else if (compare_type == CharacterCompareType::String) {
auto& length = m_bytecode->at(offset++);
StringBuilder str_builder;