comparison src/tag.c @ 188:041a413d626d

updated for version 7.0057
author vimboss
date Mon, 07 Mar 2005 23:09:59 +0000
parents 7fd70926e2e1
children 79c3648993c3
comparison
equal deleted inserted replaced
187:c757ec217a09 188:041a413d626d
3549 char *field_name; 3549 char *field_name;
3550 char_u *start; 3550 char_u *start;
3551 char_u *end; 3551 char_u *end;
3552 { 3552 {
3553 char_u buf[MAXPATHL]; 3553 char_u buf[MAXPATHL];
3554 int len; 3554 int len = 0;
3555 3555
3556 len = end - start; 3556 if (start != NULL)
3557 if (len > sizeof(buf) - 1) 3557 {
3558 len = sizeof(buf) - 1; 3558 len = end - start;
3559 STRNCPY(buf, start, len); 3559 if (len > sizeof(buf) - 1)
3560 len = sizeof(buf) - 1;
3561 STRNCPY(buf, start, len);
3562 }
3560 buf[len] = NUL; 3563 buf[len] = NUL;
3561 return dict_add_nr_str(dict, field_name, 0L, buf); 3564 return dict_add_nr_str(dict, field_name, 0L, buf);
3562 } 3565 }
3563 3566
3564 /* 3567 /*
3573 int num_matches, i, ret; 3576 int num_matches, i, ret;
3574 char_u **matches, *p; 3577 char_u **matches, *p;
3575 dict_T *dict; 3578 dict_T *dict;
3576 tagptrs_T tp; 3579 tagptrs_T tp;
3577 long is_static; 3580 long is_static;
3578 char_u buf[200];
3579 char_u *bp;
3580 3581
3581 ret = find_tags(pat, &num_matches, &matches, 3582 ret = find_tags(pat, &num_matches, &matches,
3582 TAG_REGEXP | TAG_NOIC, (int)MAXCOL, NULL); 3583 TAG_REGEXP | TAG_NOIC, (int)MAXCOL, NULL);
3583 if (ret == OK && num_matches > 0) 3584 if (ret == OK && num_matches > 0)
3584 { 3585 {
3585 for (i = 0; i < num_matches; ++i) 3586 for (i = 0; i < num_matches; ++i)
3586 { 3587 {
3588 parse_match(matches[i], &tp);
3589 is_static = test_for_static(&tp);
3590
3591 /* Skip pseudo-tag lines. */
3592 if (STRNCMP(tp.tagname, "!_TAG_", 6) == 0)
3593 continue;
3594
3587 if ((dict = dict_alloc()) == NULL) 3595 if ((dict = dict_alloc()) == NULL)
3588 ret = FAIL; 3596 ret = FAIL;
3589 if (list_append_dict(list, dict) == FAIL) 3597 if (list_append_dict(list, dict) == FAIL)
3590 ret = FAIL; 3598 ret = FAIL;
3591
3592 parse_match(matches[i], &tp);
3593 is_static = test_for_static(&tp);
3594 3599
3595 if (add_tag_field(dict, "name", tp.tagname, tp.tagname_end) == FAIL 3600 if (add_tag_field(dict, "name", tp.tagname, tp.tagname_end) == FAIL
3596 || add_tag_field(dict, "filename", tp.fname, 3601 || add_tag_field(dict, "filename", tp.fname,
3597 tp.fname_end) == FAIL 3602 tp.fname_end) == FAIL
3598 || add_tag_field(dict, "cmd", tp.command, 3603 || add_tag_field(dict, "cmd", tp.command,
3600 || add_tag_field(dict, "kind", tp.tagkind, 3605 || add_tag_field(dict, "kind", tp.tagkind,
3601 tp.tagkind_end) == FAIL 3606 tp.tagkind_end) == FAIL
3602 || dict_add_nr_str(dict, "static", is_static, NULL) == FAIL) 3607 || dict_add_nr_str(dict, "static", is_static, NULL) == FAIL)
3603 ret = FAIL; 3608 ret = FAIL;
3604 3609
3605 bp = buf;
3606
3607 if (tp.command_end != NULL) 3610 if (tp.command_end != NULL)
3608 { 3611 {
3609 for (p = tp.command_end + 3; 3612 for (p = tp.command_end + 3;
3610 *p != NUL && *p != '\n' && *p != '\r'; ++p) 3613 *p != NUL && *p != '\n' && *p != '\r'; ++p)
3611 { 3614 {
3614 /* skip "kind:<kind>" and "<kind>" */ 3617 /* skip "kind:<kind>" and "<kind>" */
3615 p = tp.tagkind_end - 1; 3618 p = tp.tagkind_end - 1;
3616 else if (STRNCMP(p, "file:", 5) == 0) 3619 else if (STRNCMP(p, "file:", 5) == 0)
3617 /* skip "file:" (static tag) */ 3620 /* skip "file:" (static tag) */
3618 p += 4; 3621 p += 4;
3619 else if (STRNCMP(p, "struct:", 7) == 0 3622 else if (!vim_iswhite(*p))
3620 || STRNCMP(p, "enum:", 5) == 0
3621 || STRNCMP(p, "class:", 6) == 0)
3622 { 3623 {
3623 char_u *s, *n; 3624 char_u *s, *n;
3624 3625 int len;
3625 /* Field we recognize, add as a dict entry. */ 3626
3627 /* Add extra field as a dict entry. */
3626 n = p; 3628 n = p;
3627 if (*n == 's') 3629 while (*p != NUL && *p > ' ' && *p < 127 && *p != ':')
3628 p += 7;
3629 else if (*n == 'e')
3630 p += 5;
3631 else
3632 p += 6;
3633 s = p;
3634 while (*p != NUL && *p != '\n' && *p != '\r')
3635 ++p; 3630 ++p;
3636 if (add_tag_field(dict, 3631 len = p - n;
3637 *n == 's' ? "struct" 3632 if (*p == ':' && len > 0)
3638 : *n == 'e' ? "enum" : "class", 3633 {
3639 s, p) == FAIL) 3634 s = ++p;
3640 ret = FAIL; 3635 while (*p != NUL && *p > ' ' && *p < 127)
3636 ++p;
3637 n[len] = NUL;
3638 if (add_tag_field(dict, (char *)n, s, p) == FAIL)
3639 ret = FAIL;
3640 n[len] = ':';
3641 }
3641 --p; 3642 --p;
3642 } 3643 }
3643 else if ((bp - buf) < sizeof(buf) - 1
3644 && (bp > buf || !vim_iswhite(*p)))
3645 /* Field not recognized, add to "extra" dict entry. */
3646 *bp++ = *p;
3647 }
3648
3649 if (bp > buf)
3650 {
3651 *bp = NUL;
3652 if (dict_add_nr_str(dict, "extra", 0L, buf) == FAIL)
3653 ret = FAIL;
3654 } 3644 }
3655 } 3645 }
3656 3646
3657 vim_free(matches[i]); 3647 vim_free(matches[i]);
3658 } 3648 }