summaryrefslogtreecommitdiff
path: root/regexec.c
diff options
context:
space:
mode:
authorLarry Wall <lwall@netlabs.com>1991-04-11 20:32:32 +0000
committerLarry Wall <lwall@netlabs.com>1991-04-11 20:32:32 +0000
commit35c8bce761056f470189967ccc824e04467151df (patch)
tree9ee76bba81900f86af5a1070bdd69d3987201c52 /regexec.c
parent1c3d792e8fc9c2a36edfbd6c01156ef7e635040f (diff)
downloadperl-35c8bce761056f470189967ccc824e04467151df.tar.gz
perl 4.0 patch 2: Patch 1 continued
Diffstat (limited to 'regexec.c')
-rw-r--r--regexec.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/regexec.c b/regexec.c
index 45076d36eb..7db8e3d3ba 100644
--- a/regexec.c
+++ b/regexec.c
@@ -7,9 +7,12 @@
* blame Henry for some of the lack of readability.
*/
-/* $Header: regexec.c,v 4.0 91/03/20 01:39:16 lwall Locked $
+/* $RCSfile: regexec.c,v $$Revision: 4.0.1.1 $$Date: 91/04/12 09:07:39 $
*
* $Log: regexec.c,v $
+ * Revision 4.0.1.1 91/04/12 09:07:39 lwall
+ * patch1: regexec only allocated space for 9 subexpresssions
+ *
* Revision 4.0 91/03/20 01:39:16 lwall
* 4.0 baseline.
*
@@ -80,8 +83,9 @@ static char **regendp; /* Ditto for endp. */
static char *reglastparen; /* Similarly for lastparen. */
static char *regtill;
-static char *regmystartp[10]; /* For remembering backreferences. */
-static char *regmyendp[10];
+static int regmyp_size = 0;
+static char **regmystartp = Null(char**);
+static char **regmyendp = Null(char**);
/*
* Forwards.
@@ -189,6 +193,24 @@ int safebase; /* no need to remember string in subbase */
/* see how far we have to get to not match where we matched before */
regtill = string+minend;
+ /* Allocate our backreference arrays */
+ if ( regmyp_size < prog->nparens + 1 ) {
+ /* Allocate or enlarge the arrays */
+ regmyp_size = prog->nparens + 1;
+ if ( regmyp_size < 10 ) regmyp_size = 10; /* minimum */
+ if ( regmystartp ) {
+ /* reallocate larger */
+ Renew(regmystartp,regmyp_size,char*);
+ Renew(regmyendp, regmyp_size,char*);
+ }
+ else {
+ /* Initial allocation */
+ New(1102,regmystartp,regmyp_size,char*);
+ New(1102,regmyendp, regmyp_size,char*);
+ }
+
+ }
+
/* Simplest case: anchored match need be tried only once. */
/* [unless multiline is set] */
if (prog->reganch & 1) {