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
relocation, which might (if the strings being searched are in the
ralloc heap) shift the data out from underneath the regexp
routines. */
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
relocation, which might (if the strings being searched are in the
ralloc heap) shift the data out from underneath the regexp
routines. */
-#if defined (REL_ALLOC)
-#if defined (C_ALLOCA)
-#define MATCH_SHOULD_NOT_ALLOCA
-#endif
+
+/* Normally, this is fine. */
+#define MATCH_MAY_ALLOCATE
+
+/* But under some circumstances, it's not. */
+#if defined (REL_ALLOC) && defined (C_ALLOCA)
+#undef MATCH_MAY_ALLOCATE
We make the fail stack a global thing, and then grow it to
re_max_failures when we compile. */
We make the fail stack a global thing, and then grow it to
re_max_failures when we compile. */
static fail_stack_type fail_stack;
static const char ** regstart, ** regend;
static fail_stack_type fail_stack;
static const char ** regstart, ** regend;
/* Initialize the failure stack to the largest possible stack. This
isn't necessary unless we're trying to avoid calling alloca in
the search and match routines. */
/* Initialize the failure stack to the largest possible stack. This
isn't necessary unless we're trying to avoid calling alloca in
the search and match routines. */
/* Some MIPS systems (at least) want this to free alloca'd storage. */
#define FREE_VARIABLES() alloca (0)
#endif /* not REGEX_MALLOC */
/* Some MIPS systems (at least) want this to free alloca'd storage. */
#define FREE_VARIABLES() alloca (0)
#endif /* not REGEX_MALLOC */
/* These values must meet several constraints. They must not be valid
register values; since we have a limit of 255 registers (because
/* These values must meet several constraints. They must not be valid
register values; since we have a limit of 255 registers (because
scanning the strings. If the latter is zero, the failure point is
a ``dummy''; if a failure happens and the failure point is a dummy,
it gets discarded and the next next one is tried. */
scanning the strings. If the latter is zero, the failure point is
a ``dummy''; if a failure happens and the failure point is a dummy,
it gets discarded and the next next one is tried. */
matching and the regnum-th regend points to right after where we
stopped matching the regnum-th subexpression. (The zeroth register
keeps track of what the whole pattern matches.) */
matching and the regnum-th regend points to right after where we
stopped matching the regnum-th subexpression. (The zeroth register
keeps track of what the whole pattern matches.) */
restored because it will have been set to wherever in the string we
are when we last see its open-group operator. Similarly for a
register's end. */
restored because it will have been set to wherever in the string we
are when we last see its open-group operator. Similarly for a
register's end. */
matched any of the pattern so far this time through the reg_num-th
subexpression. These two fields get reset each time through any
loop their register is in. */
matched any of the pattern so far this time through the reg_num-th
subexpression. These two fields get reset each time through any
loop their register is in. */
This happens as we backtrack through the failure points, which in
turn happens only if we have not yet matched the entire string. */
unsigned best_regs_set = false;
This happens as we backtrack through the failure points, which in
turn happens only if we have not yet matched the entire string. */
unsigned best_regs_set = false;
/* Do not bother to initialize all the register variables if there are
no groups in the pattern, as it takes a fair amount of time. If
there are groups, we include space for register 0 (the whole
/* Do not bother to initialize all the register variables if there are
no groups in the pattern, as it takes a fair amount of time. If
there are groups, we include space for register 0 (the whole