Also, switch from eealloc.m4 to malloc.m4 to determine whether malloc (0) returns nonnull. * lib/regex_internal.c (re_node_set_alloc): Remove special case for malloc (0). * lib/regex_internal.h (MALLOC_0_IS_NONNULL): Remove. * m4/regex.m4 (gl_PREREQ_REGEX): Do not require gl_EEMALLOC. * modules/regex (Files): Remove m4/eealloc.m4, m4/malloc.m4. (Depends-on): Add malloc-gnu. --- ChangeLog | 10 ++++++++++ lib/regex_internal.c | 3 +-- lib/regex_internal.h | 6 ------ m4/regex.m4 | 3 +-- modules/regex | 3 +-- 5 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/ChangeLog b/ChangeLog index 6c316acf90..583884d1dc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2024-11-05 Paul Eggert <egg...@cs.ucla.edu> + regex: port better to AIX extensions + Also, switch from eealloc.m4 to malloc.m4 to determine + whether malloc (0) returns nonnull. + * lib/regex_internal.c (re_node_set_alloc): + Remove special case for malloc (0). + * lib/regex_internal.h (MALLOC_0_IS_NONNULL): Remove. + * m4/regex.m4 (gl_PREREQ_REGEX): Do not require gl_EEMALLOC. + * modules/regex (Files): Remove m4/eealloc.m4, m4/malloc.m4. + (Depends-on): Add malloc-gnu. + malloca: port better to AIX extensions Also, switch from eealloc.m4 to malloc.m4 to determine whether malloc (0) returns nonnull. diff --git a/lib/regex_internal.c b/lib/regex_internal.c index 8cd096ebcf..6ccf701f26 100644 --- a/lib/regex_internal.c +++ b/lib/regex_internal.c @@ -937,8 +937,7 @@ re_node_set_alloc (re_node_set *set, Idx size) set->alloc = size; set->nelem = 0; set->elems = re_malloc (Idx, size); - if (__glibc_unlikely (set->elems == NULL) - && (MALLOC_0_IS_NONNULL || size != 0)) + if (__glibc_unlikely (set->elems == NULL)) return REG_ESPACE; return REG_NOERROR; } diff --git a/lib/regex_internal.h b/lib/regex_internal.h index 6165cb17c7..dfc5d34cba 100644 --- a/lib/regex_internal.h +++ b/lib/regex_internal.h @@ -436,12 +436,6 @@ typedef struct re_dfa_t re_dfa_t; #define re_string_skip_bytes(pstr,idx) ((pstr)->cur_idx += (idx)) #define re_string_set_index(pstr,idx) ((pstr)->cur_idx = (idx)) -#ifdef _LIBC -# define MALLOC_0_IS_NONNULL 1 -#elif !defined MALLOC_0_IS_NONNULL -# define MALLOC_0_IS_NONNULL 0 -#endif - #ifndef MAX # define MAX(a,b) ((a) < (b) ? (b) : (a)) #endif diff --git a/m4/regex.m4 b/m4/regex.m4 index 041b46d244..1060a8e898 100644 --- a/m4/regex.m4 +++ b/m4/regex.m4 @@ -1,5 +1,5 @@ # regex.m4 -# serial 77 +# serial 78 dnl Copyright (C) 1996-2001, 2003-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -392,7 +392,6 @@ AC_DEFUN([gl_PREREQ_REGEX], AC_REQUIRE([AC_C_INLINE]) AC_REQUIRE([AC_C_RESTRICT]) AC_REQUIRE([AC_TYPE_MBSTATE_T]) - AC_REQUIRE([gl_EEMALLOC]) AC_CHECK_HEADERS([libintl.h]) AC_CHECK_FUNCS_ONCE([isblank iswctype]) AC_CHECK_DECLS([isblank], [], [], [[#include <ctype.h>]]) diff --git a/modules/regex b/modules/regex index ecbfaf4156..c2264a52bd 100644 --- a/modules/regex +++ b/modules/regex @@ -11,8 +11,6 @@ lib/regex_internal.c lib/regex_internal.h lib/regexec.c lib/regcomp.c -m4/eealloc.m4 -m4/malloc.m4 m4/regex.m4 m4/mbstate_t.m4 @@ -31,6 +29,7 @@ langinfo [test $ac_use_included_regex = yes] libc-config [test $ac_use_included_regex = yes] limits-h [test $ac_use_included_regex = yes] lock [test $ac_use_included_regex = yes] +malloc-gnu [test $ac_use_included_regex = yes] memcmp [test $ac_use_included_regex = yes] memmove [test $ac_use_included_regex = yes] mbrtowc [test $ac_use_included_regex = yes] -- 2.43.0