Karsten Hopp a4e9cd
To: vim_dev@googlegroups.com
Karsten Hopp a4e9cd
Subject: Patch 7.3.609
Karsten Hopp a4e9cd
Fcc: outbox
Karsten Hopp a4e9cd
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp a4e9cd
Mime-Version: 1.0
Karsten Hopp a4e9cd
Content-Type: text/plain; charset=UTF-8
Karsten Hopp a4e9cd
Content-Transfer-Encoding: 8bit
Karsten Hopp a4e9cd
------------
Karsten Hopp a4e9cd
Karsten Hopp a4e9cd
Patch 7.3.609
Karsten Hopp a4e9cd
Problem:    File names in :checkpath! output are garbled.
Karsten Hopp a4e9cd
Solution:   Check for \zs in the pattern. (Lech Lorens)
Karsten Hopp a4e9cd
Files:	    src/search.c, src/testdir/test17.in, src/testdir/test17.ok
Karsten Hopp a4e9cd
Karsten Hopp a4e9cd
Karsten Hopp a4e9cd
*** ../vim-7.3.608/src/search.c	2012-07-19 17:18:21.000000000 +0200
Karsten Hopp a4e9cd
--- src/search.c	2012-07-25 13:33:08.000000000 +0200
Karsten Hopp a4e9cd
***************
Karsten Hopp a4e9cd
*** 4740,4756 ****
Karsten Hopp a4e9cd
  			 * Isolate the file name.
Karsten Hopp a4e9cd
  			 * Include the surrounding "" or <> if present.
Karsten Hopp a4e9cd
  			 */
Karsten Hopp a4e9cd
! 			for (p = incl_regmatch.endp[0]; !vim_isfilec(*p); p++)
Karsten Hopp a4e9cd
! 			    ;
Karsten Hopp a4e9cd
! 			for (i = 0; vim_isfilec(p[i]); i++)
Karsten Hopp a4e9cd
! 			    ;
Karsten Hopp a4e9cd
  			if (i == 0)
Karsten Hopp a4e9cd
  			{
Karsten Hopp a4e9cd
  			    /* Nothing found, use the rest of the line. */
Karsten Hopp a4e9cd
  			    p = incl_regmatch.endp[0];
Karsten Hopp a4e9cd
  			    i = (int)STRLEN(p);
Karsten Hopp a4e9cd
  			}
Karsten Hopp a4e9cd
! 			else
Karsten Hopp a4e9cd
  			{
Karsten Hopp a4e9cd
  			    if (p[-1] == '"' || p[-1] == '<')
Karsten Hopp a4e9cd
  			    {
Karsten Hopp a4e9cd
--- 4740,4772 ----
Karsten Hopp a4e9cd
  			 * Isolate the file name.
Karsten Hopp a4e9cd
  			 * Include the surrounding "" or <> if present.
Karsten Hopp a4e9cd
  			 */
Karsten Hopp a4e9cd
! 			if (inc_opt != NULL
Karsten Hopp a4e9cd
! 				   && strstr((char *)inc_opt, "\\zs") != NULL)
Karsten Hopp a4e9cd
! 			{
Karsten Hopp a4e9cd
! 			    /* pattern contains \zs, use the match */
Karsten Hopp a4e9cd
! 			    p = incl_regmatch.startp[0];
Karsten Hopp a4e9cd
! 			    i = (int)(incl_regmatch.endp[0]
Karsten Hopp a4e9cd
! 						   - incl_regmatch.startp[0]);
Karsten Hopp a4e9cd
! 			}
Karsten Hopp a4e9cd
! 			else
Karsten Hopp a4e9cd
! 			{
Karsten Hopp a4e9cd
! 			    /* find the file name after the end of the match */
Karsten Hopp a4e9cd
! 			    for (p = incl_regmatch.endp[0];
Karsten Hopp a4e9cd
! 						  *p && !vim_isfilec(*p); p++)
Karsten Hopp a4e9cd
! 				;
Karsten Hopp a4e9cd
! 			    for (i = 0; vim_isfilec(p[i]); i++)
Karsten Hopp a4e9cd
! 				;
Karsten Hopp a4e9cd
! 			}
Karsten Hopp a4e9cd
! 
Karsten Hopp a4e9cd
  			if (i == 0)
Karsten Hopp a4e9cd
  			{
Karsten Hopp a4e9cd
  			    /* Nothing found, use the rest of the line. */
Karsten Hopp a4e9cd
  			    p = incl_regmatch.endp[0];
Karsten Hopp a4e9cd
  			    i = (int)STRLEN(p);
Karsten Hopp a4e9cd
  			}
Karsten Hopp a4e9cd
! 			/* Avoid checking before the start of the line, can
Karsten Hopp a4e9cd
! 			 * happen if \zs appears in the regexp. */
Karsten Hopp a4e9cd
! 			else if (p > line)
Karsten Hopp a4e9cd
  			{
Karsten Hopp a4e9cd
  			    if (p[-1] == '"' || p[-1] == '<')
Karsten Hopp a4e9cd
  			    {
Karsten Hopp a4e9cd
*** ../vim-7.3.608/src/testdir/test17.in	2010-08-15 21:57:29.000000000 +0200
Karsten Hopp a4e9cd
--- src/testdir/test17.in	2012-07-25 13:41:43.000000000 +0200
Karsten Hopp a4e9cd
***************
Karsten Hopp a4e9cd
*** 1,4 ****
Karsten Hopp a4e9cd
! Tests for "gf" on ${VAR}
Karsten Hopp a4e9cd
  
Karsten Hopp a4e9cd
  STARTTEST
Karsten Hopp a4e9cd
  :so small.vim
Karsten Hopp a4e9cd
--- 1,6 ----
Karsten Hopp a4e9cd
! Tests for:
Karsten Hopp a4e9cd
! - "gf" on ${VAR},
Karsten Hopp a4e9cd
! - ":checkpath!" with various 'include' settings.
Karsten Hopp a4e9cd
  
Karsten Hopp a4e9cd
  STARTTEST
Karsten Hopp a4e9cd
  :so small.vim
Karsten Hopp a4e9cd
***************
Karsten Hopp a4e9cd
*** 20,27 ****
Karsten Hopp a4e9cd
  :endif
Karsten Hopp a4e9cd
  gf
Karsten Hopp a4e9cd
  :w! test.out
Karsten Hopp a4e9cd
! :qa!
Karsten Hopp a4e9cd
  ENDTEST
Karsten Hopp a4e9cd
  
Karsten Hopp a4e9cd
  	${CDIR}/test17a.in
Karsten Hopp a4e9cd
  	$TDIR/test17a.in
Karsten Hopp a4e9cd
--- 22,120 ----
Karsten Hopp a4e9cd
  :endif
Karsten Hopp a4e9cd
  gf
Karsten Hopp a4e9cd
  :w! test.out
Karsten Hopp a4e9cd
! :brewind
Karsten Hopp a4e9cd
  ENDTEST
Karsten Hopp a4e9cd
  
Karsten Hopp a4e9cd
  	${CDIR}/test17a.in
Karsten Hopp a4e9cd
  	$TDIR/test17a.in
Karsten Hopp a4e9cd
+ 
Karsten Hopp a4e9cd
+ STARTTEST
Karsten Hopp a4e9cd
+ :" check for 'include' without \zs or \ze
Karsten Hopp a4e9cd
+ :lang C
Karsten Hopp a4e9cd
+ :!rm -f ./Xbase.a
Karsten Hopp a4e9cd
+ :!rm -rf ./Xdir1
Karsten Hopp a4e9cd
+ :!mkdir -p Xdir1/dir2
Karsten Hopp a4e9cd
+ :e Xdir1/dir2/foo.a
Karsten Hopp a4e9cd
+ i#include   "bar.a"?
Karsten Hopp a4e9cd
+ :w
Karsten Hopp a4e9cd
+ :e Xdir1/dir2/bar.a
Karsten Hopp a4e9cd
+ i#include      "baz.a"?
Karsten Hopp a4e9cd
+ :w
Karsten Hopp a4e9cd
+ :e Xdir1/dir2/baz.a
Karsten Hopp a4e9cd
+ i#include            "foo.a"?
Karsten Hopp a4e9cd
+ :w
Karsten Hopp a4e9cd
+ :e Xbase.a
Karsten Hopp a4e9cd
+ :set path=Xdir1/dir2
Karsten Hopp a4e9cd
+ i#include    <foo.a>?
Karsten Hopp a4e9cd
+ :w
Karsten Hopp a4e9cd
+ :redir! >>test.out
Karsten Hopp a4e9cd
+ :checkpath!
Karsten Hopp a4e9cd
+ :redir END
Karsten Hopp a4e9cd
+ :brewind
Karsten Hopp a4e9cd
+ ENDTEST
Karsten Hopp a4e9cd
+ 
Karsten Hopp a4e9cd
+ STARTTEST
Karsten Hopp a4e9cd
+ :" check for 'include' with \zs and \ze
Karsten Hopp a4e9cd
+ :!rm -f ./Xbase.b
Karsten Hopp a4e9cd
+ :!rm -rf ./Xdir1
Karsten Hopp a4e9cd
+ :!mkdir -p Xdir1/dir2
Karsten Hopp a4e9cd
+ :let &include='^\s*%inc\s*/\zs[^/]\+\ze'
Karsten Hopp a4e9cd
+ :function! DotsToSlashes()
Karsten Hopp a4e9cd
+ :  return substitute(v:fname, '\.', '/', 'g') . '.b'
Karsten Hopp a4e9cd
+ :endfunction
Karsten Hopp a4e9cd
+ :let &includeexpr='DotsToSlashes()'
Karsten Hopp a4e9cd
+ :e Xdir1/dir2/foo.b
Karsten Hopp a4e9cd
+ i%inc   /bar/?
Karsten Hopp a4e9cd
+ :w
Karsten Hopp a4e9cd
+ :e Xdir1/dir2/bar.b
Karsten Hopp a4e9cd
+ i%inc      /baz/?
Karsten Hopp a4e9cd
+ :w
Karsten Hopp a4e9cd
+ :e Xdir1/dir2/baz.b
Karsten Hopp a4e9cd
+ i%inc            /foo/?
Karsten Hopp a4e9cd
+ :w
Karsten Hopp a4e9cd
+ :e Xbase.b
Karsten Hopp a4e9cd
+ :set path=Xdir1/dir2
Karsten Hopp a4e9cd
+ i%inc    /foo/?
Karsten Hopp a4e9cd
+ :w
Karsten Hopp a4e9cd
+ :redir! >>test.out
Karsten Hopp a4e9cd
+ :checkpath!
Karsten Hopp a4e9cd
+ :redir END
Karsten Hopp a4e9cd
+ :brewind
Karsten Hopp a4e9cd
+ ENDTEST
Karsten Hopp a4e9cd
+ 
Karsten Hopp a4e9cd
+ STARTTEST
Karsten Hopp a4e9cd
+ :" check for 'include' with \zs and no \ze
Karsten Hopp a4e9cd
+ :!rm -f ./Xbase.c
Karsten Hopp a4e9cd
+ :!rm -rf ./Xdir1
Karsten Hopp a4e9cd
+ :!mkdir -p Xdir1/dir2
Karsten Hopp a4e9cd
+ :let &include='^\s*%inc\s*\%([[:upper:]][^[:space:]]*\s\+\)\?\zs\S\+\ze'
Karsten Hopp a4e9cd
+ :function! StripNewlineChar()
Karsten Hopp a4e9cd
+ :  if v:fname =~ '\n$'
Karsten Hopp a4e9cd
+ :    return v:fname[:-2]
Karsten Hopp a4e9cd
+ :  endif
Karsten Hopp a4e9cd
+ :  return v:fname
Karsten Hopp a4e9cd
+ :endfunction
Karsten Hopp a4e9cd
+ :let &includeexpr='StripNewlineChar()'
Karsten Hopp a4e9cd
+ :e Xdir1/dir2/foo.c
Karsten Hopp a4e9cd
+ i%inc   bar.c?
Karsten Hopp a4e9cd
+ :w
Karsten Hopp a4e9cd
+ :e Xdir1/dir2/bar.c
Karsten Hopp a4e9cd
+ i%inc      baz.c?
Karsten Hopp a4e9cd
+ :w
Karsten Hopp a4e9cd
+ :e Xdir1/dir2/baz.c
Karsten Hopp a4e9cd
+ i%inc            foo.c?
Karsten Hopp a4e9cd
+ :w
Karsten Hopp a4e9cd
+ :e Xdir1/dir2/FALSE.c
Karsten Hopp a4e9cd
+ i%inc            foo.c?
Karsten Hopp a4e9cd
+ :w
Karsten Hopp a4e9cd
+ :e Xbase.c
Karsten Hopp a4e9cd
+ :set path=Xdir1/dir2
Karsten Hopp a4e9cd
+ i%inc    FALSE.c foo.c?
Karsten Hopp a4e9cd
+ :w
Karsten Hopp a4e9cd
+ :redir! >>test.out
Karsten Hopp a4e9cd
+ :checkpath!
Karsten Hopp a4e9cd
+ :redir END
Karsten Hopp a4e9cd
+ :brewind
Karsten Hopp a4e9cd
+ :q
Karsten Hopp a4e9cd
+ ENDTEST
Karsten Hopp a4e9cd
+ 
Karsten Hopp a4e9cd
*** ../vim-7.3.608/src/testdir/test17.ok	2010-08-15 21:57:29.000000000 +0200
Karsten Hopp a4e9cd
--- src/testdir/test17.ok	2012-07-25 13:45:37.000000000 +0200
Karsten Hopp a4e9cd
***************
Karsten Hopp a4e9cd
*** 1,3 ****
Karsten Hopp a4e9cd
--- 1,33 ----
Karsten Hopp a4e9cd
  This file is just to test "gf" in test 17.
Karsten Hopp a4e9cd
  The contents is not important.
Karsten Hopp a4e9cd
  Just testing!
Karsten Hopp a4e9cd
+ 
Karsten Hopp a4e9cd
+ 
Karsten Hopp a4e9cd
+ --- Included files in path ---
Karsten Hopp a4e9cd
+ Xdir1/dir2/foo.a
Karsten Hopp a4e9cd
+ Xdir1/dir2/foo.a -->
Karsten Hopp a4e9cd
+   Xdir1/dir2/bar.a
Karsten Hopp a4e9cd
+   Xdir1/dir2/bar.a -->
Karsten Hopp a4e9cd
+     Xdir1/dir2/baz.a
Karsten Hopp a4e9cd
+     Xdir1/dir2/baz.a -->
Karsten Hopp a4e9cd
+       "foo.a"  (Already listed)
Karsten Hopp a4e9cd
+ 
Karsten Hopp a4e9cd
+ 
Karsten Hopp a4e9cd
+ --- Included files in path ---
Karsten Hopp a4e9cd
+ Xdir1/dir2/foo.b
Karsten Hopp a4e9cd
+ Xdir1/dir2/foo.b -->
Karsten Hopp a4e9cd
+   Xdir1/dir2/bar.b
Karsten Hopp a4e9cd
+   Xdir1/dir2/bar.b -->
Karsten Hopp a4e9cd
+     Xdir1/dir2/baz.b
Karsten Hopp a4e9cd
+     Xdir1/dir2/baz.b -->
Karsten Hopp a4e9cd
+       foo  (Already listed)
Karsten Hopp a4e9cd
+ 
Karsten Hopp a4e9cd
+ 
Karsten Hopp a4e9cd
+ --- Included files in path ---
Karsten Hopp a4e9cd
+ Xdir1/dir2/foo.c
Karsten Hopp a4e9cd
+ Xdir1/dir2/foo.c -->
Karsten Hopp a4e9cd
+   Xdir1/dir2/bar.c
Karsten Hopp a4e9cd
+   Xdir1/dir2/bar.c -->
Karsten Hopp a4e9cd
+     Xdir1/dir2/baz.c
Karsten Hopp a4e9cd
+     Xdir1/dir2/baz.c -->
Karsten Hopp a4e9cd
+       foo.c^@  (Already listed)
Karsten Hopp a4e9cd
*** ../vim-7.3.608/src/version.c	2012-07-19 18:05:40.000000000 +0200
Karsten Hopp a4e9cd
--- src/version.c	2012-07-25 13:38:54.000000000 +0200
Karsten Hopp a4e9cd
***************
Karsten Hopp a4e9cd
*** 716,717 ****
Karsten Hopp a4e9cd
--- 716,719 ----
Karsten Hopp a4e9cd
  {   /* Add new patch number below this line */
Karsten Hopp a4e9cd
+ /**/
Karsten Hopp a4e9cd
+     609,
Karsten Hopp a4e9cd
  /**/
Karsten Hopp a4e9cd
Karsten Hopp a4e9cd
-- 
Karsten Hopp a4e9cd
"The question of whether computers can think is just like the question
Karsten Hopp a4e9cd
of whether submarines can swim."      -- Edsger W. Dijkstra
Karsten Hopp a4e9cd
Karsten Hopp a4e9cd
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp a4e9cd
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp a4e9cd
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp a4e9cd
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///