Mercurial > vim
comparison src/tag.c @ 7835:4d7ce6c03fda v7.4.1214
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jan 30 21:10:09 2016 +0100
patch 7.4.1214
Problem: Using old style function declarations.
Solution: Change to new style function declarations. (script by Hirohito
Higashi)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 30 Jan 2016 21:15:04 +0100 |
parents | 0b6c37dd858d |
children | 2f57bbe870ea |
comparison
equal
deleted
inserted
replaced
7834:2d1dc9ec41ce | 7835:4d7ce6c03fda |
---|---|
119 * type == DT_FREE: free cached matches | 119 * type == DT_FREE: free cached matches |
120 * | 120 * |
121 * for cscope, returns TRUE if we jumped to tag or aborted, FALSE otherwise | 121 * for cscope, returns TRUE if we jumped to tag or aborted, FALSE otherwise |
122 */ | 122 */ |
123 int | 123 int |
124 do_tag(tag, type, count, forceit, verbose) | 124 do_tag( |
125 char_u *tag; /* tag (pattern) to jump to */ | 125 char_u *tag, /* tag (pattern) to jump to */ |
126 int type; | 126 int type, |
127 int count; | 127 int count, |
128 int forceit; /* :ta with ! */ | 128 int forceit, /* :ta with ! */ |
129 int verbose; /* print "tag not found" message */ | 129 int verbose) /* print "tag not found" message */ |
130 { | 130 { |
131 taggy_T *tagstack = curwin->w_tagstack; | 131 taggy_T *tagstack = curwin->w_tagstack; |
132 int tagstackidx = curwin->w_tagstackidx; | 132 int tagstackidx = curwin->w_tagstackidx; |
133 int tagstacklen = curwin->w_tagstacklen; | 133 int tagstacklen = curwin->w_tagstacklen; |
134 int cur_match = 0; | 134 int cur_match = 0; |
1090 | 1090 |
1091 /* | 1091 /* |
1092 * Free cached tags. | 1092 * Free cached tags. |
1093 */ | 1093 */ |
1094 void | 1094 void |
1095 tag_freematch() | 1095 tag_freematch(void) |
1096 { | 1096 { |
1097 vim_free(tagmatchname); | 1097 vim_free(tagmatchname); |
1098 tagmatchname = NULL; | 1098 tagmatchname = NULL; |
1099 } | 1099 } |
1100 | 1100 |
1101 static void | 1101 static void |
1102 taglen_advance(l) | 1102 taglen_advance(int l) |
1103 int l; | |
1104 { | 1103 { |
1105 if (l == MAXCOL) | 1104 if (l == MAXCOL) |
1106 { | 1105 { |
1107 msg_putchar('\n'); | 1106 msg_putchar('\n'); |
1108 msg_advance(24); | 1107 msg_advance(24); |
1113 | 1112 |
1114 /* | 1113 /* |
1115 * Print the tag stack | 1114 * Print the tag stack |
1116 */ | 1115 */ |
1117 void | 1116 void |
1118 do_tags(eap) | 1117 do_tags(exarg_T *eap UNUSED) |
1119 exarg_T *eap UNUSED; | |
1120 { | 1118 { |
1121 int i; | 1119 int i; |
1122 char_u *name; | 1120 char_u *name; |
1123 taggy_T *tagstack = curwin->w_tagstack; | 1121 taggy_T *tagstack = curwin->w_tagstack; |
1124 int tagstackidx = curwin->w_tagstackidx; | 1122 int tagstackidx = curwin->w_tagstackidx; |
1167 * Compare two strings, for length "len", ignoring case the ASCII way. | 1165 * Compare two strings, for length "len", ignoring case the ASCII way. |
1168 * return 0 for match, < 0 for smaller, > 0 for bigger | 1166 * return 0 for match, < 0 for smaller, > 0 for bigger |
1169 * Make sure case is folded to uppercase in comparison (like for 'sort -f') | 1167 * Make sure case is folded to uppercase in comparison (like for 'sort -f') |
1170 */ | 1168 */ |
1171 static int | 1169 static int |
1172 tag_strnicmp(s1, s2, len) | 1170 tag_strnicmp(char_u *s1, char_u *s2, size_t len) |
1173 char_u *s1; | |
1174 char_u *s2; | |
1175 size_t len; | |
1176 { | 1171 { |
1177 int i; | 1172 int i; |
1178 | 1173 |
1179 while (len > 0) | 1174 while (len > 0) |
1180 { | 1175 { |
1207 | 1202 |
1208 /* | 1203 /* |
1209 * Extract info from the tag search pattern "pats->pat". | 1204 * Extract info from the tag search pattern "pats->pat". |
1210 */ | 1205 */ |
1211 static void | 1206 static void |
1212 prepare_pats(pats, has_re) | 1207 prepare_pats(pat_T *pats, int has_re) |
1213 pat_T *pats; | |
1214 int has_re; | |
1215 { | 1208 { |
1216 pats->head = pats->pat; | 1209 pats->head = pats->pat; |
1217 pats->headlen = pats->len; | 1210 pats->headlen = pats->len; |
1218 if (has_re) | 1211 if (has_re) |
1219 { | 1212 { |
1265 * TAG_REGEXP use "pat" as a regexp | 1258 * TAG_REGEXP use "pat" as a regexp |
1266 * TAG_NOIC don't always ignore case | 1259 * TAG_NOIC don't always ignore case |
1267 * TAG_KEEP_LANG keep language | 1260 * TAG_KEEP_LANG keep language |
1268 */ | 1261 */ |
1269 int | 1262 int |
1270 find_tags(pat, num_matches, matchesp, flags, mincount, buf_ffname) | 1263 find_tags( |
1271 char_u *pat; /* pattern to search for */ | 1264 char_u *pat, /* pattern to search for */ |
1272 int *num_matches; /* return: number of matches found */ | 1265 int *num_matches, /* return: number of matches found */ |
1273 char_u ***matchesp; /* return: array of matches found */ | 1266 char_u ***matchesp, /* return: array of matches found */ |
1274 int flags; | 1267 int flags, |
1275 int mincount; /* MAXCOL: find all matches | 1268 int mincount, /* MAXCOL: find all matches |
1276 other: minimal number of matches */ | 1269 other: minimal number of matches */ |
1277 char_u *buf_ffname; /* name of buffer for priority */ | 1270 char_u *buf_ffname) /* name of buffer for priority */ |
1278 { | 1271 { |
1279 FILE *fp; | 1272 FILE *fp; |
1280 char_u *lbuf; /* line buffer */ | 1273 char_u *lbuf; /* line buffer */ |
1281 int lbuf_size = LSIZE; /* length of lbuf */ | 1274 int lbuf_size = LSIZE; /* length of lbuf */ |
1282 char_u *tag_fname; /* name of tag file */ | 1275 char_u *tag_fname; /* name of tag file */ |
2575 /* | 2568 /* |
2576 * Callback function for finding all "tags" and "tags-??" files in | 2569 * Callback function for finding all "tags" and "tags-??" files in |
2577 * 'runtimepath' doc directories. | 2570 * 'runtimepath' doc directories. |
2578 */ | 2571 */ |
2579 static void | 2572 static void |
2580 found_tagfile_cb(fname, cookie) | 2573 found_tagfile_cb(char_u *fname, void *cookie UNUSED) |
2581 char_u *fname; | |
2582 void *cookie UNUSED; | |
2583 { | 2574 { |
2584 if (ga_grow(&tag_fnames, 1) == OK) | 2575 if (ga_grow(&tag_fnames, 1) == OK) |
2585 ((char_u **)(tag_fnames.ga_data))[tag_fnames.ga_len++] = | 2576 ((char_u **)(tag_fnames.ga_data))[tag_fnames.ga_len++] = |
2586 vim_strsave(fname); | 2577 vim_strsave(fname); |
2587 } | 2578 } |
2588 | 2579 |
2589 #if defined(EXITFREE) || defined(PROTO) | 2580 #if defined(EXITFREE) || defined(PROTO) |
2590 void | 2581 void |
2591 free_tag_stuff() | 2582 free_tag_stuff(void) |
2592 { | 2583 { |
2593 ga_clear_strings(&tag_fnames); | 2584 ga_clear_strings(&tag_fnames); |
2594 do_tag(NULL, DT_FREE, 0, 0, 0); | 2585 do_tag(NULL, DT_FREE, 0, 0, 0); |
2595 tag_freematch(); | 2586 tag_freematch(); |
2596 | 2587 |
2609 * For help files, use "tags" file only. | 2600 * For help files, use "tags" file only. |
2610 * | 2601 * |
2611 * Return FAIL if no more tag file names, OK otherwise. | 2602 * Return FAIL if no more tag file names, OK otherwise. |
2612 */ | 2603 */ |
2613 int | 2604 int |
2614 get_tagfname(tnp, first, buf) | 2605 get_tagfname( |
2615 tagname_T *tnp; /* holds status info */ | 2606 tagname_T *tnp, /* holds status info */ |
2616 int first; /* TRUE when first file name is wanted */ | 2607 int first, /* TRUE when first file name is wanted */ |
2617 char_u *buf; /* pointer to buffer of MAXPATHL chars */ | 2608 char_u *buf) /* pointer to buffer of MAXPATHL chars */ |
2618 { | 2609 { |
2619 char_u *fname = NULL; | 2610 char_u *fname = NULL; |
2620 char_u *r_ptr; | 2611 char_u *r_ptr; |
2621 | 2612 |
2622 if (first) | 2613 if (first) |
2739 | 2730 |
2740 /* | 2731 /* |
2741 * Free the contents of a tagname_T that was filled by get_tagfname(). | 2732 * Free the contents of a tagname_T that was filled by get_tagfname(). |
2742 */ | 2733 */ |
2743 void | 2734 void |
2744 tagname_free(tnp) | 2735 tagname_free(tagname_T *tnp) |
2745 tagname_T *tnp; | |
2746 { | 2736 { |
2747 vim_free(tnp->tn_tags); | 2737 vim_free(tnp->tn_tags); |
2748 vim_findfile_cleanup(tnp->tn_search_ctx); | 2738 vim_findfile_cleanup(tnp->tn_search_ctx); |
2749 tnp->tn_search_ctx = NULL; | 2739 tnp->tn_search_ctx = NULL; |
2750 ga_clear_strings(&tag_fnames); | 2740 ga_clear_strings(&tag_fnames); |
2757 * If is_etag is TRUE, tagp->fname and tagp->fname_end are not set. | 2747 * If is_etag is TRUE, tagp->fname and tagp->fname_end are not set. |
2758 * | 2748 * |
2759 * Return FAIL if there is a format error in this line, OK otherwise. | 2749 * Return FAIL if there is a format error in this line, OK otherwise. |
2760 */ | 2750 */ |
2761 static int | 2751 static int |
2762 parse_tag_line(lbuf, | 2752 parse_tag_line( |
2753 char_u *lbuf, /* line to be parsed */ | |
2763 #ifdef FEAT_EMACS_TAGS | 2754 #ifdef FEAT_EMACS_TAGS |
2764 is_etag, | 2755 int is_etag, |
2765 #endif | 2756 #endif |
2766 tagp) | 2757 tagptrs_T *tagp) |
2767 char_u *lbuf; /* line to be parsed */ | |
2768 #ifdef FEAT_EMACS_TAGS | |
2769 int is_etag; | |
2770 #endif | |
2771 tagptrs_T *tagp; | |
2772 { | 2758 { |
2773 char_u *p; | 2759 char_u *p; |
2774 | 2760 |
2775 #ifdef FEAT_EMACS_TAGS | 2761 #ifdef FEAT_EMACS_TAGS |
2776 char_u *p_7f; | 2762 char_u *p_7f; |
2893 * | 2879 * |
2894 * Return TRUE if it is a static tag and adjust *tagname to the real tag. | 2880 * Return TRUE if it is a static tag and adjust *tagname to the real tag. |
2895 * Return FALSE if it is not a static tag. | 2881 * Return FALSE if it is not a static tag. |
2896 */ | 2882 */ |
2897 static int | 2883 static int |
2898 test_for_static(tagp) | 2884 test_for_static(tagptrs_T *tagp) |
2899 tagptrs_T *tagp; | |
2900 { | 2885 { |
2901 char_u *p; | 2886 char_u *p; |
2902 | 2887 |
2903 #ifdef FEAT_TAG_OLDSTATIC | 2888 #ifdef FEAT_TAG_OLDSTATIC |
2904 int len; | 2889 int len; |
2940 * without Emacs tags: <mtt><tag_fname><NUL><lbuf> | 2925 * without Emacs tags: <mtt><tag_fname><NUL><lbuf> |
2941 * | 2926 * |
2942 * Return OK or FAIL. | 2927 * Return OK or FAIL. |
2943 */ | 2928 */ |
2944 static int | 2929 static int |
2945 parse_match(lbuf, tagp) | 2930 parse_match( |
2946 char_u *lbuf; /* input: matching line */ | 2931 char_u *lbuf, /* input: matching line */ |
2947 tagptrs_T *tagp; /* output: pointers into the line */ | 2932 tagptrs_T *tagp) /* output: pointers into the line */ |
2948 { | 2933 { |
2949 int retval; | 2934 int retval; |
2950 char_u *p; | 2935 char_u *p; |
2951 char_u *pc, *pt; | 2936 char_u *pc, *pt; |
2952 | 2937 |
3020 * Find out the actual file name of a tag. Concatenate the tags file name | 3005 * Find out the actual file name of a tag. Concatenate the tags file name |
3021 * with the matching tag file name. | 3006 * with the matching tag file name. |
3022 * Returns an allocated string or NULL (out of memory). | 3007 * Returns an allocated string or NULL (out of memory). |
3023 */ | 3008 */ |
3024 static char_u * | 3009 static char_u * |
3025 tag_full_fname(tagp) | 3010 tag_full_fname(tagptrs_T *tagp) |
3026 tagptrs_T *tagp; | |
3027 { | 3011 { |
3028 char_u *fullname; | 3012 char_u *fullname; |
3029 int c; | 3013 int c; |
3030 | 3014 |
3031 #ifdef FEAT_EMACS_TAGS | 3015 #ifdef FEAT_EMACS_TAGS |
3051 * Jump to a tag that has been found in one of the tag files | 3035 * Jump to a tag that has been found in one of the tag files |
3052 * | 3036 * |
3053 * returns OK for success, NOTAGFILE when file not found, FAIL otherwise. | 3037 * returns OK for success, NOTAGFILE when file not found, FAIL otherwise. |
3054 */ | 3038 */ |
3055 static int | 3039 static int |
3056 jumpto_tag(lbuf, forceit, keep_help) | 3040 jumpto_tag( |
3057 char_u *lbuf; /* line from the tags file for this tag */ | 3041 char_u *lbuf, /* line from the tags file for this tag */ |
3058 int forceit; /* :ta with ! */ | 3042 int forceit, /* :ta with ! */ |
3059 int keep_help; /* keep help flag (FALSE for cscope) */ | 3043 int keep_help) /* keep help flag (FALSE for cscope) */ |
3060 { | 3044 { |
3061 int save_secure; | 3045 int save_secure; |
3062 int save_magic; | 3046 int save_magic; |
3063 int save_p_ws, save_p_scs, save_p_ic; | 3047 int save_p_ws, save_p_scs, save_p_ic; |
3064 linenr_T save_lnum; | 3048 linenr_T save_lnum; |
3415 * If 'tagrelative' option set, change fname (name of file containing tag) | 3399 * If 'tagrelative' option set, change fname (name of file containing tag) |
3416 * according to tag_fname (name of tag file containing fname). | 3400 * according to tag_fname (name of tag file containing fname). |
3417 * Returns a pointer to allocated memory (or NULL when out of memory). | 3401 * Returns a pointer to allocated memory (or NULL when out of memory). |
3418 */ | 3402 */ |
3419 static char_u * | 3403 static char_u * |
3420 expand_tag_fname(fname, tag_fname, expand) | 3404 expand_tag_fname(char_u *fname, char_u *tag_fname, int expand) |
3421 char_u *fname; | |
3422 char_u *tag_fname; | |
3423 int expand; | |
3424 { | 3405 { |
3425 char_u *p; | 3406 char_u *p; |
3426 char_u *retval; | 3407 char_u *retval; |
3427 char_u *expanded_fname = NULL; | 3408 char_u *expanded_fname = NULL; |
3428 expand_T xpc; | 3409 expand_T xpc; |
3469 * its simplest form by stripping out unneeded components, if any. The | 3450 * its simplest form by stripping out unneeded components, if any. The |
3470 * resulting file name is simplified in place and will either be the same | 3451 * resulting file name is simplified in place and will either be the same |
3471 * length as that supplied, or shorter. | 3452 * length as that supplied, or shorter. |
3472 */ | 3453 */ |
3473 void | 3454 void |
3474 simplify_filename(filename) | 3455 simplify_filename(char_u *filename) |
3475 char_u *filename; | |
3476 { | 3456 { |
3477 #ifndef AMIGA /* Amiga doesn't have "..", it uses "/" */ | 3457 #ifndef AMIGA /* Amiga doesn't have "..", it uses "/" */ |
3478 int components = 0; | 3458 int components = 0; |
3479 char_u *p, *tail, *start; | 3459 char_u *p, *tail, *start; |
3480 int stripping_disabled = FALSE; | 3460 int stripping_disabled = FALSE; |
3682 * This is a bit slow, because of the full path compare in fullpathcmp(). | 3662 * This is a bit slow, because of the full path compare in fullpathcmp(). |
3683 * Return TRUE if tag for file "fname" if tag file "tag_fname" is for current | 3663 * Return TRUE if tag for file "fname" if tag file "tag_fname" is for current |
3684 * file. | 3664 * file. |
3685 */ | 3665 */ |
3686 static int | 3666 static int |
3667 test_for_current( | |
3687 #ifdef FEAT_EMACS_TAGS | 3668 #ifdef FEAT_EMACS_TAGS |
3688 test_for_current(is_etag, fname, fname_end, tag_fname, buf_ffname) | 3669 int is_etag, |
3689 int is_etag; | 3670 #endif |
3690 #else | 3671 char_u *fname, |
3691 test_for_current(fname, fname_end, tag_fname, buf_ffname) | 3672 char_u *fname_end, |
3692 #endif | 3673 char_u *tag_fname, |
3693 char_u *fname; | 3674 char_u *buf_ffname) |
3694 char_u *fname_end; | |
3695 char_u *tag_fname; | |
3696 char_u *buf_ffname; | |
3697 { | 3675 { |
3698 int c; | 3676 int c; |
3699 int retval = FALSE; | 3677 int retval = FALSE; |
3700 char_u *fullname; | 3678 char_u *fullname; |
3701 | 3679 |
3728 /* | 3706 /* |
3729 * Find the end of the tagaddress. | 3707 * Find the end of the tagaddress. |
3730 * Return OK if ";\"" is following, FAIL otherwise. | 3708 * Return OK if ";\"" is following, FAIL otherwise. |
3731 */ | 3709 */ |
3732 static int | 3710 static int |
3733 find_extra(pp) | 3711 find_extra(char_u **pp) |
3734 char_u **pp; | |
3735 { | 3712 { |
3736 char_u *str = *pp; | 3713 char_u *str = *pp; |
3737 | 3714 |
3738 /* Repeat for addresses separated with ';' */ | 3715 /* Repeat for addresses separated with ';' */ |
3739 for (;;) | 3716 for (;;) |
3764 return FAIL; | 3741 return FAIL; |
3765 } | 3742 } |
3766 | 3743 |
3767 #if defined(FEAT_CMDL_COMPL) || defined(PROTO) | 3744 #if defined(FEAT_CMDL_COMPL) || defined(PROTO) |
3768 int | 3745 int |
3769 expand_tags(tagnames, pat, num_file, file) | 3746 expand_tags( |
3770 int tagnames; /* expand tag names */ | 3747 int tagnames, /* expand tag names */ |
3771 char_u *pat; | 3748 char_u *pat, |
3772 int *num_file; | 3749 int *num_file, |
3773 char_u ***file; | 3750 char_u ***file) |
3774 { | 3751 { |
3775 int i; | 3752 int i; |
3776 int c; | 3753 int c; |
3777 int tagnmflag; | 3754 int tagnmflag; |
3778 char_u tagnm[100]; | 3755 char_u tagnm[100]; |
3820 /* | 3797 /* |
3821 * Add a tag field to the dictionary "dict". | 3798 * Add a tag field to the dictionary "dict". |
3822 * Return OK or FAIL. | 3799 * Return OK or FAIL. |
3823 */ | 3800 */ |
3824 static int | 3801 static int |
3825 add_tag_field(dict, field_name, start, end) | 3802 add_tag_field( |
3826 dict_T *dict; | 3803 dict_T *dict, |
3827 char *field_name; | 3804 char *field_name, |
3828 char_u *start; /* start of the value */ | 3805 char_u *start, /* start of the value */ |
3829 char_u *end; /* after the value; can be NULL */ | 3806 char_u *end) /* after the value; can be NULL */ |
3830 { | 3807 { |
3831 char_u *buf; | 3808 char_u *buf; |
3832 int len = 0; | 3809 int len = 0; |
3833 int retval; | 3810 int retval; |
3834 | 3811 |
3868 /* | 3845 /* |
3869 * Add the tags matching the specified pattern to the list "list" | 3846 * Add the tags matching the specified pattern to the list "list" |
3870 * as a dictionary | 3847 * as a dictionary |
3871 */ | 3848 */ |
3872 int | 3849 int |
3873 get_tags(list, pat) | 3850 get_tags(list_T *list, char_u *pat) |
3874 list_T *list; | |
3875 char_u *pat; | |
3876 { | 3851 { |
3877 int num_matches, i, ret; | 3852 int num_matches, i, ret; |
3878 char_u **matches, *p; | 3853 char_u **matches, *p; |
3879 char_u *full_fname; | 3854 char_u *full_fname; |
3880 dict_T *dict; | 3855 dict_T *dict; |