浏览代码

LibRegex: Use the parser state capture group count in BRE

Otherwise the users won't know how many capture groups are in the
parsed regular expression.
Ali Mohammad Pur 4 年之前
父节点
当前提交
11a8476cf4
共有 2 个文件被更改,包括 1 次插入2 次删除
  1. 1 1
      Userland/Libraries/LibRegex/RegexParser.cpp
  2. 0 1
      Userland/Libraries/LibRegex/RegexParser.h

+ 1 - 1
Userland/Libraries/LibRegex/RegexParser.cpp

@@ -411,7 +411,7 @@ bool PosixBasicParser::parse_nonduplicating_re(ByteCode& bytecode, size_t& match
     if (try_skip("\\(")) {
     if (try_skip("\\(")) {
         ByteCode capture_bytecode;
         ByteCode capture_bytecode;
         size_t capture_length_minimum = 0;
         size_t capture_length_minimum = 0;
-        auto capture_group_index = ++m_capture_group;
+        auto capture_group_index = ++m_parser_state.capture_groups_count;
 
 
         if (!parse_re_expression(capture_bytecode, capture_length_minimum))
         if (!parse_re_expression(capture_bytecode, capture_length_minimum))
             return false;
             return false;

+ 0 - 1
Userland/Libraries/LibRegex/RegexParser.h

@@ -155,7 +155,6 @@ private:
     bool parse_nonduplicating_re(ByteCode&, size_t&);
     bool parse_nonduplicating_re(ByteCode&, size_t&);
     bool parse_one_char_or_collation_element(ByteCode&, size_t&);
     bool parse_one_char_or_collation_element(ByteCode&, size_t&);
 
 
-    size_t m_capture_group { 0 };
     constexpr static size_t number_of_addressable_capture_groups = 9;
     constexpr static size_t number_of_addressable_capture_groups = 9;
     size_t m_capture_group_minimum_lengths[number_of_addressable_capture_groups] { 0 };
     size_t m_capture_group_minimum_lengths[number_of_addressable_capture_groups] { 0 };
     bool m_capture_group_seen[number_of_addressable_capture_groups] { false };
     bool m_capture_group_seen[number_of_addressable_capture_groups] { false };