]> sourceware.org Git - systemtap.git/commitdiff
PR28618 stapregex: allow non-capturing group
authorSerhei Makarov <smakarov@redhat.com>
Mon, 22 Nov 2021 20:15:57 +0000 (15:15 -0500)
committerSerhei Makarov <smakarov@redhat.com>
Mon, 22 Nov 2021 20:16:06 +0000 (15:16 -0500)
stapregex-parse.cxx

index b7893fca73139b1aa7a7c8cdd5af34950972236c..d227faeb2693aa70766601144b2a0c45c27f538d 100644 (file)
@@ -295,15 +295,27 @@ regex_parser::parse_factor ()
     }
   else if (c == '(')
     {
+      // Allow non-capturing group (?:...)
+      bool do_tag_now = do_tag;
+      rchar c2 = cur.peek();
+      if (c2 == '?')
+        {
+          cur.next();
+          rchar c3 = cur.peek();
+          if (c3 != ':')
+            parse_error(_F("unexpected '(?%c'", c3));
+          do_tag_now = false;
+        }
+
       // To number tags correctly, reserve a subexpression number here:
       unsigned curr_subexpression = 0;
-      if (do_tag)
+      if (do_tag_now)
         curr_subexpression = num_subexpressions++;
 
       result = parse_expr ();
 
       // PR15065 glom appropriate tag_ops onto the expr
-      if (do_tag) {
+      if (do_tag_now) {
         result = new cat_op(new tag_op(TAG_START(curr_subexpression)), result);
         result = new cat_op(result, new tag_op(TAG_END(curr_subexpression)));
       } else {
This page took 0.025015 seconds and 5 git commands to generate.