Karsten Hopp 58534c
To: vim-dev@vim.org
Karsten Hopp 58534c
Subject: Patch 7.2.259
Karsten Hopp 58534c
Fcc: outbox
Karsten Hopp 58534c
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 58534c
Mime-Version: 1.0
Karsten Hopp 58534c
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 58534c
Content-Transfer-Encoding: 8bit
Karsten Hopp 58534c
------------
Karsten Hopp 58534c
Karsten Hopp 58534c
Patch 7.2.259
Karsten Hopp 58534c
Problem:    exists() doesn't work properly for an empty aucmd group.
Karsten Hopp 58534c
Solution:   Change how au_exists() handles a missing pattern.  Also add a
Karsten Hopp 58534c
	    test for this. (Bob Hiestand)
Karsten Hopp 58534c
Files:	    src/fileio.c, src/testdir/Makefile, src/testdir/test67.in,
Karsten Hopp 58534c
	    src/testdir/test67.ok
Karsten Hopp 58534c
Karsten Hopp 58534c
Karsten Hopp 58534c
*** ../vim-7.2.258/src/fileio.c	2009-09-11 15:04:13.000000000 +0200
Karsten Hopp 58534c
--- src/fileio.c	2009-09-11 16:37:08.000000000 +0200
Karsten Hopp 58534c
***************
Karsten Hopp 58534c
*** 9498,9512 ****
Karsten Hopp 58534c
      ap = first_autopat[(int)event];
Karsten Hopp 58534c
      if (ap == NULL)
Karsten Hopp 58534c
  	goto theend;
Karsten Hopp 58534c
-     if (pattern == NULL)
Karsten Hopp 58534c
-     {
Karsten Hopp 58534c
- 	retval = TRUE;
Karsten Hopp 58534c
- 	goto theend;
Karsten Hopp 58534c
-     }
Karsten Hopp 58534c
  
Karsten Hopp 58534c
      /* if pattern is "<buffer>", special handling is needed which uses curbuf */
Karsten Hopp 58534c
      /* for pattern "<buffer=N>, fnamecmp() will work fine */
Karsten Hopp 58534c
!     if (STRICMP(pattern, "<buffer>") == 0)
Karsten Hopp 58534c
  	buflocal_buf = curbuf;
Karsten Hopp 58534c
  
Karsten Hopp 58534c
      /* Check if there is an autocommand with the given pattern. */
Karsten Hopp 58534c
--- 9498,9507 ----
Karsten Hopp 58534c
      ap = first_autopat[(int)event];
Karsten Hopp 58534c
      if (ap == NULL)
Karsten Hopp 58534c
  	goto theend;
Karsten Hopp 58534c
  
Karsten Hopp 58534c
      /* if pattern is "<buffer>", special handling is needed which uses curbuf */
Karsten Hopp 58534c
      /* for pattern "<buffer=N>, fnamecmp() will work fine */
Karsten Hopp 58534c
!     if (pattern != NULL && STRICMP(pattern, "<buffer>") == 0)
Karsten Hopp 58534c
  	buflocal_buf = curbuf;
Karsten Hopp 58534c
  
Karsten Hopp 58534c
      /* Check if there is an autocommand with the given pattern. */
Karsten Hopp 58534c
***************
Karsten Hopp 58534c
*** 9515,9523 ****
Karsten Hopp 58534c
  	/* For buffer-local autocommands, fnamecmp() works fine. */
Karsten Hopp 58534c
  	if (ap->pat != NULL && ap->cmds != NULL
Karsten Hopp 58534c
  	    && (group == AUGROUP_ALL || ap->group == group)
Karsten Hopp 58534c
! 	    && (buflocal_buf == NULL
Karsten Hopp 58534c
! 		 ? fnamecmp(ap->pat, pattern) == 0
Karsten Hopp 58534c
! 		 : ap->buflocal_nr == buflocal_buf->b_fnum))
Karsten Hopp 58534c
  	{
Karsten Hopp 58534c
  	    retval = TRUE;
Karsten Hopp 58534c
  	    break;
Karsten Hopp 58534c
--- 9510,9519 ----
Karsten Hopp 58534c
  	/* For buffer-local autocommands, fnamecmp() works fine. */
Karsten Hopp 58534c
  	if (ap->pat != NULL && ap->cmds != NULL
Karsten Hopp 58534c
  	    && (group == AUGROUP_ALL || ap->group == group)
Karsten Hopp 58534c
! 	    && (pattern == NULL
Karsten Hopp 58534c
! 		|| (buflocal_buf == NULL
Karsten Hopp 58534c
! 		    ? fnamecmp(ap->pat, pattern) == 0
Karsten Hopp 58534c
! 		    : ap->buflocal_nr == buflocal_buf->b_fnum)))
Karsten Hopp 58534c
  	{
Karsten Hopp 58534c
  	    retval = TRUE;
Karsten Hopp 58534c
  	    break;
Karsten Hopp 58534c
*** ../vim-7.2.258/src/testdir/Makefile	2009-06-24 18:07:55.000000000 +0200
Karsten Hopp 58534c
--- src/testdir/Makefile	2009-09-11 16:31:33.000000000 +0200
Karsten Hopp 58534c
***************
Karsten Hopp 58534c
*** 22,28 ****
Karsten Hopp 58534c
  		test48.out test49.out test51.out test52.out test53.out \
Karsten Hopp 58534c
  		test54.out test55.out test56.out test57.out test58.out \
Karsten Hopp 58534c
  		test59.out test60.out test61.out test62.out test63.out \
Karsten Hopp 58534c
! 		test64.out test65.out test66.out
Karsten Hopp 58534c
  
Karsten Hopp 58534c
  SCRIPTS_GUI = test16.out
Karsten Hopp 58534c
  
Karsten Hopp 58534c
--- 22,28 ----
Karsten Hopp 58534c
  		test48.out test49.out test51.out test52.out test53.out \
Karsten Hopp 58534c
  		test54.out test55.out test56.out test57.out test58.out \
Karsten Hopp 58534c
  		test59.out test60.out test61.out test62.out test63.out \
Karsten Hopp 58534c
! 		test64.out test65.out test66.out test67.out
Karsten Hopp 58534c
  
Karsten Hopp 58534c
  SCRIPTS_GUI = test16.out
Karsten Hopp 58534c
  
Karsten Hopp 58534c
*** ../vim-7.2.258/src/testdir/test67.in	2009-09-11 17:23:47.000000000 +0200
Karsten Hopp 58534c
--- src/testdir/test67.in	2009-09-11 16:43:11.000000000 +0200
Karsten Hopp 58534c
***************
Karsten Hopp 58534c
*** 0 ****
Karsten Hopp 58534c
--- 1,33 ----
Karsten Hopp 58534c
+ Test that groups and patterns are tested correctly when calling exists() for
Karsten Hopp 58534c
+ autocommands.
Karsten Hopp 58534c
+ 
Karsten Hopp 58534c
+ STARTTEST
Karsten Hopp 58534c
+ :so small.vim
Karsten Hopp 58534c
+ :let results=[]
Karsten Hopp 58534c
+ :augroup auexists
Karsten Hopp 58534c
+ :augroup END
Karsten Hopp 58534c
+ :call add(results, "##BufEnter: " . exists("##BufEnter"))
Karsten Hopp 58534c
+ :call add(results, "#BufEnter: " . exists("#BufEnter"))
Karsten Hopp 58534c
+ :au BufEnter * let g:entered=1
Karsten Hopp 58534c
+ :call add(results, "#BufEnter: " . exists("#BufEnter"))
Karsten Hopp 58534c
+ :call add(results, "#auexists#BufEnter: " . exists("#auexists#BufEnter"))
Karsten Hopp 58534c
+ :augroup auexists
Karsten Hopp 58534c
+ :au BufEnter * let g:entered=1
Karsten Hopp 58534c
+ :augroup END
Karsten Hopp 58534c
+ :call add(results, "#auexists#BufEnter: " . exists("#auexists#BufEnter"))
Karsten Hopp 58534c
+ :call add(results, "#BufEnter#*.test: " . exists("#BufEnter#*.test"))
Karsten Hopp 58534c
+ :au BufEnter *.test let g:entered=1
Karsten Hopp 58534c
+ :call add(results, "#BufEnter#*.test: " . exists("#BufEnter#*.test"))
Karsten Hopp 58534c
+ :edit testfile.test
Karsten Hopp 58534c
+ :call add(results, "#BufEnter#<buffer>: " . exists("#BufEnter#<buffer>"))
Karsten Hopp 58534c
+ :au BufEnter <buffer> let g:entered=1
Karsten Hopp 58534c
+ :call add(results, "#BufEnter#<buffer>: " . exists("#BufEnter#<buffer>"))
Karsten Hopp 58534c
+ :edit testfile2.test
Karsten Hopp 58534c
+ :call add(results, "#BufEnter#<buffer>: " . exists("#BufEnter#<buffer>"))
Karsten Hopp 58534c
+ :e test.out
Karsten Hopp 58534c
+ :call append(0, results)
Karsten Hopp 58534c
+ :$d
Karsten Hopp 58534c
+ :w
Karsten Hopp 58534c
+ :qa!
Karsten Hopp 58534c
+ ENDTEST
Karsten Hopp 58534c
+ 
Karsten Hopp 58534c
*** ../vim-7.2.258/src/testdir/test67.ok	2009-09-11 17:23:47.000000000 +0200
Karsten Hopp 58534c
--- src/testdir/test67.ok	2009-09-11 16:43:15.000000000 +0200
Karsten Hopp 58534c
***************
Karsten Hopp 58534c
*** 0 ****
Karsten Hopp 58534c
--- 1,10 ----
Karsten Hopp 58534c
+ ##BufEnter: 1
Karsten Hopp 58534c
+ #BufEnter: 0
Karsten Hopp 58534c
+ #BufEnter: 1
Karsten Hopp 58534c
+ #auexists#BufEnter: 0
Karsten Hopp 58534c
+ #auexists#BufEnter: 1
Karsten Hopp 58534c
+ #BufEnter#*.test: 0
Karsten Hopp 58534c
+ #BufEnter#*.test: 1
Karsten Hopp 58534c
+ #BufEnter#<buffer>: 0
Karsten Hopp 58534c
+ #BufEnter#<buffer>: 1
Karsten Hopp 58534c
+ #BufEnter#<buffer>: 0
Karsten Hopp 58534c
*** ../vim-7.2.258/src/version.c	2009-09-11 16:48:06.000000000 +0200
Karsten Hopp 58534c
--- src/version.c	2009-09-11 17:23:14.000000000 +0200
Karsten Hopp 58534c
***************
Karsten Hopp 58534c
*** 678,679 ****
Karsten Hopp 58534c
--- 678,681 ----
Karsten Hopp 58534c
  {   /* Add new patch number below this line */
Karsten Hopp 58534c
+ /**/
Karsten Hopp 58534c
+     259,
Karsten Hopp 58534c
  /**/
Karsten Hopp 58534c
Karsten Hopp 58534c
-- 
Karsten Hopp 58534c
hundred-and-one symptoms of being an internet addict:
Karsten Hopp 58534c
234. You started college as a chemistry major, and walk out four years
Karsten Hopp 58534c
     later as an Internet provider.
Karsten Hopp 58534c
Karsten Hopp 58534c
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 58534c
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 58534c
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 58534c
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///