Mercurial > vim
comparison src/tag.c @ 12477:68d7bc045dbe v8.0.1118
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
commit https://github.com/vim/vim/commit/4033c55eca575777718c0701e26635a0cc47d907
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Sep 16 20:54:51 2017 +0200
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Problem: FEAT_WINDOWS adds a lot of #ifdefs while it is nearly always
enabled and only adds 7% to the binary size of the tiny build.
Solution: Graduate FEAT_WINDOWS.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 16 Sep 2017 21:00:06 +0200 |
parents | 578df034735d |
children | 429bf1b9292f |
comparison
equal
deleted
inserted
replaced
12476:2516383741e6 | 12477:68d7bc045dbe |
---|---|
78 static char_u *bottommsg = (char_u *)N_("E555: at bottom of tag stack"); | 78 static char_u *bottommsg = (char_u *)N_("E555: at bottom of tag stack"); |
79 static char_u *topmsg = (char_u *)N_("E556: at top of tag stack"); | 79 static char_u *topmsg = (char_u *)N_("E556: at top of tag stack"); |
80 | 80 |
81 static char_u *tagmatchname = NULL; /* name of last used tag */ | 81 static char_u *tagmatchname = NULL; /* name of last used tag */ |
82 | 82 |
83 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) | 83 #if defined(FEAT_QUICKFIX) |
84 /* | 84 /* |
85 * Tag for preview window is remembered separately, to avoid messing up the | 85 * Tag for preview window is remembered separately, to avoid messing up the |
86 * normal tagstack. | 86 * normal tagstack. |
87 */ | 87 */ |
88 static taggy_T ptag_entry = {NULL, {INIT_POS_T(0, 0, 0), 0}, 0, 0}; | 88 static taggy_T ptag_entry = {NULL, {INIT_POS_T(0, 0, 0), 0}, 0, 0}; |
186 */ | 186 */ |
187 if ((!p_tgst && *tag != NUL)) | 187 if ((!p_tgst && *tag != NUL)) |
188 { | 188 { |
189 use_tagstack = FALSE; | 189 use_tagstack = FALSE; |
190 new_tag = TRUE; | 190 new_tag = TRUE; |
191 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) | 191 #if defined(FEAT_QUICKFIX) |
192 if (g_do_tagpreview != 0) | 192 if (g_do_tagpreview != 0) |
193 { | 193 { |
194 vim_free(ptag_entry.tagname); | 194 vim_free(ptag_entry.tagname); |
195 if ((ptag_entry.tagname = vim_strsave(tag)) == NULL) | 195 if ((ptag_entry.tagname = vim_strsave(tag)) == NULL) |
196 goto end_do_tag; | 196 goto end_do_tag; |
197 } | 197 } |
198 #endif | 198 #endif |
199 } | 199 } |
200 else | 200 else |
201 { | 201 { |
202 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) | 202 #if defined(FEAT_QUICKFIX) |
203 if (g_do_tagpreview != 0) | 203 if (g_do_tagpreview != 0) |
204 use_tagstack = FALSE; | 204 use_tagstack = FALSE; |
205 else | 205 else |
206 #endif | 206 #endif |
207 use_tagstack = TRUE; | 207 use_tagstack = TRUE; |
215 #ifdef FEAT_CSCOPE | 215 #ifdef FEAT_CSCOPE |
216 || type == DT_CSCOPE | 216 || type == DT_CSCOPE |
217 #endif | 217 #endif |
218 )) | 218 )) |
219 { | 219 { |
220 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) | 220 #if defined(FEAT_QUICKFIX) |
221 if (g_do_tagpreview != 0) | 221 if (g_do_tagpreview != 0) |
222 { | 222 { |
223 if (ptag_entry.tagname != NULL | 223 if (ptag_entry.tagname != NULL |
224 && STRCMP(ptag_entry.tagname, tag) == 0) | 224 && STRCMP(ptag_entry.tagname, tag) == 0) |
225 { | 225 { |
271 new_tag = TRUE; | 271 new_tag = TRUE; |
272 } | 272 } |
273 else | 273 else |
274 { | 274 { |
275 if ( | 275 if ( |
276 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) | 276 #if defined(FEAT_QUICKFIX) |
277 g_do_tagpreview != 0 ? ptag_entry.tagname == NULL : | 277 g_do_tagpreview != 0 ? ptag_entry.tagname == NULL : |
278 #endif | 278 #endif |
279 tagstacklen == 0) | 279 tagstacklen == 0) |
280 { | 280 { |
281 /* empty stack */ | 281 /* empty stack */ |
354 #if defined(FEAT_QUICKFIX) | 354 #if defined(FEAT_QUICKFIX) |
355 || type == DT_LTAG | 355 || type == DT_LTAG |
356 #endif | 356 #endif |
357 ) | 357 ) |
358 { | 358 { |
359 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) | 359 #if defined(FEAT_QUICKFIX) |
360 if (g_do_tagpreview != 0) | 360 if (g_do_tagpreview != 0) |
361 { | 361 { |
362 cur_match = ptag_entry.cur_match; | 362 cur_match = ptag_entry.cur_match; |
363 cur_fnum = ptag_entry.cur_fnum; | 363 cur_fnum = ptag_entry.cur_fnum; |
364 } | 364 } |
392 else /* go to other matching tag */ | 392 else /* go to other matching tag */ |
393 { | 393 { |
394 /* Save index for when selection is cancelled. */ | 394 /* Save index for when selection is cancelled. */ |
395 prevtagstackidx = tagstackidx; | 395 prevtagstackidx = tagstackidx; |
396 | 396 |
397 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) | 397 #if defined(FEAT_QUICKFIX) |
398 if (g_do_tagpreview != 0) | 398 if (g_do_tagpreview != 0) |
399 { | 399 { |
400 cur_match = ptag_entry.cur_match; | 400 cur_match = ptag_entry.cur_match; |
401 cur_fnum = ptag_entry.cur_fnum; | 401 cur_fnum = ptag_entry.cur_fnum; |
402 } | 402 } |
430 cur_fnum = curbuf->b_fnum; | 430 cur_fnum = curbuf->b_fnum; |
431 } | 431 } |
432 } | 432 } |
433 } | 433 } |
434 | 434 |
435 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) | 435 #if defined(FEAT_QUICKFIX) |
436 if (g_do_tagpreview != 0) | 436 if (g_do_tagpreview != 0) |
437 { | 437 { |
438 if (type != DT_SELECT && type != DT_JUMP) | 438 if (type != DT_SELECT && type != DT_JUMP) |
439 { | 439 { |
440 ptag_entry.cur_match = cur_match; | 440 ptag_entry.cur_match = cur_match; |
485 /* | 485 /* |
486 * When desired match not found yet, try to find it (and others). | 486 * When desired match not found yet, try to find it (and others). |
487 */ | 487 */ |
488 if (use_tagstack) | 488 if (use_tagstack) |
489 name = tagstack[tagstackidx].tagname; | 489 name = tagstack[tagstackidx].tagname; |
490 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) | 490 #if defined(FEAT_QUICKFIX) |
491 else if (g_do_tagpreview != 0) | 491 else if (g_do_tagpreview != 0) |
492 name = ptag_entry.tagname; | 492 name = ptag_entry.tagname; |
493 #endif | 493 #endif |
494 else | 494 else |
495 name = tag; | 495 name = tag; |
565 | 565 |
566 if (num_matches <= 0) | 566 if (num_matches <= 0) |
567 { | 567 { |
568 if (verbose) | 568 if (verbose) |
569 EMSG2(_("E426: tag not found: %s"), name); | 569 EMSG2(_("E426: tag not found: %s"), name); |
570 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) | 570 #if defined(FEAT_QUICKFIX) |
571 g_do_tagpreview = 0; | 571 g_do_tagpreview = 0; |
572 #endif | 572 #endif |
573 } | 573 } |
574 else | 574 else |
575 { | 575 { |
612 | 612 |
613 for (i = 0; i < num_matches && !got_int; ++i) | 613 for (i = 0; i < num_matches && !got_int; ++i) |
614 { | 614 { |
615 parse_match(matches[i], &tagp); | 615 parse_match(matches[i], &tagp); |
616 if (!new_tag && ( | 616 if (!new_tag && ( |
617 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) | 617 #if defined(FEAT_QUICKFIX) |
618 (g_do_tagpreview != 0 | 618 (g_do_tagpreview != 0 |
619 && i == ptag_entry.cur_match) || | 619 && i == ptag_entry.cur_match) || |
620 #endif | 620 #endif |
621 (use_tagstack | 621 (use_tagstack |
622 && i == tagstack[tagstackidx].cur_match))) | 622 && i == tagstack[tagstackidx].cur_match))) |
966 { | 966 { |
967 tagstack[tagstackidx].cur_match = cur_match; | 967 tagstack[tagstackidx].cur_match = cur_match; |
968 tagstack[tagstackidx].cur_fnum = cur_fnum; | 968 tagstack[tagstackidx].cur_fnum = cur_fnum; |
969 ++tagstackidx; | 969 ++tagstackidx; |
970 } | 970 } |
971 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) | 971 #if defined(FEAT_QUICKFIX) |
972 else if (g_do_tagpreview != 0) | 972 else if (g_do_tagpreview != 0) |
973 { | 973 { |
974 ptag_entry.cur_match = cur_match; | 974 ptag_entry.cur_match = cur_match; |
975 ptag_entry.cur_fnum = cur_fnum; | 975 ptag_entry.cur_fnum = cur_fnum; |
976 } | 976 } |
1071 | 1071 |
1072 end_do_tag: | 1072 end_do_tag: |
1073 /* Only store the new index when using the tagstack and it's valid. */ | 1073 /* Only store the new index when using the tagstack and it's valid. */ |
1074 if (use_tagstack && tagstackidx <= curwin->w_tagstacklen) | 1074 if (use_tagstack && tagstackidx <= curwin->w_tagstacklen) |
1075 curwin->w_tagstackidx = tagstackidx; | 1075 curwin->w_tagstackidx = tagstackidx; |
1076 #ifdef FEAT_WINDOWS | |
1077 postponed_split = 0; /* don't split next time */ | 1076 postponed_split = 0; /* don't split next time */ |
1078 # ifdef FEAT_QUICKFIX | 1077 # ifdef FEAT_QUICKFIX |
1079 g_do_tagpreview = 0; /* don't do tag preview next time */ | 1078 g_do_tagpreview = 0; /* don't do tag preview next time */ |
1080 # endif | 1079 # endif |
1081 #endif | |
1082 | 1080 |
1083 #ifdef FEAT_CSCOPE | 1081 #ifdef FEAT_CSCOPE |
1084 return jumped_to_tag; | 1082 return jumped_to_tag; |
1085 #else | 1083 #else |
1086 return FALSE; | 1084 return FALSE; |
1950 #ifdef FEAT_EMACS_TAGS | 1948 #ifdef FEAT_EMACS_TAGS |
1951 && !is_etag | 1949 && !is_etag |
1952 #endif | 1950 #endif |
1953 ) | 1951 ) |
1954 { | 1952 { |
1953 vim_memset(&tagp, 0, sizeof(tagp)); | |
1955 tagp.tagname = lbuf; | 1954 tagp.tagname = lbuf; |
1956 #ifdef FEAT_TAG_ANYWHITE | 1955 #ifdef FEAT_TAG_ANYWHITE |
1957 tagp.tagname_end = skiptowhite(lbuf); | 1956 tagp.tagname_end = skiptowhite(lbuf); |
1958 if (*tagp.tagname_end == NUL) | 1957 if (*tagp.tagname_end == NUL) |
1959 #else | 1958 #else |
1996 for (p = lbuf; p < tagp.tagname_end; ++p) | 1995 for (p = lbuf; p < tagp.tagname_end; ++p) |
1997 { | 1996 { |
1998 if (*p == ':') | 1997 if (*p == ':') |
1999 { | 1998 { |
2000 if (tagp.fname == NULL) | 1999 if (tagp.fname == NULL) |
2001 #ifdef FEAT_TAG_ANYWHITE | 2000 # ifdef FEAT_TAG_ANYWHITE |
2002 tagp.fname = skipwhite(tagp.tagname_end); | 2001 tagp.fname = skipwhite(tagp.tagname_end); |
2003 #else | 2002 # else |
2004 tagp.fname = tagp.tagname_end + 1; | 2003 tagp.fname = tagp.tagname_end + 1; |
2005 #endif | 2004 # endif |
2006 if ( fnamencmp(lbuf, tagp.fname, p - lbuf) == 0 | 2005 if ( fnamencmp(lbuf, tagp.fname, p - lbuf) == 0 |
2007 #ifdef FEAT_TAG_ANYWHITE | 2006 # ifdef FEAT_TAG_ANYWHITE |
2008 && VIM_ISWHITE(tagp.fname[p - lbuf]) | 2007 && VIM_ISWHITE(tagp.fname[p - lbuf]) |
2009 #else | 2008 # else |
2010 && tagp.fname[p - lbuf] == TAB | 2009 && tagp.fname[p - lbuf] == TAB |
2011 #endif | 2010 # endif |
2012 ) | 2011 ) |
2013 { | 2012 { |
2014 /* found one */ | 2013 /* found one */ |
2015 tagp.tagname = p + 1; | 2014 tagp.tagname = p + 1; |
2016 break; | 2015 break; |
2617 { | 2616 { |
2618 ga_clear_strings(&tag_fnames); | 2617 ga_clear_strings(&tag_fnames); |
2619 do_tag(NULL, DT_FREE, 0, 0, 0); | 2618 do_tag(NULL, DT_FREE, 0, 0, 0); |
2620 tag_freematch(); | 2619 tag_freematch(); |
2621 | 2620 |
2622 # if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) | 2621 # if defined(FEAT_QUICKFIX) |
2623 if (ptag_entry.tagname) | 2622 if (ptag_entry.tagname) |
2624 { | 2623 { |
2625 vim_free(ptag_entry.tagname); | 2624 vim_free(ptag_entry.tagname); |
2626 ptag_entry.tagname = NULL; | 2625 ptag_entry.tagname = NULL; |
2627 } | 2626 } |
3091 int getfile_result = GETFILE_UNUSED; | 3090 int getfile_result = GETFILE_UNUSED; |
3092 int search_options; | 3091 int search_options; |
3093 #ifdef FEAT_SEARCH_EXTRA | 3092 #ifdef FEAT_SEARCH_EXTRA |
3094 int save_no_hlsearch; | 3093 int save_no_hlsearch; |
3095 #endif | 3094 #endif |
3096 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) | 3095 #if defined(FEAT_QUICKFIX) |
3097 win_T *curwin_save = NULL; | 3096 win_T *curwin_save = NULL; |
3098 #endif | 3097 #endif |
3099 char_u *full_fname = NULL; | 3098 char_u *full_fname = NULL; |
3100 #ifdef FEAT_FOLDING | 3099 #ifdef FEAT_FOLDING |
3101 int old_KeyTyped = KeyTyped; /* getting the file may reset it */ | 3100 int old_KeyTyped = KeyTyped; /* getting the file may reset it */ |
3174 | 3173 |
3175 #ifdef FEAT_GUI | 3174 #ifdef FEAT_GUI |
3176 need_mouse_correct = TRUE; | 3175 need_mouse_correct = TRUE; |
3177 #endif | 3176 #endif |
3178 | 3177 |
3179 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) | 3178 #if defined(FEAT_QUICKFIX) |
3180 if (g_do_tagpreview != 0) | 3179 if (g_do_tagpreview != 0) |
3181 { | 3180 { |
3182 postponed_split = 0; /* don't split again below */ | 3181 postponed_split = 0; /* don't split again below */ |
3183 curwin_save = curwin; /* Save current window */ | 3182 curwin_save = curwin; /* Save current window */ |
3184 | 3183 |
3238 | 3237 |
3239 if (keep_help) | 3238 if (keep_help) |
3240 { | 3239 { |
3241 /* A :ta from a help file will keep the b_help flag set. For ":ptag" | 3240 /* A :ta from a help file will keep the b_help flag set. For ":ptag" |
3242 * we need to use the flag from the window where we came from. */ | 3241 * we need to use the flag from the window where we came from. */ |
3243 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) | 3242 #if defined(FEAT_QUICKFIX) |
3244 if (g_do_tagpreview != 0) | 3243 if (g_do_tagpreview != 0) |
3245 keep_help_flag = curwin_save->w_buffer->b_help; | 3244 keep_help_flag = bt_help(curwin_save->w_buffer); |
3246 else | 3245 else |
3247 #endif | 3246 #endif |
3248 keep_help_flag = curbuf->b_help; | 3247 keep_help_flag = curbuf->b_help; |
3249 } | 3248 } |
3250 if (getfile_result == GETFILE_UNUSED) | 3249 if (getfile_result == GETFILE_UNUSED) |
3252 keep_help_flag = FALSE; | 3251 keep_help_flag = FALSE; |
3253 | 3252 |
3254 if (GETFILE_SUCCESS(getfile_result)) /* got to the right file */ | 3253 if (GETFILE_SUCCESS(getfile_result)) /* got to the right file */ |
3255 { | 3254 { |
3256 curwin->w_set_curswant = TRUE; | 3255 curwin->w_set_curswant = TRUE; |
3257 #ifdef FEAT_WINDOWS | |
3258 postponed_split = 0; | 3256 postponed_split = 0; |
3259 #endif | |
3260 | 3257 |
3261 save_secure = secure; | 3258 save_secure = secure; |
3262 secure = 1; | 3259 secure = 1; |
3263 #ifdef HAVE_SANDBOX | 3260 #ifdef HAVE_SANDBOX |
3264 ++sandbox; | 3261 ++sandbox; |
3415 if ((fdo_flags & FDO_TAG) && old_KeyTyped) | 3412 if ((fdo_flags & FDO_TAG) && old_KeyTyped) |
3416 foldOpenCursor(); | 3413 foldOpenCursor(); |
3417 #endif | 3414 #endif |
3418 } | 3415 } |
3419 | 3416 |
3420 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) | 3417 #if defined(FEAT_QUICKFIX) |
3421 if (g_do_tagpreview != 0 | 3418 if (g_do_tagpreview != 0 |
3422 && curwin != curwin_save && win_valid(curwin_save)) | 3419 && curwin != curwin_save && win_valid(curwin_save)) |
3423 { | 3420 { |
3424 /* Return cursor to where we were */ | 3421 /* Return cursor to where we were */ |
3425 validate_cursor(); | 3422 validate_cursor(); |
3431 --RedrawingDisabled; | 3428 --RedrawingDisabled; |
3432 } | 3429 } |
3433 else | 3430 else |
3434 { | 3431 { |
3435 --RedrawingDisabled; | 3432 --RedrawingDisabled; |
3436 #ifdef FEAT_WINDOWS | |
3437 if (postponed_split) /* close the window */ | 3433 if (postponed_split) /* close the window */ |
3438 { | 3434 { |
3439 win_close(curwin, FALSE); | 3435 win_close(curwin, FALSE); |
3440 postponed_split = 0; | 3436 postponed_split = 0; |
3441 } | 3437 } |
3442 #endif | |
3443 } | 3438 } |
3444 | 3439 |
3445 erret: | 3440 erret: |
3446 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) | 3441 #if defined(FEAT_QUICKFIX) |
3447 g_do_tagpreview = 0; /* For next time */ | 3442 g_do_tagpreview = 0; /* For next time */ |
3448 #endif | 3443 #endif |
3449 if (tagp.fname_end != NULL) | 3444 if (tagp.fname_end != NULL) |
3450 *tagp.fname_end = csave; | 3445 *tagp.fname_end = csave; |
3451 vim_free(pbuf); | 3446 vim_free(pbuf); |