]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
regex-tests: pacify -Wshadow
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 9 May 2026 01:46:02 +0000 (18:46 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 9 May 2026 03:25:26 +0000 (20:25 -0700)
* tests/test-regex-en.c (main): Remove unused local.
Nest one of the tests, to avoid shadowing the local ‘pat’.

ChangeLog
tests/test-regex-en.c

index 4b6abd889d13b2fc4b8ab7f4c3e58b94126cee67..e555d66ed90546c6d4e38472edcfae7ee15ca1bf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2026-05-08  Paul Eggert  <eggert@cs.ucla.edu>
 
+       regex-tests: pacify -Wshadow
+       * tests/test-regex-en.c (main): Remove unused local.
+       Nest one of the tests, to avoid shadowing the local ‘pat’.
+
        Gnulib is now safe for -Wuseless-cast
        * m4/gnulib-common.m4 (gl_CC_GNULIB_WARNINGS):
        Remove -Wno-useless-cast.
index ad3790ce10cc8caaab92d1ea18500d69d994f8d0..7317961bc5824972c80ef3a8c9490554b7ca40ff 100644 (file)
@@ -165,7 +165,6 @@ int
 main (int argc, char *argv[])
 {
   struct re_pattern_buffer regex;
-  unsigned char folded_chars[UCHAR_MAX + 1];
   const char *s;
   struct re_registers regs;
 
@@ -191,27 +190,29 @@ main (int argc, char *argv[])
      GNU/Linux 3.1 x86, but it might catch the bug better
      on other platforms and it shouldn't hurt to try the
      test here.  */
-  static char const pat[] = "insert into";
-  static char const data[] =
-    "\xFF\0\x12\xA2\xAA\xC4\xB1,K\x12\xC4\xB1*\xACK";
-  re_set_syntax (RE_SYNTAX_GREP | RE_HAT_LISTS_NOT_NEWLINE
-                 | RE_ICASE);
-  memset (&regex, 0, sizeof regex);
-  s = re_compile_pattern (pat, sizeof pat - 1, &regex);
-  if (s)
-    report_error ("%s: %s", pat, s);
-  else
-    {
-      memset (&regs, 0, sizeof regs);
-      int ret = re_search (&regex, data, sizeof data - 1,
-                           0, sizeof data - 1, &regs);
-      if (ret != -1)
-        report_error ("re_search '%s' on '%s' returned %d",
-                      pat, data, ret);
-      regfree (&regex);
-      free (regs.start);
-      free (regs.end);
-    }
+  {
+    static char const pat[] = "insert into";
+    static char const data[] =
+      "\xFF\0\x12\xA2\xAA\xC4\xB1,K\x12\xC4\xB1*\xACK";
+    re_set_syntax (RE_SYNTAX_GREP | RE_HAT_LISTS_NOT_NEWLINE
+                   | RE_ICASE);
+    memset (&regex, 0, sizeof regex);
+    s = re_compile_pattern (pat, sizeof pat - 1, &regex);
+    if (s)
+      report_error ("%s: %s", pat, s);
+    else
+      {
+        memset (&regs, 0, sizeof regs);
+        int ret = re_search (&regex, data, sizeof data - 1,
+                             0, sizeof data - 1, &regs);
+        if (ret != -1)
+          report_error ("re_search '%s' on '%s' returned %d",
+                        pat, data, ret);
+        regfree (&regex);
+        free (regs.start);
+        free (regs.end);
+      }
+  }
 
   if (really_utf8 ())
     {