bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: bug-gnulib@gnu.org
Cc: Paul Eggert <eggert@cs.ucla.edu>
Subject: [PATCH 09/10] regex-tests: add bug 11053 test
Date: Fri,  5 Feb 2021 17:26:01 -0800	[thread overview]
Message-ID: <20210206012602.2257711-9-eggert@cs.ucla.edu> (raw)
In-Reply-To: <20210206012602.2257711-1-eggert@cs.ucla.edu>

* tests/test-regex.c (main): New test case for glibc bug 11053.
---
 ChangeLog          |  3 +++
 tests/test-regex.c | 29 +++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 69abc35dc..d838ad0d0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2021-02-05  Paul Eggert  <eggert@cs.ucla.edu>
 
+	regex-tests: add bug 11053 test
+	* tests/test-regex.c (main): New test case for glibc bug 11053.
+
 	regex: debug check for set member duplicates
 	* lib/regex_internal.c (re_node_set_insert): Add a DEBUG_ASSERT
 	that would have caught some recently-fixed performance bugs
diff --git a/tests/test-regex.c b/tests/test-regex.c
index a14619805..adccf2187 100644
--- a/tests/test-regex.c
+++ b/tests/test-regex.c
@@ -407,6 +407,35 @@ main (void)
       free (regs.end);
     }
 
+  /* glibc bug 11053.  */
+  re_set_syntax (RE_SYNTAX_POSIX_BASIC);
+  memset (&regex, 0, sizeof regex);
+  static char const pat_sub2[] = "\\(a*\\)*a*\\1";
+  s = re_compile_pattern (pat_sub2, sizeof pat_sub2 - 1, &regex);
+  if (s)
+    report_error ("%s: %s", pat_sub2, s);
+  else
+    {
+      memset (&regs, 0, sizeof regs);
+      static char const data[] = "a";
+      int datalen = sizeof data - 1;
+      i = re_search (&regex, data, datalen, 0, datalen, &regs);
+      if (i != 0)
+        report_error ("re_search '%s' on '%s' returned %d", pat_sub2, data, i);
+      else if (regs.num_regs < 2)
+        report_error ("re_search '%s' on '%s' returned only %d registers",
+                      pat_sub2, data, (int) regs.num_regs);
+      else if (! (regs.start[0] == 0 && regs.end[0] == 1))
+        report_error ("re_search '%s' on '%s' returned wrong match [%d,%d)",
+                      pat_sub2, data, (int) regs.start[0], (int) regs.end[0]);
+      else if (! (regs.start[1] == 0 && regs.end[1] == 0))
+        report_error ("re_search '%s' on '%s' returned wrong submatch [%d,%d)",
+                      pat_sub2, data, regs.start[1], regs.end[1]);
+      regfree (&regex);
+      free (regs.start);
+      free (regs.end);
+    }
+
   /* Catch a bug reported by Vin Shelton in
      https://lists.gnu.org/r/bug-coreutils/2007-06/msg00089.html
      */
-- 
2.27.0



  parent reply	other threads:[~2021-02-06  1:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-06  1:25 [PATCH 01/10] regex: improve comments Paul Eggert
2021-02-06  1:25 ` [PATCH 02/10] regex: avoid undefined behavior Paul Eggert
2021-02-06  1:25 ` [PATCH 03/10] regex: minor refactoring Paul Eggert
2021-02-06  1:25 ` [PATCH 04/10] regex: make it easier to merge into glibc Paul Eggert
2021-02-06  1:25 ` [PATCH 05/10] regex-tests: fix typo Paul Eggert
2021-02-06  1:25 ` [PATCH 06/10] regex: avoid duplicate in espilon closure Paul Eggert
2021-02-06  1:25 ` [PATCH 07/10] regex: fix longstanding backref match bug Paul Eggert
2021-02-09 19:42   ` Adhemerval Zanella
2021-02-09 22:22     ` Paul Eggert
2021-04-16 21:37   ` Dmitry V. Levin
2021-02-06  1:26 ` [PATCH 08/10] regex: debug check for set member duplicates Paul Eggert
2021-02-06  1:26 ` Paul Eggert [this message]
2021-02-06  1:26 ` [PATCH 10/10] regex: fix comment location Paul Eggert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210206012602.2257711-9-eggert@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=bug-gnulib@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).