changeset 1602:0358abf2b5d4 v7.1.315

updated for version 7.1-315
author vimboss
date Sun, 15 Jun 2008 12:21:50 +0000
parents eef96cfdbbbe
children 694e8715dce6
files src/regexp.c src/version.c
diffstat 2 files changed, 32 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/src/regexp.c
+++ b/src/regexp.c
@@ -3044,6 +3044,7 @@ typedef struct regbehind_S
 {
     regsave_T	save_after;
     regsave_T	save_behind;
+    int		save_need_clear_subexpr;
     save_se_T   save_start[NSUBEXP];
     save_se_T   save_end[NSUBEXP];
 } regbehind_T;
@@ -5858,17 +5859,23 @@ save_subexpr(bp)
 {
     int i;
 
-    for (i = 0; i < NSUBEXP; ++i)
+    /* When "need_clear_subexpr" is set we don't need to save the values, only
+     * remember that this flag needs to be set again when restoring. */
+    bp->save_need_clear_subexpr = need_clear_subexpr;
+    if (!need_clear_subexpr)
     {
-	if (REG_MULTI)
+	for (i = 0; i < NSUBEXP; ++i)
 	{
-	    bp->save_start[i].se_u.pos = reg_startpos[i];
-	    bp->save_end[i].se_u.pos = reg_endpos[i];
-	}
-	else
-	{
-	    bp->save_start[i].se_u.ptr = reg_startp[i];
-	    bp->save_end[i].se_u.ptr = reg_endp[i];
+	    if (REG_MULTI)
+	    {
+		bp->save_start[i].se_u.pos = reg_startpos[i];
+		bp->save_end[i].se_u.pos = reg_endpos[i];
+	    }
+	    else
+	    {
+		bp->save_start[i].se_u.ptr = reg_startp[i];
+		bp->save_end[i].se_u.ptr = reg_endp[i];
+	    }
 	}
     }
 }
@@ -5882,17 +5889,22 @@ restore_subexpr(bp)
 {
     int i;
 
-    for (i = 0; i < NSUBEXP; ++i)
+    /* Only need to restore saved values when they are not to be cleared. */
+    need_clear_subexpr = bp->save_need_clear_subexpr;
+    if (!need_clear_subexpr)
     {
-	if (REG_MULTI)
+	for (i = 0; i < NSUBEXP; ++i)
 	{
-	    reg_startpos[i] = bp->save_start[i].se_u.pos;
-	    reg_endpos[i] = bp->save_end[i].se_u.pos;
-	}
-	else
-	{
-	    reg_startp[i] = bp->save_start[i].se_u.ptr;
-	    reg_endp[i] = bp->save_end[i].se_u.ptr;
+	    if (REG_MULTI)
+	    {
+		reg_startpos[i] = bp->save_start[i].se_u.pos;
+		reg_endpos[i] = bp->save_end[i].se_u.pos;
+	    }
+	    else
+	    {
+		reg_startp[i] = bp->save_start[i].se_u.ptr;
+		reg_endp[i] = bp->save_end[i].se_u.ptr;
+	    }
 	}
     }
 }
--- a/src/version.c
+++ b/src/version.c
@@ -667,6 +667,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    315,
+/**/
     314,
 /**/
     313,