summaryrefslogtreecommitdiff
path: root/source/ap/vim/patches/7.2.308
diff options
context:
space:
mode:
Diffstat (limited to 'source/ap/vim/patches/7.2.308')
-rw-r--r--source/ap/vim/patches/7.2.308182
1 files changed, 182 insertions, 0 deletions
diff --git a/source/ap/vim/patches/7.2.308 b/source/ap/vim/patches/7.2.308
new file mode 100644
index 00000000..1e19b21d
--- /dev/null
+++ b/source/ap/vim/patches/7.2.308
@@ -0,0 +1,182 @@
+To: vim-dev@vim.org
+Subject: Patch 7.2.308
+Fcc: outbox
+From: Bram Moolenaar <Bram@moolenaar.net>
+Mime-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+------------
+
+Patch 7.2.308
+Problem: When using a regexp in the "\=" expression of a substitute
+ command, submatch() returns empty strings for further lines.
+ (Clockwork Jam)
+Solution: Save and restore the line number and line count when calling
+ reg_getline().
+Files: src/regexp.c
+
+
+*** ../vim-7.2.307/src/regexp.c 2009-11-25 18:21:48.000000000 +0100
+--- src/regexp.c 2009-11-25 19:45:07.000000000 +0100
+***************
+*** 6828,6833 ****
+--- 6828,6835 ----
+ * 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,6947 ****
+ }
+ else
+ {
+- linenr_T save_reg_maxline;
+ win_T *save_reg_win;
+ int save_ireg_ic;
+
+--- 6943,6948 ----
+***************
+*** 6953,6959 ****
+ * vim_regexec_multi() can't be called recursively. */
+ submatch_match = reg_match;
+ submatch_mmatch = reg_mmatch;
+! save_reg_maxline = reg_maxline;
+ save_reg_win = reg_win;
+ save_ireg_ic = ireg_ic;
+ can_f_submatch = TRUE;
+--- 6954,6961 ----
+ * vim_regexec_multi() can't be called recursively. */
+ submatch_match = reg_match;
+ submatch_mmatch = reg_mmatch;
+! submatch_firstlnum = reg_firstlnum;
+! submatch_maxline = reg_maxline;
+ save_reg_win = reg_win;
+ save_ireg_ic = ireg_ic;
+ can_f_submatch = TRUE;
+***************
+*** 6976,6982 ****
+
+ reg_match = submatch_match;
+ reg_mmatch = submatch_mmatch;
+! reg_maxline = save_reg_maxline;
+ reg_win = save_reg_win;
+ ireg_ic = save_ireg_ic;
+ can_f_submatch = FALSE;
+--- 6978,6985 ----
+
+ reg_match = submatch_match;
+ reg_mmatch = submatch_mmatch;
+! reg_firstlnum = submatch_firstlnum;
+! reg_maxline = submatch_maxline;
+ reg_win = save_reg_win;
+ ireg_ic = save_ireg_ic;
+ can_f_submatch = FALSE;
+***************
+*** 7212,7217 ****
+--- 7215,7243 ----
+
+ #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.
+ * Returns NULL when not in a ":s" command and for a non-existing submatch.
+***************
+*** 7241,7247 ****
+ if (lnum < 0 || submatch_mmatch->endpos[no].lnum < 0)
+ return NULL;
+
+! s = reg_getline(lnum) + submatch_mmatch->startpos[no].col;
+ if (s == NULL) /* anti-crash check, cannot happen? */
+ break;
+ if (submatch_mmatch->endpos[no].lnum == lnum)
+--- 7267,7273 ----
+ if (lnum < 0 || submatch_mmatch->endpos[no].lnum < 0)
+ return NULL;
+
+! 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,7273 ****
+ ++lnum;
+ while (lnum < submatch_mmatch->endpos[no].lnum)
+ {
+! s = reg_getline(lnum++);
+ if (round == 2)
+ STRCPY(retval + len, s);
+ len += (int)STRLEN(s);
+--- 7293,7299 ----
+ ++lnum;
+ while (lnum < submatch_mmatch->endpos[no].lnum)
+ {
+! s = reg_getline_submatch(lnum++);
+ if (round == 2)
+ STRCPY(retval + len, s);
+ len += (int)STRLEN(s);
+***************
+*** 7276,7282 ****
+ ++len;
+ }
+ if (round == 2)
+! STRNCPY(retval + len, reg_getline(lnum),
+ submatch_mmatch->endpos[no].col);
+ len += submatch_mmatch->endpos[no].col;
+ if (round == 2)
+--- 7302,7308 ----
+ ++len;
+ }
+ if (round == 2)
+! STRNCPY(retval + len, reg_getline_submatch(lnum),
+ submatch_mmatch->endpos[no].col);
+ len += submatch_mmatch->endpos[no].col;
+ if (round == 2)
+*** ../vim-7.2.307/src/version.c 2009-11-25 18:21:48.000000000 +0100
+--- src/version.c 2009-11-25 19:50:16.000000000 +0100
+***************
+*** 683,684 ****
+--- 683,686 ----
+ { /* Add new patch number below this line */
++ /**/
++ 308,
+ /**/
+
+--
+Engineers are always delighted to share wisdom, even in areas in which they
+have no experience whatsoever. Their logic provides them with inherent
+insight into any field of expertise. This can be a problem when dealing with
+the illogical people who believe that knowledge can only be derived through
+experience.
+ (Scott Adams - The Dilbert principle)
+
+ /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
+/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
+\\\ download, build and distribute -- http://www.A-A-P.org ///
+ \\\ help me help AIDS victims -- http://ICCF-Holland.org ///