annotate src/help.c @ 32088:cdab211f342a v9.0.1375

patch 9.0.1375: crash when getting member of obj of unknown class Commit: https://github.com/vim/vim/commit/f77a7f704ffd0ca1050e82f609c8b8bd61863277 Author: Ernie Rael <errael@raelity.com> Date: Fri Mar 3 15:05:30 2023 +0000 patch 9.0.1375: crash when getting member of obj of unknown class Problem: Crash when getting member of obj of unknown class. Solution: Check for NULL class and give an error message. (Ernie Rael, closes #12096)
author Bram Moolenaar <Bram@vim.org>
date Fri, 03 Mar 2023 16:15:03 +0100
parents 8f443f987f47
children 61389a392fe8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet:
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2 *
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4 *
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 */
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 /*
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 * help.c: functions for Vim help
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12 */
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14 #include "vim.h"
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 /*
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17 * ":help": open a read-only window on a help file
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 */
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19 void
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 ex_help(exarg_T *eap)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 char_u *arg;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 char_u *tag;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 FILE *helpfd; // file descriptor of help file
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 int n;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 int i;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27 win_T *wp;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28 int num_matches;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 char_u **matches;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 char_u *p;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 int empty_fnum = 0;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 int alt_fnum = 0;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 buf_T *buf;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 #ifdef FEAT_MULTI_LANG
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 int len;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 char_u *lang;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 #ifdef FEAT_FOLDING
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 int old_KeyTyped = KeyTyped;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41
22518
81ae5fa92928 patch 8.2.1807: can use :help in a terminal popup window
Bram Moolenaar <Bram@vim.org>
parents: 21423
diff changeset
42 if (ERROR_IF_ANY_POPUP_WINDOW)
81ae5fa92928 patch 8.2.1807: can use :help in a terminal popup window
Bram Moolenaar <Bram@vim.org>
parents: 21423
diff changeset
43 return;
81ae5fa92928 patch 8.2.1807: can use :help in a terminal popup window
Bram Moolenaar <Bram@vim.org>
parents: 21423
diff changeset
44
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 if (eap != NULL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 // A ":help" command ends at the first LF, or at a '|' that is
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 // followed by some text. Set nextcmd to the following command.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49 for (arg = eap->arg; *arg; ++arg)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 if (*arg == '\n' || *arg == '\r'
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52 || (*arg == '|' && arg[1] != NUL && arg[1] != '|'))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54 *arg++ = NUL;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55 eap->nextcmd = arg;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59 arg = eap->arg;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61 if (eap->forceit && *arg == NUL && !curbuf->b_help)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62 {
26915
3631d2deb36c patch 8.2.3986: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
63 emsg(_(e_dont_panic));
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64 return;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67 if (eap->skip) // not executing commands
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
68 return;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
69 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70 else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
71 arg = (char_u *)"";
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73 // remove trailing blanks
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74 p = arg + STRLEN(arg) - 1;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 while (p > arg && VIM_ISWHITE(*p) && p[-1] != '\\')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 *p-- = NUL;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78 #ifdef FEAT_MULTI_LANG
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79 // Check for a specified language
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80 lang = check_help_lang(arg);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83 // When no argument given go to the index.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
84 if (*arg == NUL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85 arg = (char_u *)"help.txt";
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
87 // Check if there is a match for the argument.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
88 n = find_help_tags(arg, &num_matches, &matches,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89 eap != NULL && eap->forceit);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
90
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91 i = 0;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92 #ifdef FEAT_MULTI_LANG
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
93 if (n != FAIL && lang != NULL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94 // Find first item with the requested language.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
95 for (i = 0; i < num_matches; ++i)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
96 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97 len = (int)STRLEN(matches[i]);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
98 if (len > 3 && matches[i][len - 3] == '@'
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
99 && STRICMP(matches[i] + len - 2, lang) == 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
100 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
101 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
102 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
103 if (i >= num_matches || n == FAIL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
104 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
105 #ifdef FEAT_MULTI_LANG
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
106 if (lang != NULL)
26952
b34ddbca305c patch 8.2.4005: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26943
diff changeset
107 semsg(_(e_sorry_no_str_help_for_str), lang, arg);
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
108 else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
109 #endif
26853
806f31579357 patch 8.2.3955: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26276
diff changeset
110 semsg(_(e_sorry_no_help_for_str), arg);
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
111 if (n != FAIL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
112 FreeWild(num_matches, matches);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
113 return;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
114 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
115
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
116 // The first match (in the requested language) is the best match.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
117 tag = vim_strsave(matches[i]);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
118 FreeWild(num_matches, matches);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
119
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
120 #ifdef FEAT_GUI
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
121 need_mouse_correct = TRUE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
122 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
123
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
124 // Re-use an existing help window or open a new one.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
125 // Always open a new one for ":tab help".
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22574
diff changeset
126 if (!bt_help(curwin->w_buffer) || cmdmod.cmod_tab != 0)
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
127 {
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22574
diff changeset
128 if (cmdmod.cmod_tab != 0)
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
129 wp = NULL;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
130 else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
131 FOR_ALL_WINDOWS(wp)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
132 if (bt_help(wp->w_buffer))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
133 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
134 if (wp != NULL && wp->w_buffer->b_nwindows > 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
135 win_enter(wp, TRUE);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
136 else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
137 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
138 // There is no help window yet.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
139 // Try to open the file specified by the "helpfile" option.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
140 if ((helpfd = mch_fopen((char *)p_hf, READBIN)) == NULL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
141 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
142 smsg(_("Sorry, help file \"%s\" not found"), p_hf);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
143 goto erret;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
144 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
145 fclose(helpfd);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
146
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
147 // Split off help window; put it at far top if no position
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
148 // specified, the current window is vertically split and
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
149 // narrow.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
150 n = WSP_HELP;
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22574
diff changeset
151 if (cmdmod.cmod_split == 0 && curwin->w_width != Columns
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
152 && curwin->w_width < 80)
30743
8f443f987f47 patch 9.0.0706: :help in a narrow window always opens at the top
Bram Moolenaar <Bram@vim.org>
parents: 29566
diff changeset
153 n |= p_sb ? WSP_BOT : WSP_TOP;
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
154 if (win_split(0, n) == FAIL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
155 goto erret;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
156
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
157 if (curwin->w_height < p_hh)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
158 win_setheight((int)p_hh);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
159
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
160 // Open help file (do_ecmd() will set b_help flag, readfile() will
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
161 // set b_p_ro flag).
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
162 // Set the alternate file to the previously edited file.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
163 alt_fnum = curbuf->b_fnum;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
164 (void)do_ecmd(0, NULL, NULL, NULL, ECMD_LASTL,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
165 ECMD_HIDE + ECMD_SET_HELP,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
166 NULL); // buffer is still open, don't store info
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22574
diff changeset
167 if ((cmdmod.cmod_flags & CMOD_KEEPALT) == 0)
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
168 curwin->w_alt_fnum = alt_fnum;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
169 empty_fnum = curbuf->b_fnum;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
170 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
171 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
172
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
173 if (!p_im)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
174 restart_edit = 0; // don't want insert mode in help file
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
175
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
176 #ifdef FEAT_FOLDING
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
177 // Restore KeyTyped, setting 'filetype=help' may reset it.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
178 // It is needed for do_tag top open folds under the cursor.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
179 KeyTyped = old_KeyTyped;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
180 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
181
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
182 if (tag != NULL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
183 do_tag(tag, DT_HELP, 1, FALSE, TRUE);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
184
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
185 // Delete the empty buffer if we're not using it. Careful: autocommands
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
186 // may have jumped to another window, check that the buffer is not in a
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
187 // window.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
188 if (empty_fnum != 0 && curbuf->b_fnum != empty_fnum)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
189 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
190 buf = buflist_findnr(empty_fnum);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
191 if (buf != NULL && buf->b_nwindows == 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
192 wipe_buffer(buf, TRUE);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
193 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
194
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
195 // keep the previous alternate file
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22574
diff changeset
196 if (alt_fnum != 0 && curwin->w_alt_fnum == empty_fnum
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22574
diff changeset
197 && (cmdmod.cmod_flags & CMOD_KEEPALT) == 0)
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
198 curwin->w_alt_fnum = alt_fnum;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
199
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
200 erret:
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
201 vim_free(tag);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
202 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
203
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
204 /*
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
205 * ":helpclose": Close one help window
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
206 */
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
207 void
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
208 ex_helpclose(exarg_T *eap UNUSED)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
209 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
210 win_T *win;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
211
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
212 FOR_ALL_WINDOWS(win)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
213 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
214 if (bt_help(win->w_buffer))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
215 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
216 win_close(win, FALSE);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
217 return;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
218 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
219 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
220 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
221
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
222 #if defined(FEAT_MULTI_LANG) || defined(PROTO)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
223 /*
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
224 * In an argument search for a language specifiers in the form "@xx".
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
225 * Changes the "@" to NUL if found, and returns a pointer to "xx".
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
226 * Returns NULL if not found.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
227 */
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
228 char_u *
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
229 check_help_lang(char_u *arg)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
230 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
231 int len = (int)STRLEN(arg);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
232
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
233 if (len >= 3 && arg[len - 3] == '@' && ASCII_ISALPHA(arg[len - 2])
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
234 && ASCII_ISALPHA(arg[len - 1]))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
235 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
236 arg[len - 3] = NUL; // remove the '@'
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
237 return arg + len - 2;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
238 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
239 return NULL;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
240 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
241 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
242
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
243 /*
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
244 * Return a heuristic indicating how well the given string matches. The
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
245 * smaller the number, the better the match. This is the order of priorities,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
246 * from best match to worst match:
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
247 * - Match with least alphanumeric characters is better.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
248 * - Match with least total characters is better.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
249 * - Match towards the start is better.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
250 * - Match starting with "+" is worse (feature instead of command)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
251 * Assumption is made that the matched_string passed has already been found to
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
252 * match some string for which help is requested. webb.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
253 */
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
254 int
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
255 help_heuristic(
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
256 char_u *matched_string,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
257 int offset, // offset for match
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
258 int wrong_case) // no matching case
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
259 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
260 int num_letters;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
261 char_u *p;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
262
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
263 num_letters = 0;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
264 for (p = matched_string; *p; p++)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
265 if (ASCII_ISALNUM(*p))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
266 num_letters++;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
267
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
268 // Multiply the number of letters by 100 to give it a much bigger
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
269 // weighting than the number of characters.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
270 // If there only is a match while ignoring case, add 5000.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
271 // If the match starts in the middle of a word, add 10000 to put it
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
272 // somewhere in the last half.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
273 // If the match is more than 2 chars from the start, multiply by 200 to
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
274 // put it after matches at the start.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
275 if (ASCII_ISALNUM(matched_string[offset]) && offset > 0
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
276 && ASCII_ISALNUM(matched_string[offset - 1]))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
277 offset += 10000;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
278 else if (offset > 2)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
279 offset *= 200;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
280 if (wrong_case)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
281 offset += 5000;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
282 // Features are less interesting than the subjects themselves, but "+"
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
283 // alone is not a feature.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
284 if (matched_string[0] == '+' && matched_string[1] != NUL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
285 offset += 100;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
286 return (int)(100 * num_letters + STRLEN(matched_string) + offset);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
287 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
288
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
289 /*
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
290 * Compare functions for qsort() below, that checks the help heuristics number
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
291 * that has been put after the tagname by find_tags().
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
292 */
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
293 static int
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
294 help_compare(const void *s1, const void *s2)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
295 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
296 char *p1;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
297 char *p2;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
298 int cmp;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
299
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
300 p1 = *(char **)s1 + strlen(*(char **)s1) + 1;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
301 p2 = *(char **)s2 + strlen(*(char **)s2) + 1;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
302
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
303 // Compare by help heuristic number first.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
304 cmp = strcmp(p1, p2);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
305 if (cmp != 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
306 return cmp;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
307
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
308 // Compare by strings as tie-breaker when same heuristic number.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
309 return strcmp(*(char **)s1, *(char **)s2);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
310 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
311
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
312 /*
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
313 * Find all help tags matching "arg", sort them and return in matches[], with
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
314 * the number of matches in num_matches.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
315 * The matches will be sorted with a "best" match algorithm.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
316 * When "keep_lang" is TRUE try keeping the language of the current buffer.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
317 */
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
318 int
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
319 find_help_tags(
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
320 char_u *arg,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
321 int *num_matches,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
322 char_u ***matches,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
323 int keep_lang)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
324 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
325 char_u *s, *d;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
326 int i;
22574
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
327 // Specific tags that either have a specific replacement or won't go
23229
b545334ae654 patch 8.2.2160: various typos
Bram Moolenaar <Bram@vim.org>
parents: 22699
diff changeset
328 // through the generic rules.
22574
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
329 static char *(except_tbl[][2]) = {
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
330 {"*", "star"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
331 {"g*", "gstar"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
332 {"[*", "[star"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
333 {"]*", "]star"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
334 {":*", ":star"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
335 {"/*", "/star"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
336 {"/\\*", "/\\\\star"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
337 {"\"*", "quotestar"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
338 {"**", "starstar"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
339 {"cpo-*", "cpo-star"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
340 {"/\\(\\)", "/\\\\(\\\\)"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
341 {"/\\%(\\)", "/\\\\%(\\\\)"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
342 {"?", "?"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
343 {"??", "??"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
344 {":?", ":?"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
345 {"?<CR>", "?<CR>"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
346 {"g?", "g?"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
347 {"g?g?", "g?g?"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
348 {"g??", "g??"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
349 {"-?", "-?"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
350 {"q?", "q?"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
351 {"v_g?", "v_g?"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
352 {"/\\?", "/\\\\?"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
353 {"/\\z(\\)", "/\\\\z(\\\\)"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
354 {"\\=", "\\\\="},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
355 {":s\\=", ":s\\\\="},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
356 {"[count]", "\\[count]"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
357 {"[quotex]", "\\[quotex]"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
358 {"[range]", "\\[range]"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
359 {":[range]", ":\\[range]"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
360 {"[pattern]", "\\[pattern]"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
361 {"\\|", "\\\\bar"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
362 {"\\%$", "/\\\\%\\$"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
363 {"s/\\~", "s/\\\\\\~"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
364 {"s/\\U", "s/\\\\U"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
365 {"s/\\L", "s/\\\\L"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
366 {"s/\\1", "s/\\\\1"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
367 {"s/\\2", "s/\\\\2"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
368 {"s/\\3", "s/\\\\3"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
369 {"s/\\9", "s/\\\\9"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
370 {NULL, NULL}
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
371 };
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
372 static char *(expr_table[]) = {"!=?", "!~?", "<=?", "<?", "==?", "=~?",
22574
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
373 ">=?", ">?", "is?", "isnot?"};
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
374 int flags;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
375
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
376 d = IObuff; // assume IObuff is long enough!
22574
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
377 d[0] = NUL;
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
378
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
379 if (STRNICMP(arg, "expr-", 5) == 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
380 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
381 // When the string starting with "expr-" and containing '?' and matches
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
382 // the table, it is taken literally (but ~ is escaped). Otherwise '?'
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
383 // is recognized as a wildcard.
24768
7334bf933510 patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents: 23229
diff changeset
384 for (i = (int)ARRAY_LENGTH(expr_table); --i >= 0; )
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
385 if (STRCMP(arg + 5, expr_table[i]) == 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
386 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
387 int si = 0, di = 0;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
388
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
389 for (;;)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
390 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
391 if (arg[si] == '~')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
392 d[di++] = '\\';
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
393 d[di++] = arg[si];
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
394 if (arg[si] == NUL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
395 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
396 ++si;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
397 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
398 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
399 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
400 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
401 else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
402 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
403 // Recognize a few exceptions to the rule. Some strings that contain
22574
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
404 // '*'are changed to "star", otherwise '*' is recognized as a wildcard.
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
405 for (i = 0; except_tbl[i][0] != NULL; ++i)
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
406 if (STRCMP(arg, except_tbl[i][0]) == 0)
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
407 {
22574
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
408 STRCPY(d, except_tbl[i][1]);
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
409 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
410 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
411 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
412
22574
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
413 if (d[0] == NUL) // no match in table
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
414 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
415 // Replace "\S" with "/\\S", etc. Otherwise every tag is matched.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
416 // Also replace "\%^" and "\%(", they match every tag too.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
417 // Also "\zs", "\z1", etc.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
418 // Also "\@<", "\@=", "\@<=", etc.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
419 // And also "\_$" and "\_^".
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
420 if (arg[0] == '\\'
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
421 && ((arg[1] != NUL && arg[2] == NUL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
422 || (vim_strchr((char_u *)"%_z@", arg[1]) != NULL
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
423 && arg[2] != NUL)))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
424 {
26276
35d000f3d591 patch 8.2.3669: buffer overflow with long help argument
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
425 vim_snprintf((char *)d, IOSIZE, "/\\\\%s", arg + 1);
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
426 // Check for "/\\_$", should be "/\\_\$"
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
427 if (d[3] == '_' && d[4] == '$')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
428 STRCPY(d + 4, "\\$");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
429 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
430 else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
431 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
432 // Replace:
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
433 // "[:...:]" with "\[:...:]"
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
434 // "[++...]" with "\[++...]"
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
435 // "\{" with "\\{" -- matching "} \}"
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
436 if ((arg[0] == '[' && (arg[1] == ':'
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
437 || (arg[1] == '+' && arg[2] == '+')))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
438 || (arg[0] == '\\' && arg[1] == '{'))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
439 *d++ = '\\';
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
440
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
441 // If tag starts with "('", skip the "(". Fixes CTRL-] on ('option'.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
442 if (*arg == '(' && arg[1] == '\'')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
443 arg++;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
444 for (s = arg; *s; ++s)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
445 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
446 // Replace "|" with "bar" and '"' with "quote" to match the name of
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
447 // the tags for these commands.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
448 // Replace "*" with ".*" and "?" with "." to match command line
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
449 // completion.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
450 // Insert a backslash before '~', '$' and '.' to avoid their
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
451 // special meaning.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
452 if (d - IObuff > IOSIZE - 10) // getting too long!?
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
453 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
454 switch (*s)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
455 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
456 case '|': STRCPY(d, "bar");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
457 d += 3;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
458 continue;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
459 case '"': STRCPY(d, "quote");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
460 d += 5;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
461 continue;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
462 case '*': *d++ = '.';
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
463 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
464 case '?': *d++ = '.';
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
465 continue;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
466 case '$':
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
467 case '.':
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
468 case '~': *d++ = '\\';
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
469 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
470 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
471
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
472 // Replace "^x" by "CTRL-X". Don't do this for "^_" to make
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
473 // ":help i_^_CTRL-D" work.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
474 // Insert '-' before and after "CTRL-X" when applicable.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
475 if (*s < ' ' || (*s == '^' && s[1] && (ASCII_ISALPHA(s[1])
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
476 || vim_strchr((char_u *)"?@[\\]^", s[1]) != NULL)))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
477 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
478 if (d > IObuff && d[-1] != '_' && d[-1] != '\\')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
479 *d++ = '_'; // prepend a '_' to make x_CTRL-x
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
480 STRCPY(d, "CTRL-");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
481 d += 5;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
482 if (*s < ' ')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
483 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
484 *d++ = *s + '@';
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
485 if (d[-1] == '\\')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
486 *d++ = '\\'; // double a backslash
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
487 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
488 else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
489 *d++ = *++s;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
490 if (s[1] != NUL && s[1] != '_')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
491 *d++ = '_'; // append a '_'
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
492 continue;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
493 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
494 else if (*s == '^') // "^" or "CTRL-^" or "^_"
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
495 *d++ = '\\';
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
496
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
497 // Insert a backslash before a backslash after a slash, for search
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
498 // pattern tags: "/\|" --> "/\\|".
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
499 else if (s[0] == '\\' && s[1] != '\\'
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
500 && *arg == '/' && s == arg + 1)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
501 *d++ = '\\';
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
502
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
503 // "CTRL-\_" -> "CTRL-\\_" to avoid the special meaning of "\_" in
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
504 // "CTRL-\_CTRL-N"
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
505 if (STRNICMP(s, "CTRL-\\_", 7) == 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
506 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
507 STRCPY(d, "CTRL-\\\\");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
508 d += 7;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
509 s += 6;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
510 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
511
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
512 *d++ = *s;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
513
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
514 // If tag contains "({" or "([", tag terminates at the "(".
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
515 // This is for help on functions, e.g.: abs({expr}).
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
516 if (*s == '(' && (s[1] == '{' || s[1] =='['))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
517 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
518
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
519 // If tag starts with ', toss everything after a second '. Fixes
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
520 // CTRL-] on 'option'. (would include the trailing '.').
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
521 if (*s == '\'' && s > arg && *arg == '\'')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
522 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
523 // Also '{' and '}'.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
524 if (*s == '}' && s > arg && *arg == '{')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
525 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
526 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
527 *d = NUL;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
528
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
529 if (*IObuff == '`')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
530 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
531 if (d > IObuff + 2 && d[-1] == '`')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
532 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
533 // remove the backticks from `command`
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
534 mch_memmove(IObuff, IObuff + 1, STRLEN(IObuff));
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
535 d[-2] = NUL;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
536 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
537 else if (d > IObuff + 3 && d[-2] == '`' && d[-1] == ',')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
538 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
539 // remove the backticks and comma from `command`,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
540 mch_memmove(IObuff, IObuff + 1, STRLEN(IObuff));
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
541 d[-3] = NUL;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
542 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
543 else if (d > IObuff + 4 && d[-3] == '`'
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
544 && d[-2] == '\\' && d[-1] == '.')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
545 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
546 // remove the backticks and dot from `command`\.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
547 mch_memmove(IObuff, IObuff + 1, STRLEN(IObuff));
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
548 d[-4] = NUL;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
549 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
550 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
551 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
552 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
553
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
554 *matches = (char_u **)"";
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
555 *num_matches = 0;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
556 flags = TAG_HELP | TAG_REGEXP | TAG_NAMES | TAG_VERBOSE | TAG_NO_TAGFUNC;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
557 if (keep_lang)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
558 flags |= TAG_KEEP_LANG;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
559 if (find_tags(IObuff, num_matches, matches, flags, (int)MAXCOL, NULL) == OK
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
560 && *num_matches > 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
561 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
562 // Sort the matches found on the heuristic number that is after the
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
563 // tag name.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
564 qsort((void *)*matches, (size_t)*num_matches,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
565 sizeof(char_u *), help_compare);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
566 // Delete more than TAG_MANY to reduce the size of the listing.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
567 while (*num_matches > TAG_MANY)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
568 vim_free((*matches)[--*num_matches]);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
569 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
570 return OK;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
571 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
572
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
573 #ifdef FEAT_MULTI_LANG
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
574 /*
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
575 * Cleanup matches for help tags:
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
576 * Remove "@ab" if the top of 'helplang' is "ab" and the language of the first
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
577 * tag matches it. Otherwise remove "@en" if "en" is the only language.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
578 */
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
579 void
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
580 cleanup_help_tags(int num_file, char_u **file)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
581 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
582 int i, j;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
583 int len;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
584 char_u buf[4];
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
585 char_u *p = buf;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
586
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
587 if (p_hlg[0] != NUL && (p_hlg[0] != 'e' || p_hlg[1] != 'n'))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
588 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
589 *p++ = '@';
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
590 *p++ = p_hlg[0];
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
591 *p++ = p_hlg[1];
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
592 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
593 *p = NUL;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
594
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
595 for (i = 0; i < num_file; ++i)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
596 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
597 len = (int)STRLEN(file[i]) - 3;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
598 if (len <= 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
599 continue;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
600 if (STRCMP(file[i] + len, "@en") == 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
601 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
602 // Sorting on priority means the same item in another language may
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
603 // be anywhere. Search all items for a match up to the "@en".
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
604 for (j = 0; j < num_file; ++j)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
605 if (j != i && (int)STRLEN(file[j]) == len + 3
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
606 && STRNCMP(file[i], file[j], len + 1) == 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
607 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
608 if (j == num_file)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
609 // item only exists with @en, remove it
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
610 file[i][len] = NUL;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
611 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
612 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
613
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
614 if (*buf != NUL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
615 for (i = 0; i < num_file; ++i)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
616 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
617 len = (int)STRLEN(file[i]) - 3;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
618 if (len <= 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
619 continue;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
620 if (STRCMP(file[i] + len, buf) == 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
621 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
622 // remove the default language
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
623 file[i][len] = NUL;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
624 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
625 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
626 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
627 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
628
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
629 /*
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
630 * Called when starting to edit a buffer for a help file.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
631 */
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
632 void
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
633 prepare_help_buffer(void)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
634 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
635 char_u *p;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
636
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
637 curbuf->b_help = TRUE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
638 #ifdef FEAT_QUICKFIX
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
639 set_string_option_direct((char_u *)"buftype", -1,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
640 (char_u *)"help", OPT_FREE|OPT_LOCAL, 0);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
641 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
642
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
643 // Always set these options after jumping to a help tag, because the
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
644 // user may have an autocommand that gets in the way.
23229
b545334ae654 patch 8.2.2160: various typos
Bram Moolenaar <Bram@vim.org>
parents: 22699
diff changeset
645 // When adding an option here, also update the help file helphelp.txt.
b545334ae654 patch 8.2.2160: various typos
Bram Moolenaar <Bram@vim.org>
parents: 22699
diff changeset
646
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
647 // Accept all ASCII chars for keywords, except ' ', '*', '"', '|', and
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
648 // latin1 word characters (for translated help files).
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
649 // Only set it when needed, buf_init_chartab() is some work.
27490
fb4c30606b4a patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 27028
diff changeset
650 p = (char_u *)"!-~,^*,^|,^\",192-255";
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
651 if (STRCMP(curbuf->b_p_isk, p) != 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
652 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
653 set_string_option_direct((char_u *)"isk", -1, p, OPT_FREE|OPT_LOCAL, 0);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
654 check_buf_options(curbuf);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
655 (void)buf_init_chartab(curbuf, FALSE);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
656 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
657
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
658 #ifdef FEAT_FOLDING
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
659 // Don't use the global foldmethod.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
660 set_string_option_direct((char_u *)"fdm", -1, (char_u *)"manual",
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
661 OPT_FREE|OPT_LOCAL, 0);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
662 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
663
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
664 curbuf->b_p_ts = 8; // 'tabstop' is 8
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
665 curwin->w_p_list = FALSE; // no list mode
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
666
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
667 curbuf->b_p_ma = FALSE; // not modifiable
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
668 curbuf->b_p_bin = FALSE; // reset 'bin' before reading file
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
669 curwin->w_p_nu = 0; // no line numbers
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
670 curwin->w_p_rnu = 0; // no relative line numbers
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
671 RESET_BINDING(curwin); // no scroll or cursor binding
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
672 #ifdef FEAT_ARABIC
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
673 curwin->w_p_arab = FALSE; // no arabic mode
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
674 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
675 #ifdef FEAT_RIGHTLEFT
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
676 curwin->w_p_rl = FALSE; // help window is left-to-right
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
677 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
678 #ifdef FEAT_FOLDING
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
679 curwin->w_p_fen = FALSE; // No folding in the help window
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
680 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
681 #ifdef FEAT_DIFF
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
682 curwin->w_p_diff = FALSE; // No 'diff'
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
683 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
684 #ifdef FEAT_SPELL
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
685 curwin->w_p_spell = FALSE; // No spell checking
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
686 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
687
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
688 set_buflisted(FALSE);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
689 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
690
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
691 /*
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
692 * After reading a help file: May cleanup a help buffer when syntax
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
693 * highlighting is not used.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
694 */
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
695 void
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
696 fix_help_buffer(void)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
697 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
698 linenr_T lnum;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
699 char_u *line;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
700 int in_example = FALSE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
701 int len;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
702 char_u *fname;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
703 char_u *p;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
704 char_u *rt;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
705 int mustfree;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
706
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
707 // Set filetype to "help" if still needed.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
708 if (STRCMP(curbuf->b_p_ft, "help") != 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
709 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
710 ++curbuf_lock;
28457
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28199
diff changeset
711 set_option_value_give_err((char_u *)"ft",
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28199
diff changeset
712 0L, (char_u *)"help", OPT_LOCAL);
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
713 --curbuf_lock;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
714 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
715
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
716 #ifdef FEAT_SYN_HL
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
717 if (!syntax_present(curwin))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
718 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
719 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
720 for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; ++lnum)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
721 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
722 line = ml_get_buf(curbuf, lnum, FALSE);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
723 len = (int)STRLEN(line);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
724 if (in_example && len > 0 && !VIM_ISWHITE(line[0]))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
725 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
726 // End of example: non-white or '<' in first column.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
727 if (line[0] == '<')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
728 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
729 // blank-out a '<' in the first column
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
730 line = ml_get_buf(curbuf, lnum, TRUE);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
731 line[0] = ' ';
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
732 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
733 in_example = FALSE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
734 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
735 if (!in_example && len > 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
736 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
737 if (line[len - 1] == '>' && (len == 1 || line[len - 2] == ' '))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
738 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
739 // blank-out a '>' in the last column (start of example)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
740 line = ml_get_buf(curbuf, lnum, TRUE);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
741 line[len - 1] = ' ';
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
742 in_example = TRUE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
743 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
744 else if (line[len - 1] == '~')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
745 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
746 // blank-out a '~' at the end of line (header marker)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
747 line = ml_get_buf(curbuf, lnum, TRUE);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
748 line[len - 1] = ' ';
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
749 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
750 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
751 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
752 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
753
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
754 // In the "help.txt" and "help.abx" file, add the locally added help
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
755 // files. This uses the very first line in the help file.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
756 fname = gettail(curbuf->b_fname);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
757 if (fnamecmp(fname, "help.txt") == 0
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
758 #ifdef FEAT_MULTI_LANG
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
759 || (fnamencmp(fname, "help.", 5) == 0
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
760 && ASCII_ISALPHA(fname[5])
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
761 && ASCII_ISALPHA(fname[6])
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
762 && TOLOWER_ASC(fname[7]) == 'x'
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
763 && fname[8] == NUL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
764 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
765 )
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
766 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
767 for (lnum = 1; lnum < curbuf->b_ml.ml_line_count; ++lnum)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
768 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
769 line = ml_get_buf(curbuf, lnum, FALSE);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
770 if (strstr((char *)line, "*local-additions*") == NULL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
771 continue;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
772
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
773 // Go through all directories in 'runtimepath', skipping
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
774 // $VIMRUNTIME.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
775 p = p_rtp;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
776 while (*p != NUL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
777 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
778 copy_option_part(&p, NameBuff, MAXPATHL, ",");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
779 mustfree = FALSE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
780 rt = vim_getenv((char_u *)"VIMRUNTIME", &mustfree);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
781 if (rt != NULL &&
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
782 fullpathcmp(rt, NameBuff, FALSE, TRUE) != FPC_SAME)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
783 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
784 int fcount;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
785 char_u **fnames;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
786 FILE *fd;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
787 char_u *s;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
788 int fi;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
789 vimconv_T vc;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
790 char_u *cp;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
791
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
792 // Find all "doc/ *.txt" files in this directory.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
793 add_pathsep(NameBuff);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
794 #ifdef FEAT_MULTI_LANG
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
795 STRCAT(NameBuff, "doc/*.??[tx]");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
796 #else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
797 STRCAT(NameBuff, "doc/*.txt");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
798 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
799 if (gen_expand_wildcards(1, &NameBuff, &fcount,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
800 &fnames, EW_FILE|EW_SILENT) == OK
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
801 && fcount > 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
802 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
803 #ifdef FEAT_MULTI_LANG
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
804 int i1, i2;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
805 char_u *f1, *f2;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
806 char_u *t1, *t2;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
807 char_u *e1, *e2;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
808
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
809 // If foo.abx is found use it instead of foo.txt in
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
810 // the same directory.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
811 for (i1 = 0; i1 < fcount; ++i1)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
812 {
26927
e3f3108a780a patch 8.2.3992: wrong local-additions in the help with language mix
Bram Moolenaar <Bram@vim.org>
parents: 26915
diff changeset
813 f1 = fnames[i1];
e3f3108a780a patch 8.2.3992: wrong local-additions in the help with language mix
Bram Moolenaar <Bram@vim.org>
parents: 26915
diff changeset
814 t1 = gettail(f1);
e3f3108a780a patch 8.2.3992: wrong local-additions in the help with language mix
Bram Moolenaar <Bram@vim.org>
parents: 26915
diff changeset
815 e1 = vim_strrchr(t1, '.');
e3f3108a780a patch 8.2.3992: wrong local-additions in the help with language mix
Bram Moolenaar <Bram@vim.org>
parents: 26915
diff changeset
816 if (fnamecmp(e1, ".txt") != 0
e3f3108a780a patch 8.2.3992: wrong local-additions in the help with language mix
Bram Moolenaar <Bram@vim.org>
parents: 26915
diff changeset
817 && fnamecmp(e1, fname + 4) != 0)
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
818 {
26927
e3f3108a780a patch 8.2.3992: wrong local-additions in the help with language mix
Bram Moolenaar <Bram@vim.org>
parents: 26915
diff changeset
819 // Not .txt and not .abx, remove it.
e3f3108a780a patch 8.2.3992: wrong local-additions in the help with language mix
Bram Moolenaar <Bram@vim.org>
parents: 26915
diff changeset
820 VIM_CLEAR(fnames[i1]);
e3f3108a780a patch 8.2.3992: wrong local-additions in the help with language mix
Bram Moolenaar <Bram@vim.org>
parents: 26915
diff changeset
821 continue;
e3f3108a780a patch 8.2.3992: wrong local-additions in the help with language mix
Bram Moolenaar <Bram@vim.org>
parents: 26915
diff changeset
822 }
e3f3108a780a patch 8.2.3992: wrong local-additions in the help with language mix
Bram Moolenaar <Bram@vim.org>
parents: 26915
diff changeset
823
e3f3108a780a patch 8.2.3992: wrong local-additions in the help with language mix
Bram Moolenaar <Bram@vim.org>
parents: 26915
diff changeset
824 for (i2 = i1 + 1; i2 < fcount; ++i2)
e3f3108a780a patch 8.2.3992: wrong local-additions in the help with language mix
Bram Moolenaar <Bram@vim.org>
parents: 26915
diff changeset
825 {
e3f3108a780a patch 8.2.3992: wrong local-additions in the help with language mix
Bram Moolenaar <Bram@vim.org>
parents: 26915
diff changeset
826 f2 = fnames[i2];
e3f3108a780a patch 8.2.3992: wrong local-additions in the help with language mix
Bram Moolenaar <Bram@vim.org>
parents: 26915
diff changeset
827 if (f2 == NULL)
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
828 continue;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
829 t2 = gettail(f2);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
830 e2 = vim_strrchr(t2, '.');
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
831 if (e1 - f1 != e2 - f2
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
832 || fnamencmp(f1, f2, e1 - f1) != 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
833 continue;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
834 if (fnamecmp(e1, ".txt") == 0
26927
e3f3108a780a patch 8.2.3992: wrong local-additions in the help with language mix
Bram Moolenaar <Bram@vim.org>
parents: 26915
diff changeset
835 && fnamecmp(e2, fname + 4) == 0)
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
836 // use .abx instead of .txt
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
837 VIM_CLEAR(fnames[i1]);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
838 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
839 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
840 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
841 for (fi = 0; fi < fcount; ++fi)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
842 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
843 if (fnames[fi] == NULL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
844 continue;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
845 fd = mch_fopen((char *)fnames[fi], "r");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
846 if (fd != NULL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
847 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
848 vim_fgets(IObuff, IOSIZE, fd);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
849 if (IObuff[0] == '*'
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
850 && (s = vim_strchr(IObuff + 1, '*'))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
851 != NULL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
852 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
853 int this_utf = MAYBE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
854
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
855 // Change tag definition to a
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
856 // reference and remove <CR>/<NL>.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
857 IObuff[0] = '|';
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
858 *s = '|';
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
859 while (*s != NUL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
860 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
861 if (*s == '\r' || *s == '\n')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
862 *s = NUL;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
863 // The text is utf-8 when a byte
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
864 // above 127 is found and no
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
865 // illegal byte sequence is found.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
866 if (*s >= 0x80 && this_utf != FALSE)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
867 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
868 int l;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
869
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
870 this_utf = TRUE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
871 l = utf_ptr2len(s);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
872 if (l == 1)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
873 this_utf = FALSE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
874 s += l - 1;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
875 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
876 ++s;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
877 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
878
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
879 // The help file is latin1 or utf-8;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
880 // conversion to the current
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
881 // 'encoding' may be required.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
882 vc.vc_type = CONV_NONE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
883 convert_setup(&vc, (char_u *)(
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
884 this_utf == TRUE ? "utf-8"
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
885 : "latin1"), p_enc);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
886 if (vc.vc_type == CONV_NONE)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
887 // No conversion needed.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
888 cp = IObuff;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
889 else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
890 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
891 // Do the conversion. If it fails
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
892 // use the unconverted text.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
893 cp = string_convert(&vc, IObuff,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
894 NULL);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
895 if (cp == NULL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
896 cp = IObuff;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
897 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
898 convert_setup(&vc, NULL, NULL);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
899
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
900 ml_append(lnum, cp, (colnr_T)0, FALSE);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
901 if (cp != IObuff)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
902 vim_free(cp);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
903 ++lnum;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
904 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
905 fclose(fd);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
906 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
907 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
908 FreeWild(fcount, fnames);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
909 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
910 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
911 if (mustfree)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
912 vim_free(rt);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
913 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
914 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
915 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
916 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
917 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
918
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
919 /*
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
920 * ":exusage"
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
921 */
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
922 void
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
923 ex_exusage(exarg_T *eap UNUSED)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
924 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
925 do_cmdline_cmd((char_u *)"help ex-cmd-index");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
926 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
927
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
928 /*
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
929 * ":viusage"
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
930 */
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
931 void
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
932 ex_viusage(exarg_T *eap UNUSED)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
933 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
934 do_cmdline_cmd((char_u *)"help normal-index");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
935 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
936
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
937 /*
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
938 * Generate tags in one help directory.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
939 */
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
940 static void
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
941 helptags_one(
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
942 char_u *dir, // doc directory
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
943 char_u *ext, // suffix, ".txt", ".itx", ".frx", etc.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
944 char_u *tagfname, // "tags" for English, "tags-fr" for French.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
945 int add_help_tags, // add "help-tags" tag
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
946 int ignore_writeerr) // ignore write error
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
947 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
948 FILE *fd_tags;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
949 FILE *fd;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
950 garray_T ga;
28199
c8056de13879 patch 8.2.4625: old Coverity warning for resource leak
Bram Moolenaar <Bram@vim.org>
parents: 27490
diff changeset
951 int res;
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
952 int filecount;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
953 char_u **files;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
954 char_u *p1, *p2;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
955 int fi;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
956 char_u *s;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
957 int i;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
958 char_u *fname;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
959 int dirlen;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
960 int utf8 = MAYBE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
961 int this_utf8;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
962 int firstline;
29538
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 28457
diff changeset
963 int in_example;
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 28457
diff changeset
964 int len;
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
965 int mix = FALSE; // detected mixed encodings
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
966
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
967 // Find all *.txt files.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
968 dirlen = (int)STRLEN(dir);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
969 STRCPY(NameBuff, dir);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
970 STRCAT(NameBuff, "/**/*");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
971 STRCAT(NameBuff, ext);
28199
c8056de13879 patch 8.2.4625: old Coverity warning for resource leak
Bram Moolenaar <Bram@vim.org>
parents: 27490
diff changeset
972 res = gen_expand_wildcards(1, &NameBuff, &filecount, &files,
c8056de13879 patch 8.2.4625: old Coverity warning for resource leak
Bram Moolenaar <Bram@vim.org>
parents: 27490
diff changeset
973 EW_FILE|EW_SILENT);
c8056de13879 patch 8.2.4625: old Coverity warning for resource leak
Bram Moolenaar <Bram@vim.org>
parents: 27490
diff changeset
974 if (res == FAIL || filecount == 0)
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
975 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
976 if (!got_int)
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26857
diff changeset
977 semsg(_(e_no_match_str_1), NameBuff);
28199
c8056de13879 patch 8.2.4625: old Coverity warning for resource leak
Bram Moolenaar <Bram@vim.org>
parents: 27490
diff changeset
978 if (res != FAIL)
c8056de13879 patch 8.2.4625: old Coverity warning for resource leak
Bram Moolenaar <Bram@vim.org>
parents: 27490
diff changeset
979 FreeWild(filecount, files);
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
980 return;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
981 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
982
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
983 // Open the tags file for writing.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
984 // Do this before scanning through all the files.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
985 STRCPY(NameBuff, dir);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
986 add_pathsep(NameBuff);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
987 STRCAT(NameBuff, tagfname);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
988 fd_tags = mch_fopen((char *)NameBuff, "w");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
989 if (fd_tags == NULL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
990 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
991 if (!ignore_writeerr)
26857
2aeea8611342 patch 8.2.3957: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26853
diff changeset
992 semsg(_(e_cannot_open_str_for_writing_1), NameBuff);
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
993 FreeWild(filecount, files);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
994 return;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
995 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
996
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
997 // If using the "++t" argument or generating tags for "$VIMRUNTIME/doc"
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
998 // add the "help-tags" tag.
27028
c9474ae175f4 patch 8.2.4043: using int for second argument of ga_init2()
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
999 ga_init2(&ga, sizeof(char_u *), 100);
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1000 if (add_help_tags || fullpathcmp((char_u *)"$VIMRUNTIME/doc",
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1001 dir, FALSE, TRUE) == FPC_SAME)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1002 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1003 if (ga_grow(&ga, 1) == FAIL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1004 got_int = TRUE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1005 else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1006 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1007 s = alloc(18 + (unsigned)STRLEN(tagfname));
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1008 if (s == NULL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1009 got_int = TRUE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1010 else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1011 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1012 sprintf((char *)s, "help-tags\t%s\t1\n", tagfname);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1013 ((char_u **)ga.ga_data)[ga.ga_len] = s;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1014 ++ga.ga_len;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1015 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1016 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1017 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1018
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1019 // Go over all the files and extract the tags.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1020 for (fi = 0; fi < filecount && !got_int; ++fi)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1021 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1022 fd = mch_fopen((char *)files[fi], "r");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1023 if (fd == NULL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1024 {
26853
806f31579357 patch 8.2.3955: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26276
diff changeset
1025 semsg(_(e_unable_to_open_str_for_reading), files[fi]);
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1026 continue;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1027 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1028 fname = files[fi] + dirlen + 1;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1029
29538
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 28457
diff changeset
1030 in_example = FALSE;
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1031 firstline = TRUE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1032 while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1033 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1034 if (firstline)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1035 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1036 // Detect utf-8 file by a non-ASCII char in the first line.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1037 this_utf8 = MAYBE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1038 for (s = IObuff; *s != NUL; ++s)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1039 if (*s >= 0x80)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1040 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1041 int l;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1042
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1043 this_utf8 = TRUE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1044 l = utf_ptr2len(s);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1045 if (l == 1)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1046 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1047 // Illegal UTF-8 byte sequence.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1048 this_utf8 = FALSE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1049 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1050 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1051 s += l - 1;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1052 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1053 if (this_utf8 == MAYBE) // only ASCII characters found
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1054 this_utf8 = FALSE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1055 if (utf8 == MAYBE) // first file
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1056 utf8 = this_utf8;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1057 else if (utf8 != this_utf8)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1058 {
26952
b34ddbca305c patch 8.2.4005: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26943
diff changeset
1059 semsg(_(e_mix_of_help_file_encodings_within_language_str), files[fi]);
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1060 mix = !got_int;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1061 got_int = TRUE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1062 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1063 firstline = FALSE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1064 }
29538
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 28457
diff changeset
1065 if (in_example)
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 28457
diff changeset
1066 {
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 28457
diff changeset
1067 // skip over example; a non-white in the first column ends it
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 28457
diff changeset
1068 if (vim_strchr((char_u *)" \t\n\r", IObuff[0]))
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 28457
diff changeset
1069 continue;
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 28457
diff changeset
1070 in_example = FALSE;
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 28457
diff changeset
1071 }
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1072 p1 = vim_strchr(IObuff, '*'); // find first '*'
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1073 while (p1 != NULL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1074 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1075 // Use vim_strbyte() instead of vim_strchr() so that when
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1076 // 'encoding' is dbcs it still works, don't find '*' in the
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1077 // second byte.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1078 p2 = vim_strbyte(p1 + 1, '*'); // find second '*'
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1079 if (p2 != NULL && p2 > p1 + 1) // skip "*" and "**"
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1080 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1081 for (s = p1 + 1; s < p2; ++s)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1082 if (*s == ' ' || *s == '\t' || *s == '|')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1083 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1084
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1085 // Only accept a *tag* when it consists of valid
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1086 // characters, there is white space before it and is
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1087 // followed by a white character or end-of-line.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1088 if (s == p2
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1089 && (p1 == IObuff || p1[-1] == ' ' || p1[-1] == '\t')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1090 && (vim_strchr((char_u *)" \t\n\r", s[1]) != NULL
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1091 || s[1] == '\0'))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1092 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1093 *p2 = '\0';
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1094 ++p1;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1095 if (ga_grow(&ga, 1) == FAIL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1096 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1097 got_int = TRUE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1098 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1099 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1100 s = alloc(p2 - p1 + STRLEN(fname) + 2);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1101 if (s == NULL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1102 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1103 got_int = TRUE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1104 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1105 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1106 ((char_u **)ga.ga_data)[ga.ga_len] = s;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1107 ++ga.ga_len;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1108 sprintf((char *)s, "%s\t%s", p1, fname);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1109
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1110 // find next '*'
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1111 p2 = vim_strchr(p2 + 1, '*');
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1112 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1113 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1114 p1 = p2;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1115 }
29538
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 28457
diff changeset
1116 len = (int)STRLEN(IObuff);
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 28457
diff changeset
1117 if ((len == 2 && STRCMP(&IObuff[len - 2], ">\n") == 0)
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 28457
diff changeset
1118 || (len >= 3 && STRCMP(&IObuff[len - 3], " >\n") == 0))
af4ffc4b2a26 patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents: 28457
diff changeset
1119 in_example = TRUE;
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1120 line_breakcheck();
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1121 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1122
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1123 fclose(fd);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1124 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1125
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1126 FreeWild(filecount, files);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1127
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1128 if (!got_int)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1129 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1130 // Sort the tags.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1131 if (ga.ga_data != NULL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1132 sort_strings((char_u **)ga.ga_data, ga.ga_len);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1133
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1134 // Check for duplicates.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1135 for (i = 1; i < ga.ga_len; ++i)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1136 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1137 p1 = ((char_u **)ga.ga_data)[i - 1];
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1138 p2 = ((char_u **)ga.ga_data)[i];
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1139 while (*p1 == *p2)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1140 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1141 if (*p2 == '\t')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1142 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1143 *p2 = NUL;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1144 vim_snprintf((char *)NameBuff, MAXPATHL,
26853
806f31579357 patch 8.2.3955: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26276
diff changeset
1145 _(e_duplicate_tag_str_in_file_str_str),
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1146 ((char_u **)ga.ga_data)[i], dir, p2 + 1);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1147 emsg((char *)NameBuff);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1148 *p2 = '\t';
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1149 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1150 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1151 ++p1;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1152 ++p2;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1153 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1154 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1155
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1156 if (utf8 == TRUE)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1157 fprintf(fd_tags, "!_TAG_FILE_ENCODING\tutf-8\t//\n");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1158
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1159 // Write the tags into the file.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1160 for (i = 0; i < ga.ga_len; ++i)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1161 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1162 s = ((char_u **)ga.ga_data)[i];
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1163 if (STRNCMP(s, "help-tags\t", 10) == 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1164 // help-tags entry was added in formatted form
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1165 fputs((char *)s, fd_tags);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1166 else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1167 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1168 fprintf(fd_tags, "%s\t/*", s);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1169 for (p1 = s; *p1 != '\t'; ++p1)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1170 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1171 // insert backslash before '\\' and '/'
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1172 if (*p1 == '\\' || *p1 == '/')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1173 putc('\\', fd_tags);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1174 putc(*p1, fd_tags);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1175 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1176 fprintf(fd_tags, "*\n");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1177 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1178 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1179 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1180 if (mix)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1181 got_int = FALSE; // continue with other languages
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1182
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1183 for (i = 0; i < ga.ga_len; ++i)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1184 vim_free(((char_u **)ga.ga_data)[i]);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1185 ga_clear(&ga);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1186 fclose(fd_tags); // there is no check for an error...
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1187 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1188
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1189 /*
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1190 * Generate tags in one help directory, taking care of translations.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1191 */
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1192 static void
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1193 do_helptags(char_u *dirname, int add_help_tags, int ignore_writeerr)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1194 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1195 #ifdef FEAT_MULTI_LANG
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1196 int len;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1197 int i, j;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1198 garray_T ga;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1199 char_u lang[2];
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1200 char_u ext[5];
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1201 char_u fname[8];
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1202 int filecount;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1203 char_u **files;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1204
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1205 // Get a list of all files in the help directory and in subdirectories.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1206 STRCPY(NameBuff, dirname);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1207 add_pathsep(NameBuff);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1208 STRCAT(NameBuff, "**");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1209 if (gen_expand_wildcards(1, &NameBuff, &filecount, &files,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1210 EW_FILE|EW_SILENT) == FAIL
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1211 || filecount == 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1212 {
26966
ac75c145f0a9 patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26952
diff changeset
1213 semsg(_(e_no_match_str_1), NameBuff);
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1214 return;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1215 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1216
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1217 // Go over all files in the directory to find out what languages are
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1218 // present.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1219 ga_init2(&ga, 1, 10);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1220 for (i = 0; i < filecount; ++i)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1221 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1222 len = (int)STRLEN(files[i]);
29566
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29538
diff changeset
1223 if (len <= 4)
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29538
diff changeset
1224 continue;
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29538
diff changeset
1225
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29538
diff changeset
1226 if (STRICMP(files[i] + len - 4, ".txt") == 0)
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29538
diff changeset
1227 {
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29538
diff changeset
1228 // ".txt" -> language "en"
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29538
diff changeset
1229 lang[0] = 'e';
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29538
diff changeset
1230 lang[1] = 'n';
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29538
diff changeset
1231 }
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29538
diff changeset
1232 else if (files[i][len - 4] == '.'
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29538
diff changeset
1233 && ASCII_ISALPHA(files[i][len - 3])
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29538
diff changeset
1234 && ASCII_ISALPHA(files[i][len - 2])
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29538
diff changeset
1235 && TOLOWER_ASC(files[i][len - 1]) == 'x')
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1236 {
29566
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29538
diff changeset
1237 // ".abx" -> language "ab"
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29538
diff changeset
1238 lang[0] = TOLOWER_ASC(files[i][len - 3]);
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29538
diff changeset
1239 lang[1] = TOLOWER_ASC(files[i][len - 2]);
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29538
diff changeset
1240 }
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29538
diff changeset
1241 else
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29538
diff changeset
1242 continue;
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1243
29566
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29538
diff changeset
1244 // Did we find this language already?
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29538
diff changeset
1245 for (j = 0; j < ga.ga_len; j += 2)
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29538
diff changeset
1246 if (STRNCMP(lang, ((char_u *)ga.ga_data) + j, 2) == 0)
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29538
diff changeset
1247 break;
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29538
diff changeset
1248 if (j == ga.ga_len)
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29538
diff changeset
1249 {
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29538
diff changeset
1250 // New language, add it.
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29538
diff changeset
1251 if (ga_grow(&ga, 2) == FAIL)
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29538
diff changeset
1252 break;
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29538
diff changeset
1253 ((char_u *)ga.ga_data)[ga.ga_len++] = lang[0];
99e3763cbd34 patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents: 29538
diff changeset
1254 ((char_u *)ga.ga_data)[ga.ga_len++] = lang[1];
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1255 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1256 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1257
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1258 // Loop over the found languages to generate a tags file for each one.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1259 for (j = 0; j < ga.ga_len; j += 2)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1260 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1261 STRCPY(fname, "tags-xx");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1262 fname[5] = ((char_u *)ga.ga_data)[j];
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1263 fname[6] = ((char_u *)ga.ga_data)[j + 1];
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1264 if (fname[5] == 'e' && fname[6] == 'n')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1265 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1266 // English is an exception: use ".txt" and "tags".
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1267 fname[4] = NUL;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1268 STRCPY(ext, ".txt");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1269 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1270 else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1271 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1272 // Language "ab" uses ".abx" and "tags-ab".
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1273 STRCPY(ext, ".xxx");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1274 ext[1] = fname[5];
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1275 ext[2] = fname[6];
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1276 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1277 helptags_one(dirname, ext, fname, add_help_tags, ignore_writeerr);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1278 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1279
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1280 ga_clear(&ga);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1281 FreeWild(filecount, files);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1282
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1283 #else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1284 // No language support, just use "*.txt" and "tags".
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1285 helptags_one(dirname, (char_u *)".txt", (char_u *)"tags", add_help_tags,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1286 ignore_writeerr);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1287 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1288 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1289
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1290 static void
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1291 helptags_cb(char_u *fname, void *cookie)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1292 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1293 do_helptags(fname, *(int *)cookie, TRUE);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1294 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1295
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1296 /*
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1297 * ":helptags"
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1298 */
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1299 void
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1300 ex_helptags(exarg_T *eap)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1301 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1302 expand_T xpc;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1303 char_u *dirname;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1304 int add_help_tags = FALSE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1305
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1306 // Check for ":helptags ++t {dir}".
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1307 if (STRNCMP(eap->arg, "++t", 3) == 0 && VIM_ISWHITE(eap->arg[3]))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1308 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1309 add_help_tags = TRUE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1310 eap->arg = skipwhite(eap->arg + 3);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1311 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1312
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1313 if (STRCMP(eap->arg, "ALL") == 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1314 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1315 do_in_path(p_rtp, (char_u *)"doc", DIP_ALL + DIP_DIR,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1316 helptags_cb, &add_help_tags);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1317 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1318 else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1319 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1320 ExpandInit(&xpc);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1321 xpc.xp_context = EXPAND_DIRECTORIES;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1322 dirname = ExpandOne(&xpc, eap->arg, NULL,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1323 WILD_LIST_NOTFOUND|WILD_SILENT, WILD_EXPAND_FREE);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1324 if (dirname == NULL || !mch_isdir(dirname))
26853
806f31579357 patch 8.2.3955: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26276
diff changeset
1325 semsg(_(e_not_a_directory_str), eap->arg);
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1326 else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1327 do_helptags(dirname, add_help_tags, FALSE);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1328 vim_free(dirname);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1329 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1330 }