Skip to content

Commit 8c96af9

Browse files
committed
patch 8.1.2096: too many #ifdefs
Problem: Too many #ifdefs. Solution: Graduate FEAT_COMMENTS.
1 parent a893194 commit 8c96af9

21 files changed

Lines changed: 44 additions & 231 deletions

runtime/doc/change.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,8 +1618,6 @@ By default, "b:#" is included. This means that a line that starts with
16181618
"#include" is not recognized as a comment line. But a line that starts with
16191619
"# define" is recognized. This is a compromise.
16201620

1621-
{not available when compiled without the |+comments| feature}
1622-
16231621
*fo-table*
16241622
You can use the 'formatoptions' option to influence how Vim formats text.
16251623
'formatoptions' is a string that can contain any of the letters below. The

runtime/doc/options.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,8 +1685,6 @@ A jump table for the options with a short description can be found at |Q_op|.
16851685
'comments' 'com' string (default
16861686
"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-")
16871687
local to buffer
1688-
{not available when compiled without the |+comments|
1689-
feature}
16901688
A comma separated list of strings that can start a comment line. See
16911689
|format-comments|. See |option-backslash| about using backslashes to
16921690
insert a space.

runtime/doc/various.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*various.txt* For Vim version 8.1. Last change: 2019 Sep 04
1+
*various.txt* For Vim version 8.1. Last change: 2019 Sep 28
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -337,7 +337,7 @@ N *+clientserver* Unix and Win32: Remote invocation |clientserver|
337337
T *+cmdline_compl* command line completion |cmdline-completion|
338338
S *+cmdline_hist* command line history |cmdline-history|
339339
N *+cmdline_info* |'showcmd'| and |'ruler'|
340-
N *+comments* |'comments'| support
340+
T *+comments* |'comments'| support
341341
B *+conceal* "conceal" support, see |conceal| |:syn-conceal| etc.
342342
N *+cryptv* encryption support |encryption|
343343
B *+cscope* |cscope| support

src/buffer.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2226,9 +2226,7 @@ free_buf_options(
22262226
keymap_clear(&buf->b_kmap_ga);
22272227
ga_clear(&buf->b_kmap_ga);
22282228
#endif
2229-
#ifdef FEAT_COMMENTS
22302229
clear_string_option(&buf->b_p_com);
2231-
#endif
22322230
#ifdef FEAT_FOLDING
22332231
clear_string_option(&buf->b_p_cms);
22342232
#endif

src/change.c

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,18 +1414,14 @@ open_line(
14141414
int n;
14151415
int trunc_line = FALSE; // truncate current line afterwards
14161416
int retval = FAIL; // return value
1417-
#ifdef FEAT_COMMENTS
14181417
int extra_len = 0; // length of p_extra string
14191418
int lead_len; // length of comment leader
14201419
char_u *lead_flags; // position in 'comments' for comment leader
14211420
char_u *leader = NULL; // copy of comment leader
1422-
#endif
14231421
char_u *allocated = NULL; // allocated memory
14241422
char_u *p;
14251423
int saved_char = NUL; // init for GCC
1426-
#if defined(FEAT_SMARTINDENT) || defined(FEAT_COMMENTS)
14271424
pos_T *pos;
1428-
#endif
14291425
#ifdef FEAT_SMARTINDENT
14301426
int do_si = (!p_paste && curbuf->b_p_si
14311427
# ifdef FEAT_CINDENT
@@ -1493,9 +1489,7 @@ open_line(
14931489
first_char = *p;
14941490
}
14951491
#endif
1496-
#ifdef FEAT_COMMENTS
14971492
extra_len = (int)STRLEN(p_extra);
1498-
#endif
14991493
saved_char = *p_extra;
15001494
*p_extra = NUL;
15011495
}
@@ -1544,27 +1538,20 @@ open_line(
15441538

15451539
old_cursor = curwin->w_cursor;
15461540
ptr = saved_line;
1547-
# ifdef FEAT_COMMENTS
15481541
if (flags & OPENLINE_DO_COM)
15491542
lead_len = get_leader_len(ptr, NULL, FALSE, TRUE);
15501543
else
15511544
lead_len = 0;
1552-
# endif
15531545
if (dir == FORWARD)
15541546
{
15551547
// Skip preprocessor directives, unless they are
15561548
// recognised as comments.
1557-
if (
1558-
# ifdef FEAT_COMMENTS
1559-
lead_len == 0 &&
1560-
# endif
1561-
ptr[0] == '#')
1549+
if ( lead_len == 0 && ptr[0] == '#')
15621550
{
15631551
while (ptr[0] == '#' && curwin->w_cursor.lnum > 1)
15641552
ptr = ml_get(--curwin->w_cursor.lnum);
15651553
newindent = get_indent();
15661554
}
1567-
# ifdef FEAT_COMMENTS
15681555
if (flags & OPENLINE_DO_COM)
15691556
lead_len = get_leader_len(ptr, NULL, FALSE, TRUE);
15701557
else
@@ -1600,7 +1587,6 @@ open_line(
16001587
}
16011588
}
16021589
else // Not a comment line
1603-
# endif
16041590
{
16051591
// Find last non-blank in line
16061592
p = ptr + STRLEN(ptr) - 1;
@@ -1651,11 +1637,7 @@ open_line(
16511637
{
16521638
// Skip preprocessor directives, unless they are
16531639
// recognised as comments.
1654-
if (
1655-
# ifdef FEAT_COMMENTS
1656-
lead_len == 0 &&
1657-
# endif
1658-
ptr[0] == '#')
1640+
if (lead_len == 0 && ptr[0] == '#')
16591641
{
16601642
int was_backslashed = FALSE;
16611643

@@ -1688,7 +1670,6 @@ open_line(
16881670
did_ai = TRUE;
16891671
}
16901672

1691-
#ifdef FEAT_COMMENTS
16921673
// Find out if the current line starts with a comment leader.
16931674
// This may then be inserted in front of the new line.
16941675
end_comment_pending = NUL;
@@ -2086,7 +2067,6 @@ open_line(
20862067
}
20872068
}
20882069
}
2089-
#endif
20902070

20912071
// (State == INSERT || State == REPLACE), only when dir == FORWARD
20922072
if (p_extra != NULL)
@@ -2120,7 +2100,6 @@ open_line(
21202100
if (p_extra == NULL)
21212101
p_extra = (char_u *)""; // append empty line
21222102

2123-
#ifdef FEAT_COMMENTS
21242103
// concatenate leader and p_extra, if there is a leader
21252104
if (lead_len)
21262105
{
@@ -2147,7 +2126,6 @@ open_line(
21472126
}
21482127
else
21492128
end_comment_pending = NUL; // turns out there was no leader
2150-
#endif
21512129

21522130
old_cursor = curwin->w_cursor;
21532131
if (dir == BACKWARD)
@@ -2237,13 +2215,11 @@ open_line(
22372215
#endif
22382216
}
22392217

2240-
#ifdef FEAT_COMMENTS
22412218
// In REPLACE mode, for each character in the extra leader, there must be
22422219
// a NUL on the replace stack, for when it is deleted with BS.
22432220
if (REPLACE_NORMAL(State))
22442221
while (lead_len-- > 0)
22452222
replace_push(NUL);
2246-
#endif
22472223

22482224
curwin->w_cursor = old_cursor;
22492225

@@ -2299,9 +2275,7 @@ open_line(
22992275
#ifdef FEAT_LISP
23002276
// May do lisp indenting.
23012277
if (!p_paste
2302-
# ifdef FEAT_COMMENTS
23032278
&& leader == NULL
2304-
# endif
23052279
&& curbuf->b_p_lisp
23062280
&& curbuf->b_p_ai)
23072281
{

0 commit comments

Comments
 (0)