]> granicus.if.org Git - vim/commitdiff
updated for version 7.3.225 v7.3.225
authorBram Moolenaar <Bram@vim.org>
Sun, 19 Jun 2011 02:32:15 +0000 (04:32 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 19 Jun 2011 02:32:15 +0000 (04:32 +0200)
Problem:    Using "\n" in a substitute inside ":s" does not result in a line
            break.
Solution:   Change behavior inside vim_regexec_nl().   Add tests.  (Motoya
            Kurotsu)

12 files changed:
src/regexp.c
src/testdir/Make_amiga.mak
src/testdir/Make_dos.mak
src/testdir/Make_ming.mak
src/testdir/Make_os2.mak
src/testdir/Make_vms.mms
src/testdir/Makefile
src/testdir/test79.in [new file with mode: 0644]
src/testdir/test79.ok [new file with mode: 0644]
src/testdir/test80.in [new file with mode: 0644]
src/testdir/test80.ok [new file with mode: 0644]
src/version.c

index 57ea7369690d89c9ee19429e256e2df5a327c04e..a09ab6194b2015c87d73732c00dbbdf767f95ec5 100644 (file)
@@ -6872,6 +6872,7 @@ static regmatch_T *submatch_match;
 static regmmatch_T     *submatch_mmatch;
 static linenr_T                submatch_firstlnum;
 static linenr_T                submatch_maxline;
+static int             submatch_line_lbr;
 #endif
 
 #if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) || defined(PROTO)
@@ -6998,6 +6999,7 @@ vim_regsub_both(source, dest, copy, magic, backslash)
            submatch_mmatch = reg_mmatch;
            submatch_firstlnum = reg_firstlnum;
            submatch_maxline = reg_maxline;
+           submatch_line_lbr = reg_line_lbr;
            save_reg_win = reg_win;
            save_ireg_ic = ireg_ic;
            can_f_submatch = TRUE;
@@ -7009,9 +7011,10 @@ vim_regsub_both(source, dest, copy, magic, backslash)
 
                for (s = eval_result; *s != NUL; mb_ptr_adv(s))
                {
-                   /* Change NL to CR, so that it becomes a line break.
+                   /* Change NL to CR, so that it becomes a line break,
+                    * unless called from vim_regexec_nl().
                     * Skip over a backslashed character. */
-                   if (*s == NL)
+                   if (*s == NL && !submatch_line_lbr)
                        *s = CAR;
                    else if (*s == '\\' && s[1] != NUL)
                    {
@@ -7020,8 +7023,9 @@ vim_regsub_both(source, dest, copy, magic, backslash)
                         * :s/abc\\\ndef/\="aaa\\\nbbb"/  on text:
                         *   abc\
                         *   def
+                        * Not when called from vim_regexec_nl().
                         */
-                       if (*s == NL)
+                       if (*s == NL && !submatch_line_lbr)
                            *s = CAR;
                        had_backslash = TRUE;
                    }
@@ -7044,6 +7048,7 @@ vim_regsub_both(source, dest, copy, magic, backslash)
            reg_mmatch = submatch_mmatch;
            reg_firstlnum = submatch_firstlnum;
            reg_maxline = submatch_maxline;
+           reg_line_lbr = submatch_line_lbr;
            reg_win = save_reg_win;
            ireg_ic = save_ireg_ic;
            can_f_submatch = FALSE;
index 7eae20cfe5905273706b4156cdf1c401c6e4eb61..e9c30c450e8c57ef6ae5db02cdf3db0b4c8ffe28 100644 (file)
@@ -28,7 +28,7 @@ SCRIPTS = test1.out test3.out test4.out test5.out test6.out \
                test61.out test62.out test63.out test64.out test65.out \
                test66.out test67.out test68.out test69.out test70.out \
                test71.out test72.out test73.out test74.out test75.out \
-               test76.out test77.out test78.out
+               test76.out test77.out test78.out test79.out test80.out
 
 .SUFFIXES: .in .out
 
@@ -126,3 +126,5 @@ test75.out: test75.in
 test76.out: test76.in
 test77.out: test77.in
 test78.out: test78.in
+test79.out: test79.in
+test80.out: test80.in
index 3c221d03e1baed1423eb8d37b247735e92cc3c44..e6b5ff2e0c90b911bbcd2c59e2675adadabf1bb9 100644 (file)
@@ -28,7 +28,8 @@ SCRIPTS =     test3.out test4.out test5.out test6.out test7.out \
                test37.out test38.out test39.out test40.out test41.out \
                test42.out test52.out test65.out test66.out test67.out \
                test68.out test69.out test71.out test72.out test73.out \
-               test74.out test75.out test76.out test77.out test78.out
+               test74.out test75.out test76.out test77.out test78.out \
+               test79.out test80.out
 
 SCRIPTS32 =    test50.out test70.out
 
index 1735062a26bb45c90c024d38b3fff77bbeee9b94..e7528259d73c7798fb35aa20410b502e1bfe04e8 100644 (file)
@@ -48,7 +48,8 @@ SCRIPTS =     test3.out test4.out test5.out test6.out test7.out \
                test37.out test38.out test39.out test40.out test41.out \
                test42.out test52.out test65.out test66.out test67.out \
                test68.out test69.out test71.out test72.out test73.out \
-               test74.out test75.out test76.out test77.out test78.out
+               test74.out test75.out test76.out test77.out test78.out \
+               test79.out test80.out
 
 SCRIPTS32 =    test50.out test70.out
 
index 82e07f45493ff89d12d229b0f3493ea0cb8c2bb8..a80dff5deae148225884d5a983b3ce9d0fbedc0e 100644 (file)
@@ -28,7 +28,7 @@ SCRIPTS = test1.out test3.out test4.out test5.out test6.out \
                test61.out test62.out test63.out test64.out test65.out \
                test66.out test67.out test68.out test69.out test70.out \
                test71.out test72.out test73.out test74.out test75.out \
-               test76.out test77.out test78.out
+               test76.out test77.out test78.out test79.out test80.out
 
 .SUFFIXES: .in .out
 
index 7702b98017633050559f8b62c9cac14c722e714f..58ab4e8129d4ca416c9c67faeff9ee9aa05023ca 100644 (file)
@@ -4,7 +4,7 @@
 # Authors:     Zoltan Arpadffy, <arpadffy@polarhome.com>
 #              Sandor Kopanyi,  <sandor.kopanyi@mailbox.hu>
 #
-# Last change:  2011 Jun 13
+# Last change:  2011 Jun 19
 #
 # This has been tested on VMS 6.2 to 8.3 on DEC Alpha, VAX and IA64.
 # Edit the lines in the Configuration section below to select.
@@ -75,7 +75,7 @@ SCRIPT = test1.out  test2.out  test3.out  test4.out  test5.out  \
         test61.out test62.out test63.out test64.out test65.out \
         test66.out test67.out test68.out test69.out \
         test71.out test72.out test74.out test75.out test76.out \
-        test77.out test78.out
+        test77.out test78.out test79.out test80.out
 
 # Known problems:
 # Test 30: a problem around mac format - unknown reason
index 7a2a09fb3463129df0fece8a02fea5aa7f9dbd28..85610162739fb5ae16b16ee67e91d382c1c9ad3e 100644 (file)
@@ -25,7 +25,8 @@ SCRIPTS = test1.out test2.out test3.out test4.out test5.out test6.out \
                test59.out test60.out test61.out test62.out test63.out \
                test64.out test65.out test66.out test67.out test68.out \
                test69.out test70.out test71.out test72.out test73.out \
-               test74.out test75.out test76.out test77.out test78.out
+               test74.out test75.out test76.out test77.out test78.out \
+               test79.out test80.out
 
 SCRIPTS_GUI = test16.out
 
diff --git a/src/testdir/test79.in b/src/testdir/test79.in
new file mode 100644 (file)
index 0000000..8fa11d9
Binary files /dev/null and b/src/testdir/test79.in differ
diff --git a/src/testdir/test79.ok b/src/testdir/test79.ok
new file mode 100644 (file)
index 0000000..6685b44
Binary files /dev/null and b/src/testdir/test79.ok differ
diff --git a/src/testdir/test80.in b/src/testdir/test80.in
new file mode 100644 (file)
index 0000000..b496500
--- /dev/null
@@ -0,0 +1,150 @@
+Test for *sub-replace-special* and *sub-replace-expression* on substitue().
+Test for submatch() on substitue().
+Test for *:s%* on :substitute.
+
+STARTTEST
+:so small.vim
+ENDTEST
+
+TEST_1:
+
+STARTTEST
+:set magic
+:set cpo&
+:$put =\"\n\nTEST_1:\"
+:$put =substitute('A', 'A', '&&', '')
+:$put =substitute('B', 'B', '\&', '')
+:$put =substitute('C123456789', 'C\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)', '\0\9\8\7\6\5\4\3\2\1', '')
+:$put =substitute('D', 'D', 'd', '')
+:$put =substitute('E', 'E', '~', '')
+:$put =substitute('F', 'F', '\~', '')
+:$put =substitute('G', 'G', '\ugg', '')
+:$put =substitute('H', 'H', '\Uh\Eh', '')
+:$put =substitute('I', 'I', '\lII', '')
+:$put =substitute('J', 'J', '\LJ\EJ', '')
+:$put =substitute('K', 'K', '\Uk\ek', '')
+:$put =substitute('lLl', 'L', '\16\r', '')
+:$put =substitute('mMm', 'M', '\r', '')
+:$put =substitute('nNn', 'N', '\\16\r', '')
+:$put =substitute('oOo', 'O', '\n', '')
+:$put =substitute('pPp', 'P', '\b', '')
+:$put =substitute('qQq', 'Q', '\t', '')
+:$put =substitute('rRr', 'R', '\\', '')
+:$put =substitute('sSs', 'S', '\c', '')
+:$put =substitute('uUu', 'U', \"\n\", '')
+:$put =substitute('vVv', 'V', \"\b\", '')
+:$put =substitute('wWw', 'W', \"\\\", '')
+:$put =substitute('xXx', 'X', \"\r\", '')
+/^TEST_2
+ENDTEST
+
+TEST_2:
+
+STARTTEST
+:set nomagic
+:set cpo&
+:$put =\"\n\nTEST_2:\"
+:$put =substitute('A', 'A', '&&', '')
+:$put =substitute('B', 'B', '\&', '')
+:$put =substitute('C123456789', 'C\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)', '\0\9\8\7\6\5\4\3\2\1', '')
+:$put =substitute('D', 'D', 'd', '')
+:$put =substitute('E', 'E', '~', '')
+:$put =substitute('F', 'F', '\~', '')
+:$put =substitute('G', 'G', '\ugg', '')
+:$put =substitute('H', 'H', '\Uh\Eh', '')
+:$put =substitute('I', 'I', '\lII', '')
+:$put =substitute('J', 'J', '\LJ\EJ', '')
+:$put =substitute('K', 'K', '\Uk\ek', '')
+:$put =substitute('lLl', 'L', '\16\r', '')
+:$put =substitute('mMm', 'M', '\r', '')
+:$put =substitute('nNn', 'N', '\\16\r', '')
+:$put =substitute('oOo', 'O', '\n', '')
+:$put =substitute('pPp', 'P', '\b', '')
+:$put =substitute('qQq', 'Q', '\t', '')
+:$put =substitute('rRr', 'R', '\\', '')
+:$put =substitute('sSs', 'S', '\c', '')
+:$put =substitute('tTt', 'T', \"\r\", '')
+:$put =substitute('uUu', 'U', \"\n\", '')
+:$put =substitute('vVv', 'V', \"\b\", '')
+:$put =substitute('wWw', 'W', \"\\\", '')
+/^TEST_3
+ENDTEST
+
+TEST_3:
+
+STARTTEST
+:set magic&
+:set cpo&
+:$put =\"\n\nTEST_3:\"
+:let y = substitute('aAa', 'A', '\="\\"', '')           | $put =y
+:let y = substitute('bBb', 'B', '\="\\\\"', '')         | $put =y
+:let y = substitute('cCc', 'C', '\="\16\r"', '')         | $put =y
+:let y = substitute('dDd', 'D', '\="\\\16\r"', '')       | $put =y
+:let y = substitute('eEe', 'E', '\="\\\\\16\r"', '')     | $put =y
+:let y = substitute('fFf', 'F', '\="\\r"', '')          | $put =y
+:let y = substitute('jJj', 'J', '\="\\n"', '')          | $put =y
+:let y = substitute('kKk', 'K', '\="\r"', '')           | $put =y
+:let y = substitute('lLl', 'L', '\="\n"', '')           | $put =y
+/^TEST_4
+ENDTEST
+
+TEST_4:
+
+STARTTEST
+:set magic&
+:set cpo&
+:$put =\"\n\nTEST_4:\"
+:let y = substitute('aAa', 'A', '\=substitute(submatch(0), ".", "\\", "")', '')       | $put =y
+:let y = substitute('bBb', 'B', '\=substitute(submatch(0), ".", "\\\\", "")', '')     | $put =y
+:let y = substitute('cCc', 'C', '\=substitute(submatch(0), ".", "\16\r", "")', '')     | $put =y
+:let y = substitute('dDd', 'D', '\=substitute(submatch(0), ".", "\\\16\r", "")', '')   | $put =y
+:let y = substitute('eEe', 'E', '\=substitute(submatch(0), ".", "\\\\\16\r", "")', '') | $put =y
+:let y = substitute('fFf', 'F', '\=substitute(submatch(0), ".", "\\r", "")', '')      | $put =y
+:let y = substitute('jJj', 'J', '\=substitute(submatch(0), ".", "\\n", "")', '')      | $put =y
+:let y = substitute('kKk', 'K', '\=substitute(submatch(0), ".", "\r", "")', '')       | $put =y
+:let y = substitute('lLl', 'L', '\=substitute(submatch(0), ".", "\n", "")', '')       | $put =y
+/^TEST_5
+ENDTEST
+
+TEST_5:
+
+STARTTEST
+:set magic&
+:set cpo&
+:$put =\"\n\nTEST_5:\"
+:$put =substitute('A123456789', 'A\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)', '\=submatch(0) . submatch(9) . submatch(8) . submatch(7) . submatch(6) . submatch(5) . submatch(4) . submatch(3) . submatch(2) . submatch(1)', '')
+/^TEST_6
+ENDTEST
+
+TEST_6:
+
+STARTTEST
+:set magic&
+:$put =\"\n\nTEST_6:\"
+:set cpo+=/
+:$put =substitute('A', 'A', 'a', '')
+:$put =substitute('B', 'B', '%', '')
+:set cpo-=/
+:$put =substitute('C', 'C', 'c', '')
+:$put =substitute('D', 'D', '%', '')
+/^TEST_7
+ENDTEST
+
+TEST_7:
+
+STARTTEST
+:set magic&
+:set cpo&
+:$put =\"\n\nTEST_7:\"
+:$put =substitute('A\16\rA', 'A.', '\=submatch(0)', '')
+:$put =substitute(\"B\nB\", 'B.', '\=submatch(0)', '')
+/^TEST_8
+ENDTEST
+
+TEST_8:
+
+STARTTEST
+:/^Results/,$wq! test.out
+ENDTEST
+
+Results of test72:
diff --git a/src/testdir/test80.ok b/src/testdir/test80.ok
new file mode 100644 (file)
index 0000000..fd5b5e7
--- /dev/null
@@ -0,0 +1,101 @@
+Results of test72:
+
+
+TEST_1:
+AA
+&
+C123456789987654321
+d
+~
+~
+Gg
+Hh
+iI
+jJ
+Kk
+l\rl
+m\rm
+n\rn
+o
+o
+p\bp
+q      q
+r\r
+scs
+u
+u
+v\bv
+w\w
+x\rx
+
+
+TEST_2:
+AA
+&
+C123456789987654321
+d
+~
+~
+Gg
+Hh
+iI
+jJ
+Kk
+l\rl
+m\rm
+n\rn
+o
+o
+p\bp
+q      q
+r\r
+scs
+t\rt
+u
+u
+v\bv
+w\w
+
+
+TEST_3:
+a\a
+b\\b
+c\rc
+d\\rd
+e\\\re
+f\rf
+j\nj
+k\rk
+l
+l
+
+
+TEST_4:
+a\a
+b\b
+c\rc
+d\rd
+e\\re
+f\rf
+j
+j
+k\rk
+l
+l
+
+
+TEST_5:
+A123456789987654321
+
+
+TEST_6:
+a
+%
+c
+%
+
+
+TEST_7:
+A\rA
+B
+B
index a5afd2242e9c4c825224c7767386d01cc27d41d2..f169b56a301668e8ba3fc7195ca94577504ea651 100644 (file)
@@ -709,6 +709,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    225,
 /**/
     224,
 /**/