comparison src/tag.c @ 18814:7e7ec935e7c8 v8.1.2395

patch 8.1.2395: using old C style comments Commit: https://github.com/vim/vim/commit/0d6f5d9740dbad1b0207f3ab257de806169dd905 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Dec 5 21:33:15 2019 +0100 patch 8.1.2395: using old C style comments Problem: Using old C style comments. Solution: Use // comments where appropriate.
author Bram Moolenaar <Bram@vim.org>
date Thu, 05 Dec 2019 21:45:04 +0100
parents 49b78d6465e5
children f0312cf3c792
comparison
equal deleted inserted replaced
18813:89d78230790e 18814:7e7ec935e7c8
43 * which one depends on the priority of the match. 43 * which one depends on the priority of the match.
44 * ht_match[] is used to find duplicates, ga_match[] to keep them in sequence. 44 * ht_match[] is used to find duplicates, ga_match[] to keep them in sequence.
45 * At the end, all the matches from ga_match[] are concatenated, to make a list 45 * At the end, all the matches from ga_match[] are concatenated, to make a list
46 * sorted on priority. 46 * sorted on priority.
47 */ 47 */
48 #define MT_ST_CUR 0 /* static match in current file */ 48 #define MT_ST_CUR 0 // static match in current file
49 #define MT_GL_CUR 1 /* global match in current file */ 49 #define MT_GL_CUR 1 // global match in current file
50 #define MT_GL_OTH 2 /* global match in other file */ 50 #define MT_GL_OTH 2 // global match in other file
51 #define MT_ST_OTH 3 /* static match in other file */ 51 #define MT_ST_OTH 3 // static match in other file
52 #define MT_IC_OFF 4 /* add for icase match */ 52 #define MT_IC_OFF 4 // add for icase match
53 #define MT_RE_OFF 8 /* add for regexp match */ 53 #define MT_RE_OFF 8 // add for regexp match
54 #define MT_MASK 7 /* mask for printing priority */ 54 #define MT_MASK 7 // mask for printing priority
55 #define MT_COUNT 16 55 #define MT_COUNT 16
56 56
57 static char *mt_names[MT_COUNT/2] = 57 static char *mt_names[MT_COUNT/2] =
58 {"FSC", "F C", "F ", "FS ", " SC", " C", " ", " S "}; 58 {"FSC", "F C", "F ", "FS ", " SC", " C", " ", " S "};
59 59
60 #define NOTAGFILE 99 /* return value for jumpto_tag */ 60 #define NOTAGFILE 99 // return value for jumpto_tag
61 static char_u *nofile_fname = NULL; /* fname for NOTAGFILE error */ 61 static char_u *nofile_fname = NULL; // fname for NOTAGFILE error
62 62
63 static void taglen_advance(int l); 63 static void taglen_advance(int l);
64 64
65 static int jumpto_tag(char_u *lbuf, int forceit, int keep_help); 65 static int jumpto_tag(char_u *lbuf, int forceit, int keep_help);
66 #ifdef FEAT_EMACS_TAGS 66 #ifdef FEAT_EMACS_TAGS
89 #ifdef FEAT_EVAL 89 #ifdef FEAT_EVAL
90 static char_u *recurmsg = (char_u *)N_("E986: cannot modify the tag stack within tagfunc"); 90 static char_u *recurmsg = (char_u *)N_("E986: cannot modify the tag stack within tagfunc");
91 static char_u *tfu_inv_ret_msg = (char_u *)N_("E987: invalid return value from tagfunc"); 91 static char_u *tfu_inv_ret_msg = (char_u *)N_("E987: invalid return value from tagfunc");
92 #endif 92 #endif
93 93
94 static char_u *tagmatchname = NULL; /* name of last used tag */ 94 static char_u *tagmatchname = NULL; // name of last used tag
95 95
96 #if defined(FEAT_QUICKFIX) 96 #if defined(FEAT_QUICKFIX)
97 /* 97 /*
98 * Tag for preview window is remembered separately, to avoid messing up the 98 * Tag for preview window is remembered separately, to avoid messing up the
99 * normal tagstack. 99 * normal tagstack.
128 * 128 *
129 * for cscope, returns TRUE if we jumped to tag or aborted, FALSE otherwise 129 * for cscope, returns TRUE if we jumped to tag or aborted, FALSE otherwise
130 */ 130 */
131 int 131 int
132 do_tag( 132 do_tag(
133 char_u *tag, /* tag (pattern) to jump to */ 133 char_u *tag, // tag (pattern) to jump to
134 int type, 134 int type,
135 int count, 135 int count,
136 int forceit, /* :ta with ! */ 136 int forceit, // :ta with !
137 int verbose) /* print "tag not found" message */ 137 int verbose) // print "tag not found" message
138 { 138 {
139 taggy_T *tagstack = curwin->w_tagstack; 139 taggy_T *tagstack = curwin->w_tagstack;
140 int tagstackidx = curwin->w_tagstackidx; 140 int tagstackidx = curwin->w_tagstackidx;
141 int tagstacklen = curwin->w_tagstacklen; 141 int tagstacklen = curwin->w_tagstacklen;
142 int cur_match = 0; 142 int cur_match = 0;
156 #endif 156 #endif
157 int new_num_matches; 157 int new_num_matches;
158 char_u **new_matches; 158 char_u **new_matches;
159 int use_tagstack; 159 int use_tagstack;
160 int skip_msg = FALSE; 160 int skip_msg = FALSE;
161 char_u *buf_ffname = curbuf->b_ffname; /* name to use for 161 char_u *buf_ffname = curbuf->b_ffname; // name to use for
162 priority computation */ 162 // priority computation
163 int use_tfu = 1; 163 int use_tfu = 1;
164 164
165 /* remember the matches for the last used tag */ 165 // remember the matches for the last used tag
166 static int num_matches = 0; 166 static int num_matches = 0;
167 static int max_num_matches = 0; /* limit used for match search */ 167 static int max_num_matches = 0; // limit used for match search
168 static char_u **matches = NULL; 168 static char_u **matches = NULL;
169 static int flags; 169 static int flags;
170 170
171 #ifdef FEAT_EVAL 171 #ifdef FEAT_EVAL
172 if (tfu_in_use) 172 if (tfu_in_use)
177 #endif 177 #endif
178 178
179 #ifdef EXITFREE 179 #ifdef EXITFREE
180 if (type == DT_FREE) 180 if (type == DT_FREE)
181 { 181 {
182 /* remove the list of matches */ 182 // remove the list of matches
183 FreeWild(num_matches, matches); 183 FreeWild(num_matches, matches);
184 # ifdef FEAT_CSCOPE 184 # ifdef FEAT_CSCOPE
185 cs_free_tags(); 185 cs_free_tags();
186 # endif 186 # endif
187 num_matches = 0; 187 num_matches = 0;
198 198
199 prev_num_matches = num_matches; 199 prev_num_matches = num_matches;
200 free_string_option(nofile_fname); 200 free_string_option(nofile_fname);
201 nofile_fname = NULL; 201 nofile_fname = NULL;
202 202
203 CLEAR_POS(&saved_fmark.mark); /* shutup gcc 4.0 */ 203 CLEAR_POS(&saved_fmark.mark); // shutup gcc 4.0
204 saved_fmark.fnum = 0; 204 saved_fmark.fnum = 0;
205 205
206 /* 206 /*
207 * Don't add a tag to the tagstack if 'tagstack' has been reset. 207 * Don't add a tag to the tagstack if 'tagstack' has been reset.
208 */ 208 */
226 use_tagstack = FALSE; 226 use_tagstack = FALSE;
227 else 227 else
228 #endif 228 #endif
229 use_tagstack = TRUE; 229 use_tagstack = TRUE;
230 230
231 /* new pattern, add to the tag stack */ 231 // new pattern, add to the tag stack
232 if (*tag != NUL 232 if (*tag != NUL
233 && (type == DT_TAG || type == DT_SELECT || type == DT_JUMP 233 && (type == DT_TAG || type == DT_SELECT || type == DT_JUMP
234 #ifdef FEAT_QUICKFIX 234 #ifdef FEAT_QUICKFIX
235 || type == DT_LTAG 235 || type == DT_LTAG
236 #endif 236 #endif
243 if (g_do_tagpreview != 0) 243 if (g_do_tagpreview != 0)
244 { 244 {
245 if (ptag_entry.tagname != NULL 245 if (ptag_entry.tagname != NULL
246 && STRCMP(ptag_entry.tagname, tag) == 0) 246 && STRCMP(ptag_entry.tagname, tag) == 0)
247 { 247 {
248 /* Jumping to same tag: keep the current match, so that 248 // Jumping to same tag: keep the current match, so that
249 * the CursorHold autocommand example works. */ 249 // the CursorHold autocommand example works.
250 cur_match = ptag_entry.cur_match; 250 cur_match = ptag_entry.cur_match;
251 cur_fnum = ptag_entry.cur_fnum; 251 cur_fnum = ptag_entry.cur_fnum;
252 } 252 }
253 else 253 else
254 { 254 {
265 * stack entries above it. 265 * stack entries above it.
266 */ 266 */
267 while (tagstackidx < tagstacklen) 267 while (tagstackidx < tagstacklen)
268 tagstack_clear_entry(&tagstack[--tagstacklen]); 268 tagstack_clear_entry(&tagstack[--tagstacklen]);
269 269
270 /* if the tagstack is full: remove oldest entry */ 270 // if the tagstack is full: remove oldest entry
271 if (++tagstacklen > TAGSTACKSIZE) 271 if (++tagstacklen > TAGSTACKSIZE)
272 { 272 {
273 tagstacklen = TAGSTACKSIZE; 273 tagstacklen = TAGSTACKSIZE;
274 tagstack_clear_entry(&tagstack[0]); 274 tagstack_clear_entry(&tagstack[0]);
275 for (i = 1; i < tagstacklen; ++i) 275 for (i = 1; i < tagstacklen; ++i)
285 curwin->w_tagstacklen = tagstacklen - 1; 285 curwin->w_tagstacklen = tagstacklen - 1;
286 goto end_do_tag; 286 goto end_do_tag;
287 } 287 }
288 curwin->w_tagstacklen = tagstacklen; 288 curwin->w_tagstacklen = tagstacklen;
289 289
290 save_pos = TRUE; /* save the cursor position below */ 290 save_pos = TRUE; // save the cursor position below
291 } 291 }
292 292
293 new_tag = TRUE; 293 new_tag = TRUE;
294 } 294 }
295 else 295 else
298 #if defined(FEAT_QUICKFIX) 298 #if defined(FEAT_QUICKFIX)
299 g_do_tagpreview != 0 ? ptag_entry.tagname == NULL : 299 g_do_tagpreview != 0 ? ptag_entry.tagname == NULL :
300 #endif 300 #endif
301 tagstacklen == 0) 301 tagstacklen == 0)
302 { 302 {
303 /* empty stack */ 303 // empty stack
304 emsg(_(e_tagstack)); 304 emsg(_(e_tagstack));
305 goto end_do_tag; 305 goto end_do_tag;
306 } 306 }
307 307
308 if (type == DT_POP) /* go to older position */ 308 if (type == DT_POP) // go to older position
309 { 309 {
310 #ifdef FEAT_FOLDING 310 #ifdef FEAT_FOLDING
311 int old_KeyTyped = KeyTyped; 311 int old_KeyTyped = KeyTyped;
312 #endif 312 #endif
313 if ((tagstackidx -= count) < 0) 313 if ((tagstackidx -= count) < 0)
314 { 314 {
315 emsg(_(bottommsg)); 315 emsg(_(bottommsg));
316 if (tagstackidx + count == 0) 316 if (tagstackidx + count == 0)
317 { 317 {
318 /* We did [num]^T from the bottom of the stack */ 318 // We did [num]^T from the bottom of the stack
319 tagstackidx = 0; 319 tagstackidx = 0;
320 goto end_do_tag; 320 goto end_do_tag;
321 } 321 }
322 /* We weren't at the bottom of the stack, so jump all the 322 // We weren't at the bottom of the stack, so jump all the
323 * way to the bottom now. 323 // way to the bottom now.
324 */
325 tagstackidx = 0; 324 tagstackidx = 0;
326 } 325 }
327 else if (tagstackidx >= tagstacklen) /* count == 0? */ 326 else if (tagstackidx >= tagstacklen) // count == 0?
328 { 327 {
329 emsg(_(topmsg)); 328 emsg(_(topmsg));
330 goto end_do_tag; 329 goto end_do_tag;
331 } 330 }
332 331
333 /* Make a copy of the fmark, autocommands may invalidate the 332 // Make a copy of the fmark, autocommands may invalidate the
334 * tagstack before it's used. */ 333 // tagstack before it's used.
335 saved_fmark = tagstack[tagstackidx].fmark; 334 saved_fmark = tagstack[tagstackidx].fmark;
336 if (saved_fmark.fnum != curbuf->b_fnum) 335 if (saved_fmark.fnum != curbuf->b_fnum)
337 { 336 {
338 /* 337 /*
339 * Jump to other file. If this fails (e.g. because the 338 * Jump to other file. If this fails (e.g. because the
340 * file was changed) keep original position in tag stack. 339 * file was changed) keep original position in tag stack.
341 */ 340 */
342 if (buflist_getfile(saved_fmark.fnum, saved_fmark.mark.lnum, 341 if (buflist_getfile(saved_fmark.fnum, saved_fmark.mark.lnum,
343 GETF_SETMARK, forceit) == FAIL) 342 GETF_SETMARK, forceit) == FAIL)
344 { 343 {
345 tagstackidx = oldtagstackidx; /* back to old posn */ 344 tagstackidx = oldtagstackidx; // back to old posn
346 goto end_do_tag; 345 goto end_do_tag;
347 } 346 }
348 /* An BufReadPost autocommand may jump to the '" mark, but 347 // An BufReadPost autocommand may jump to the '" mark, but
349 * we don't what that here. */ 348 // we don't what that here.
350 curwin->w_cursor.lnum = saved_fmark.mark.lnum; 349 curwin->w_cursor.lnum = saved_fmark.mark.lnum;
351 } 350 }
352 else 351 else
353 { 352 {
354 setpcmark(); 353 setpcmark();
360 #ifdef FEAT_FOLDING 359 #ifdef FEAT_FOLDING
361 if ((fdo_flags & FDO_TAG) && old_KeyTyped) 360 if ((fdo_flags & FDO_TAG) && old_KeyTyped)
362 foldOpenCursor(); 361 foldOpenCursor();
363 #endif 362 #endif
364 363
365 /* remove the old list of matches */ 364 // remove the old list of matches
366 FreeWild(num_matches, matches); 365 FreeWild(num_matches, matches);
367 #ifdef FEAT_CSCOPE 366 #ifdef FEAT_CSCOPE
368 cs_free_tags(); 367 cs_free_tags();
369 #endif 368 #endif
370 num_matches = 0; 369 num_matches = 0;
385 cur_fnum = ptag_entry.cur_fnum; 384 cur_fnum = ptag_entry.cur_fnum;
386 } 385 }
387 else 386 else
388 #endif 387 #endif
389 { 388 {
390 /* ":tag" (no argument): go to newer pattern */ 389 // ":tag" (no argument): go to newer pattern
391 save_pos = TRUE; /* save the cursor position below */ 390 save_pos = TRUE; // save the cursor position below
392 if ((tagstackidx += count - 1) >= tagstacklen) 391 if ((tagstackidx += count - 1) >= tagstacklen)
393 { 392 {
394 /* 393 /*
395 * Beyond the last one, just give an error message and 394 * Beyond the last one, just give an error message and
396 * go to the last one. Don't store the cursor 395 * go to the last one. Don't store the cursor
398 */ 397 */
399 tagstackidx = tagstacklen - 1; 398 tagstackidx = tagstacklen - 1;
400 emsg(_(topmsg)); 399 emsg(_(topmsg));
401 save_pos = FALSE; 400 save_pos = FALSE;
402 } 401 }
403 else if (tagstackidx < 0) /* must have been count == 0 */ 402 else if (tagstackidx < 0) // must have been count == 0
404 { 403 {
405 emsg(_(bottommsg)); 404 emsg(_(bottommsg));
406 tagstackidx = 0; 405 tagstackidx = 0;
407 goto end_do_tag; 406 goto end_do_tag;
408 } 407 }
409 cur_match = tagstack[tagstackidx].cur_match; 408 cur_match = tagstack[tagstackidx].cur_match;
410 cur_fnum = tagstack[tagstackidx].cur_fnum; 409 cur_fnum = tagstack[tagstackidx].cur_fnum;
411 } 410 }
412 new_tag = TRUE; 411 new_tag = TRUE;
413 } 412 }
414 else /* go to other matching tag */ 413 else // go to other matching tag
415 { 414 {
416 /* Save index for when selection is cancelled. */ 415 // Save index for when selection is cancelled.
417 prevtagstackidx = tagstackidx; 416 prevtagstackidx = tagstackidx;
418 417
419 #if defined(FEAT_QUICKFIX) 418 #if defined(FEAT_QUICKFIX)
420 if (g_do_tagpreview != 0) 419 if (g_do_tagpreview != 0)
421 { 420 {
474 { 473 {
475 tagstack[tagstackidx].fmark.mark = curwin->w_cursor; 474 tagstack[tagstackidx].fmark.mark = curwin->w_cursor;
476 tagstack[tagstackidx].fmark.fnum = curbuf->b_fnum; 475 tagstack[tagstackidx].fmark.fnum = curbuf->b_fnum;
477 } 476 }
478 477
479 /* Curwin will change in the call to jumpto_tag() if ":stag" was 478 // Curwin will change in the call to jumpto_tag() if ":stag" was
480 * used or an autocommand jumps to another window; store value of 479 // used or an autocommand jumps to another window; store value of
481 * tagstackidx now. */ 480 // tagstackidx now.
482 curwin->w_tagstackidx = tagstackidx; 481 curwin->w_tagstackidx = tagstackidx;
483 if (type != DT_SELECT && type != DT_JUMP) 482 if (type != DT_SELECT && type != DT_JUMP)
484 { 483 {
485 curwin->w_tagstack[tagstackidx].cur_match = cur_match; 484 curwin->w_tagstack[tagstackidx].cur_match = cur_match;
486 curwin->w_tagstack[tagstackidx].cur_fnum = cur_fnum; 485 curwin->w_tagstack[tagstackidx].cur_fnum = cur_fnum;
487 } 486 }
488 } 487 }
489 } 488 }
490 489
491 /* When not using the current buffer get the name of buffer "cur_fnum". 490 // When not using the current buffer get the name of buffer "cur_fnum".
492 * Makes sure that the tag order doesn't change when using a remembered 491 // Makes sure that the tag order doesn't change when using a remembered
493 * position for "cur_match". */ 492 // position for "cur_match".
494 if (cur_fnum != curbuf->b_fnum) 493 if (cur_fnum != curbuf->b_fnum)
495 { 494 {
496 buf_T *buf = buflist_findnr(cur_fnum); 495 buf_T *buf = buflist_findnr(cur_fnum);
497 496
498 if (buf != NULL) 497 if (buf != NULL)
538 if (type == DT_TAG) 537 if (type == DT_TAG)
539 max_num_matches = MAXCOL; 538 max_num_matches = MAXCOL;
540 else 539 else
541 max_num_matches = cur_match + 1; 540 max_num_matches = cur_match + 1;
542 541
543 /* when the argument starts with '/', use it as a regexp */ 542 // when the argument starts with '/', use it as a regexp
544 if (!no_regexp && *name == '/') 543 if (!no_regexp && *name == '/')
545 { 544 {
546 flags = TAG_REGEXP; 545 flags = TAG_REGEXP;
547 ++name; 546 ++name;
548 } 547 }
560 flags |= TAG_NO_TAGFUNC; 559 flags |= TAG_NO_TAGFUNC;
561 560
562 if (find_tags(name, &new_num_matches, &new_matches, flags, 561 if (find_tags(name, &new_num_matches, &new_matches, flags,
563 max_num_matches, buf_ffname) == OK 562 max_num_matches, buf_ffname) == OK
564 && new_num_matches < max_num_matches) 563 && new_num_matches < max_num_matches)
565 max_num_matches = MAXCOL; /* If less than max_num_matches 564 max_num_matches = MAXCOL; // If less than max_num_matches
566 found: all matches found. */ 565 // found: all matches found.
567 566
568 /* If there already were some matches for the same name, move them 567 // If there already were some matches for the same name, move them
569 * to the start. Avoids that the order changes when using 568 // to the start. Avoids that the order changes when using
570 * ":tnext" and jumping to another file. */ 569 // ":tnext" and jumping to another file.
571 if (!new_tag && !other_name) 570 if (!new_tag && !other_name)
572 { 571 {
573 int j, k; 572 int j, k;
574 int idx = 0; 573 int idx = 0;
575 tagptrs_T tagp, tagp2; 574 tagptrs_T tagp, tagp2;
576 575
577 /* Find the position of each old match in the new list. Need 576 // Find the position of each old match in the new list. Need
578 * to use parse_match() to find the tag line. */ 577 // to use parse_match() to find the tag line.
579 for (j = 0; j < num_matches; ++j) 578 for (j = 0; j < num_matches; ++j)
580 { 579 {
581 parse_match(matches[j], &tagp); 580 parse_match(matches[j], &tagp);
582 for (i = idx; i < new_num_matches; ++i) 581 for (i = idx; i < new_num_matches; ++i)
583 { 582 {
630 #if defined(FEAT_QUICKFIX) && defined(FEAT_EVAL) 629 #if defined(FEAT_QUICKFIX) && defined(FEAT_EVAL)
631 else if (type == DT_LTAG) 630 else if (type == DT_LTAG)
632 { 631 {
633 if (add_llist_tags(tag, num_matches, matches) == FAIL) 632 if (add_llist_tags(tag, num_matches, matches) == FAIL)
634 goto end_do_tag; 633 goto end_do_tag;
635 cur_match = 0; /* Jump to the first tag */ 634 cur_match = 0; // Jump to the first tag
636 } 635 }
637 #endif 636 #endif
638 637
639 if (ask_for_selection == TRUE) 638 if (ask_for_selection == TRUE)
640 { 639 {
642 * Ask to select a tag from the list. 641 * Ask to select a tag from the list.
643 */ 642 */
644 i = prompt_for_number(NULL); 643 i = prompt_for_number(NULL);
645 if (i <= 0 || i > num_matches || got_int) 644 if (i <= 0 || i > num_matches || got_int)
646 { 645 {
647 /* no valid choice: don't change anything */ 646 // no valid choice: don't change anything
648 if (use_tagstack) 647 if (use_tagstack)
649 { 648 {
650 tagstack[tagstackidx].fmark = saved_fmark; 649 tagstack[tagstackidx].fmark = saved_fmark;
651 tagstackidx = prevtagstackidx; 650 tagstackidx = prevtagstackidx;
652 } 651 }
659 cur_match = i - 1; 658 cur_match = i - 1;
660 } 659 }
661 660
662 if (cur_match >= num_matches) 661 if (cur_match >= num_matches)
663 { 662 {
664 /* Avoid giving this error when a file wasn't found and we're 663 // Avoid giving this error when a file wasn't found and we're
665 * looking for a match in another file, which wasn't found. 664 // looking for a match in another file, which wasn't found.
666 * There will be an emsg("file doesn't exist") below then. */ 665 // There will be an emsg("file doesn't exist") below then.
667 if ((type == DT_NEXT || type == DT_FIRST) 666 if ((type == DT_NEXT || type == DT_FIRST)
668 && nofile_fname == NULL) 667 && nofile_fname == NULL)
669 { 668 {
670 if (num_matches == 1) 669 if (num_matches == 1)
671 emsg(_("E427: There is only one matching tag")); 670 emsg(_("E427: There is only one matching tag"));
715 && type != DT_CSCOPE 714 && type != DT_CSCOPE
716 #endif 715 #endif
717 && (num_matches > 1 || ic) 716 && (num_matches > 1 || ic)
718 && !skip_msg) 717 && !skip_msg)
719 { 718 {
720 /* Give an indication of the number of matching tags */ 719 // Give an indication of the number of matching tags
721 sprintf((char *)IObuff, _("tag %d of %d%s"), 720 sprintf((char *)IObuff, _("tag %d of %d%s"),
722 cur_match + 1, 721 cur_match + 1,
723 num_matches, 722 num_matches,
724 max_num_matches != MAXCOL ? _(" or more") : ""); 723 max_num_matches != MAXCOL ? _(" or more") : "");
725 if (ic) 724 if (ic)
729 { 728 {
730 if (ic) 729 if (ic)
731 msg_attr((char *)IObuff, HL_ATTR(HLF_W)); 730 msg_attr((char *)IObuff, HL_ATTR(HLF_W));
732 else 731 else
733 msg((char *)IObuff); 732 msg((char *)IObuff);
734 msg_scroll = TRUE; /* don't overwrite this message */ 733 msg_scroll = TRUE; // don't overwrite this message
735 } 734 }
736 else 735 else
737 give_warning(IObuff, ic); 736 give_warning(IObuff, ic);
738 if (ic && !msg_scrolled && msg_silent == 0) 737 if (ic && !msg_scrolled && msg_silent == 0)
739 { 738 {
741 ui_delay(1007L, TRUE); 740 ui_delay(1007L, TRUE);
742 } 741 }
743 } 742 }
744 743
745 #if defined(FEAT_EVAL) 744 #if defined(FEAT_EVAL)
746 /* Let the SwapExists event know what tag we are jumping to. */ 745 // Let the SwapExists event know what tag we are jumping to.
747 vim_snprintf((char *)IObuff, IOSIZE, ":ta %s\r", name); 746 vim_snprintf((char *)IObuff, IOSIZE, ":ta %s\r", name);
748 set_vim_var_string(VV_SWAPCOMMAND, IObuff, -1); 747 set_vim_var_string(VV_SWAPCOMMAND, IObuff, -1);
749 #endif 748 #endif
750 749
751 /* 750 /*
757 set_vim_var_string(VV_SWAPCOMMAND, NULL, -1); 756 set_vim_var_string(VV_SWAPCOMMAND, NULL, -1);
758 #endif 757 #endif
759 758
760 if (i == NOTAGFILE) 759 if (i == NOTAGFILE)
761 { 760 {
762 /* File not found: try again with another matching tag */ 761 // File not found: try again with another matching tag
763 if ((type == DT_PREV && cur_match > 0) 762 if ((type == DT_PREV && cur_match > 0)
764 || ((type == DT_TAG || type == DT_NEXT 763 || ((type == DT_TAG || type == DT_NEXT
765 || type == DT_FIRST) 764 || type == DT_FIRST)
766 && (max_num_matches != MAXCOL 765 && (max_num_matches != MAXCOL
767 || cur_match < num_matches - 1))) 766 || cur_match < num_matches - 1)))
780 } 779 }
781 semsg(_("E429: File \"%s\" does not exist"), nofile_fname); 780 semsg(_("E429: File \"%s\" does not exist"), nofile_fname);
782 } 781 }
783 else 782 else
784 { 783 {
785 /* We may have jumped to another window, check that 784 // We may have jumped to another window, check that
786 * tagstackidx is still valid. */ 785 // tagstackidx is still valid.
787 if (use_tagstack && tagstackidx > curwin->w_tagstacklen) 786 if (use_tagstack && tagstackidx > curwin->w_tagstacklen)
788 tagstackidx = curwin->w_tagstackidx; 787 tagstackidx = curwin->w_tagstackidx;
789 #ifdef FEAT_CSCOPE 788 #ifdef FEAT_CSCOPE
790 jumped_to_tag = TRUE; 789 jumped_to_tag = TRUE;
791 #endif 790 #endif
793 } 792 }
794 break; 793 break;
795 } 794 }
796 795
797 end_do_tag: 796 end_do_tag:
798 /* Only store the new index when using the tagstack and it's valid. */ 797 // Only store the new index when using the tagstack and it's valid.
799 if (use_tagstack && tagstackidx <= curwin->w_tagstacklen) 798 if (use_tagstack && tagstackidx <= curwin->w_tagstacklen)
800 curwin->w_tagstackidx = tagstackidx; 799 curwin->w_tagstackidx = tagstackidx;
801 postponed_split = 0; /* don't split next time */ 800 postponed_split = 0; // don't split next time
802 # ifdef FEAT_QUICKFIX 801 # ifdef FEAT_QUICKFIX
803 g_do_tagpreview = 0; /* don't do tag preview next time */ 802 g_do_tagpreview = 0; // don't do tag preview next time
804 # endif 803 # endif
805 804
806 #ifdef FEAT_CSCOPE 805 #ifdef FEAT_CSCOPE
807 return jumped_to_tag; 806 return jumped_to_tag;
808 #else 807 #else
1039 long lnum; 1038 long lnum;
1040 dict_T *dict; 1039 dict_T *dict;
1041 1040
1042 parse_match(matches[i], &tagp); 1041 parse_match(matches[i], &tagp);
1043 1042
1044 /* Save the tag name */ 1043 // Save the tag name
1045 len = (int)(tagp.tagname_end - tagp.tagname); 1044 len = (int)(tagp.tagname_end - tagp.tagname);
1046 if (len > 128) 1045 if (len > 128)
1047 len = 128; 1046 len = 128;
1048 vim_strncpy(tag_name, tagp.tagname, len); 1047 vim_strncpy(tag_name, tagp.tagname, len);
1049 tag_name[len] = NUL; 1048 tag_name[len] = NUL;
1183 char_u *name; 1182 char_u *name;
1184 taggy_T *tagstack = curwin->w_tagstack; 1183 taggy_T *tagstack = curwin->w_tagstack;
1185 int tagstackidx = curwin->w_tagstackidx; 1184 int tagstackidx = curwin->w_tagstackidx;
1186 int tagstacklen = curwin->w_tagstacklen; 1185 int tagstacklen = curwin->w_tagstacklen;
1187 1186
1188 /* Highlight title */ 1187 // Highlight title
1189 msg_puts_title(_("\n # TO tag FROM line in file/text")); 1188 msg_puts_title(_("\n # TO tag FROM line in file/text"));
1190 for (i = 0; i < tagstacklen; ++i) 1189 for (i = 0; i < tagstacklen; ++i)
1191 { 1190 {
1192 if (tagstack[i].tagname != NULL) 1191 if (tagstack[i].tagname != NULL)
1193 { 1192 {
1194 name = fm_getname(&(tagstack[i].fmark), 30); 1193 name = fm_getname(&(tagstack[i].fmark), 30);
1195 if (name == NULL) /* file name not available */ 1194 if (name == NULL) // file name not available
1196 continue; 1195 continue;
1197 1196
1198 msg_putchar('\n'); 1197 msg_putchar('\n');
1199 vim_snprintf((char *)IObuff, IOSIZE, "%c%2d %2d %-15s %5ld ", 1198 vim_snprintf((char *)IObuff, IOSIZE, "%c%2d %2d %-15s %5ld ",
1200 i == tagstackidx ? '>' : ' ', 1199 i == tagstackidx ? '>' : ' ',
1205 msg_outtrans(IObuff); 1204 msg_outtrans(IObuff);
1206 msg_outtrans_attr(name, tagstack[i].fmark.fnum == curbuf->b_fnum 1205 msg_outtrans_attr(name, tagstack[i].fmark.fnum == curbuf->b_fnum
1207 ? HL_ATTR(HLF_D) : 0); 1206 ? HL_ATTR(HLF_D) : 0);
1208 vim_free(name); 1207 vim_free(name);
1209 } 1208 }
1210 out_flush(); /* show one line at a time */ 1209 out_flush(); // show one line at a time
1211 } 1210 }
1212 if (tagstackidx == tagstacklen) /* idx at top of stack */ 1211 if (tagstackidx == tagstacklen) // idx at top of stack
1213 msg_puts("\n>"); 1212 msg_puts("\n>");
1214 } 1213 }
1215 1214
1216 #ifdef FEAT_TAG_BINS 1215 #ifdef FEAT_TAG_BINS
1217 /* 1216 /*
1226 1225
1227 while (len > 0) 1226 while (len > 0)
1228 { 1227 {
1229 i = (int)TOUPPER_ASC(*s1) - (int)TOUPPER_ASC(*s2); 1228 i = (int)TOUPPER_ASC(*s1) - (int)TOUPPER_ASC(*s2);
1230 if (i != 0) 1229 if (i != 0)
1231 return i; /* this character different */ 1230 return i; // this character different
1232 if (*s1 == NUL) 1231 if (*s1 == NUL)
1233 break; /* strings match until NUL */ 1232 break; // strings match until NUL
1234 ++s1; 1233 ++s1;
1235 ++s2; 1234 ++s2;
1236 --len; 1235 --len;
1237 } 1236 }
1238 return 0; /* strings match */ 1237 return 0; // strings match
1239 } 1238 }
1240 #endif 1239 #endif
1241 1240
1242 /* 1241 /*
1243 * Structure to hold info about the tag pattern being used. 1242 * Structure to hold info about the tag pattern being used.
1244 */ 1243 */
1245 typedef struct 1244 typedef struct
1246 { 1245 {
1247 char_u *pat; /* the pattern */ 1246 char_u *pat; // the pattern
1248 int len; /* length of pat[] */ 1247 int len; // length of pat[]
1249 char_u *head; /* start of pattern head */ 1248 char_u *head; // start of pattern head
1250 int headlen; /* length of head[] */ 1249 int headlen; // length of head[]
1251 regmatch_T regmatch; /* regexp program, may be NULL */ 1250 regmatch_T regmatch; // regexp program, may be NULL
1252 } pat_T; 1251 } pat_T;
1253 1252
1254 /* 1253 /*
1255 * Extract info from the tag search pattern "pats->pat". 1254 * Extract info from the tag search pattern "pats->pat".
1256 */ 1255 */
1259 { 1258 {
1260 pats->head = pats->pat; 1259 pats->head = pats->pat;
1261 pats->headlen = pats->len; 1260 pats->headlen = pats->len;
1262 if (has_re) 1261 if (has_re)
1263 { 1262 {
1264 /* When the pattern starts with '^' or "\\<", binary searching can be 1263 // When the pattern starts with '^' or "\\<", binary searching can be
1265 * used (much faster). */ 1264 // used (much faster).
1266 if (pats->pat[0] == '^') 1265 if (pats->pat[0] == '^')
1267 pats->head = pats->pat + 1; 1266 pats->head = pats->pat + 1;
1268 else if (pats->pat[0] == '\\' && pats->pat[1] == '<') 1267 else if (pats->pat[0] == '\\' && pats->pat[1] == '<')
1269 pats->head = pats->pat + 2; 1268 pats->head = pats->pat + 2;
1270 if (pats->head == pats->pat) 1269 if (pats->head == pats->pat)
1273 for (pats->headlen = 0; pats->head[pats->headlen] != NUL; 1272 for (pats->headlen = 0; pats->head[pats->headlen] != NUL;
1274 ++pats->headlen) 1273 ++pats->headlen)
1275 if (vim_strchr((char_u *)(p_magic ? ".[~*\\$" : "\\$"), 1274 if (vim_strchr((char_u *)(p_magic ? ".[~*\\$" : "\\$"),
1276 pats->head[pats->headlen]) != NULL) 1275 pats->head[pats->headlen]) != NULL)
1277 break; 1276 break;
1278 if (p_tl != 0 && pats->headlen > p_tl) /* adjust for 'taglength' */ 1277 if (p_tl != 0 && pats->headlen > p_tl) // adjust for 'taglength'
1279 pats->headlen = p_tl; 1278 pats->headlen = p_tl;
1280 } 1279 }
1281 1280
1282 if (has_re) 1281 if (has_re)
1283 pats->regmatch.regprog = vim_regcomp(pats->pat, p_magic ? RE_MAGIC : 0); 1282 pats->regmatch.regprog = vim_regcomp(pats->pat, p_magic ? RE_MAGIC : 0);
1543 * TAG_CSCOPE use cscope results for tags 1542 * TAG_CSCOPE use cscope results for tags
1544 * TAG_NO_TAGFUNC do not call the 'tagfunc' function 1543 * TAG_NO_TAGFUNC do not call the 'tagfunc' function
1545 */ 1544 */
1546 int 1545 int
1547 find_tags( 1546 find_tags(
1548 char_u *pat, /* pattern to search for */ 1547 char_u *pat, // pattern to search for
1549 int *num_matches, /* return: number of matches found */ 1548 int *num_matches, // return: number of matches found
1550 char_u ***matchesp, /* return: array of matches found */ 1549 char_u ***matchesp, // return: array of matches found
1551 int flags, 1550 int flags,
1552 int mincount, /* MAXCOL: find all matches 1551 int mincount, // MAXCOL: find all matches
1553 other: minimal number of matches */ 1552 // other: minimal number of matches
1554 char_u *buf_ffname) /* name of buffer for priority */ 1553 char_u *buf_ffname) // name of buffer for priority
1555 { 1554 {
1556 FILE *fp; 1555 FILE *fp;
1557 char_u *lbuf; /* line buffer */ 1556 char_u *lbuf; // line buffer
1558 int lbuf_size = LSIZE; /* length of lbuf */ 1557 int lbuf_size = LSIZE; // length of lbuf
1559 char_u *tag_fname; /* name of tag file */ 1558 char_u *tag_fname; // name of tag file
1560 tagname_T tn; /* info for get_tagfname() */ 1559 tagname_T tn; // info for get_tagfname()
1561 int first_file; /* trying first tag file */ 1560 int first_file; // trying first tag file
1562 tagptrs_T tagp; 1561 tagptrs_T tagp;
1563 int did_open = FALSE; /* did open a tag file */ 1562 int did_open = FALSE; // did open a tag file
1564 int stop_searching = FALSE; /* stop when match found or error */ 1563 int stop_searching = FALSE; // stop when match found or error
1565 int retval = FAIL; /* return value */ 1564 int retval = FAIL; // return value
1566 int is_static; /* current tag line is static */ 1565 int is_static; // current tag line is static
1567 int is_current; /* file name matches */ 1566 int is_current; // file name matches
1568 int eof = FALSE; /* found end-of-file */ 1567 int eof = FALSE; // found end-of-file
1569 char_u *p; 1568 char_u *p;
1570 char_u *s; 1569 char_u *s;
1571 int i; 1570 int i;
1572 #ifdef FEAT_TAG_BINS 1571 #ifdef FEAT_TAG_BINS
1573 int tag_file_sorted = NUL; /* !_TAG_FILE_SORTED value */ 1572 int tag_file_sorted = NUL; // !_TAG_FILE_SORTED value
1574 struct tag_search_info /* Binary search file offsets */ 1573 struct tag_search_info // Binary search file offsets
1575 { 1574 {
1576 off_T low_offset; /* offset for first char of first line that 1575 off_T low_offset; // offset for first char of first line that
1577 could match */ 1576 // could match
1578 off_T high_offset; /* offset of char after last line that could 1577 off_T high_offset; // offset of char after last line that could
1579 match */ 1578 // match
1580 off_T curr_offset; /* Current file offset in search range */ 1579 off_T curr_offset; // Current file offset in search range
1581 off_T curr_offset_used; /* curr_offset used when skipping back */ 1580 off_T curr_offset_used; // curr_offset used when skipping back
1582 off_T match_offset; /* Where the binary search found a tag */ 1581 off_T match_offset; // Where the binary search found a tag
1583 int low_char; /* first char at low_offset */ 1582 int low_char; // first char at low_offset
1584 int high_char; /* first char at high_offset */ 1583 int high_char; // first char at high_offset
1585 } search_info; 1584 } search_info;
1586 off_T filesize; 1585 off_T filesize;
1587 int tagcmp; 1586 int tagcmp;
1588 off_T offset; 1587 off_T offset;
1589 int round; 1588 int round;
1590 #endif 1589 #endif
1591 enum 1590 enum
1592 { 1591 {
1593 TS_START, /* at start of file */ 1592 TS_START, // at start of file
1594 TS_LINEAR /* linear searching forward, till EOF */ 1593 TS_LINEAR // linear searching forward, till EOF
1595 #ifdef FEAT_TAG_BINS 1594 #ifdef FEAT_TAG_BINS
1596 , TS_BINARY, /* binary searching */ 1595 , TS_BINARY, // binary searching
1597 TS_SKIP_BACK, /* skipping backwards */ 1596 TS_SKIP_BACK, // skipping backwards
1598 TS_STEP_FORWARD /* stepping forwards */ 1597 TS_STEP_FORWARD // stepping forwards
1599 #endif 1598 #endif
1600 } state; /* Current search state */ 1599 } state; // Current search state
1601 1600
1602 int cmplen; 1601 int cmplen;
1603 int match; /* matches */ 1602 int match; // matches
1604 int match_no_ic = 0;/* matches with rm_ic == FALSE */ 1603 int match_no_ic = 0;// matches with rm_ic == FALSE
1605 int match_re; /* match with regexp */ 1604 int match_re; // match with regexp
1606 int matchoff = 0; 1605 int matchoff = 0;
1607 int save_emsg_off; 1606 int save_emsg_off;
1608 1607
1609 #ifdef FEAT_EMACS_TAGS 1608 #ifdef FEAT_EMACS_TAGS
1610 /* 1609 /*
1616 { 1615 {
1617 FILE *fp; 1616 FILE *fp;
1618 char_u *etag_fname; 1617 char_u *etag_fname;
1619 } incstack[INCSTACK_SIZE]; 1618 } incstack[INCSTACK_SIZE];
1620 1619
1621 int incstack_idx = 0; /* index in incstack */ 1620 int incstack_idx = 0; // index in incstack
1622 char_u *ebuf; /* additional buffer for etag fname */ 1621 char_u *ebuf; // additional buffer for etag fname
1623 int is_etag; /* current file is emaces style */ 1622 int is_etag; // current file is emaces style
1624 #endif 1623 #endif
1625 1624
1626 char_u *mfp; 1625 char_u *mfp;
1627 garray_T ga_match[MT_COUNT]; /* stores matches in sequence */ 1626 garray_T ga_match[MT_COUNT]; // stores matches in sequence
1628 hashtab_T ht_match[MT_COUNT]; /* stores matches by key */ 1627 hashtab_T ht_match[MT_COUNT]; // stores matches by key
1629 hash_T hash = 0; 1628 hash_T hash = 0;
1630 int match_count = 0; /* number of matches found */ 1629 int match_count = 0; // number of matches found
1631 char_u **matches; 1630 char_u **matches;
1632 int mtt; 1631 int mtt;
1633 int help_save; 1632 int help_save;
1634 #ifdef FEAT_MULTI_LANG 1633 #ifdef FEAT_MULTI_LANG
1635 int help_pri = 0; 1634 int help_pri = 0;
1636 char_u *help_lang_find = NULL; /* lang to be found */ 1635 char_u *help_lang_find = NULL; // lang to be found
1637 char_u help_lang[3]; /* lang of current tags file */ 1636 char_u help_lang[3]; // lang of current tags file
1638 char_u *saved_pat = NULL; /* copy of pat[] */ 1637 char_u *saved_pat = NULL; // copy of pat[]
1639 int is_txt = FALSE; /* flag of file extension */ 1638 int is_txt = FALSE; // flag of file extension
1640 #endif 1639 #endif
1641 1640
1642 pat_T orgpat; /* holds unconverted pattern info */ 1641 pat_T orgpat; // holds unconverted pattern info
1643 vimconv_T vimconv; 1642 vimconv_T vimconv;
1644 1643
1645 #ifdef FEAT_TAG_BINS 1644 #ifdef FEAT_TAG_BINS
1646 int findall = (mincount == MAXCOL || mincount == TAG_MANY); 1645 int findall = (mincount == MAXCOL || mincount == TAG_MANY);
1647 /* find all matching tags */ 1646 // find all matching tags
1648 int sort_error = FALSE; /* tags file not sorted */ 1647 int sort_error = FALSE; // tags file not sorted
1649 int linear; /* do a linear search */ 1648 int linear; // do a linear search
1650 int sortic = FALSE; /* tag file sorted in nocase */ 1649 int sortic = FALSE; // tag file sorted in nocase
1651 #endif 1650 #endif
1652 int line_error = FALSE; /* syntax error */ 1651 int line_error = FALSE; // syntax error
1653 int has_re = (flags & TAG_REGEXP); /* regexp used */ 1652 int has_re = (flags & TAG_REGEXP); // regexp used
1654 int help_only = (flags & TAG_HELP); 1653 int help_only = (flags & TAG_HELP);
1655 int name_only = (flags & TAG_NAMES); 1654 int name_only = (flags & TAG_NAMES);
1656 int noic = (flags & TAG_NOIC); 1655 int noic = (flags & TAG_NOIC);
1657 int get_it_again = FALSE; 1656 int get_it_again = FALSE;
1658 #ifdef FEAT_CSCOPE 1657 #ifdef FEAT_CSCOPE
1693 { 1692 {
1694 ga_init2(&ga_match[mtt], (int)sizeof(char_u *), 100); 1693 ga_init2(&ga_match[mtt], (int)sizeof(char_u *), 100);
1695 hash_init(&ht_match[mtt]); 1694 hash_init(&ht_match[mtt]);
1696 } 1695 }
1697 1696
1698 /* check for out of memory situation */ 1697 // check for out of memory situation
1699 if (lbuf == NULL || tag_fname == NULL 1698 if (lbuf == NULL || tag_fname == NULL
1700 #ifdef FEAT_EMACS_TAGS 1699 #ifdef FEAT_EMACS_TAGS
1701 || ebuf == NULL 1700 || ebuf == NULL
1702 #endif 1701 #endif
1703 ) 1702 )
1704 goto findtag_end; 1703 goto findtag_end;
1705 1704
1706 #ifdef FEAT_CSCOPE 1705 #ifdef FEAT_CSCOPE
1707 STRCPY(tag_fname, "from cscope"); /* for error messages */ 1706 STRCPY(tag_fname, "from cscope"); // for error messages
1708 #endif 1707 #endif
1709 1708
1710 /* 1709 /*
1711 * Initialize a few variables 1710 * Initialize a few variables
1712 */ 1711 */
1713 if (help_only) /* want tags from help file */ 1712 if (help_only) // want tags from help file
1714 curbuf->b_help = TRUE; /* will be restored later */ 1713 curbuf->b_help = TRUE; // will be restored later
1715 #ifdef FEAT_CSCOPE 1714 #ifdef FEAT_CSCOPE
1716 else if (use_cscope) 1715 else if (use_cscope)
1717 { 1716 {
1718 /* Make sure we don't mix help and cscope, confuses Coverity. */ 1717 // Make sure we don't mix help and cscope, confuses Coverity.
1719 help_only = FALSE; 1718 help_only = FALSE;
1720 curbuf->b_help = FALSE; 1719 curbuf->b_help = FALSE;
1721 } 1720 }
1722 #endif 1721 #endif
1723 1722
1724 orgpat.len = (int)STRLEN(pat); 1723 orgpat.len = (int)STRLEN(pat);
1725 #ifdef FEAT_MULTI_LANG 1724 #ifdef FEAT_MULTI_LANG
1726 if (curbuf->b_help) 1725 if (curbuf->b_help)
1727 { 1726 {
1728 /* When "@ab" is specified use only the "ab" language, otherwise 1727 // When "@ab" is specified use only the "ab" language, otherwise
1729 * search all languages. */ 1728 // search all languages.
1730 if (orgpat.len > 3 && pat[orgpat.len - 3] == '@' 1729 if (orgpat.len > 3 && pat[orgpat.len - 3] == '@'
1731 && ASCII_ISALPHA(pat[orgpat.len - 2]) 1730 && ASCII_ISALPHA(pat[orgpat.len - 2])
1732 && ASCII_ISALPHA(pat[orgpat.len - 1])) 1731 && ASCII_ISALPHA(pat[orgpat.len - 1]))
1733 { 1732 {
1734 saved_pat = vim_strnsave(pat, orgpat.len - 3); 1733 saved_pat = vim_strnsave(pat, orgpat.len - 3);
1739 orgpat.len -= 3; 1738 orgpat.len -= 3;
1740 } 1739 }
1741 } 1740 }
1742 } 1741 }
1743 #endif 1742 #endif
1744 if (p_tl != 0 && orgpat.len > p_tl) /* adjust for 'taglength' */ 1743 if (p_tl != 0 && orgpat.len > p_tl) // adjust for 'taglength'
1745 orgpat.len = p_tl; 1744 orgpat.len = p_tl;
1746 1745
1747 save_emsg_off = emsg_off; 1746 save_emsg_off = emsg_off;
1748 emsg_off = TRUE; /* don't want error for invalid RE here */ 1747 emsg_off = TRUE; // don't want error for invalid RE here
1749 prepare_pats(&orgpat, has_re); 1748 prepare_pats(&orgpat, has_re);
1750 emsg_off = save_emsg_off; 1749 emsg_off = save_emsg_off;
1751 if (has_re && orgpat.regmatch.regprog == NULL) 1750 if (has_re && orgpat.regmatch.regprog == NULL)
1752 goto findtag_end; 1751 goto findtag_end;
1753 1752
1754 #ifdef FEAT_TAG_BINS 1753 #ifdef FEAT_TAG_BINS
1755 /* This is only to avoid a compiler warning for using search_info 1754 // This is only to avoid a compiler warning for using search_info
1756 * uninitialised. */ 1755 // uninitialised.
1757 vim_memset(&search_info, 0, (size_t)1); 1756 vim_memset(&search_info, 0, (size_t)1);
1758 #endif 1757 #endif
1759 1758
1760 #ifdef FEAT_EVAL 1759 #ifdef FEAT_EVAL
1761 if (*curbuf->b_p_tfu != NUL && use_tfu && !tfu_in_use) 1760 if (*curbuf->b_p_tfu != NUL && use_tfu && !tfu_in_use)
1778 * tags files twice. 1777 * tags files twice.
1779 * When the tag file is case-fold sorted, it is either one or the other. 1778 * When the tag file is case-fold sorted, it is either one or the other.
1780 * Only ignore case when TAG_NOIC not used or 'ignorecase' set. 1779 * Only ignore case when TAG_NOIC not used or 'ignorecase' set.
1781 */ 1780 */
1782 #ifdef FEAT_MULTI_LANG 1781 #ifdef FEAT_MULTI_LANG
1783 /* Set a flag if the file extension is .txt */ 1782 // Set a flag if the file extension is .txt
1784 if ((flags & TAG_KEEP_LANG) 1783 if ((flags & TAG_KEEP_LANG)
1785 && help_lang_find == NULL 1784 && help_lang_find == NULL
1786 && curbuf->b_fname != NULL 1785 && curbuf->b_fname != NULL
1787 && (i = (int)STRLEN(curbuf->b_fname)) > 4 1786 && (i = (int)STRLEN(curbuf->b_fname)) > 4
1788 && STRICMP(curbuf->b_fname + i - 4, ".txt") == 0) 1787 && STRICMP(curbuf->b_fname + i - 4, ".txt") == 0)
1812 * A file that doesn't exist is silently ignored. Only when not a 1811 * A file that doesn't exist is silently ignored. Only when not a
1813 * single file is found, an error message is given (further on). 1812 * single file is found, an error message is given (further on).
1814 */ 1813 */
1815 #ifdef FEAT_CSCOPE 1814 #ifdef FEAT_CSCOPE
1816 if (use_cscope) 1815 if (use_cscope)
1817 fp = NULL; /* avoid GCC warning */ 1816 fp = NULL; // avoid GCC warning
1818 else 1817 else
1819 #endif 1818 #endif
1820 { 1819 {
1821 #ifdef FEAT_MULTI_LANG 1820 #ifdef FEAT_MULTI_LANG
1822 if (curbuf->b_help) 1821 if (curbuf->b_help)
1823 { 1822 {
1824 /* Keep en if the file extension is .txt*/ 1823 // Keep en if the file extension is .txt
1825 if (is_txt) 1824 if (is_txt)
1826 STRCPY(help_lang, "en"); 1825 STRCPY(help_lang, "en");
1827 else 1826 else
1828 { 1827 {
1829 /* Prefer help tags according to 'helplang'. Put the 1828 // Prefer help tags according to 'helplang'. Put the
1830 * two-letter language name in help_lang[]. */ 1829 // two-letter language name in help_lang[].
1831 i = (int)STRLEN(tag_fname); 1830 i = (int)STRLEN(tag_fname);
1832 if (i > 3 && tag_fname[i - 3] == '-') 1831 if (i > 3 && tag_fname[i - 3] == '-')
1833 STRCPY(help_lang, tag_fname + i - 2); 1832 STRCPY(help_lang, tag_fname + i - 2);
1834 else 1833 else
1835 STRCPY(help_lang, "en"); 1834 STRCPY(help_lang, "en");
1836 } 1835 }
1837 /* When searching for a specific language skip tags files 1836 // When searching for a specific language skip tags files
1838 * for other languages. */ 1837 // for other languages.
1839 if (help_lang_find != NULL 1838 if (help_lang_find != NULL
1840 && STRICMP(help_lang, help_lang_find) != 0) 1839 && STRICMP(help_lang, help_lang_find) != 0)
1841 continue; 1840 continue;
1842 1841
1843 /* For CTRL-] in a help file prefer a match with the same 1842 // For CTRL-] in a help file prefer a match with the same
1844 * language. */ 1843 // language.
1845 if ((flags & TAG_KEEP_LANG) 1844 if ((flags & TAG_KEEP_LANG)
1846 && help_lang_find == NULL 1845 && help_lang_find == NULL
1847 && curbuf->b_fname != NULL 1846 && curbuf->b_fname != NULL
1848 && (i = (int)STRLEN(curbuf->b_fname)) > 4 1847 && (i = (int)STRLEN(curbuf->b_fname)) > 4
1849 && curbuf->b_fname[i - 1] == 'x' 1848 && curbuf->b_fname[i - 1] == 'x'
1861 if ((s = vim_strchr(s, ',')) == NULL) 1860 if ((s = vim_strchr(s, ',')) == NULL)
1862 break; 1861 break;
1863 } 1862 }
1864 if (s == NULL || *s == NUL) 1863 if (s == NULL || *s == NUL)
1865 { 1864 {
1866 /* Language not in 'helplang': use last, prefer English, 1865 // Language not in 'helplang': use last, prefer English,
1867 * unless found already. */ 1866 // unless found already.
1868 ++help_pri; 1867 ++help_pri;
1869 if (STRICMP(help_lang, "en") != 0) 1868 if (STRICMP(help_lang, "en") != 0)
1870 ++help_pri; 1869 ++help_pri;
1871 } 1870 }
1872 } 1871 }
1881 verbose_enter(); 1880 verbose_enter();
1882 smsg(_("Searching tags file %s"), tag_fname); 1881 smsg(_("Searching tags file %s"), tag_fname);
1883 verbose_leave(); 1882 verbose_leave();
1884 } 1883 }
1885 } 1884 }
1886 did_open = TRUE; /* remember that we found at least one file */ 1885 did_open = TRUE; // remember that we found at least one file
1887 1886
1888 state = TS_START; /* we're at the start of the file */ 1887 state = TS_START; // we're at the start of the file
1889 #ifdef FEAT_EMACS_TAGS 1888 #ifdef FEAT_EMACS_TAGS
1890 is_etag = 0; /* default is: not emacs style */ 1889 is_etag = 0; // default is: not emacs style
1891 #endif 1890 #endif
1892 1891
1893 /* 1892 /*
1894 * Read and parse the lines in the file one by one 1893 * Read and parse the lines in the file one by one
1895 */ 1894 */
1896 for (;;) 1895 for (;;)
1897 { 1896 {
1898 #ifdef FEAT_TAG_BINS 1897 #ifdef FEAT_TAG_BINS
1899 /* check for CTRL-C typed, more often when jumping around */ 1898 // check for CTRL-C typed, more often when jumping around
1900 if (state == TS_BINARY || state == TS_SKIP_BACK) 1899 if (state == TS_BINARY || state == TS_SKIP_BACK)
1901 line_breakcheck(); 1900 line_breakcheck();
1902 else 1901 else
1903 #endif 1902 #endif
1904 fast_breakcheck(); 1903 fast_breakcheck();
1905 if ((flags & TAG_INS_COMP)) /* Double brackets for gcc */ 1904 if ((flags & TAG_INS_COMP)) // Double brackets for gcc
1906 ins_compl_check_keys(30, FALSE); 1905 ins_compl_check_keys(30, FALSE);
1907 if (got_int || ins_compl_interrupted()) 1906 if (got_int || ins_compl_interrupted())
1908 { 1907 {
1909 stop_searching = TRUE; 1908 stop_searching = TRUE;
1910 break; 1909 break;
1911 } 1910 }
1912 /* When mincount is TAG_MANY, stop when enough matches have been 1911 // When mincount is TAG_MANY, stop when enough matches have been
1913 * found (for completion). */ 1912 // found (for completion).
1914 if (mincount == TAG_MANY && match_count >= TAG_MANY) 1913 if (mincount == TAG_MANY && match_count >= TAG_MANY)
1915 { 1914 {
1916 stop_searching = TRUE; 1915 stop_searching = TRUE;
1917 retval = OK; 1916 retval = OK;
1918 break; 1917 break;
1926 if (state == TS_BINARY) 1925 if (state == TS_BINARY)
1927 { 1926 {
1928 offset = search_info.low_offset + ((search_info.high_offset 1927 offset = search_info.low_offset + ((search_info.high_offset
1929 - search_info.low_offset) / 2); 1928 - search_info.low_offset) / 2);
1930 if (offset == search_info.curr_offset) 1929 if (offset == search_info.curr_offset)
1931 break; /* End the binary search without a match. */ 1930 break; // End the binary search without a match.
1932 else 1931 else
1933 search_info.curr_offset = offset; 1932 search_info.curr_offset = offset;
1934 } 1933 }
1935 1934
1936 /* 1935 /*
1951 * When jumping around in the file, first read a line to find the 1950 * When jumping around in the file, first read a line to find the
1952 * start of the next line. 1951 * start of the next line.
1953 */ 1952 */
1954 if (state == TS_BINARY || state == TS_SKIP_BACK) 1953 if (state == TS_BINARY || state == TS_SKIP_BACK)
1955 { 1954 {
1956 /* Adjust the search file offset to the correct position */ 1955 // Adjust the search file offset to the correct position
1957 search_info.curr_offset_used = search_info.curr_offset; 1956 search_info.curr_offset_used = search_info.curr_offset;
1958 vim_fseek(fp, search_info.curr_offset, SEEK_SET); 1957 vim_fseek(fp, search_info.curr_offset, SEEK_SET);
1959 eof = vim_fgets(lbuf, lbuf_size, fp); 1958 eof = vim_fgets(lbuf, lbuf_size, fp);
1960 if (!eof && search_info.curr_offset != 0) 1959 if (!eof && search_info.curr_offset != 0)
1961 { 1960 {
1962 /* The explicit cast is to work around a bug in gcc 3.4.2 1961 // The explicit cast is to work around a bug in gcc 3.4.2
1963 * (repeated below). */ 1962 // (repeated below).
1964 search_info.curr_offset = vim_ftell(fp); 1963 search_info.curr_offset = vim_ftell(fp);
1965 if (search_info.curr_offset == search_info.high_offset) 1964 if (search_info.curr_offset == search_info.high_offset)
1966 { 1965 {
1967 /* oops, gone a bit too far; try from low offset */ 1966 // oops, gone a bit too far; try from low offset
1968 vim_fseek(fp, search_info.low_offset, SEEK_SET); 1967 vim_fseek(fp, search_info.low_offset, SEEK_SET);
1969 search_info.curr_offset = search_info.low_offset; 1968 search_info.curr_offset = search_info.low_offset;
1970 } 1969 }
1971 eof = vim_fgets(lbuf, lbuf_size, fp); 1970 eof = vim_fgets(lbuf, lbuf_size, fp);
1972 } 1971 }
1973 /* skip empty and blank lines */ 1972 // skip empty and blank lines
1974 while (!eof && vim_isblankline(lbuf)) 1973 while (!eof && vim_isblankline(lbuf))
1975 { 1974 {
1976 search_info.curr_offset = vim_ftell(fp); 1975 search_info.curr_offset = vim_ftell(fp);
1977 eof = vim_fgets(lbuf, lbuf_size, fp); 1976 eof = vim_fgets(lbuf, lbuf_size, fp);
1978 } 1977 }
1979 if (eof) 1978 if (eof)
1980 { 1979 {
1981 /* Hit end of file. Skip backwards. */ 1980 // Hit end of file. Skip backwards.
1982 state = TS_SKIP_BACK; 1981 state = TS_SKIP_BACK;
1983 search_info.match_offset = vim_ftell(fp); 1982 search_info.match_offset = vim_ftell(fp);
1984 search_info.curr_offset = search_info.curr_offset_used; 1983 search_info.curr_offset = search_info.curr_offset_used;
1985 continue; 1984 continue;
1986 } 1985 }
1990 * Not jumping around in the file: Read the next line. 1989 * Not jumping around in the file: Read the next line.
1991 */ 1990 */
1992 else 1991 else
1993 #endif 1992 #endif
1994 { 1993 {
1995 /* skip empty and blank lines */ 1994 // skip empty and blank lines
1996 do 1995 do
1997 { 1996 {
1998 #ifdef FEAT_CSCOPE 1997 #ifdef FEAT_CSCOPE
1999 if (use_cscope) 1998 if (use_cscope)
2000 eof = cs_fgets(lbuf, lbuf_size); 1999 eof = cs_fgets(lbuf, lbuf_size);
2004 } while (!eof && vim_isblankline(lbuf)); 2003 } while (!eof && vim_isblankline(lbuf));
2005 2004
2006 if (eof) 2005 if (eof)
2007 { 2006 {
2008 #ifdef FEAT_EMACS_TAGS 2007 #ifdef FEAT_EMACS_TAGS
2009 if (incstack_idx) /* this was an included file */ 2008 if (incstack_idx) // this was an included file
2010 { 2009 {
2011 --incstack_idx; 2010 --incstack_idx;
2012 fclose(fp); /* end of this file ... */ 2011 fclose(fp); // end of this file ...
2013 fp = incstack[incstack_idx].fp; 2012 fp = incstack[incstack_idx].fp;
2014 STRCPY(tag_fname, incstack[incstack_idx].etag_fname); 2013 STRCPY(tag_fname, incstack[incstack_idx].etag_fname);
2015 vim_free(incstack[incstack_idx].etag_fname); 2014 vim_free(incstack[incstack_idx].etag_fname);
2016 is_etag = 1; /* (only etags can include) */ 2015 is_etag = 1; // (only etags can include)
2017 continue; /* ... continue with parent file */ 2016 continue; // ... continue with parent file
2018 } 2017 }
2019 else 2018 else
2020 #endif 2019 #endif
2021 break; /* end of file */ 2020 break; // end of file
2022 } 2021 }
2023 } 2022 }
2024 line_read_in: 2023 line_read_in:
2025 2024
2026 if (vimconv.vc_type != CONV_NONE) 2025 if (vimconv.vc_type != CONV_NONE)
2027 { 2026 {
2028 char_u *conv_line; 2027 char_u *conv_line;
2029 int len; 2028 int len;
2030 2029
2031 /* Convert every line. Converting the pattern from 'enc' to 2030 // Convert every line. Converting the pattern from 'enc' to
2032 * the tags file encoding doesn't work, because characters are 2031 // the tags file encoding doesn't work, because characters are
2033 * not recognized. */ 2032 // not recognized.
2034 conv_line = string_convert(&vimconv, lbuf, NULL); 2033 conv_line = string_convert(&vimconv, lbuf, NULL);
2035 if (conv_line != NULL) 2034 if (conv_line != NULL)
2036 { 2035 {
2037 /* Copy or swap lbuf and conv_line. */ 2036 // Copy or swap lbuf and conv_line.
2038 len = (int)STRLEN(conv_line) + 1; 2037 len = (int)STRLEN(conv_line) + 1;
2039 if (len > lbuf_size) 2038 if (len > lbuf_size)
2040 { 2039 {
2041 vim_free(lbuf); 2040 vim_free(lbuf);
2042 lbuf = conv_line; 2041 lbuf = conv_line;
2061 # ifdef FEAT_CSCOPE 2060 # ifdef FEAT_CSCOPE
2062 && !use_cscope 2061 && !use_cscope
2063 # endif 2062 # endif
2064 ) 2063 )
2065 { 2064 {
2066 is_etag = 1; /* in case at the start */ 2065 is_etag = 1; // in case at the start
2067 state = TS_LINEAR; 2066 state = TS_LINEAR;
2068 if (!vim_fgets(ebuf, LSIZE, fp)) 2067 if (!vim_fgets(ebuf, LSIZE, fp))
2069 { 2068 {
2070 for (p = ebuf; *p && *p != ','; p++) 2069 for (p = ebuf; *p && *p != ','; p++)
2071 ; 2070 ;
2076 * unless it is an include statement. 2075 * unless it is an include statement.
2077 */ 2076 */
2078 if (STRNCMP(p + 1, "include", 7) == 0 2077 if (STRNCMP(p + 1, "include", 7) == 0
2079 && incstack_idx < INCSTACK_SIZE) 2078 && incstack_idx < INCSTACK_SIZE)
2080 { 2079 {
2081 /* Save current "fp" and "tag_fname" in the stack. */ 2080 // Save current "fp" and "tag_fname" in the stack.
2082 if ((incstack[incstack_idx].etag_fname = 2081 if ((incstack[incstack_idx].etag_fname =
2083 vim_strsave(tag_fname)) != NULL) 2082 vim_strsave(tag_fname)) != NULL)
2084 { 2083 {
2085 char_u *fullpath_ebuf; 2084 char_u *fullpath_ebuf;
2086 2085
2087 incstack[incstack_idx].fp = fp; 2086 incstack[incstack_idx].fp = fp;
2088 fp = NULL; 2087 fp = NULL;
2089 2088
2090 /* Figure out "tag_fname" and "fp" to use for 2089 // Figure out "tag_fname" and "fp" to use for
2091 * included file. */ 2090 // included file.
2092 fullpath_ebuf = expand_tag_fname(ebuf, 2091 fullpath_ebuf = expand_tag_fname(ebuf,
2093 tag_fname, FALSE); 2092 tag_fname, FALSE);
2094 if (fullpath_ebuf != NULL) 2093 if (fullpath_ebuf != NULL)
2095 { 2094 {
2096 fp = mch_fopen((char *)fullpath_ebuf, "r"); 2095 fp = mch_fopen((char *)fullpath_ebuf, "r");
2099 if (STRLEN(fullpath_ebuf) > LSIZE) 2098 if (STRLEN(fullpath_ebuf) > LSIZE)
2100 semsg(_("E430: Tag file path truncated for %s\n"), ebuf); 2099 semsg(_("E430: Tag file path truncated for %s\n"), ebuf);
2101 vim_strncpy(tag_fname, fullpath_ebuf, 2100 vim_strncpy(tag_fname, fullpath_ebuf,
2102 MAXPATHL); 2101 MAXPATHL);
2103 ++incstack_idx; 2102 ++incstack_idx;
2104 is_etag = 0; /* we can include anything */ 2103 is_etag = 0; // we can include anything
2105 } 2104 }
2106 vim_free(fullpath_ebuf); 2105 vim_free(fullpath_ebuf);
2107 } 2106 }
2108 if (fp == NULL) 2107 if (fp == NULL)
2109 { 2108 {
2110 /* Can't open the included file, skip it and 2109 // Can't open the included file, skip it and
2111 * restore old value of "fp". */ 2110 // restore old value of "fp".
2112 fp = incstack[incstack_idx].fp; 2111 fp = incstack[incstack_idx].fp;
2113 vim_free(incstack[incstack_idx].etag_fname); 2112 vim_free(incstack[incstack_idx].etag_fname);
2114 } 2113 }
2115 } 2114 }
2116 } 2115 }
2123 * When still at the start of the file, check for Emacs tags file 2122 * When still at the start of the file, check for Emacs tags file
2124 * format, and for "not sorted" flag. 2123 * format, and for "not sorted" flag.
2125 */ 2124 */
2126 if (state == TS_START) 2125 if (state == TS_START)
2127 { 2126 {
2128 /* The header ends when the line sorts below "!_TAG_". When 2127 // The header ends when the line sorts below "!_TAG_". When
2129 * case is folded lower case letters sort before "_". */ 2128 // case is folded lower case letters sort before "_".
2130 if (STRNCMP(lbuf, "!_TAG_", 6) <= 0 2129 if (STRNCMP(lbuf, "!_TAG_", 6) <= 0
2131 || (lbuf[0] == '!' && ASCII_ISLOWER(lbuf[1]))) 2130 || (lbuf[0] == '!' && ASCII_ISLOWER(lbuf[1])))
2132 { 2131 {
2133 if (STRNCMP(lbuf, "!_TAG_", 6) != 0) 2132 if (STRNCMP(lbuf, "!_TAG_", 6) != 0)
2134 /* Non-header item before the header, e.g. "!" itself. 2133 // Non-header item before the header, e.g. "!" itself.
2135 */
2136 goto parse_line; 2134 goto parse_line;
2137 2135
2138 /* 2136 /*
2139 * Read header line. 2137 * Read header line.
2140 */ 2138 */
2142 if (STRNCMP(lbuf, "!_TAG_FILE_SORTED\t", 18) == 0) 2140 if (STRNCMP(lbuf, "!_TAG_FILE_SORTED\t", 18) == 0)
2143 tag_file_sorted = lbuf[18]; 2141 tag_file_sorted = lbuf[18];
2144 #endif 2142 #endif
2145 if (STRNCMP(lbuf, "!_TAG_FILE_ENCODING\t", 20) == 0) 2143 if (STRNCMP(lbuf, "!_TAG_FILE_ENCODING\t", 20) == 0)
2146 { 2144 {
2147 /* Prepare to convert every line from the specified 2145 // Prepare to convert every line from the specified
2148 * encoding to 'encoding'. */ 2146 // encoding to 'encoding'.
2149 for (p = lbuf + 20; *p > ' ' && *p < 127; ++p) 2147 for (p = lbuf + 20; *p > ' ' && *p < 127; ++p)
2150 ; 2148 ;
2151 *p = NUL; 2149 *p = NUL;
2152 convert_setup(&vimconv, lbuf + 20, p_enc); 2150 convert_setup(&vimconv, lbuf + 20, p_enc);
2153 } 2151 }
2154 2152
2155 /* Read the next line. Unrecognized flags are ignored. */ 2153 // Read the next line. Unrecognized flags are ignored.
2156 continue; 2154 continue;
2157 } 2155 }
2158 2156
2159 /* Headers ends. */ 2157 // Headers ends.
2160 2158
2161 #ifdef FEAT_TAG_BINS 2159 #ifdef FEAT_TAG_BINS
2162 /* 2160 /*
2163 * When there is no tag head, or ignoring case, need to do a 2161 * When there is no tag head, or ignoring case, need to do a
2164 * linear search. 2162 * linear search.
2187 else 2185 else
2188 state = TS_LINEAR; 2186 state = TS_LINEAR;
2189 2187
2190 if (state == TS_BINARY && orgpat.regmatch.rm_ic && !sortic) 2188 if (state == TS_BINARY && orgpat.regmatch.rm_ic && !sortic)
2191 { 2189 {
2192 /* Binary search won't work for ignoring case, use linear 2190 // Binary search won't work for ignoring case, use linear
2193 * search. */ 2191 // search.
2194 linear = TRUE; 2192 linear = TRUE;
2195 state = TS_LINEAR; 2193 state = TS_LINEAR;
2196 } 2194 }
2197 #else 2195 #else
2198 state = TS_LINEAR; 2196 state = TS_LINEAR;
2265 vim_memset(&tagp, 0, sizeof(tagp)); 2263 vim_memset(&tagp, 0, sizeof(tagp));
2266 tagp.tagname = lbuf; 2264 tagp.tagname = lbuf;
2267 tagp.tagname_end = vim_strchr(lbuf, TAB); 2265 tagp.tagname_end = vim_strchr(lbuf, TAB);
2268 if (tagp.tagname_end == NULL) 2266 if (tagp.tagname_end == NULL)
2269 { 2267 {
2270 /* Corrupted tag line. */ 2268 // Corrupted tag line.
2271 line_error = TRUE; 2269 line_error = TRUE;
2272 break; 2270 break;
2273 } 2271 }
2274 2272
2275 /* 2273 /*
2276 * Skip this line if the length of the tag is different and 2274 * Skip this line if the length of the tag is different and
2277 * there is no regexp, or the tag is too short. 2275 * there is no regexp, or the tag is too short.
2278 */ 2276 */
2279 cmplen = (int)(tagp.tagname_end - tagp.tagname); 2277 cmplen = (int)(tagp.tagname_end - tagp.tagname);
2280 if (p_tl != 0 && cmplen > p_tl) /* adjust for 'taglength' */ 2278 if (p_tl != 0 && cmplen > p_tl) // adjust for 'taglength'
2281 cmplen = p_tl; 2279 cmplen = p_tl;
2282 if (has_re && orgpat.headlen < cmplen) 2280 if (has_re && orgpat.headlen < cmplen)
2283 cmplen = orgpat.headlen; 2281 cmplen = orgpat.headlen;
2284 else if (state == TS_LINEAR && orgpat.headlen != cmplen) 2282 else if (state == TS_LINEAR && orgpat.headlen != cmplen)
2285 continue; 2283 continue;
2317 tagcmp = 1; 2315 tagcmp = 1;
2318 } 2316 }
2319 2317
2320 if (tagcmp == 0) 2318 if (tagcmp == 0)
2321 { 2319 {
2322 /* We've located the tag, now skip back and search 2320 // We've located the tag, now skip back and search
2323 * forward until the first matching tag is found. 2321 // forward until the first matching tag is found.
2324 */
2325 state = TS_SKIP_BACK; 2322 state = TS_SKIP_BACK;
2326 search_info.match_offset = search_info.curr_offset; 2323 search_info.match_offset = search_info.curr_offset;
2327 continue; 2324 continue;
2328 } 2325 }
2329 if (tagcmp < 0) 2326 if (tagcmp < 0)
2350 else 2347 else
2351 search_info.high_char = tagp.tagname[0]; 2348 search_info.high_char = tagp.tagname[0];
2352 continue; 2349 continue;
2353 } 2350 }
2354 2351
2355 /* No match yet and are at the end of the binary search. */ 2352 // No match yet and are at the end of the binary search.
2356 break; 2353 break;
2357 } 2354 }
2358 else if (state == TS_SKIP_BACK) 2355 else if (state == TS_SKIP_BACK)
2359 { 2356 {
2360 if (MB_STRNICMP(tagp.tagname, orgpat.head, cmplen) != 0) 2357 if (MB_STRNICMP(tagp.tagname, orgpat.head, cmplen) != 0)
2361 state = TS_STEP_FORWARD; 2358 state = TS_STEP_FORWARD;
2362 else 2359 else
2363 /* Have to skip back more. Restore the curr_offset 2360 // Have to skip back more. Restore the curr_offset
2364 * used, otherwise we get stuck at a long line. */ 2361 // used, otherwise we get stuck at a long line.
2365 search_info.curr_offset = search_info.curr_offset_used; 2362 search_info.curr_offset = search_info.curr_offset_used;
2366 continue; 2363 continue;
2367 } 2364 }
2368 else if (state == TS_STEP_FORWARD) 2365 else if (state == TS_STEP_FORWARD)
2369 { 2366 {
2370 if (MB_STRNICMP(tagp.tagname, orgpat.head, cmplen) != 0) 2367 if (MB_STRNICMP(tagp.tagname, orgpat.head, cmplen) != 0)
2371 { 2368 {
2372 if ((off_T)vim_ftell(fp) > search_info.match_offset) 2369 if ((off_T)vim_ftell(fp) > search_info.match_offset)
2373 break; /* past last match */ 2370 break; // past last match
2374 else 2371 else
2375 continue; /* before first match */ 2372 continue; // before first match
2376 } 2373 }
2377 } 2374 }
2378 else 2375 else
2379 #endif 2376 #endif
2380 /* skip this match if it can't match */ 2377 // skip this match if it can't match
2381 if (MB_STRNICMP(tagp.tagname, orgpat.head, cmplen) != 0) 2378 if (MB_STRNICMP(tagp.tagname, orgpat.head, cmplen) != 0)
2382 continue; 2379 continue;
2383 2380
2384 /* 2381 /*
2385 * Can be a matching tag, isolate the file name and command. 2382 * Can be a matching tag, isolate the file name and command.
2411 /* 2408 /*
2412 * First try matching with the pattern literally (also when it is 2409 * First try matching with the pattern literally (also when it is
2413 * a regexp). 2410 * a regexp).
2414 */ 2411 */
2415 cmplen = (int)(tagp.tagname_end - tagp.tagname); 2412 cmplen = (int)(tagp.tagname_end - tagp.tagname);
2416 if (p_tl != 0 && cmplen > p_tl) /* adjust for 'taglength' */ 2413 if (p_tl != 0 && cmplen > p_tl) // adjust for 'taglength'
2417 cmplen = p_tl; 2414 cmplen = p_tl;
2418 /* if tag length does not match, don't try comparing */ 2415 // if tag length does not match, don't try comparing
2419 if (orgpat.len != cmplen) 2416 if (orgpat.len != cmplen)
2420 match = FALSE; 2417 match = FALSE;
2421 else 2418 else
2422 { 2419 {
2423 if (orgpat.regmatch.rm_ic) 2420 if (orgpat.regmatch.rm_ic)
2465 int len = 0; 2462 int len = 0;
2466 2463
2467 #ifdef FEAT_CSCOPE 2464 #ifdef FEAT_CSCOPE
2468 if (use_cscope) 2465 if (use_cscope)
2469 { 2466 {
2470 /* Don't change the ordering, always use the same table. */ 2467 // Don't change the ordering, always use the same table.
2471 mtt = MT_GL_OTH; 2468 mtt = MT_GL_OTH;
2472 } 2469 }
2473 else 2470 else
2474 #endif 2471 #endif
2475 { 2472 {
2476 /* Decide in which array to store this match. */ 2473 // Decide in which array to store this match.
2477 is_current = test_for_current( 2474 is_current = test_for_current(
2478 #ifdef FEAT_EMACS_TAGS 2475 #ifdef FEAT_EMACS_TAGS
2479 is_etag, 2476 is_etag,
2480 #endif 2477 #endif
2481 tagp.fname, tagp.fname_end, tag_fname, 2478 tagp.fname, tagp.fname_end, tag_fname,
2482 buf_ffname); 2479 buf_ffname);
2483 #ifdef FEAT_EMACS_TAGS 2480 #ifdef FEAT_EMACS_TAGS
2484 is_static = FALSE; 2481 is_static = FALSE;
2485 if (!is_etag) /* emacs tags are never static */ 2482 if (!is_etag) // emacs tags are never static
2486 #endif 2483 #endif
2487 is_static = test_for_static(&tagp); 2484 is_static = test_for_static(&tagp);
2488 2485
2489 /* decide in which of the sixteen tables to store this 2486 // decide in which of the sixteen tables to store this
2490 * match */ 2487 // match
2491 if (is_static) 2488 if (is_static)
2492 { 2489 {
2493 if (is_current) 2490 if (is_current)
2494 mtt = MT_ST_CUR; 2491 mtt = MT_ST_CUR;
2495 else 2492 else
2578 len = (int)(tagp.tagname_end - tagp.tagname); 2575 len = (int)(tagp.tagname_end - tagp.tagname);
2579 mfp = alloc(sizeof(char_u) + len + 1); 2576 mfp = alloc(sizeof(char_u) + len + 1);
2580 if (mfp != NULL) 2577 if (mfp != NULL)
2581 vim_strncpy(mfp, tagp.tagname, len); 2578 vim_strncpy(mfp, tagp.tagname, len);
2582 2579
2583 /* if wanted, re-read line to get long form too */ 2580 // if wanted, re-read line to get long form too
2584 if (State & INSERT) 2581 if (State & INSERT)
2585 get_it_again = p_sft; 2582 get_it_again = p_sft;
2586 } 2583 }
2587 } 2584 }
2588 else 2585 else
2590 size_t tag_fname_len = STRLEN(tag_fname); 2587 size_t tag_fname_len = STRLEN(tag_fname);
2591 #ifdef FEAT_EMACS_TAGS 2588 #ifdef FEAT_EMACS_TAGS
2592 size_t ebuf_len = 0; 2589 size_t ebuf_len = 0;
2593 #endif 2590 #endif
2594 2591
2595 /* Save the tag in a buffer. 2592 // Save the tag in a buffer.
2596 * Use 0x02 to separate fields (Can't use NUL because the 2593 // Use 0x02 to separate fields (Can't use NUL because the
2597 * hash key is terminated by NUL, or Ctrl_A because that is 2594 // hash key is terminated by NUL, or Ctrl_A because that is
2598 * part of some Emacs tag files -- see parse_tag_line). 2595 // part of some Emacs tag files -- see parse_tag_line).
2599 * Emacs tag: <mtt><tag_fname><0x02><ebuf><0x02><lbuf><NUL> 2596 // Emacs tag: <mtt><tag_fname><0x02><ebuf><0x02><lbuf><NUL>
2600 * other tag: <mtt><tag_fname><0x02><0x02><lbuf><NUL> 2597 // other tag: <mtt><tag_fname><0x02><0x02><lbuf><NUL>
2601 * without Emacs tags: <mtt><tag_fname><0x02><lbuf><NUL> 2598 // without Emacs tags: <mtt><tag_fname><0x02><lbuf><NUL>
2602 * Here <mtt> is the "mtt" value plus 1 to avoid NUL. 2599 // Here <mtt> is the "mtt" value plus 1 to avoid NUL.
2603 */
2604 len = (int)tag_fname_len + (int)STRLEN(lbuf) + 3; 2600 len = (int)tag_fname_len + (int)STRLEN(lbuf) + 3;
2605 #ifdef FEAT_EMACS_TAGS 2601 #ifdef FEAT_EMACS_TAGS
2606 if (is_etag) 2602 if (is_etag)
2607 { 2603 {
2608 ebuf_len = STRLEN(ebuf); 2604 ebuf_len = STRLEN(ebuf);
2616 { 2612 {
2617 p = mfp; 2613 p = mfp;
2618 p[0] = mtt + 1; 2614 p[0] = mtt + 1;
2619 STRCPY(p + 1, tag_fname); 2615 STRCPY(p + 1, tag_fname);
2620 #ifdef BACKSLASH_IN_FILENAME 2616 #ifdef BACKSLASH_IN_FILENAME
2621 /* Ignore differences in slashes, avoid adding 2617 // Ignore differences in slashes, avoid adding
2622 * both path/file and path\file. */ 2618 // both path/file and path\file.
2623 slash_adjust(p + 1); 2619 slash_adjust(p + 1);
2624 #endif 2620 #endif
2625 p[tag_fname_len + 1] = TAG_SEP; 2621 p[tag_fname_len + 1] = TAG_SEP;
2626 s = p + 1 + tag_fname_len + 1; 2622 s = p + 1 + tag_fname_len + 1;
2627 #ifdef FEAT_EMACS_TAGS 2623 #ifdef FEAT_EMACS_TAGS
2661 { 2657 {
2662 if (hash_add_item(&ht_match[mtt], hi, mfp, hash) 2658 if (hash_add_item(&ht_match[mtt], hi, mfp, hash)
2663 == FAIL 2659 == FAIL
2664 || ga_grow(&ga_match[mtt], 1) != OK) 2660 || ga_grow(&ga_match[mtt], 1) != OK)
2665 { 2661 {
2666 /* Out of memory! Just forget about the rest. */ 2662 // Out of memory! Just forget about the rest.
2667 retval = OK; 2663 retval = OK;
2668 stop_searching = TRUE; 2664 stop_searching = TRUE;
2669 break; 2665 break;
2670 } 2666 }
2671 else 2667 else
2674 [ga_match[mtt].ga_len++] = mfp; 2670 [ga_match[mtt].ga_len++] = mfp;
2675 ++match_count; 2671 ++match_count;
2676 } 2672 }
2677 } 2673 }
2678 else 2674 else
2679 /* duplicate tag, drop it */ 2675 // duplicate tag, drop it
2680 vim_free(mfp); 2676 vim_free(mfp);
2681 } 2677 }
2682 } 2678 }
2683 #ifdef FEAT_CSCOPE 2679 #ifdef FEAT_CSCOPE
2684 if (use_cscope && eof) 2680 if (use_cscope && eof)
2685 break; 2681 break;
2686 #endif 2682 #endif
2687 } /* forever */ 2683 } // forever
2688 2684
2689 if (line_error) 2685 if (line_error)
2690 { 2686 {
2691 semsg(_("E431: Format error in tags file \"%s\""), tag_fname); 2687 semsg(_("E431: Format error in tags file \"%s\""), tag_fname);
2692 #ifdef FEAT_CSCOPE 2688 #ifdef FEAT_CSCOPE
2735 #else 2731 #else
2736 if (stop_searching) 2732 if (stop_searching)
2737 #endif 2733 #endif
2738 break; 2734 break;
2739 2735
2740 } /* end of for-each-file loop */ 2736 } // end of for-each-file loop
2741 2737
2742 #ifdef FEAT_CSCOPE 2738 #ifdef FEAT_CSCOPE
2743 if (!use_cscope) 2739 if (!use_cscope)
2744 #endif 2740 #endif
2745 tagname_free(&tn); 2741 tagname_free(&tn);
2746 2742
2747 #ifdef FEAT_TAG_BINS 2743 #ifdef FEAT_TAG_BINS
2748 /* stop searching when already did a linear search, or when TAG_NOIC 2744 // stop searching when already did a linear search, or when TAG_NOIC
2749 * used, and 'ignorecase' not set or already did case-ignore search */ 2745 // used, and 'ignorecase' not set or already did case-ignore search
2750 if (stop_searching || linear || (!p_ic && noic) || orgpat.regmatch.rm_ic) 2746 if (stop_searching || linear || (!p_ic && noic) || orgpat.regmatch.rm_ic)
2751 break; 2747 break;
2752 # ifdef FEAT_CSCOPE 2748 # ifdef FEAT_CSCOPE
2753 if (use_cscope) 2749 if (use_cscope)
2754 break; 2750 break;
2755 # endif 2751 # endif
2756 orgpat.regmatch.rm_ic = TRUE; /* try another time while ignoring case */ 2752 orgpat.regmatch.rm_ic = TRUE; // try another time while ignoring case
2757 } 2753 }
2758 #endif 2754 #endif
2759 2755
2760 if (!stop_searching) 2756 if (!stop_searching)
2761 { 2757 {
2762 if (!did_open && verbose) /* never opened any tags file */ 2758 if (!did_open && verbose) // never opened any tags file
2763 emsg(_("E433: No tags file")); 2759 emsg(_("E433: No tags file"));
2764 retval = OK; /* It's OK even when no tag found */ 2760 retval = OK; // It's OK even when no tag found
2765 } 2761 }
2766 2762
2767 findtag_end: 2763 findtag_end:
2768 vim_free(lbuf); 2764 vim_free(lbuf);
2769 vim_regfree(orgpat.regmatch.regprog); 2765 vim_regfree(orgpat.regmatch.regprog);
2793 vim_free(mfp); 2789 vim_free(mfp);
2794 else 2790 else
2795 { 2791 {
2796 if (!name_only) 2792 if (!name_only)
2797 { 2793 {
2798 /* Change mtt back to zero-based. */ 2794 // Change mtt back to zero-based.
2799 *mfp = *mfp - 1; 2795 *mfp = *mfp - 1;
2800 2796
2801 /* change the TAG_SEP back to NUL */ 2797 // change the TAG_SEP back to NUL
2802 for (p = mfp + 1; *p != NUL; ++p) 2798 for (p = mfp + 1; *p != NUL; ++p)
2803 if (*p == TAG_SEP) 2799 if (*p == TAG_SEP)
2804 *p = NUL; 2800 *p = NUL;
2805 } 2801 }
2806 matches[match_count++] = (char_u *)mfp; 2802 matches[match_count++] = (char_u *)mfp;
2866 * 2862 *
2867 * Return FAIL if no more tag file names, OK otherwise. 2863 * Return FAIL if no more tag file names, OK otherwise.
2868 */ 2864 */
2869 int 2865 int
2870 get_tagfname( 2866 get_tagfname(
2871 tagname_T *tnp, /* holds status info */ 2867 tagname_T *tnp, // holds status info
2872 int first, /* TRUE when first file name is wanted */ 2868 int first, // TRUE when first file name is wanted
2873 char_u *buf) /* pointer to buffer of MAXPATHL chars */ 2869 char_u *buf) // pointer to buffer of MAXPATHL chars
2874 { 2870 {
2875 char_u *fname = NULL; 2871 char_u *fname = NULL;
2876 char_u *r_ptr; 2872 char_u *r_ptr;
2877 int i; 2873 int i;
2878 2874
2891 ga_clear_strings(&tag_fnames); 2887 ga_clear_strings(&tag_fnames);
2892 ga_init2(&tag_fnames, (int)sizeof(char_u *), 10); 2888 ga_init2(&tag_fnames, (int)sizeof(char_u *), 10);
2893 do_in_runtimepath((char_u *) 2889 do_in_runtimepath((char_u *)
2894 #ifdef FEAT_MULTI_LANG 2890 #ifdef FEAT_MULTI_LANG
2895 # ifdef VMS 2891 # ifdef VMS
2896 /* Functions decc$to_vms() and decc$translate_vms() crash 2892 // Functions decc$to_vms() and decc$translate_vms() crash
2897 * on some VMS systems with wildcards "??". Seems ECO 2893 // on some VMS systems with wildcards "??". Seems ECO
2898 * patches do fix the problem in C RTL, but we can't use 2894 // patches do fix the problem in C RTL, but we can't use
2899 * an #ifdef for that. */ 2895 // an #ifdef for that.
2900 "doc/tags doc/tags-*" 2896 "doc/tags doc/tags-*"
2901 # else 2897 # else
2902 "doc/tags doc/tags-??" 2898 "doc/tags doc/tags-??"
2903 # endif 2899 # endif
2904 #else 2900 #else
2907 , DIP_ALL, found_tagfile_cb, NULL); 2903 , DIP_ALL, found_tagfile_cb, NULL);
2908 } 2904 }
2909 2905
2910 if (tnp->tn_hf_idx >= tag_fnames.ga_len) 2906 if (tnp->tn_hf_idx >= tag_fnames.ga_len)
2911 { 2907 {
2912 /* Not found in 'runtimepath', use 'helpfile', if it exists and 2908 // Not found in 'runtimepath', use 'helpfile', if it exists and
2913 * wasn't used yet, replacing "help.txt" with "tags". */ 2909 // wasn't used yet, replacing "help.txt" with "tags".
2914 if (tnp->tn_hf_idx > tag_fnames.ga_len || *p_hf == NUL) 2910 if (tnp->tn_hf_idx > tag_fnames.ga_len || *p_hf == NUL)
2915 return FAIL; 2911 return FAIL;
2916 ++tnp->tn_hf_idx; 2912 ++tnp->tn_hf_idx;
2917 STRCPY(buf, p_hf); 2913 STRCPY(buf, p_hf);
2918 STRCPY(gettail(buf), "tags"); 2914 STRCPY(gettail(buf), "tags");
2931 return OK; 2927 return OK;
2932 } 2928 }
2933 2929
2934 if (first) 2930 if (first)
2935 { 2931 {
2936 /* Init. We make a copy of 'tags', because autocommands may change 2932 // Init. We make a copy of 'tags', because autocommands may change
2937 * the value without notifying us. */ 2933 // the value without notifying us.
2938 tnp->tn_tags = vim_strsave((*curbuf->b_p_tags != NUL) 2934 tnp->tn_tags = vim_strsave((*curbuf->b_p_tags != NUL)
2939 ? curbuf->b_p_tags : p_tags); 2935 ? curbuf->b_p_tags : p_tags);
2940 if (tnp->tn_tags == NULL) 2936 if (tnp->tn_tags == NULL)
2941 return FAIL; 2937 return FAIL;
2942 tnp->tn_np = tnp->tn_tags; 2938 tnp->tn_np = tnp->tn_tags;
2960 } 2956 }
2961 else 2957 else
2962 { 2958 {
2963 char_u *filename = NULL; 2959 char_u *filename = NULL;
2964 2960
2965 /* Stop when used all parts of 'tags'. */ 2961 // Stop when used all parts of 'tags'.
2966 if (*tnp->tn_np == NUL) 2962 if (*tnp->tn_np == NUL)
2967 { 2963 {
2968 vim_findfile_cleanup(tnp->tn_search_ctx); 2964 vim_findfile_cleanup(tnp->tn_search_ctx);
2969 tnp->tn_search_ctx = NULL; 2965 tnp->tn_search_ctx = NULL;
2970 return FAIL; 2966 return FAIL;
2979 #ifdef FEAT_PATH_EXTRA 2975 #ifdef FEAT_PATH_EXTRA
2980 r_ptr = vim_findfile_stopdir(buf); 2976 r_ptr = vim_findfile_stopdir(buf);
2981 #else 2977 #else
2982 r_ptr = NULL; 2978 r_ptr = NULL;
2983 #endif 2979 #endif
2984 /* move the filename one char forward and truncate the 2980 // move the filename one char forward and truncate the
2985 * filepath with a NUL */ 2981 // filepath with a NUL
2986 filename = gettail(buf); 2982 filename = gettail(buf);
2987 STRMOVE(filename + 1, filename); 2983 STRMOVE(filename + 1, filename);
2988 *filename++ = NUL; 2984 *filename++ = NUL;
2989 2985
2990 tnp->tn_search_ctx = vim_findfile_init(buf, filename, 2986 tnp->tn_search_ctx = vim_findfile_init(buf, filename,
2991 r_ptr, 100, 2987 r_ptr, 100,
2992 FALSE, /* don't free visited list */ 2988 FALSE, // don't free visited list
2993 FINDFILE_FILE, /* we search for a file */ 2989 FINDFILE_FILE, // we search for a file
2994 tnp->tn_search_ctx, TRUE, curbuf->b_ffname); 2990 tnp->tn_search_ctx, TRUE, curbuf->b_ffname);
2995 if (tnp->tn_search_ctx != NULL) 2991 if (tnp->tn_search_ctx != NULL)
2996 tnp->tn_did_filefind_init = TRUE; 2992 tnp->tn_did_filefind_init = TRUE;
2997 } 2993 }
2998 } 2994 }
3022 * 3018 *
3023 * Return FAIL if there is a format error in this line, OK otherwise. 3019 * Return FAIL if there is a format error in this line, OK otherwise.
3024 */ 3020 */
3025 static int 3021 static int
3026 parse_tag_line( 3022 parse_tag_line(
3027 char_u *lbuf, /* line to be parsed */ 3023 char_u *lbuf, // line to be parsed
3028 #ifdef FEAT_EMACS_TAGS 3024 #ifdef FEAT_EMACS_TAGS
3029 int is_etag, 3025 int is_etag,
3030 #endif 3026 #endif
3031 tagptrs_T *tagp) 3027 tagptrs_T *tagp)
3032 { 3028 {
3046 if (p_7f == NULL) 3042 if (p_7f == NULL)
3047 { 3043 {
3048 etag_fail: 3044 etag_fail:
3049 if (vim_strchr(lbuf, '\n') == NULL) 3045 if (vim_strchr(lbuf, '\n') == NULL)
3050 { 3046 {
3051 /* Truncated line. Ignore it. */ 3047 // Truncated line. Ignore it.
3052 if (p_verbose >= 5) 3048 if (p_verbose >= 5)
3053 { 3049 {
3054 verbose_enter(); 3050 verbose_enter();
3055 msg(_("Ignoring long line in tags file")); 3051 msg(_("Ignoring long line in tags file"));
3056 verbose_leave(); 3052 verbose_leave();
3061 return OK; 3057 return OK;
3062 } 3058 }
3063 return FAIL; 3059 return FAIL;
3064 } 3060 }
3065 3061
3066 /* Find ^A. If not found the line number is after the 0x7f */ 3062 // Find ^A. If not found the line number is after the 0x7f
3067 p = vim_strchr(p_7f, Ctrl_A); 3063 p = vim_strchr(p_7f, Ctrl_A);
3068 if (p == NULL) 3064 if (p == NULL)
3069 p = p_7f + 1; 3065 p = p_7f + 1;
3070 else 3066 else
3071 ++p; 3067 ++p;
3072 3068
3073 if (!VIM_ISDIGIT(*p)) /* check for start of line number */ 3069 if (!VIM_ISDIGIT(*p)) // check for start of line number
3074 goto etag_fail; 3070 goto etag_fail;
3075 tagp->command = p; 3071 tagp->command = p;
3076 3072
3077 3073
3078 if (p[-1] == Ctrl_A) /* first format: explicit tagname given */ 3074 if (p[-1] == Ctrl_A) // first format: explicit tagname given
3079 { 3075 {
3080 tagp->tagname = p_7f + 1; 3076 tagp->tagname = p_7f + 1;
3081 tagp->tagname_end = p - 1; 3077 tagp->tagname_end = p - 1;
3082 } 3078 }
3083 else /* second format: isolate tagname */ 3079 else // second format: isolate tagname
3084 { 3080 {
3085 /* find end of tagname */ 3081 // find end of tagname
3086 for (p = p_7f - 1; !vim_iswordc(*p); --p) 3082 for (p = p_7f - 1; !vim_iswordc(*p); --p)
3087 if (p == lbuf) 3083 if (p == lbuf)
3088 goto etag_fail; 3084 goto etag_fail;
3089 tagp->tagname_end = p + 1; 3085 tagp->tagname_end = p + 1;
3090 while (p >= lbuf && vim_iswordc(*p)) 3086 while (p >= lbuf && vim_iswordc(*p))
3091 --p; 3087 --p;
3092 tagp->tagname = p + 1; 3088 tagp->tagname = p + 1;
3093 } 3089 }
3094 } 3090 }
3095 else /* not an Emacs tag */ 3091 else // not an Emacs tag
3096 { 3092 {
3097 #endif 3093 #endif
3098 // Isolate the tagname, from lbuf up to the first white 3094 // Isolate the tagname, from lbuf up to the first white
3099 tagp->tagname = lbuf; 3095 tagp->tagname = lbuf;
3100 p = vim_strchr(lbuf, TAB); 3096 p = vim_strchr(lbuf, TAB);
3163 static size_t 3159 static size_t
3164 matching_line_len(char_u *lbuf) 3160 matching_line_len(char_u *lbuf)
3165 { 3161 {
3166 char_u *p = lbuf + 1; 3162 char_u *p = lbuf + 1;
3167 3163
3168 /* does the same thing as parse_match() */ 3164 // does the same thing as parse_match()
3169 p += STRLEN(p) + 1; 3165 p += STRLEN(p) + 1;
3170 #ifdef FEAT_EMACS_TAGS 3166 #ifdef FEAT_EMACS_TAGS
3171 p += STRLEN(p) + 1; 3167 p += STRLEN(p) + 1;
3172 #endif 3168 #endif
3173 return (p - lbuf) + STRLEN(p); 3169 return (p - lbuf) + STRLEN(p);
3183 * 3179 *
3184 * Return OK or FAIL. 3180 * Return OK or FAIL.
3185 */ 3181 */
3186 static int 3182 static int
3187 parse_match( 3183 parse_match(
3188 char_u *lbuf, /* input: matching line */ 3184 char_u *lbuf, // input: matching line
3189 tagptrs_T *tagp) /* output: pointers into the line */ 3185 tagptrs_T *tagp) // output: pointers into the line
3190 { 3186 {
3191 int retval; 3187 int retval;
3192 char_u *p; 3188 char_u *p;
3193 char_u *pc, *pt; 3189 char_u *pc, *pt;
3194 3190
3207 tagp->is_etag = FALSE; 3203 tagp->is_etag = FALSE;
3208 ++lbuf; 3204 ++lbuf;
3209 } 3205 }
3210 #endif 3206 #endif
3211 3207
3212 /* Find search pattern and the file name for non-etags. */ 3208 // Find search pattern and the file name for non-etags.
3213 retval = parse_tag_line(lbuf, 3209 retval = parse_tag_line(lbuf,
3214 #ifdef FEAT_EMACS_TAGS 3210 #ifdef FEAT_EMACS_TAGS
3215 tagp->is_etag, 3211 tagp->is_etag,
3216 #endif 3212 #endif
3217 tagp); 3213 tagp);
3221 tagp->tagline = 0; 3217 tagp->tagline = 0;
3222 tagp->command_end = NULL; 3218 tagp->command_end = NULL;
3223 3219
3224 if (retval == OK) 3220 if (retval == OK)
3225 { 3221 {
3226 /* Try to find a kind field: "kind:<kind>" or just "<kind>"*/ 3222 // Try to find a kind field: "kind:<kind>" or just "<kind>"
3227 p = tagp->command; 3223 p = tagp->command;
3228 if (find_extra(&p) == OK) 3224 if (find_extra(&p) == OK)
3229 { 3225 {
3230 if (p > tagp->command && p[-1] == '|') 3226 if (p > tagp->command && p[-1] == '|')
3231 tagp->command_end = p - 1; // drop trailing bar 3227 tagp->command_end = p - 1; // drop trailing bar
3232 else 3228 else
3233 tagp->command_end = p; 3229 tagp->command_end = p;
3234 p += 2; /* skip ";\"" */ 3230 p += 2; // skip ";\""
3235 if (*p++ == TAB) 3231 if (*p++ == TAB)
3236 while (ASCII_ISALPHA(*p)) 3232 while (ASCII_ISALPHA(*p))
3237 { 3233 {
3238 if (STRNCMP(p, "kind:", 5) == 0) 3234 if (STRNCMP(p, "kind:", 5) == 0)
3239 tagp->tagkind = p + 5; 3235 tagp->tagkind = p + 5;
3281 char_u *fullname; 3277 char_u *fullname;
3282 int c; 3278 int c;
3283 3279
3284 #ifdef FEAT_EMACS_TAGS 3280 #ifdef FEAT_EMACS_TAGS
3285 if (tagp->is_etag) 3281 if (tagp->is_etag)
3286 c = 0; /* to shut up GCC */ 3282 c = 0; // to shut up GCC
3287 else 3283 else
3288 #endif 3284 #endif
3289 { 3285 {
3290 c = *tagp->fname_end; 3286 c = *tagp->fname_end;
3291 *tagp->fname_end = NUL; 3287 *tagp->fname_end = NUL;
3305 * 3301 *
3306 * returns OK for success, NOTAGFILE when file not found, FAIL otherwise. 3302 * returns OK for success, NOTAGFILE when file not found, FAIL otherwise.
3307 */ 3303 */
3308 static int 3304 static int
3309 jumpto_tag( 3305 jumpto_tag(
3310 char_u *lbuf_arg, /* line from the tags file for this tag */ 3306 char_u *lbuf_arg, // line from the tags file for this tag
3311 int forceit, /* :ta with ! */ 3307 int forceit, // :ta with !
3312 int keep_help) /* keep help flag (FALSE for cscope) */ 3308 int keep_help) // keep help flag (FALSE for cscope)
3313 { 3309 {
3314 int save_secure; 3310 int save_secure;
3315 int save_magic; 3311 int save_magic;
3316 int save_p_ws, save_p_scs, save_p_ic; 3312 int save_p_ws, save_p_scs, save_p_ic;
3317 linenr_T save_lnum; 3313 linenr_T save_lnum;
3318 char_u *str; 3314 char_u *str;
3319 char_u *pbuf; /* search pattern buffer */ 3315 char_u *pbuf; // search pattern buffer
3320 char_u *pbuf_end; 3316 char_u *pbuf_end;
3321 char_u *tofree_fname = NULL; 3317 char_u *tofree_fname = NULL;
3322 char_u *fname; 3318 char_u *fname;
3323 tagptrs_T tagp; 3319 tagptrs_T tagp;
3324 int retval = FAIL; 3320 int retval = FAIL;
3330 #if defined(FEAT_QUICKFIX) 3326 #if defined(FEAT_QUICKFIX)
3331 win_T *curwin_save = NULL; 3327 win_T *curwin_save = NULL;
3332 #endif 3328 #endif
3333 char_u *full_fname = NULL; 3329 char_u *full_fname = NULL;
3334 #ifdef FEAT_FOLDING 3330 #ifdef FEAT_FOLDING
3335 int old_KeyTyped = KeyTyped; /* getting the file may reset it */ 3331 int old_KeyTyped = KeyTyped; // getting the file may reset it
3336 #endif 3332 #endif
3337 size_t len; 3333 size_t len;
3338 char_u *lbuf; 3334 char_u *lbuf;
3339 3335
3340 /* Make a copy of the line, it can become invalid when an autocommand calls 3336 // Make a copy of the line, it can become invalid when an autocommand calls
3341 * back here recursively. */ 3337 // back here recursively.
3342 len = matching_line_len(lbuf_arg) + 1; 3338 len = matching_line_len(lbuf_arg) + 1;
3343 lbuf = alloc(len); 3339 lbuf = alloc(len);
3344 if (lbuf != NULL) 3340 if (lbuf != NULL)
3345 mch_memmove(lbuf, lbuf_arg, len); 3341 mch_memmove(lbuf, lbuf_arg, len);
3346 3342
3347 pbuf = alloc(LSIZE); 3343 pbuf = alloc(LSIZE);
3348 3344
3349 /* parse the match line into the tagp structure */ 3345 // parse the match line into the tagp structure
3350 if (pbuf == NULL || lbuf == NULL || parse_match(lbuf, &tagp) == FAIL) 3346 if (pbuf == NULL || lbuf == NULL || parse_match(lbuf, &tagp) == FAIL)
3351 { 3347 {
3352 tagp.fname_end = NULL; 3348 tagp.fname_end = NULL;
3353 goto erret; 3349 goto erret;
3354 } 3350 }
3355 3351
3356 /* truncate the file name, so it can be used as a string */ 3352 // truncate the file name, so it can be used as a string
3357 *tagp.fname_end = NUL; 3353 *tagp.fname_end = NUL;
3358 fname = tagp.fname; 3354 fname = tagp.fname;
3359 3355
3360 /* copy the command to pbuf[], remove trailing CR/NL */ 3356 // copy the command to pbuf[], remove trailing CR/NL
3361 str = tagp.command; 3357 str = tagp.command;
3362 for (pbuf_end = pbuf; *str && *str != '\n' && *str != '\r'; ) 3358 for (pbuf_end = pbuf; *str && *str != '\n' && *str != '\r'; )
3363 { 3359 {
3364 #ifdef FEAT_EMACS_TAGS 3360 #ifdef FEAT_EMACS_TAGS
3365 if (tagp.is_etag && *str == ',')/* stop at ',' after line number */ 3361 if (tagp.is_etag && *str == ',')// stop at ',' after line number
3366 break; 3362 break;
3367 #endif 3363 #endif
3368 *pbuf_end++ = *str++; 3364 *pbuf_end++ = *str++;
3369 if (pbuf_end - pbuf + 1 >= LSIZE) 3365 if (pbuf_end - pbuf + 1 >= LSIZE)
3370 break; 3366 break;
3391 * If 'tagrelative' option set, may change file name. 3387 * If 'tagrelative' option set, may change file name.
3392 */ 3388 */
3393 fname = expand_tag_fname(fname, tagp.tag_fname, TRUE); 3389 fname = expand_tag_fname(fname, tagp.tag_fname, TRUE);
3394 if (fname == NULL) 3390 if (fname == NULL)
3395 goto erret; 3391 goto erret;
3396 tofree_fname = fname; /* free() it later */ 3392 tofree_fname = fname; // free() it later
3397 3393
3398 /* 3394 /*
3399 * Check if the file with the tag exists before abandoning the current 3395 * Check if the file with the tag exists before abandoning the current
3400 * file. Also accept a file name for which there is a matching BufReadCmd 3396 * file. Also accept a file name for which there is a matching BufReadCmd
3401 * autocommand event (e.g., http://sys/file). 3397 * autocommand event (e.g., http://sys/file).
3417 #endif 3413 #endif
3418 3414
3419 #if defined(FEAT_QUICKFIX) 3415 #if defined(FEAT_QUICKFIX)
3420 if (g_do_tagpreview != 0) 3416 if (g_do_tagpreview != 0)
3421 { 3417 {
3422 postponed_split = 0; /* don't split again below */ 3418 postponed_split = 0; // don't split again below
3423 curwin_save = curwin; /* Save current window */ 3419 curwin_save = curwin; // Save current window
3424 3420
3425 /* 3421 /*
3426 * If we are reusing a window, we may change dir when 3422 * If we are reusing a window, we may change dir when
3427 * entering it (autocommands) so turn the tag filename 3423 * entering it (autocommands) so turn the tag filename
3428 * into a fullpath 3424 * into a fullpath
3438 */ 3434 */
3439 prepare_tagpreview(TRUE, TRUE, FALSE); 3435 prepare_tagpreview(TRUE, TRUE, FALSE);
3440 } 3436 }
3441 } 3437 }
3442 3438
3443 /* If it was a CTRL-W CTRL-] command split window now. For ":tab tag" 3439 // If it was a CTRL-W CTRL-] command split window now. For ":tab tag"
3444 * open a new tab page. */ 3440 // open a new tab page.
3445 if (postponed_split && (swb_flags & (SWB_USEOPEN | SWB_USETAB))) 3441 if (postponed_split && (swb_flags & (SWB_USEOPEN | SWB_USETAB)))
3446 { 3442 {
3447 buf_T *existing_buf = buflist_findname_exp(fname); 3443 buf_T *existing_buf = buflist_findname_exp(fname);
3448 3444
3449 if (existing_buf != NULL) 3445 if (existing_buf != NULL)
3451 win_T *wp = NULL; 3447 win_T *wp = NULL;
3452 3448
3453 if (swb_flags & SWB_USEOPEN) 3449 if (swb_flags & SWB_USEOPEN)
3454 wp = buf_jump_open_win(existing_buf); 3450 wp = buf_jump_open_win(existing_buf);
3455 3451
3456 /* If 'switchbuf' contains "usetab": jump to first window in any tab 3452 // If 'switchbuf' contains "usetab": jump to first window in any tab
3457 * page containing "existing_buf" if one exists */ 3453 // page containing "existing_buf" if one exists
3458 if (wp == NULL && (swb_flags & SWB_USETAB)) 3454 if (wp == NULL && (swb_flags & SWB_USETAB))
3459 wp = buf_jump_open_tab(existing_buf); 3455 wp = buf_jump_open_tab(existing_buf);
3460 /* We've switched to the buffer, the usual loading of the file must 3456 // We've switched to the buffer, the usual loading of the file must
3461 * be skipped. */ 3457 // be skipped.
3462 if (wp != NULL) 3458 if (wp != NULL)
3463 getfile_result = GETFILE_SAME_FILE; 3459 getfile_result = GETFILE_SAME_FILE;
3464 } 3460 }
3465 } 3461 }
3466 if (getfile_result == GETFILE_UNUSED 3462 if (getfile_result == GETFILE_UNUSED
3476 } 3472 }
3477 #endif 3473 #endif
3478 3474
3479 if (keep_help) 3475 if (keep_help)
3480 { 3476 {
3481 /* A :ta from a help file will keep the b_help flag set. For ":ptag" 3477 // A :ta from a help file will keep the b_help flag set. For ":ptag"
3482 * we need to use the flag from the window where we came from. */ 3478 // we need to use the flag from the window where we came from.
3483 #if defined(FEAT_QUICKFIX) 3479 #if defined(FEAT_QUICKFIX)
3484 if (g_do_tagpreview != 0) 3480 if (g_do_tagpreview != 0)
3485 keep_help_flag = bt_help(curwin_save->w_buffer); 3481 keep_help_flag = bt_help(curwin_save->w_buffer);
3486 else 3482 else
3487 #endif 3483 #endif
3488 keep_help_flag = curbuf->b_help; 3484 keep_help_flag = curbuf->b_help;
3489 } 3485 }
3490 3486
3491 if (getfile_result == GETFILE_UNUSED) 3487 if (getfile_result == GETFILE_UNUSED)
3492 /* Careful: getfile() may trigger autocommands and call jumpto_tag() 3488 // Careful: getfile() may trigger autocommands and call jumpto_tag()
3493 * recursively. */ 3489 // recursively.
3494 getfile_result = getfile(0, fname, NULL, TRUE, (linenr_T)0, forceit); 3490 getfile_result = getfile(0, fname, NULL, TRUE, (linenr_T)0, forceit);
3495 keep_help_flag = FALSE; 3491 keep_help_flag = FALSE;
3496 3492
3497 if (GETFILE_SUCCESS(getfile_result)) /* got to the right file */ 3493 if (GETFILE_SUCCESS(getfile_result)) // got to the right file
3498 { 3494 {
3499 curwin->w_set_curswant = TRUE; 3495 curwin->w_set_curswant = TRUE;
3500 postponed_split = 0; 3496 postponed_split = 0;
3501 3497
3502 save_secure = secure; 3498 save_secure = secure;
3503 secure = 1; 3499 secure = 1;
3504 #ifdef HAVE_SANDBOX 3500 #ifdef HAVE_SANDBOX
3505 ++sandbox; 3501 ++sandbox;
3506 #endif 3502 #endif
3507 save_magic = p_magic; 3503 save_magic = p_magic;
3508 p_magic = FALSE; /* always execute with 'nomagic' */ 3504 p_magic = FALSE; // always execute with 'nomagic'
3509 #ifdef FEAT_SEARCH_EXTRA 3505 #ifdef FEAT_SEARCH_EXTRA
3510 /* Save value of no_hlsearch, jumping to a tag is not a real search */ 3506 // Save value of no_hlsearch, jumping to a tag is not a real search
3511 save_no_hlsearch = no_hlsearch; 3507 save_no_hlsearch = no_hlsearch;
3512 #endif 3508 #endif
3513 3509
3514 /* 3510 /*
3515 * If 'cpoptions' contains 't', store the search pattern for the "n" 3511 * If 'cpoptions' contains 't', store the search pattern for the "n"
3530 * anything following. 3526 * anything following.
3531 */ 3527 */
3532 str = pbuf; 3528 str = pbuf;
3533 if (pbuf[0] == '/' || pbuf[0] == '?') 3529 if (pbuf[0] == '/' || pbuf[0] == '?')
3534 str = skip_regexp(pbuf + 1, pbuf[0], FALSE, NULL) + 1; 3530 str = skip_regexp(pbuf + 1, pbuf[0], FALSE, NULL) + 1;
3535 if (str > pbuf_end - 1) /* search command with nothing following */ 3531 if (str > pbuf_end - 1) // search command with nothing following
3536 { 3532 {
3537 save_p_ws = p_ws; 3533 save_p_ws = p_ws;
3538 save_p_ic = p_ic; 3534 save_p_ic = p_ic;
3539 save_p_scs = p_scs; 3535 save_p_scs = p_scs;
3540 p_ws = TRUE; /* need 'wrapscan' for backward searches */ 3536 p_ws = TRUE; // need 'wrapscan' for backward searches
3541 p_ic = FALSE; /* don't ignore case now */ 3537 p_ic = FALSE; // don't ignore case now
3542 p_scs = FALSE; 3538 p_scs = FALSE;
3543 save_lnum = curwin->w_cursor.lnum; 3539 save_lnum = curwin->w_cursor.lnum;
3544 if (tagp.tagline > 0) 3540 if (tagp.tagline > 0)
3545 // start search before line from "line:" field 3541 // start search before line from "line:" field
3546 curwin->w_cursor.lnum = tagp.tagline - 1; 3542 curwin->w_cursor.lnum = tagp.tagline - 1;
3571 *tagp.tagname_end = NUL; 3567 *tagp.tagname_end = NUL;
3572 sprintf((char *)pbuf, "^%s\\s\\*(", tagp.tagname); 3568 sprintf((char *)pbuf, "^%s\\s\\*(", tagp.tagname);
3573 if (!do_search(NULL, '/', pbuf, (long)1, 3569 if (!do_search(NULL, '/', pbuf, (long)1,
3574 search_options, NULL)) 3570 search_options, NULL))
3575 { 3571 {
3576 /* Guess again: "^char * \<func (" */ 3572 // Guess again: "^char * \<func ("
3577 sprintf((char *)pbuf, "^\\[#a-zA-Z_]\\.\\*\\<%s\\s\\*(", 3573 sprintf((char *)pbuf, "^\\[#a-zA-Z_]\\.\\*\\<%s\\s\\*(",
3578 tagp.tagname); 3574 tagp.tagname);
3579 if (!do_search(NULL, '/', pbuf, (long)1, 3575 if (!do_search(NULL, '/', pbuf, (long)1,
3580 search_options, NULL)) 3576 search_options, NULL))
3581 found = 0; 3577 found = 0;
3607 } 3603 }
3608 p_ws = save_p_ws; 3604 p_ws = save_p_ws;
3609 p_ic = save_p_ic; 3605 p_ic = save_p_ic;
3610 p_scs = save_p_scs; 3606 p_scs = save_p_scs;
3611 3607
3612 /* A search command may have positioned the cursor beyond the end 3608 // A search command may have positioned the cursor beyond the end
3613 * of the line. May need to correct that here. */ 3609 // of the line. May need to correct that here.
3614 check_cursor(); 3610 check_cursor();
3615 } 3611 }
3616 else 3612 else
3617 { 3613 {
3618 curwin->w_cursor.lnum = 1; /* start command in line 1 */ 3614 curwin->w_cursor.lnum = 1; // start command in line 1
3619 do_cmdline_cmd(pbuf); 3615 do_cmdline_cmd(pbuf);
3620 retval = OK; 3616 retval = OK;
3621 } 3617 }
3622 3618
3623 /* 3619 /*
3630 p_magic = save_magic; 3626 p_magic = save_magic;
3631 #ifdef HAVE_SANDBOX 3627 #ifdef HAVE_SANDBOX
3632 --sandbox; 3628 --sandbox;
3633 #endif 3629 #endif
3634 #ifdef FEAT_SEARCH_EXTRA 3630 #ifdef FEAT_SEARCH_EXTRA
3635 /* restore no_hlsearch when keeping the old search pattern */ 3631 // restore no_hlsearch when keeping the old search pattern
3636 if (search_options) 3632 if (search_options)
3637 set_no_hlsearch(save_no_hlsearch); 3633 set_no_hlsearch(save_no_hlsearch);
3638 #endif 3634 #endif
3639 3635
3640 /* Return OK if jumped to another file (at least we found the file!). */ 3636 // Return OK if jumped to another file (at least we found the file!).
3641 if (getfile_result == GETFILE_OPEN_OTHER) 3637 if (getfile_result == GETFILE_OPEN_OTHER)
3642 retval = OK; 3638 retval = OK;
3643 3639
3644 if (retval == OK) 3640 if (retval == OK)
3645 { 3641 {
3695 win_enter(firstwin, TRUE); 3691 win_enter(firstwin, TRUE);
3696 #endif 3692 #endif
3697 3693
3698 erret: 3694 erret:
3699 #if defined(FEAT_QUICKFIX) 3695 #if defined(FEAT_QUICKFIX)
3700 g_do_tagpreview = 0; /* For next time */ 3696 g_do_tagpreview = 0; // For next time
3701 #endif 3697 #endif
3702 vim_free(lbuf); 3698 vim_free(lbuf);
3703 vim_free(pbuf); 3699 vim_free(pbuf);
3704 vim_free(tofree_fname); 3700 vim_free(tofree_fname);
3705 vim_free(full_fname); 3701 vim_free(full_fname);
3776 { 3772 {
3777 int c; 3773 int c;
3778 int retval = FALSE; 3774 int retval = FALSE;
3779 char_u *fullname; 3775 char_u *fullname;
3780 3776
3781 if (buf_ffname != NULL) /* if the buffer has a name */ 3777 if (buf_ffname != NULL) // if the buffer has a name
3782 { 3778 {
3783 #ifdef FEAT_EMACS_TAGS 3779 #ifdef FEAT_EMACS_TAGS
3784 if (is_etag) 3780 if (is_etag)
3785 c = 0; /* to shut up GCC */ 3781 c = 0; // to shut up GCC
3786 else 3782 else
3787 #endif 3783 #endif
3788 { 3784 {
3789 c = *fname_end; 3785 c = *fname_end;
3790 *fname_end = NUL; 3786 *fname_end = NUL;
3838 3834
3839 } 3835 }
3840 if (str == NULL || *str != ';' 3836 if (str == NULL || *str != ';'
3841 || !(VIM_ISDIGIT(str[1]) || str[1] == '/' || str[1] == '?')) 3837 || !(VIM_ISDIGIT(str[1]) || str[1] == '/' || str[1] == '?'))
3842 break; 3838 break;
3843 ++str; /* skip ';' */ 3839 ++str; // skip ';'
3844 } 3840 }
3845 3841
3846 if (str != NULL && STRNCMP(str, ";\"", 2) == 0) 3842 if (str != NULL && STRNCMP(str, ";\"", 2) == 0)
3847 { 3843 {
3848 *pp = str; 3844 *pp = str;
3861 VIM_CLEAR(item->user_data); 3857 VIM_CLEAR(item->user_data);
3862 } 3858 }
3863 3859
3864 int 3860 int
3865 expand_tags( 3861 expand_tags(
3866 int tagnames, /* expand tag names */ 3862 int tagnames, // expand tag names
3867 char_u *pat, 3863 char_u *pat,
3868 int *num_file, 3864 int *num_file,
3869 char_u ***file) 3865 char_u ***file)
3870 { 3866 {
3871 int i; 3867 int i;
3887 ret = find_tags(pat, num_file, file, 3883 ret = find_tags(pat, num_file, file,
3888 TAG_REGEXP | tagnmflag | TAG_VERBOSE | TAG_NO_TAGFUNC | TAG_NOIC, 3884 TAG_REGEXP | tagnmflag | TAG_VERBOSE | TAG_NO_TAGFUNC | TAG_NOIC,
3889 TAG_MANY, curbuf->b_ffname); 3885 TAG_MANY, curbuf->b_ffname);
3890 if (ret == OK && !tagnames) 3886 if (ret == OK && !tagnames)
3891 { 3887 {
3892 /* Reorganize the tags for display and matching as strings of: 3888 // Reorganize the tags for display and matching as strings of:
3893 * "<tagname>\0<kind>\0<filename>\0" 3889 // "<tagname>\0<kind>\0<filename>\0"
3894 */
3895 for (i = 0; i < *num_file; i++) 3890 for (i = 0; i < *num_file; i++)
3896 { 3891 {
3897 parse_match((*file)[i], &t_p); 3892 parse_match((*file)[i], &t_p);
3898 c = (int)(t_p.tagname_end - t_p.tagname); 3893 c = (int)(t_p.tagname_end - t_p.tagname);
3899 mch_memmove(tagnm, t_p.tagname, (size_t)c); 3894 mch_memmove(tagnm, t_p.tagname, (size_t)c);
3916 */ 3911 */
3917 static int 3912 static int
3918 add_tag_field( 3913 add_tag_field(
3919 dict_T *dict, 3914 dict_T *dict,
3920 char *field_name, 3915 char *field_name,
3921 char_u *start, /* start of the value */ 3916 char_u *start, // start of the value
3922 char_u *end) /* after the value; can be NULL */ 3917 char_u *end) // after the value; can be NULL
3923 { 3918 {
3924 char_u *buf; 3919 char_u *buf;
3925 int len = 0; 3920 int len = 0;
3926 int retval; 3921 int retval;
3927 3922
3928 /* check that the field name doesn't exist yet */ 3923 // check that the field name doesn't exist yet
3929 if (dict_find(dict, (char_u *)field_name, -1) != NULL) 3924 if (dict_find(dict, (char_u *)field_name, -1) != NULL)
3930 { 3925 {
3931 if (p_verbose > 0) 3926 if (p_verbose > 0)
3932 { 3927 {
3933 verbose_enter(); 3928 verbose_enter();
3979 for (i = 0; i < num_matches; ++i) 3974 for (i = 0; i < num_matches; ++i)
3980 { 3975 {
3981 parse_match(matches[i], &tp); 3976 parse_match(matches[i], &tp);
3982 is_static = test_for_static(&tp); 3977 is_static = test_for_static(&tp);
3983 3978
3984 /* Skip pseudo-tag lines. */ 3979 // Skip pseudo-tag lines.
3985 if (STRNCMP(tp.tagname, "!_TAG_", 6) == 0) 3980 if (STRNCMP(tp.tagname, "!_TAG_", 6) == 0)
3986 continue; 3981 continue;
3987 3982
3988 if ((dict = dict_alloc()) == NULL) 3983 if ((dict = dict_alloc()) == NULL)
3989 ret = FAIL; 3984 ret = FAIL;
4008 for (p = tp.command_end + 3; 4003 for (p = tp.command_end + 3;
4009 *p != NUL && *p != '\n' && *p != '\r'; ++p) 4004 *p != NUL && *p != '\n' && *p != '\r'; ++p)
4010 { 4005 {
4011 if (p == tp.tagkind || (p + 5 == tp.tagkind 4006 if (p == tp.tagkind || (p + 5 == tp.tagkind
4012 && STRNCMP(p, "kind:", 5) == 0)) 4007 && STRNCMP(p, "kind:", 5) == 0))
4013 /* skip "kind:<kind>" and "<kind>" */ 4008 // skip "kind:<kind>" and "<kind>"
4014 p = tp.tagkind_end - 1; 4009 p = tp.tagkind_end - 1;
4015 else if (STRNCMP(p, "file:", 5) == 0) 4010 else if (STRNCMP(p, "file:", 5) == 0)
4016 /* skip "file:" (static tag) */ 4011 // skip "file:" (static tag)
4017 p += 4; 4012 p += 4;
4018 else if (!VIM_ISWHITE(*p)) 4013 else if (!VIM_ISWHITE(*p))
4019 { 4014 {
4020 char_u *s, *n; 4015 char_u *s, *n;
4021 int len; 4016 int len;
4022 4017
4023 /* Add extra field as a dict entry. Fields are 4018 // Add extra field as a dict entry. Fields are
4024 * separated by Tabs. */ 4019 // separated by Tabs.
4025 n = p; 4020 n = p;
4026 while (*p != NUL && *p >= ' ' && *p < 127 && *p != ':') 4021 while (*p != NUL && *p >= ' ' && *p < 127 && *p != ':')
4027 ++p; 4022 ++p;
4028 len = (int)(p - n); 4023 len = (int)(p - n);
4029 if (*p == ':' && len > 0) 4024 if (*p == ':' && len > 0)
4035 if (add_tag_field(dict, (char *)n, s, p) == FAIL) 4030 if (add_tag_field(dict, (char *)n, s, p) == FAIL)
4036 ret = FAIL; 4031 ret = FAIL;
4037 n[len] = ':'; 4032 n[len] = ':';
4038 } 4033 }
4039 else 4034 else
4040 /* Skip field without colon. */ 4035 // Skip field without colon.
4041 while (*p != NUL && *p >= ' ') 4036 while (*p != NUL && *p >= ' ')
4042 ++p; 4037 ++p;
4043 if (*p == NUL) 4038 if (*p == NUL)
4044 break; 4039 break;
4045 } 4040 }