]> granicus.if.org Git - vim/commitdiff
updated for version 7.2-308 v7.2.308
authorBram Moolenaar <Bram@vim.org>
Wed, 25 Nov 2009 18:51:24 +0000 (18:51 +0000)
committerBram Moolenaar <Bram@vim.org>
Wed, 25 Nov 2009 18:51:24 +0000 (18:51 +0000)
src/regexp.c
src/version.c

index 9ce4cd8f8f7f1d5d24d33775e4b29461649c3031..e507e40e5c03f960d6ccd7cc2d693a3d7d3aaaf4 100644 (file)
@@ -6828,6 +6828,8 @@ static int can_f_submatch = FALSE;        /* TRUE when submatch() can be used */
  * that contains a call to substitute() and submatch(). */
 static regmatch_T      *submatch_match;
 static regmmatch_T     *submatch_mmatch;
+static linenr_T                submatch_firstlnum;
+static linenr_T                submatch_maxline;
 #endif
 
 #if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) || defined(PROTO)
@@ -6941,7 +6943,6 @@ vim_regsub_both(source, dest, copy, magic, backslash)
        }
        else
        {
-           linenr_T    save_reg_maxline;
            win_T       *save_reg_win;
            int         save_ireg_ic;
 
@@ -6953,7 +6954,8 @@ vim_regsub_both(source, dest, copy, magic, backslash)
             * vim_regexec_multi() can't be called recursively. */
            submatch_match = reg_match;
            submatch_mmatch = reg_mmatch;
-           save_reg_maxline = reg_maxline;
+           submatch_firstlnum = reg_firstlnum;
+           submatch_maxline = reg_maxline;
            save_reg_win = reg_win;
            save_ireg_ic = ireg_ic;
            can_f_submatch = TRUE;
@@ -6976,7 +6978,8 @@ vim_regsub_both(source, dest, copy, magic, backslash)
 
            reg_match = submatch_match;
            reg_mmatch = submatch_mmatch;
-           reg_maxline = save_reg_maxline;
+           reg_firstlnum = submatch_firstlnum;
+           reg_maxline = submatch_maxline;
            reg_win = save_reg_win;
            ireg_ic = save_ireg_ic;
            can_f_submatch = FALSE;
@@ -7211,6 +7214,29 @@ exit:
 }
 
 #ifdef FEAT_EVAL
+/*
+ * Call reg_getline() with the line numbers from the submatch.  If a
+ * substitute() was used the reg_maxline and other values have been
+ * overwritten.
+ */
+    static char_u *
+reg_getline_submatch(lnum)
+    linenr_T   lnum;
+{
+    char_u *s;
+    linenr_T save_first = reg_firstlnum;
+    linenr_T save_max = reg_maxline;
+
+    reg_firstlnum = submatch_firstlnum;
+    reg_maxline = submatch_maxline;
+
+    s = reg_getline(lnum);
+
+    reg_firstlnum = save_first;
+    reg_maxline = save_max;
+    return s;
+}
+
 /*
  * Used for the submatch() function: get the string from the n'th submatch in
  * allocated memory.
@@ -7241,7 +7267,7 @@ reg_submatch(no)
            if (lnum < 0 || submatch_mmatch->endpos[no].lnum < 0)
                return NULL;
 
-           s = reg_getline(lnum) + submatch_mmatch->startpos[no].col;
+           s = reg_getline_submatch(lnum) + submatch_mmatch->startpos[no].col;
            if (s == NULL)  /* anti-crash check, cannot happen? */
                break;
            if (submatch_mmatch->endpos[no].lnum == lnum)
@@ -7267,7 +7293,7 @@ reg_submatch(no)
                ++lnum;
                while (lnum < submatch_mmatch->endpos[no].lnum)
                {
-                   s = reg_getline(lnum++);
+                   s = reg_getline_submatch(lnum++);
                    if (round == 2)
                        STRCPY(retval + len, s);
                    len += (int)STRLEN(s);
@@ -7276,7 +7302,7 @@ reg_submatch(no)
                    ++len;
                }
                if (round == 2)
-                   STRNCPY(retval + len, reg_getline(lnum),
+                   STRNCPY(retval + len, reg_getline_submatch(lnum),
                                             submatch_mmatch->endpos[no].col);
                len += submatch_mmatch->endpos[no].col;
                if (round == 2)
index 0748170ee843a28316c5e4facd29f76803860350..7d3c43594b984af2e91c44a62926fd149f771878 100644 (file)
@@ -681,6 +681,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    308,
 /**/
     307,
 /**/