From 4033c55eca575777718c0701e26635a0cc47d907 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 16 Sep 2017 20:54:51 +0200 Subject: 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. --- src/option.c | 147 ++++------------------------------------------------------- 1 file changed, 10 insertions(+), 137 deletions(-) (limited to 'src/option.c') diff --git a/src/option.c b/src/option.c index 828d9eb464..4e2b929693 100644 --- a/src/option.c +++ b/src/option.c @@ -222,7 +222,7 @@ #ifdef FEAT_LINEBREAK # define PV_NUW OPT_WIN(WV_NUW) #endif -#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) +#if defined(FEAT_QUICKFIX) # define PV_PVW OPT_WIN(WV_PVW) #endif #ifdef FEAT_RIGHTLEFT @@ -245,10 +245,8 @@ # define PV_STL OPT_BOTH(OPT_WIN(WV_STL)) #endif #define PV_UL OPT_BOTH(OPT_BUF(BV_UL)) -#ifdef FEAT_WINDOWS # define PV_WFH OPT_WIN(WV_WFH) # define PV_WFW OPT_WIN(WV_WFW) -#endif #define PV_WRAP OPT_WIN(WV_WRAP) #ifdef FEAT_CURSORBIND # define PV_CRBIND OPT_WIN(WV_CRBIND) @@ -475,16 +473,7 @@ struct vimoption # define ISP_LATIN1 (char_u *)"@,161-255" #endif -/* Make the string as short as possible when compiling with few features. */ -#if defined(FEAT_DIFF) || defined(FEAT_FOLDING) || defined(FEAT_SPELL) \ - || defined(FEAT_WINDOWS) || defined(FEAT_CLIPBOARD) \ - || defined(FEAT_INS_EXPAND) || defined(FEAT_SYN_HL) \ - || defined(FEAT_CONCEAL) || defined(FEAT_QUICKFIX) \ - || defined(FEAT_TERMINAL) # define HIGHLIGHT_INIT "8:SpecialKey,~:EndOfBuffer,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,N:CursorLineNr,r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn,-:Conceal,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel,x:PmenuSbar,X:PmenuThumb,*:TabLine,#:TabLineSel,_:TabLineFill,!:CursorColumn,.:CursorLine,o:ColorColumn,q:QuickFixLine,z:StatusLineTerm,Z:StatusLineTermNC" -#else -# define HIGHLIGHT_INIT "8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,N:CursorLineNr,r:Question,s:StatusLine,S:StatusLineNC,t:Title,v:Visual,w:WarningMsg,W:WildMenu,>:SignColumn,*:TabLine,#:TabLineSel,_:TabLineFill" -#endif /* Default python version for pyx* commands */ #if defined(FEAT_PYTHON) && defined(FEAT_PYTHON3) @@ -1069,13 +1058,8 @@ static struct vimoption options[] = (char_u *)&p_dy, PV_NONE, {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, {"eadirection", "ead", P_STRING|P_VI_DEF, -#ifdef FEAT_WINDOWS (char_u *)&p_ead, PV_NONE, {(char_u *)"both", (char_u *)0L} -#else - (char_u *)NULL, PV_NONE, - {(char_u *)NULL, (char_u *)0L} -#endif SCRIPTID_INIT}, {"edcompatible","ed", P_BOOL|P_VI_DEF, (char_u *)&p_ed, PV_NONE, @@ -1190,13 +1174,8 @@ static struct vimoption options[] = #endif SCRIPTID_INIT}, {"fillchars", "fcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP, -#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) (char_u *)&p_fcs, PV_NONE, {(char_u *)"vert:|,fold:-", (char_u *)0L} -#else - (char_u *)NULL, PV_NONE, - {(char_u *)"", (char_u *)0L} -#endif SCRIPTID_INIT}, {"fixendofline", "fixeol", P_BOOL|P_VI_DEF|P_RSTAT, (char_u *)&p_fixeol, PV_FIXEOL, @@ -1495,11 +1474,7 @@ static struct vimoption options[] = {(char_u *)DFLT_HELPFILE, (char_u *)0L} SCRIPTID_INIT}, {"helpheight", "hh", P_NUM|P_VI_DEF, -#ifdef FEAT_WINDOWS (char_u *)&p_hh, PV_NONE, -#else - (char_u *)NULL, PV_NONE, -#endif {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT}, {"helplang", "hlg", P_STRING|P_VI_DEF|P_ONECOMMA, #ifdef FEAT_MULTI_LANG @@ -1806,11 +1781,7 @@ static struct vimoption options[] = #endif {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, {"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL, -#ifdef FEAT_WINDOWS (char_u *)&p_ls, PV_NONE, -#else - (char_u *)NULL, PV_NONE, -#endif {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT}, {"lazyredraw", "lz", P_BOOL|P_VI_DEF, (char_u *)&p_lz, PV_NONE, @@ -2139,14 +2110,14 @@ static struct vimoption options[] = (char_u *)&p_pi, PV_PI, {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, {"previewheight", "pvh", P_NUM|P_VI_DEF, -#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) +#if defined(FEAT_QUICKFIX) (char_u *)&p_pvh, PV_NONE, #else (char_u *)NULL, PV_NONE, #endif {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT}, {"previewwindow", "pvw", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB, -#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) +#if defined(FEAT_QUICKFIX) (char_u *)VAR_WIN, PV_PVW, #else (char_u *)NULL, PV_NONE, @@ -2539,11 +2510,7 @@ static struct vimoption options[] = (char_u *)&p_smd, PV_NONE, {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT}, {"showtabline", "stal", P_NUM|P_VI_DEF|P_RALL, -#ifdef FEAT_WINDOWS (char_u *)&p_stal, PV_NONE, -#else - (char_u *)NULL, PV_NONE, -#endif {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT}, {"sidescroll", "ss", P_NUM|P_VI_DEF, (char_u *)&p_ss, PV_NONE, @@ -2628,18 +2595,10 @@ static struct vimoption options[] = #endif SCRIPTID_INIT}, {"splitbelow", "sb", P_BOOL|P_VI_DEF, -#ifdef FEAT_WINDOWS (char_u *)&p_sb, PV_NONE, -#else - (char_u *)NULL, PV_NONE, -#endif {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, {"splitright", "spr", P_BOOL|P_VI_DEF, -#ifdef FEAT_WINDOWS (char_u *)&p_spr, PV_NONE, -#else - (char_u *)NULL, PV_NONE, -#endif {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, {"startofline", "sol", P_BOOL|P_VI_DEF|P_VIM, (char_u *)&p_sol, PV_NONE, @@ -2699,11 +2658,7 @@ static struct vimoption options[] = #endif {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, {"tabpagemax", "tpm", P_NUM|P_VI_DEF, -#ifdef FEAT_WINDOWS (char_u *)&p_tpm, PV_NONE, -#else - (char_u *)NULL, PV_NONE, -#endif {(char_u *)10L, (char_u *)0L} SCRIPTID_INIT}, {"tabstop", "ts", P_NUM|P_VI_DEF|P_RBUF, (char_u *)&p_ts, PV_TS, @@ -3067,39 +3022,19 @@ static struct vimoption options[] = (char_u *)&p_window, PV_NONE, {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, {"winheight", "wh", P_NUM|P_VI_DEF, -#ifdef FEAT_WINDOWS (char_u *)&p_wh, PV_NONE, -#else - (char_u *)NULL, PV_NONE, -#endif {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT}, {"winfixheight", "wfh", P_BOOL|P_VI_DEF|P_RSTAT, -#ifdef FEAT_WINDOWS (char_u *)VAR_WIN, PV_WFH, -#else - (char_u *)NULL, PV_NONE, -#endif {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, {"winfixwidth", "wfw", P_BOOL|P_VI_DEF|P_RSTAT, -#ifdef FEAT_WINDOWS (char_u *)VAR_WIN, PV_WFW, -#else - (char_u *)NULL, PV_NONE, -#endif {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, {"winminheight", "wmh", P_NUM|P_VI_DEF, -#ifdef FEAT_WINDOWS (char_u *)&p_wmh, PV_NONE, -#else - (char_u *)NULL, PV_NONE, -#endif {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT}, {"winminwidth", "wmw", P_NUM|P_VI_DEF, -#ifdef FEAT_WINDOWS (char_u *)&p_wmw, PV_NONE, -#else - (char_u *)NULL, PV_NONE, -#endif {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT}, {"winptydll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, #if defined(WIN3264) && defined(FEAT_TERMINAL) @@ -3116,11 +3051,7 @@ static struct vimoption options[] = #endif SCRIPTID_INIT}, {"winwidth", "wiw", P_NUM|P_VI_DEF, -#ifdef FEAT_WINDOWS (char_u *)&p_wiw, PV_NONE, -#else - (char_u *)NULL, PV_NONE, -#endif {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT}, {"wrap", NULL, P_BOOL|P_VI_DEF|P_RWIN, (char_u *)VAR_WIN, PV_WRAP, @@ -3171,9 +3102,7 @@ static struct vimoption options[] = p_term("t_CS", T_CCS) p_term("t_Cs", T_UCS) p_term("t_cs", T_CS) -#ifdef FEAT_WINDOWS p_term("t_CV", T_CSV) -#endif p_term("t_da", T_DA) p_term("t_db", T_DB) p_term("t_DL", T_CDL) @@ -3265,9 +3194,7 @@ static char *(p_bsdir_values[]) = {"current", "last", "buffer", NULL}; static char *(p_scbopt_values[]) = {"ver", "hor", "jump", NULL}; #endif static char *(p_debug_values[]) = {"msg", "throw", "beep", NULL}; -#ifdef FEAT_WINDOWS static char *(p_ead_values[]) = {"both", "ver", "hor", NULL}; -#endif #ifdef FEAT_AUTOCMD static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "terminal", "acwrite", NULL}; #else @@ -3855,10 +3782,8 @@ set_options_default( int opt_flags) /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */ { int i; -#ifdef FEAT_WINDOWS win_T *wp; tabpage_T *tp; -#endif for (i = 0; !istermoption(&options[i]); i++) if (!(options[i].flags & P_NODEFAULT) @@ -3877,13 +3802,9 @@ set_options_default( ) set_option_default(i, opt_flags, p_cp); -#ifdef FEAT_WINDOWS /* The 'scroll' option must be computed for all windows. */ FOR_ALL_TAB_WINDOWS(tp, wp) win_comp_scroll(wp); -#else - win_comp_scroll(curwin); -#endif #ifdef FEAT_CINDENT parse_cino(curbuf); #endif @@ -5633,10 +5554,8 @@ didset_options2(void) check_opt_wim(); (void)set_chars_option(&p_lcs); -#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) /* Parse default for 'fillchars'. */ (void)set_chars_option(&p_fcs); -#endif #ifdef FEAT_CLIPBOARD /* Parse default for 'clipboard' */ @@ -5875,9 +5794,7 @@ static void redraw_titles(void); static void redraw_titles(void) { need_maketitle = TRUE; -# ifdef FEAT_WINDOWS redraw_tabline = TRUE; -# endif } #endif @@ -6280,10 +6197,8 @@ did_set_string_option( errmsg = e_invarg; else if (set_chars_option(&p_lcs) != NULL) errmsg = (char_u *)_("E834: Conflicts with value of 'listchars'"); -# if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) else if (set_chars_option(&p_fcs) != NULL) errmsg = (char_u *)_("E835: Conflicts with value of 'fillchars'"); -# endif } #endif @@ -6503,9 +6418,7 @@ did_set_string_option( set_iminsert_global(); set_imsearch_global(); } -# ifdef FEAT_WINDOWS status_redraw_curbuf(); -# endif } } #endif @@ -6708,13 +6621,11 @@ did_set_string_option( errmsg = set_chars_option(varp); } -#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) /* 'fillchars' */ else if (varp == &p_fcs) { errmsg = set_chars_option(varp); } -#endif #ifdef FEAT_CMDWIN /* 'cedit' */ @@ -7088,14 +6999,12 @@ did_set_string_option( } -#ifdef FEAT_WINDOWS /* 'eadirection' */ else if (varp == &p_ead) { if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK) errmsg = e_invarg; } -#endif #ifdef FEAT_CLIPBOARD /* 'clipboard' */ @@ -7144,13 +7053,11 @@ did_set_string_option( errmsg = e_invarg; else { -#ifdef FEAT_WINDOWS if (curwin->w_status_height) { curwin->w_redr_status = TRUE; redraw_later(VALID); } -#endif curbuf->b_help = (curbuf->b_p_bt[0] == 'h'); #ifdef FEAT_TITLE redraw_titles(); @@ -7773,7 +7680,6 @@ set_chars_option(char_u **varp) int *cp; char *name; }; -#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) static struct charstab filltab[] = { {&fill_stl, "stl"}, @@ -7782,7 +7688,6 @@ set_chars_option(char_u **varp) {&fill_fold, "fold"}, {&fill_diff, "diff"}, }; -#endif static struct charstab lcstab[] = { {&lcs_eol, "eol"}, @@ -7800,20 +7705,16 @@ set_chars_option(char_u **varp) }; struct charstab *tab; -#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) if (varp == &p_lcs) -#endif { tab = lcstab; entries = sizeof(lcstab) / sizeof(struct charstab); } -#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) else { tab = filltab; entries = sizeof(filltab) / sizeof(struct charstab); } -#endif /* first round: check for valid value, second round: assign values */ for (round = 0; round <= 1; ++round) @@ -7827,10 +7728,8 @@ set_chars_option(char_u **varp) *(tab[i].cp) = (varp == &p_lcs ? NUL : ' '); if (varp == &p_lcs) lcs_tab1 = NUL; -#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) else fill_diff = '-'; -#endif } p = *varp; while (*p) @@ -8077,9 +7976,7 @@ did_set_spell_option(int is_spellfile) if (wp->w_buffer == curbuf && wp->w_p_spell) { errmsg = did_set_spelllang(wp); -# ifdef FEAT_WINDOWS break; -# endif } } return errmsg; @@ -8388,7 +8285,7 @@ set_bool_option( } #endif -#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) +#if defined(FEAT_QUICKFIX) /* There can be only one window with 'previewwindow' set. */ else if ((int *)varp == &curwin->w_p_pvw) { @@ -8486,13 +8383,11 @@ set_bool_option( curwin->w_leftcol = 0; } -#ifdef FEAT_WINDOWS else if ((int *)varp == &p_ea) { if (p_ea && !old_value) win_equal(curwin, FALSE, 0); } -#endif else if ((int *)varp == &p_wiv) { @@ -8803,7 +8698,6 @@ set_num_option( /* * Number options that need some action when changed */ -#ifdef FEAT_WINDOWS if (pp == &p_wh || pp == &p_hh) { if (p_wh < 1) @@ -8847,8 +8741,6 @@ set_num_option( } win_setminheight(); } - -# ifdef FEAT_WINDOWS else if (pp == &p_wiw) { if (p_wiw < 1) @@ -8882,11 +8774,7 @@ set_num_option( } win_setminheight(); } -# endif - -#endif -#ifdef FEAT_WINDOWS /* (re)set last window status line */ else if (pp == &p_ls) { @@ -8898,7 +8786,6 @@ set_num_option( { shell_new_rows(); /* recompute window positions and heights */ } -#endif #ifdef FEAT_GUI else if (pp == &p_linespace) @@ -8987,7 +8874,7 @@ set_num_option( p_iminsert = curbuf->b_p_iminsert; if (termcap_active) /* don't do this in the alternate screen */ showmode(); -#if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP) +#if defined(FEAT_KEYMAP) /* Show/unshow value of 'keymap' in status lines. */ status_redraw_curbuf(); #endif @@ -9137,7 +9024,6 @@ set_num_option( curbuf->b_p_tw = 0; } #ifdef FEAT_SYN_HL -# ifdef FEAT_WINDOWS { win_T *wp; tabpage_T *tp; @@ -9145,9 +9031,6 @@ set_num_option( FOR_ALL_TAB_WINDOWS(tp, wp) check_colorcolumn(wp); } -# else - check_colorcolumn(curwin); -# endif #endif } @@ -9329,10 +9212,8 @@ check_redraw(long_u flags) int doclear = (flags & P_RCLR) == P_RCLR; int all = ((flags & P_RALL) == P_RALL || doclear); -#ifdef FEAT_WINDOWS if ((flags & P_RSTAT) || all) /* mark all status lines dirty */ status_redraw_all(); -#endif if ((flags & P_RBUF) || (flags & P_RWIN) || all) changed_window_setting(); @@ -10420,18 +10301,18 @@ istermoption(struct vimoption *p) void comp_col(void) { -#if defined(FEAT_CMDL_INFO) && defined(FEAT_WINDOWS) +#if defined(FEAT_CMDL_INFO) int last_has_status = (p_ls == 2 || (p_ls == 1 && !ONE_WINDOW)); sc_col = 0; ru_col = 0; if (p_ru) { -#ifdef FEAT_STL_OPT +# ifdef FEAT_STL_OPT ru_col = (ru_wid ? ru_wid : COL_RULER) + 1; -#else +# else ru_col = COL_RULER + 1; -#endif +# endif /* no last status line, adjust sc_col */ if (!last_has_status) sc_col = ru_col; @@ -10723,11 +10604,9 @@ get_varp(struct vimoption *p) #ifdef FEAT_LINEBREAK case PV_NUW: return (char_u *)&(curwin->w_p_nuw); #endif -#ifdef FEAT_WINDOWS case PV_WFH: return (char_u *)&(curwin->w_p_wfh); case PV_WFW: return (char_u *)&(curwin->w_p_wfw); -#endif -#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) +#if defined(FEAT_QUICKFIX) case PV_PVW: return (char_u *)&(curwin->w_p_pvw); #endif #ifdef FEAT_RIGHTLEFT @@ -10879,7 +10758,6 @@ get_equalprg(void) return curbuf->b_p_ep; } -#if defined(FEAT_WINDOWS) || defined(PROTO) /* * Copy options from one window to another. * Used when splitting a window. @@ -10899,7 +10777,6 @@ win_copy_options(win_T *wp_from, win_T *wp_to) briopt_check(wp_to); #endif } -#endif /* * Copy the options from one winopt_T to another. @@ -12176,10 +12053,8 @@ paste_option_changed(void) p_sm = 0; /* no showmatch */ p_sta = 0; /* no smarttab */ #ifdef FEAT_CMDL_INFO -# ifdef FEAT_WINDOWS if (p_ru) status_redraw_all(); /* redraw to remove the ruler */ -# endif p_ru = 0; /* no ruler */ #endif #ifdef FEAT_RIGHTLEFT @@ -12212,10 +12087,8 @@ paste_option_changed(void) p_sm = save_sm; p_sta = save_sta; #ifdef FEAT_CMDL_INFO -# ifdef FEAT_WINDOWS if (p_ru != save_ru) status_redraw_all(); /* redraw to draw the ruler */ -# endif p_ru = save_ru; #endif #ifdef FEAT_RIGHTLEFT -- cgit v1.2.3