2012-12-29 Paul Eggert <eggert@cs.ucla.edu>
+ regex: port to hosts where malloc (0) == NULL
+ Reported by Aharon Robbins in
+ <http://sourceware.org/ml/libc-alpha/2012-12/msg00456.html>.
+ * lib/regex_internal.c (re_node_set_alloc):
+ Don't assume that malloc (0) yields nonnull.
+ * lib/regex_internal.h (MALLOC_0_IS_NONNULL): New macro.
+ * m4/regex.m4 (gl_PREREQ_REGEX): Require gl_EEMALLOC.
+ * modules/regex (Files): Add m4/eealloc.m4.
+
regex: port to C89
Reported by Aharon Robbins in
<http://sourceware.org/ml/libc-alpha/2012-12/msg00456.html>.
set->alloc = size;
set->nelem = 0;
set->elems = re_malloc (Idx, size);
- if (BE (set->elems == NULL, 0))
+ if (BE (set->elems == NULL, 0) && (MALLOC_0_IS_NONNULL || size != 0))
return REG_ESPACE;
return REG_NOERROR;
}
# endif
#endif
+#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
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 wcscoll])
AC_CHECK_DECLS([isblank], [], [], [[#include <ctype.h>]])
lib/regex_internal.h
lib/regexec.c
lib/regcomp.c
+m4/eealloc.m4
m4/regex.m4
m4/mbstate_t.m4