From: Paul Eggert Date: Mon, 14 Apr 2025 22:42:40 +0000 (-0700) Subject: regex: remove _REGEX_NELTS X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=7fddad0294390f85855c93175bfc513107ebd7ee;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index 1d4a399379..0c2ed01bff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2025-04-14 Paul Eggert + 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: diff --git a/lib/regex.h b/lib/regex.h index 0eb72ce908..e9ab85e8b5 100644 --- a/lib/regex.h +++ b/lib/regex.h @@ -522,24 +522,6 @@ typedef struct /* 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++ */ diff --git a/lib/regexec.c b/lib/regexec.c index 6923394a08..c5ab9b6649 100644 --- a/lib/regexec.c +++ b/lib/regexec.c @@ -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));