#define _GNU_SOURCE
#ifdef HAVE_CONFIG_H
-#if defined (CONFIG_BROKETS)
+#if defined (emacs) || defined (CONFIG_BROKETS)
/* We use <config.h> instead of "config.h" so that a compilation
using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
(which it would do because it found this file in $srcdir). */
/* We need this for `regex.h', and perhaps for the Emacs include files. */
#include <sys/types.h>
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
/* The `emacs' switch turns on certain matching commands
that make sense only in Emacs. */
#ifdef emacs
/* We used to test for `BSTRING' here, but only GCC and Emacs define
`BSTRING', as far as I know, and neither of them use this code. */
+#ifndef INHIBIT_STRING_HEADER
#if HAVE_STRING_H || STDC_HEADERS
#include <string.h>
#ifndef bcmp
#else
#include <strings.h>
#endif
+#endif
/* Define the syntax stuff for \<, \>, etc. */
\f
/* Avoiding alloca during matching, to placate r_alloc. */
-/* Define MATCH_MAY_ALLOCATE if we need to make sure that the
+/* Define MATCH_MAY_ALLOCATE unless we need to make sure that the
searching and matching functions should not call alloca. On some
systems, alloca is implemented in terms of malloc, and if we're
using the relocating allocator routines, then malloc could cause a
/* Since DOUBLE_FAIL_STACK refuses to double only if the current size
is strictly greater than re_max_failures, the largest possible stack
is 2 * re_max_failures failure points. */
- fail_stack.size = (2 * re_max_failures * MAX_FAILURE_ITEMS);
- if (! fail_stack.stack)
- fail_stack.stack =
- (fail_stack_elt_t *) malloc (fail_stack.size
- * sizeof (fail_stack_elt_t));
+ if (fail_stack.size < (2 * re_max_failures * MAX_FAILURE_ITEMS))
+ {
+ fail_stack.size = (2 * re_max_failures * MAX_FAILURE_ITEMS);
+
+#ifdef emacs
+ if (! fail_stack.stack)
+ fail_stack.stack
+ = (fail_stack_elt_t *) xmalloc (fail_stack.size
+ * sizeof (fail_stack_elt_t));
+ else
+ fail_stack.stack
+ = (fail_stack_elt_t *) xrealloc (fail_stack.stack,
+ (fail_stack.size
+ * sizeof (fail_stack_elt_t)));
+#else /* not emacs */
+ if (! fail_stack.stack)
+ fail_stack.stack
+ = (fail_stack_elt_t *) malloc (fail_stack.size
+ * sizeof (fail_stack_elt_t));
+ else
+ fail_stack.stack
+ = (fail_stack_elt_t *) realloc (fail_stack.stack,
+ (fail_stack.size
+ * sizeof (fail_stack_elt_t)));
+#endif /* not emacs */
+ }
/* Initialize some other variables the matcher uses. */
RETALLOC_IF (regstart, num_regs, const char *);
goto fail;
#ifdef emacs
-#ifdef emacs19
case before_dot:
DEBUG_PRINT1 ("EXECUTING before_dot.\n");
if (PTR_CHAR_POS ((unsigned char *) d) >= point)
if (PTR_CHAR_POS ((unsigned char *) d) <= point)
goto fail;
break;
-#else /* not emacs19 */
+#if 0 /* not emacs19 */
case at_dot:
DEBUG_PRINT1 ("EXECUTING at_dot.\n");
if (PTR_CHAR_POS ((unsigned char *) d) + 1 != point)