1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
|
To: vim_dev@googlegroups.com
Subject: Patch 7.3.341
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------
Patch 7.3.341
Problem: Local help files are only listed in help.txt, not in translated
help files.
Solution: Also find translated help files. (Yasuhiro Matsumoto)
Files: src/ex_cmds.c
*** ../vim-7.3.340/src/ex_cmds.c 2011-09-30 17:30:27.000000000 +0200
--- src/ex_cmds.c 2011-10-20 17:39:45.000000000 +0200
***************
*** 5982,5987 ****
--- 5982,5988 ----
char_u *line;
int in_example = FALSE;
int len;
+ char_u *fname;
char_u *p;
char_u *rt;
int mustfree;
***************
*** 6028,6151 ****
}
/*
! * In the "help.txt" file, add the locally added help files.
! * This uses the very first line in the help file.
*/
! if (fnamecmp(gettail(curbuf->b_fname), "help.txt") == 0)
{
for (lnum = 1; lnum < curbuf->b_ml.ml_line_count; ++lnum)
{
line = ml_get_buf(curbuf, lnum, FALSE);
! if (strstr((char *)line, "*local-additions*") != NULL)
{
! /* Go through all directories in 'runtimepath', skipping
! * $VIMRUNTIME. */
! p = p_rtp;
! while (*p != NUL)
{
! copy_option_part(&p, NameBuff, MAXPATHL, ",");
! mustfree = FALSE;
! rt = vim_getenv((char_u *)"VIMRUNTIME", &mustfree);
! if (fullpathcmp(rt, NameBuff, FALSE) != FPC_SAME)
! {
! int fcount;
! char_u **fnames;
! FILE *fd;
! char_u *s;
! int fi;
#ifdef FEAT_MBYTE
! vimconv_T vc;
! char_u *cp;
#endif
! /* Find all "doc/ *.txt" files in this directory. */
! add_pathsep(NameBuff);
! STRCAT(NameBuff, "doc/*.txt");
! if (gen_expand_wildcards(1, &NameBuff, &fcount,
! &fnames, EW_FILE|EW_SILENT) == OK
! && fcount > 0)
{
! for (fi = 0; fi < fcount; ++fi)
{
! fd = mch_fopen((char *)fnames[fi], "r");
! if (fd != NULL)
{
! vim_fgets(IObuff, IOSIZE, fd);
! if (IObuff[0] == '*'
! && (s = vim_strchr(IObuff + 1, '*'))
! != NULL)
! {
! #ifdef FEAT_MBYTE
! int this_utf = MAYBE;
#endif
! /* Change tag definition to a
! * reference and remove <CR>/<NL>. */
! IObuff[0] = '|';
! *s = '|';
! while (*s != NUL)
! {
! if (*s == '\r' || *s == '\n')
! *s = NUL;
#ifdef FEAT_MBYTE
! /* The text is utf-8 when a byte
! * above 127 is found and no
! * illegal byte sequence is found.
! */
! if (*s >= 0x80 && this_utf != FALSE)
! {
! int l;
!
! this_utf = TRUE;
! l = utf_ptr2len(s);
! if (l == 1)
! this_utf = FALSE;
! s += l - 1;
! }
#endif
! ++s;
! }
#ifdef FEAT_MBYTE
! /* The help file is latin1 or utf-8;
! * conversion to the current
! * 'encoding' may be required. */
! vc.vc_type = CONV_NONE;
! convert_setup(&vc, (char_u *)(
! this_utf == TRUE ? "utf-8"
! : "latin1"), p_enc);
! if (vc.vc_type == CONV_NONE)
! /* No conversion needed. */
! cp = IObuff;
! else
{
! /* Do the conversion. If it fails
! * use the unconverted text. */
! cp = string_convert(&vc, IObuff,
! NULL);
! if (cp == NULL)
! cp = IObuff;
}
! convert_setup(&vc, NULL, NULL);
! ml_append(lnum, cp, (colnr_T)0, FALSE);
! if (cp != IObuff)
! vim_free(cp);
#else
! ml_append(lnum, IObuff, (colnr_T)0,
! FALSE);
#endif
! ++lnum;
! }
! fclose(fd);
}
}
- FreeWild(fcount, fnames);
}
}
- if (mustfree)
- vim_free(rt);
}
! break;
}
}
}
}
--- 6029,6215 ----
}
/*
! * In the "help.txt" and "help.abx" file, add the locally added help
! * files. This uses the very first line in the help file.
*/
! fname = gettail(curbuf->b_fname);
! if (fnamecmp(fname, "help.txt") == 0
! #ifdef FEAT_MULTI_LANG
! || (fnamencmp(fname, "help.", 5) == 0
! && ASCII_ISALPHA(fname[5])
! && ASCII_ISALPHA(fname[6])
! && TOLOWER_ASC(fname[7]) == 'x'
! && fname[8] == NUL)
! #endif
! )
{
for (lnum = 1; lnum < curbuf->b_ml.ml_line_count; ++lnum)
{
line = ml_get_buf(curbuf, lnum, FALSE);
! if (strstr((char *)line, "*local-additions*") == NULL)
! continue;
!
! /* Go through all directories in 'runtimepath', skipping
! * $VIMRUNTIME. */
! p = p_rtp;
! while (*p != NUL)
{
! copy_option_part(&p, NameBuff, MAXPATHL, ",");
! mustfree = FALSE;
! rt = vim_getenv((char_u *)"VIMRUNTIME", &mustfree);
! if (fullpathcmp(rt, NameBuff, FALSE) != FPC_SAME)
{
! int fcount;
! char_u **fnames;
! FILE *fd;
! char_u *s;
! int fi;
#ifdef FEAT_MBYTE
! vimconv_T vc;
! char_u *cp;
#endif
! /* Find all "doc/ *.txt" files in this directory. */
! add_pathsep(NameBuff);
! #ifdef FEAT_MULTI_LANG
! STRCAT(NameBuff, "doc/*.??[tx]");
! #else
! STRCAT(NameBuff, "doc/*.txt");
! #endif
! if (gen_expand_wildcards(1, &NameBuff, &fcount,
! &fnames, EW_FILE|EW_SILENT) == OK
! && fcount > 0)
! {
! #ifdef FEAT_MULTI_LANG
! int i1;
! int i2;
! char_u *f1;
! char_u *f2;
! char_u *t1;
! char_u *e1;
! char_u *e2;
!
! /* If foo.abx is found use it instead of foo.txt in
! * the same directory. */
! for (i1 = 0; i1 < fcount; ++i1)
{
! for (i2 = 0; i2 < fcount; ++i2)
{
! if (i1 == i2)
! continue;
! if (fnames[i1] == NULL || fnames[i2] == NULL)
! continue;
! f1 = fnames[i1];
! f2 = fnames[i2];
! t1 = gettail(f1);
! if (fnamencmp(f1, f2, t1 - f1) != 0)
! continue;
! e1 = vim_strrchr(t1, '.');
! e2 = vim_strrchr(gettail(f2), '.');
! if (e1 == NUL || e2 == NUL)
! continue;
! if (fnamecmp(e1, ".txt") != 0
! && fnamecmp(e1, fname + 4) != 0)
{
! /* Not .txt and not .abx, remove it. */
! vim_free(fnames[i1]);
! fnames[i1] = NULL;
! continue;
! }
! if (fnamencmp(f1, f2, e1 - f1) != 0)
! continue;
! if (fnamecmp(e1, ".txt") == 0
! && fnamecmp(e2, fname + 4) == 0)
! {
! /* use .abx instead of .txt */
! vim_free(fnames[i1]);
! fnames[i1] = NULL;
! }
! }
! }
#endif
! for (fi = 0; fi < fcount; ++fi)
! {
! if (fnames[fi] == NULL)
! continue;
! fd = mch_fopen((char *)fnames[fi], "r");
! if (fd != NULL)
! {
! vim_fgets(IObuff, IOSIZE, fd);
! if (IObuff[0] == '*'
! && (s = vim_strchr(IObuff + 1, '*'))
! != NULL)
! {
#ifdef FEAT_MBYTE
! int this_utf = MAYBE;
#endif
! /* Change tag definition to a
! * reference and remove <CR>/<NL>. */
! IObuff[0] = '|';
! *s = '|';
! while (*s != NUL)
! {
! if (*s == '\r' || *s == '\n')
! *s = NUL;
#ifdef FEAT_MBYTE
! /* The text is utf-8 when a byte
! * above 127 is found and no
! * illegal byte sequence is found.
! */
! if (*s >= 0x80 && this_utf != FALSE)
{
! int l;
!
! this_utf = TRUE;
! l = utf_ptr2len(s);
! if (l == 1)
! this_utf = FALSE;
! s += l - 1;
}
! #endif
! ++s;
! }
! #ifdef FEAT_MBYTE
! /* The help file is latin1 or utf-8;
! * conversion to the current
! * 'encoding' may be required. */
! vc.vc_type = CONV_NONE;
! convert_setup(&vc, (char_u *)(
! this_utf == TRUE ? "utf-8"
! : "latin1"), p_enc);
! if (vc.vc_type == CONV_NONE)
! /* No conversion needed. */
! cp = IObuff;
! else
! {
! /* Do the conversion. If it fails
! * use the unconverted text. */
! cp = string_convert(&vc, IObuff,
! NULL);
! if (cp == NULL)
! cp = IObuff;
! }
! convert_setup(&vc, NULL, NULL);
! ml_append(lnum, cp, (colnr_T)0, FALSE);
! if (cp != IObuff)
! vim_free(cp);
#else
! ml_append(lnum, IObuff, (colnr_T)0,
! FALSE);
#endif
! ++lnum;
}
+ fclose(fd);
}
}
+ FreeWild(fcount, fnames);
}
}
! if (mustfree)
! vim_free(rt);
}
+ break;
}
}
}
*** ../vim-7.3.340/src/version.c 2011-10-20 18:12:27.000000000 +0200
--- src/version.c 2011-10-20 18:13:46.000000000 +0200
***************
*** 711,712 ****
--- 711,714 ----
{ /* Add new patch number below this line */
+ /**/
+ 341,
/**/
--
From "know your smileys":
:-)-O Smiling doctor with stethoscope
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|