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