To: vim_dev@googlegroups.com Subject: Patch 8.2.0272 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0272 Problem: ":helptags ALL" gives error for directories without write permission. (Matěj Cepl) Solution: Ignore errors for ":helptags ALL". (Ken Takata, closes #5026, closes #5652) Files: src/ex_cmds.c, src/testdir/test_help.vim *** ../vim-8.2.0271/src/ex_cmds.c 2020-02-14 13:21:55.642197064 +0100 --- src/ex_cmds.c 2020-02-17 22:21:39.444664754 +0100 *************** *** 5920,5926 **** char_u *dir, // doc directory char_u *ext, // suffix, ".txt", ".itx", ".frx", etc. char_u *tagfname, // "tags" for English, "tags-fr" for French. ! int add_help_tags) // add "help-tags" tag { FILE *fd_tags; FILE *fd; --- 5920,5927 ---- char_u *dir, // doc directory char_u *ext, // suffix, ".txt", ".itx", ".frx", etc. char_u *tagfname, // "tags" for English, "tags-fr" for French. ! int add_help_tags, // add "help-tags" tag ! int ignore_writeerr) // ignore write error { FILE *fd_tags; FILE *fd; *************** *** 5964,5970 **** fd_tags = mch_fopen((char *)NameBuff, "w"); if (fd_tags == NULL) { ! semsg(_("E152: Cannot open %s for writing"), NameBuff); FreeWild(filecount, files); return; } --- 5965,5972 ---- fd_tags = mch_fopen((char *)NameBuff, "w"); if (fd_tags == NULL) { ! if (!ignore_writeerr) ! semsg(_("E152: Cannot open %s for writing"), NameBuff); FreeWild(filecount, files); return; } *************** *** 6165,6171 **** * Generate tags in one help directory, taking care of translations. */ static void ! do_helptags(char_u *dirname, int add_help_tags) { #ifdef FEAT_MULTI_LANG int len; --- 6167,6173 ---- * Generate tags in one help directory, taking care of translations. */ static void ! do_helptags(char_u *dirname, int add_help_tags, int ignore_writeerr) { #ifdef FEAT_MULTI_LANG int len; *************** *** 6251,6257 **** ext[1] = fname[5]; ext[2] = fname[6]; } ! helptags_one(dirname, ext, fname, add_help_tags); } ga_clear(&ga); --- 6253,6259 ---- ext[1] = fname[5]; ext[2] = fname[6]; } ! helptags_one(dirname, ext, fname, add_help_tags, ignore_writeerr); } ga_clear(&ga); *************** *** 6259,6272 **** #else // No language support, just use "*.txt" and "tags". ! helptags_one(dirname, (char_u *)".txt", (char_u *)"tags", add_help_tags); #endif } static void helptags_cb(char_u *fname, void *cookie) { ! do_helptags(fname, *(int *)cookie); } /* --- 6261,6275 ---- #else // No language support, just use "*.txt" and "tags". ! helptags_one(dirname, (char_u *)".txt", (char_u *)"tags", add_help_tags, ! ignore_writeerr); #endif } static void helptags_cb(char_u *fname, void *cookie) { ! do_helptags(fname, *(int *)cookie, TRUE); } /* *************** *** 6300,6306 **** if (dirname == NULL || !mch_isdir(dirname)) semsg(_("E150: Not a directory: %s"), eap->arg); else ! do_helptags(dirname, add_help_tags); vim_free(dirname); } } --- 6303,6309 ---- if (dirname == NULL || !mch_isdir(dirname)) semsg(_("E150: Not a directory: %s"), eap->arg); else ! do_helptags(dirname, add_help_tags, FALSE); vim_free(dirname); } } *** ../vim-8.2.0271/src/testdir/test_help.vim 2020-02-03 21:40:00.005363654 +0100 --- src/testdir/test_help.vim 2020-02-17 22:38:21.228271423 +0100 *************** *** 90,99 **** " The following tests fail on FreeBSD for some reason if has('unix') && !has('bsd') " Read-only tags file ! call writefile([''], 'Xdir/tags') ! call setfperm('Xdir/tags', 'r-xr--r--') ! call assert_fails('helptags Xdir', 'E152:', getfperm('Xdir/tags')) ! call delete('Xdir/tags') " No permission to read the help file call setfperm('Xdir/a/doc/sample.txt', '-w-------') --- 90,107 ---- " The following tests fail on FreeBSD for some reason if has('unix') && !has('bsd') " Read-only tags file ! call mkdir('Xdir/doc', 'p') ! call writefile([''], 'Xdir/doc/tags') ! call writefile([], 'Xdir/doc/sample.txt') ! call setfperm('Xdir/doc/tags', 'r-xr--r--') ! call assert_fails('helptags Xdir/doc', 'E152:', getfperm('Xdir/doc/tags')) ! ! let rtp = &rtp ! let &rtp = 'Xdir' ! helptags ALL ! let &rtp = rtp ! ! call delete('Xdir/doc/tags') " No permission to read the help file call setfperm('Xdir/a/doc/sample.txt', '-w-------') *** ../vim-8.2.0271/src/version.c 2020-02-17 22:11:39.670644186 +0100 --- src/version.c 2020-02-17 22:38:49.780163582 +0100 *************** *** 740,741 **** --- 740,743 ---- { /* Add new patch number below this line */ + /**/ + 272, /**/ -- From "know your smileys": :q vi user saying, "How do I get out of this damn emacs editor?" /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///