Mutt's configure.ac doesn't call AC_FUNC_ALLOCA, so Mutt is using the
malloc version by default.  Trim out the code using alloca and the
code for when it's bundled inside emacs.

Remove unneeded destination variable for
REGEX_REALLOCATE_STACK/REGEX_REALLOCATE, because the malloc versions
don't use it.

Remove unneeded osize parameter for REGEX_REALLOCATE() and
REGEX_REALLOCATE_STACK, because the malloc versions don't use it.
---
 regex.c | 115 ++++----------------------------------------------------
 1 file changed, 8 insertions(+), 107 deletions(-)

diff --git a/regex.c b/regex.c
index dde6d78d..f1b4a9d8 100644
--- a/regex.c
+++ b/regex.c
@@ -38,15 +38,6 @@
  * the use of alloca.  So let's disable it for AIX.
  */
 
-#if 0
-
-/* AIX requires this to be the first thing in the file. */
-# if defined (_AIX) && !defined (REGEX_MALLOC)
-#  pragma alloca
-# endif
-
-#endif
-
 #undef  _GNU_SOURCE
 #define _GNU_SOURCE
 
@@ -63,20 +54,11 @@
 #define _DONT_USE_CTYPE_INLINE_
 #endif
 
-#if (defined(HAVE_ALLOCA_H) && !defined(_AIX))
-# include <alloca.h>
-#endif
+/* The Mutt embedded version only use REGEX_MALLOC, so define it clearly */
+#define REGEX_MALLOC
+#undef REL_ALLOC
 
-#if (!defined(HAVE_ALLOCA) || defined(_AIX))
-# define REGEX_MALLOC
-#endif
-
-#if !defined(emacs)
 #include <stddef.h>
-#else
-/* We need this for `regex.h', and perhaps for the Emacs include files.  */
-#include <sys/types.h>
-#endif
 
 /* For platform which support the ISO C amendment 1 functionality we
    support user defined character classes.  */
@@ -96,21 +78,6 @@
 #define gettext_noop(String) String
 #endif
 
-/* The `emacs' switch turns on certain matching commands
-   that make sense only in Emacs. */
-#ifdef emacs
-
-#include "lisp.h"
-#include "buffer.h"
-#include "syntax.h"
-
-#else  /* not emacs */
-
-/* If we are not linking with Emacs proper,
-   we can't use the relocating allocator
-   even if config.h says that we can.  */
-#undef REL_ALLOC
-
 #include <stdlib.h>
 
 /* When used in Emacs's lib-src, we need to get bzero and bcopy somehow.
@@ -193,7 +160,6 @@ init_syntax_once ()
 
 #define SYNTAX(c) re_syntax_table[c]
 
-#endif /* not emacs */
 
 /* Get the interface, including the syntax bits.  */
 
@@ -256,77 +222,16 @@ init_syntax_once ()
    not functions -- `alloca'-allocated space disappears at the end of the
    function it is called in.  */
 
-#ifdef REGEX_MALLOC
-
 #define REGEX_ALLOCATE malloc
-#define REGEX_REALLOCATE(source, osize, nsize) realloc (source, nsize)
+#define REGEX_REALLOCATE(source, nsize) realloc (source, nsize)
 #define REGEX_FREE free
 
-#else /* not REGEX_MALLOC  */
-
-/* Emacs already defines alloca, sometimes.  */
-#ifndef alloca
-
-/* Make alloca work the best possible way.  */
-#ifdef __GNUC__
-#define alloca __builtin_alloca
-#else /* not __GNUC__ */
-#if HAVE_ALLOCA_H
-#include <alloca.h>
-#else /* not __GNUC__ or HAVE_ALLOCA_H */
-#if 0 /* It is a bad idea to declare alloca.  We always cast the result.  */
-#ifndef _AIX /* Already did AIX, up at the top.  */
-char *alloca ();
-#endif /* not _AIX */
-#endif
-#endif /* not HAVE_ALLOCA_H */
-#endif /* not __GNUC__ */
-
-#endif /* not alloca */
-
-#define REGEX_ALLOCATE alloca
-
-/* Assumes a `char *destination' variable.  */
-#define REGEX_REALLOCATE(source, osize, nsize)                          \
-  (destination = (char *) alloca (nsize),                               \
-   bcopy (source, destination, osize),                                  \
-   destination)
-
-/* No need to do anything to free, after alloca.  */
-#define REGEX_FREE(arg) ((void)0) /* Do nothing!  But inhibit gcc warning.  */
-
-#endif /* not REGEX_MALLOC */
-
 /* Define how to allocate the failure stack.  */
 
-#if defined (REL_ALLOC) && defined (REGEX_MALLOC)
-
-#define REGEX_ALLOCATE_STACK(size)                              \
-  r_alloc (&failure_stack_ptr, (size))
-#define REGEX_REALLOCATE_STACK(source, osize, nsize)            \
-  r_re_alloc (&failure_stack_ptr, (nsize))
-#define REGEX_FREE_STACK(ptr)                                   \
-  r_alloc_free (&failure_stack_ptr)
-
-#else /* not using relocating allocator */
-
-#ifdef REGEX_MALLOC
-
 #define REGEX_ALLOCATE_STACK malloc
-#define REGEX_REALLOCATE_STACK(source, osize, nsize) realloc (source, nsize)
+#define REGEX_REALLOCATE_STACK(source, nsize) realloc (source, nsize)
 #define REGEX_FREE_STACK free
 
-#else /* not REGEX_MALLOC */
-
-#define REGEX_ALLOCATE_STACK alloca
-
-#define REGEX_REALLOCATE_STACK(source, osize, nsize)                    \
-   REGEX_REALLOCATE (source, osize, nsize)
-/* No need to explicitly free anything.  */
-#define REGEX_FREE_STACK(arg)
-
-#endif /* not REGEX_MALLOC */
-#endif /* not using relocating allocator */
 
 
 /* True if `size1' is non-NULL and PTR is pointing anywhere inside
@@ -1138,16 +1043,14 @@ typedef struct
 /* Double the size of FAIL_STACK, up to approximately `re_max_failures' items.
 
    Return 1 if succeeds, and 0 if either ran out of memory
-   allocating space for it or it was already too large.
+   allocating space for it or it was already too large.  */
 
-   REGEX_REALLOCATE_STACK requires `destination' be declared.   */
 
 #define DOUBLE_FAIL_STACK(fail_stack)                                   \
   ((fail_stack).size > (unsigned) (re_max_failures * MAX_FAILURE_ITEMS) \
    ? 0                                                                  \
    : ((fail_stack).stack = (fail_stack_elt_t *)                         \
         REGEX_REALLOCATE_STACK ((fail_stack).stack,                     \
-          (fail_stack).size * sizeof (fail_stack_elt_t),                \
           ((fail_stack).size << 1) * sizeof (fail_stack_elt_t)),        \
                                                                         \
       (fail_stack).stack == NULL                                        \
@@ -1204,14 +1107,12 @@ typedef struct
    if we ever fail back to it.
 
    Requires variables fail_stack, regstart, regend, reg_info, and
-   num_regs be declared.  DOUBLE_FAIL_STACK requires `destination' be
-   declared.
+   num_regs be declared.
 
    Does `return FAILURE_CODE' if runs out of memory.  */
 
 #define PUSH_FAILURE_POINT(pattern_place, string_place, failure_code)   \
   do {                                                                  \
-    char *destination;                                                  \
     /* Must be int, so when we don't save any registers, the arithmetic \
        of 0 + -1 isn't done as unsigned.  */                            \
     /* Can't be int, since there is not a shred of a guarantee that int \
@@ -4690,7 +4591,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, 
const char *string1,
                                dummy_low_reg, dummy_high_reg,
                                reg_dummy, reg_dummy, reg_info_dummy);
           }
-          /* Note fall through.  */
+          /* fall through.  */
 
         unconditional_jump:
 #ifdef _LIBC
-- 
2.55.0

Reply via email to