]> granicus.if.org Git - vim/commitdiff
updated for version 7.3.609 v7.3.609
authorBram Moolenaar <Bram@vim.org>
Wed, 25 Jul 2012 11:46:30 +0000 (13:46 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 25 Jul 2012 11:46:30 +0000 (13:46 +0200)
Problem:    File names in :checkpath! output are garbled.
Solution:   Check for \zs in the pattern. (Lech Lorens)

src/search.c
src/testdir/test17.in
src/testdir/test17.ok
src/version.c

index e231a3a10e5b48e00dfb2c59a8c10d612354ff49..9f9f0c1c21e695aa4cc045f0a7ee703b338b3133 100644 (file)
@@ -4740,17 +4740,33 @@ find_pattern_in_path(ptr, dir, len, whole, skip_comments,
                         * Isolate the file name.
                         * Include the surrounding "" or <> if present.
                         */
-                       for (p = incl_regmatch.endp[0]; !vim_isfilec(*p); p++)
-                           ;
-                       for (i = 0; vim_isfilec(p[i]); i++)
-                           ;
+                       if (inc_opt != NULL
+                                  && strstr((char *)inc_opt, "\\zs") != NULL)
+                       {
+                           /* pattern contains \zs, use the match */
+                           p = incl_regmatch.startp[0];
+                           i = (int)(incl_regmatch.endp[0]
+                                                  - incl_regmatch.startp[0]);
+                       }
+                       else
+                       {
+                           /* find the file name after the end of the match */
+                           for (p = incl_regmatch.endp[0];
+                                                 *p && !vim_isfilec(*p); p++)
+                               ;
+                           for (i = 0; vim_isfilec(p[i]); i++)
+                               ;
+                       }
+
                        if (i == 0)
                        {
                            /* Nothing found, use the rest of the line. */
                            p = incl_regmatch.endp[0];
                            i = (int)STRLEN(p);
                        }
-                       else
+                       /* Avoid checking before the start of the line, can
+                        * happen if \zs appears in the regexp. */
+                       else if (p > line)
                        {
                            if (p[-1] == '"' || p[-1] == '<')
                            {
index e59144ffbf767125cec63959a53acbe9796bb2df..9c25e99917bff6c9bc35ae6907159b9f33a80aeb 100644 (file)
@@ -1,4 +1,6 @@
-Tests for "gf" on ${VAR}
+Tests for:
+- "gf" on ${VAR},
+- ":checkpath!" with various 'include' settings.
 
 STARTTEST
 :so small.vim
@@ -20,8 +22,99 @@ STARTTEST
 :endif
 gf
 :w! test.out
-:qa!
+:brewind
 ENDTEST
 
        ${CDIR}/test17a.in
        $TDIR/test17a.in
+
+STARTTEST
+:" check for 'include' without \zs or \ze
+:lang C
+:!rm -f ./Xbase.a
+:!rm -rf ./Xdir1
+:!mkdir -p Xdir1/dir2
+:e Xdir1/dir2/foo.a
+i#include   "bar.a"\e
+:w
+:e Xdir1/dir2/bar.a
+i#include      "baz.a"\e
+:w
+:e Xdir1/dir2/baz.a
+i#include            "foo.a"\e
+:w
+:e Xbase.a
+:set path=Xdir1/dir2
+i#include    <foo.a>\e
+:w
+:redir! >>test.out
+:checkpath!
+:redir END
+:brewind
+ENDTEST
+
+STARTTEST
+:" check for 'include' with \zs and \ze
+:!rm -f ./Xbase.b
+:!rm -rf ./Xdir1
+:!mkdir -p Xdir1/dir2
+:let &include='^\s*%inc\s*/\zs[^/]\+\ze'
+:function! DotsToSlashes()
+:  return substitute(v:fname, '\.', '/', 'g') . '.b'
+:endfunction
+:let &includeexpr='DotsToSlashes()'
+:e Xdir1/dir2/foo.b
+i%inc   /bar/\e
+:w
+:e Xdir1/dir2/bar.b
+i%inc      /baz/\e
+:w
+:e Xdir1/dir2/baz.b
+i%inc            /foo/\e
+:w
+:e Xbase.b
+:set path=Xdir1/dir2
+i%inc    /foo/\e
+:w
+:redir! >>test.out
+:checkpath!
+:redir END
+:brewind
+ENDTEST
+
+STARTTEST
+:" check for 'include' with \zs and no \ze
+:!rm -f ./Xbase.c
+:!rm -rf ./Xdir1
+:!mkdir -p Xdir1/dir2
+:let &include='^\s*%inc\s*\%([[:upper:]][^[:space:]]*\s\+\)\?\zs\S\+\ze'
+:function! StripNewlineChar()
+:  if v:fname =~ '\n$'
+:    return v:fname[:-2]
+:  endif
+:  return v:fname
+:endfunction
+:let &includeexpr='StripNewlineChar()'
+:e Xdir1/dir2/foo.c
+i%inc   bar.c\e
+:w
+:e Xdir1/dir2/bar.c
+i%inc      baz.c\e
+:w
+:e Xdir1/dir2/baz.c
+i%inc            foo.c\e
+:w
+:e Xdir1/dir2/FALSE.c
+i%inc            foo.c\e
+:w
+:e Xbase.c
+:set path=Xdir1/dir2
+i%inc    FALSE.c foo.c\e
+:w
+:redir! >>test.out
+:checkpath!
+:redir END
+:brewind
+:q
+ENDTEST
+
index 7e89364797d7d8cfbfcd3cd80087eb80df0f7e3d..79fef07d0213966095a1764498085fb23b7d1d61 100644 (file)
@@ -1,3 +1,33 @@
 This file is just to test "gf" in test 17.
 The contents is not important.
 Just testing!
+
+
+--- Included files in path ---
+Xdir1/dir2/foo.a
+Xdir1/dir2/foo.a -->
+  Xdir1/dir2/bar.a
+  Xdir1/dir2/bar.a -->
+    Xdir1/dir2/baz.a
+    Xdir1/dir2/baz.a -->
+      "foo.a"  (Already listed)
+
+
+--- Included files in path ---
+Xdir1/dir2/foo.b
+Xdir1/dir2/foo.b -->
+  Xdir1/dir2/bar.b
+  Xdir1/dir2/bar.b -->
+    Xdir1/dir2/baz.b
+    Xdir1/dir2/baz.b -->
+      foo  (Already listed)
+
+
+--- Included files in path ---
+Xdir1/dir2/foo.c
+Xdir1/dir2/foo.c -->
+  Xdir1/dir2/bar.c
+  Xdir1/dir2/bar.c -->
+    Xdir1/dir2/baz.c
+    Xdir1/dir2/baz.c -->
+      foo.c^@  (Already listed)
index c8a283e06b924b9ae7422753bcb9a7a81d9dcbfc..397d9b09d3e188bfcdf481787130fadc5a75854e 100644 (file)
@@ -714,6 +714,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    609,
 /**/
     608,
 /**/