summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/regexp.c48
-rw-r--r--src/version.c2
2 files changed, 32 insertions, 18 deletions
diff --git a/src/regexp.c b/src/regexp.c
index 97181b862..6347eeda9 100644
--- 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)
- {
- bp->save_start[i].se_u.pos = reg_startpos[i];
- bp->save_end[i].se_u.pos = reg_endpos[i];
- }
- else
+ for (i = 0; i < NSUBEXP; ++i)
{
- 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)
- {
- reg_startpos[i] = bp->save_start[i].se_u.pos;
- reg_endpos[i] = bp->save_end[i].se_u.pos;
- }
- else
+ for (i = 0; i < NSUBEXP; ++i)
{
- 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;
+ }
}
}
}
diff --git a/src/version.c b/src/version.c
index 61a8944f8..aa283c4fc 100644
--- 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,