]> Savannah Git Hosting - gnulib.git/commitdiff
regex: remove _REGEX_NELTS
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 14 Apr 2025 22:42:40 +0000 (15:42 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 14 Apr 2025 22:44:48 +0000 (15:44 -0700)
This is a cleanup after the recent fix for undefined behavior.
* lib/regex.h (_REGEX_NELTS): Remove, as it is no longer useful.
All uses removed.  Remove no-longer-needed uses of #pragma GCC.

ChangeLog
lib/regex.h
lib/regexec.c

index 1d4a3993791bf1144837e543dd27858f6fcc2266..0c2ed01bff4e9019b115f176aaf39728adbe1f56 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2025-04-14  Paul Eggert  <eggert@cs.ucla.edu>
 
+       regex: remove _REGEX_NELTS
+       This is a cleanup after the recent fix for undefined behavior.
+       * lib/regex.h (_REGEX_NELTS): Remove, as it is no longer useful.
+       All uses removed.  Remove no-longer-needed uses of #pragma GCC.
+
        regex: don’t check RE_SYNTAX_EMACS
        * m4/regex.m4 (gl_REGEX): Do not check RE_SYNTAX_EMACS’s value.
        Suggested by Bruno Haible in:
index 0eb72ce908b5c0e8edc21cb34a5f2ecbdb915961..e9ab85e8b5a00a0edfd61d9cf3f9d2c4e8fb038b 100644 (file)
@@ -522,24 +522,6 @@ typedef struct
 \f
 /* Declarations for routines.  */
 
-#ifndef _REGEX_NELTS
-/* The macro _REGEX_NELTS denotes the number of elements in a variable-length
-   array passed to a function.
-   It was meant to make use of ISO C99 variable-length arrays, but this does
-   not work: ISO C23 § 6.7.6.2.(5) requires the number of elements to be > 0,
-   but the NMATCH argument to regexec() is allowed to be 0.  */
-# if 0
-#  define _REGEX_NELTS(n) n
-# else
-#  define _REGEX_NELTS(n)
-# endif
-#endif
-
-#if defined __GNUC__ && 4 < __GNUC__ + (6 <= __GNUC_MINOR__)
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wvla"
-#endif
-
 #ifndef _Attr_access_
 # ifdef __attr_access
 #  define _Attr_access_(arg) __attr_access (arg)
@@ -686,8 +668,7 @@ extern int regcomp (regex_t *_Restrict_ __preg,
 
 extern int regexec (const regex_t *_Restrict_ __preg,
                    const char *_Restrict_ __String, size_t __nmatch,
-                   regmatch_t __pmatch[_Restrict_arr_
-                                       _REGEX_NELTS (__nmatch)],
+                   regmatch_t __pmatch[_Restrict_arr_],
                    int __eflags);
 
 extern size_t regerror (int __errcode, const regex_t *_Restrict_ __preg,
@@ -696,10 +677,6 @@ extern size_t regerror (int __errcode, const regex_t *_Restrict_ __preg,
 
 extern void regfree (regex_t *__preg);
 
-#if defined __GNUC__ && 4 < __GNUC__ + (6 <= __GNUC_MINOR__)
-# pragma GCC diagnostic pop
-#endif
-
 #ifdef __cplusplus
 }
 #endif /* C++ */
index 6923394a085913603bebbf56fae7a5d19cf8b0da..c5ab9b6649f36752047cfbd55704ef5f0e211a97 100644 (file)
@@ -185,7 +185,7 @@ static reg_errcode_t extend_buffers (re_match_context_t *mctx, int min_len);
 
 int
 regexec (const regex_t *__restrict preg, const char *__restrict string,
-        size_t nmatch, regmatch_t pmatch[_REGEX_NELTS (nmatch)], int eflags)
+        size_t nmatch, regmatch_t pmatch[], int eflags)
 {
   reg_errcode_t err;
   Idx start, length;
@@ -229,7 +229,7 @@ int
 attribute_compat_text_section
 __compat_regexec (const regex_t *__restrict preg,
                  const char *__restrict string, size_t nmatch,
-                 regmatch_t pmatch[_REGEX_NELTS (nmatch)], int eflags)
+                 regmatch_t pmatch[], int eflags)
 {
   return regexec (preg, string, nmatch, pmatch,
                  eflags & (REG_NOTBOL | REG_NOTEOL));