Skip to content

Commit 414b796

Browse files
committed
patch 8.2.0272: ":helptags ALL" gives error for some directories
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)
1 parent 82f654e commit 414b796

3 files changed

Lines changed: 24 additions & 11 deletions

File tree

src/ex_cmds.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5920,7 +5920,8 @@ helptags_one(
59205920
char_u *dir, // doc directory
59215921
char_u *ext, // suffix, ".txt", ".itx", ".frx", etc.
59225922
char_u *tagfname, // "tags" for English, "tags-fr" for French.
5923-
int add_help_tags) // add "help-tags" tag
5923+
int add_help_tags, // add "help-tags" tag
5924+
int ignore_writeerr) // ignore write error
59245925
{
59255926
FILE *fd_tags;
59265927
FILE *fd;
@@ -5964,7 +5965,8 @@ helptags_one(
59645965
fd_tags = mch_fopen((char *)NameBuff, "w");
59655966
if (fd_tags == NULL)
59665967
{
5967-
semsg(_("E152: Cannot open %s for writing"), NameBuff);
5968+
if (!ignore_writeerr)
5969+
semsg(_("E152: Cannot open %s for writing"), NameBuff);
59685970
FreeWild(filecount, files);
59695971
return;
59705972
}
@@ -6165,7 +6167,7 @@ helptags_one(
61656167
* Generate tags in one help directory, taking care of translations.
61666168
*/
61676169
static void
6168-
do_helptags(char_u *dirname, int add_help_tags)
6170+
do_helptags(char_u *dirname, int add_help_tags, int ignore_writeerr)
61696171
{
61706172
#ifdef FEAT_MULTI_LANG
61716173
int len;
@@ -6251,22 +6253,23 @@ do_helptags(char_u *dirname, int add_help_tags)
62516253
ext[1] = fname[5];
62526254
ext[2] = fname[6];
62536255
}
6254-
helptags_one(dirname, ext, fname, add_help_tags);
6256+
helptags_one(dirname, ext, fname, add_help_tags, ignore_writeerr);
62556257
}
62566258

62576259
ga_clear(&ga);
62586260
FreeWild(filecount, files);
62596261

62606262
#else
62616263
// No language support, just use "*.txt" and "tags".
6262-
helptags_one(dirname, (char_u *)".txt", (char_u *)"tags", add_help_tags);
6264+
helptags_one(dirname, (char_u *)".txt", (char_u *)"tags", add_help_tags,
6265+
ignore_writeerr);
62636266
#endif
62646267
}
62656268

62666269
static void
62676270
helptags_cb(char_u *fname, void *cookie)
62686271
{
6269-
do_helptags(fname, *(int *)cookie);
6272+
do_helptags(fname, *(int *)cookie, TRUE);
62706273
}
62716274

62726275
/*
@@ -6300,7 +6303,7 @@ ex_helptags(exarg_T *eap)
63006303
if (dirname == NULL || !mch_isdir(dirname))
63016304
semsg(_("E150: Not a directory: %s"), eap->arg);
63026305
else
6303-
do_helptags(dirname, add_help_tags);
6306+
do_helptags(dirname, add_help_tags, FALSE);
63046307
vim_free(dirname);
63056308
}
63066309
}

src/testdir/test_help.vim

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,18 @@ func Test_helptag_cmd()
9090
" The following tests fail on FreeBSD for some reason
9191
if has('unix') && !has('bsd')
9292
" Read-only tags file
93-
call writefile([''], 'Xdir/tags')
94-
call setfperm('Xdir/tags', 'r-xr--r--')
95-
call assert_fails('helptags Xdir', 'E152:', getfperm('Xdir/tags'))
96-
call delete('Xdir/tags')
93+
call mkdir('Xdir/doc', 'p')
94+
call writefile([''], 'Xdir/doc/tags')
95+
call writefile([], 'Xdir/doc/sample.txt')
96+
call setfperm('Xdir/doc/tags', 'r-xr--r--')
97+
call assert_fails('helptags Xdir/doc', 'E152:', getfperm('Xdir/doc/tags'))
98+
99+
let rtp = &rtp
100+
let &rtp = 'Xdir'
101+
helptags ALL
102+
let &rtp = rtp
103+
104+
call delete('Xdir/doc/tags')
97105

98106
" No permission to read the help file
99107
call setfperm('Xdir/a/doc/sample.txt', '-w-------')

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,8 @@ static char *(features[]) =
738738

739739
static int included_patches[] =
740740
{ /* Add new patch number below this line */
741+
/**/
742+
272,
741743
/**/
742744
271,
743745
/**/

0 commit comments

Comments
 (0)