summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-09-28 19:05:57 +0200
committerBram Moolenaar <Bram@vim.org>2019-09-28 19:05:57 +0200
commit8c96af9c05bfcac2d5ae081e098d4863db561511 (patch)
treeaa01cdaf87cf8050334c8cb20014774623614e73
parenta893194d91a2942d4d54085d746ed137a9251b69 (diff)
downloadvim-git-8c96af9c05bfcac2d5ae081e098d4863db561511.tar.gz
patch 8.1.2096: too many #ifdefsv8.1.2096
Problem: Too many #ifdefs. Solution: Graduate FEAT_COMMENTS.
-rw-r--r--runtime/doc/change.txt2
-rw-r--r--runtime/doc/options.txt2
-rw-r--r--runtime/doc/various.txt4
-rw-r--r--src/buffer.c2
-rw-r--r--src/change.c30
-rw-r--r--src/edit.c65
-rw-r--r--src/evalfunc.c2
-rw-r--r--src/feature.h8
-rw-r--r--src/fold.c2
-rw-r--r--src/globals.h2
-rw-r--r--src/insexpand.c4
-rw-r--r--src/misc1.c7
-rw-r--r--src/normal.c8
-rw-r--r--src/ops.c106
-rw-r--r--src/option.c4
-rw-r--r--src/option.h4
-rw-r--r--src/optiondefs.h9
-rw-r--r--src/optionstr.c4
-rw-r--r--src/search.c2
-rw-r--r--src/structs.h2
-rw-r--r--src/version.c6
21 files changed, 44 insertions, 231 deletions
diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt
index 345bc8f61..542d97217 100644
--- a/runtime/doc/change.txt
+++ b/runtime/doc/change.txt
@@ -1618,8 +1618,6 @@ By default, "b:#" is included. This means that a line that starts with
"#include" is not recognized as a comment line. But a line that starts with
"# define" is recognized. This is a compromise.
-{not available when compiled without the |+comments| feature}
-
*fo-table*
You can use the 'formatoptions' option to influence how Vim formats text.
'formatoptions' is a string that can contain any of the letters below. The
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index d216f0ca5..cb65535bb 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -1685,8 +1685,6 @@ A jump table for the options with a short description can be found at |Q_op|.
'comments' 'com' string (default
"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-")
local to buffer
- {not available when compiled without the |+comments|
- feature}
A comma separated list of strings that can start a comment line. See
|format-comments|. See |option-backslash| about using backslashes to
insert a space.
diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt
index f251613ca..8f3d94646 100644
--- a/runtime/doc/various.txt
+++ b/runtime/doc/various.txt
@@ -1,4 +1,4 @@
-*various.txt* For Vim version 8.1. Last change: 2019 Sep 04
+*various.txt* For Vim version 8.1. Last change: 2019 Sep 28
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -337,7 +337,7 @@ N *+clientserver* Unix and Win32: Remote invocation |clientserver|
T *+cmdline_compl* command line completion |cmdline-completion|
S *+cmdline_hist* command line history |cmdline-history|
N *+cmdline_info* |'showcmd'| and |'ruler'|
-N *+comments* |'comments'| support
+T *+comments* |'comments'| support
B *+conceal* "conceal" support, see |conceal| |:syn-conceal| etc.
N *+cryptv* encryption support |encryption|
B *+cscope* |cscope| support
diff --git a/src/buffer.c b/src/buffer.c
index 4f754f545..aa1770a94 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -2226,9 +2226,7 @@ free_buf_options(
keymap_clear(&buf->b_kmap_ga);
ga_clear(&buf->b_kmap_ga);
#endif
-#ifdef FEAT_COMMENTS
clear_string_option(&buf->b_p_com);
-#endif
#ifdef FEAT_FOLDING
clear_string_option(&buf->b_p_cms);
#endif
diff --git a/src/change.c b/src/change.c
index 8eec45257..6b402f189 100644
--- a/src/change.c
+++ b/src/change.c
@@ -1414,18 +1414,14 @@ open_line(
int n;
int trunc_line = FALSE; // truncate current line afterwards
int retval = FAIL; // return value
-#ifdef FEAT_COMMENTS
int extra_len = 0; // length of p_extra string
int lead_len; // length of comment leader
char_u *lead_flags; // position in 'comments' for comment leader
char_u *leader = NULL; // copy of comment leader
-#endif
char_u *allocated = NULL; // allocated memory
char_u *p;
int saved_char = NUL; // init for GCC
-#if defined(FEAT_SMARTINDENT) || defined(FEAT_COMMENTS)
pos_T *pos;
-#endif
#ifdef FEAT_SMARTINDENT
int do_si = (!p_paste && curbuf->b_p_si
# ifdef FEAT_CINDENT
@@ -1493,9 +1489,7 @@ open_line(
first_char = *p;
}
#endif
-#ifdef FEAT_COMMENTS
extra_len = (int)STRLEN(p_extra);
-#endif
saved_char = *p_extra;
*p_extra = NUL;
}
@@ -1544,27 +1538,20 @@ open_line(
old_cursor = curwin->w_cursor;
ptr = saved_line;
-# ifdef FEAT_COMMENTS
if (flags & OPENLINE_DO_COM)
lead_len = get_leader_len(ptr, NULL, FALSE, TRUE);
else
lead_len = 0;
-# endif
if (dir == FORWARD)
{
// Skip preprocessor directives, unless they are
// recognised as comments.
- if (
-# ifdef FEAT_COMMENTS
- lead_len == 0 &&
-# endif
- ptr[0] == '#')
+ if ( lead_len == 0 && ptr[0] == '#')
{
while (ptr[0] == '#' && curwin->w_cursor.lnum > 1)
ptr = ml_get(--curwin->w_cursor.lnum);
newindent = get_indent();
}
-# ifdef FEAT_COMMENTS
if (flags & OPENLINE_DO_COM)
lead_len = get_leader_len(ptr, NULL, FALSE, TRUE);
else
@@ -1600,7 +1587,6 @@ open_line(
}
}
else // Not a comment line
-# endif
{
// Find last non-blank in line
p = ptr + STRLEN(ptr) - 1;
@@ -1651,11 +1637,7 @@ open_line(
{
// Skip preprocessor directives, unless they are
// recognised as comments.
- if (
-# ifdef FEAT_COMMENTS
- lead_len == 0 &&
-# endif
- ptr[0] == '#')
+ if (lead_len == 0 && ptr[0] == '#')
{
int was_backslashed = FALSE;
@@ -1688,7 +1670,6 @@ open_line(
did_ai = TRUE;
}
-#ifdef FEAT_COMMENTS
// Find out if the current line starts with a comment leader.
// This may then be inserted in front of the new line.
end_comment_pending = NUL;
@@ -2086,7 +2067,6 @@ open_line(
}
}
}
-#endif
// (State == INSERT || State == REPLACE), only when dir == FORWARD
if (p_extra != NULL)
@@ -2120,7 +2100,6 @@ open_line(
if (p_extra == NULL)
p_extra = (char_u *)""; // append empty line
-#ifdef FEAT_COMMENTS
// concatenate leader and p_extra, if there is a leader
if (lead_len)
{
@@ -2147,7 +2126,6 @@ open_line(
}
else
end_comment_pending = NUL; // turns out there was no leader
-#endif
old_cursor = curwin->w_cursor;
if (dir == BACKWARD)
@@ -2237,13 +2215,11 @@ open_line(
#endif
}
-#ifdef FEAT_COMMENTS
// In REPLACE mode, for each character in the extra leader, there must be
// a NUL on the replace stack, for when it is deleted with BS.
if (REPLACE_NORMAL(State))
while (lead_len-- > 0)
replace_push(NUL);
-#endif
curwin->w_cursor = old_cursor;
@@ -2299,9 +2275,7 @@ open_line(
#ifdef FEAT_LISP
// May do lisp indenting.
if (!p_paste
-# ifdef FEAT_COMMENTS
&& leader == NULL
-# endif
&& curbuf->b_p_lisp
&& curbuf->b_p_ai)
{
diff --git a/src/edit.c b/src/edit.c
index c6486be3a..312095ed9 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -2272,9 +2272,7 @@ insertchar(
int second_indent) /* indent for second line if >= 0 */
{
int textwidth;
-#ifdef FEAT_COMMENTS
char_u *p;
-#endif
int fo_ins_blank;
int force_format = flags & INSCHAR_FORMAT;
@@ -2332,12 +2330,11 @@ insertchar(
if (c == NUL) /* only formatting was wanted */
return;
-#ifdef FEAT_COMMENTS
- /* Check whether this character should end a comment. */
+ // Check whether this character should end a comment.
if (did_ai && (int)c == end_comment_pending)
{
char_u *line;
- char_u lead_end[COM_MAX_LEN]; /* end-comment string */
+ char_u lead_end[COM_MAX_LEN]; // end-comment string
int middle_len, end_len;
int i;
@@ -2346,46 +2343,43 @@ insertchar(
* comment leader. First, check what comment leader we can find.
*/
i = get_leader_len(line = ml_get_curline(), &p, FALSE, TRUE);
- if (i > 0 && vim_strchr(p, COM_MIDDLE) != NULL) /* Just checking */
+ if (i > 0 && vim_strchr(p, COM_MIDDLE) != NULL) // Just checking
{
- /* Skip middle-comment string */
- while (*p && p[-1] != ':') /* find end of middle flags */
+ // Skip middle-comment string
+ while (*p && p[-1] != ':') // find end of middle flags
++p;
middle_len = copy_option_part(&p, lead_end, COM_MAX_LEN, ",");
- /* Don't count trailing white space for middle_len */
+ // Don't count trailing white space for middle_len
while (middle_len > 0 && VIM_ISWHITE(lead_end[middle_len - 1]))
--middle_len;
- /* Find the end-comment string */
- while (*p && p[-1] != ':') /* find end of end flags */
+ // Find the end-comment string
+ while (*p && p[-1] != ':') // find end of end flags
++p;
end_len = copy_option_part(&p, lead_end, COM_MAX_LEN, ",");
- /* Skip white space before the cursor */
+ // Skip white space before the cursor
i = curwin->w_cursor.col;
while (--i >= 0 && VIM_ISWHITE(line[i]))
;
i++;
- /* Skip to before the middle leader */
+ // Skip to before the middle leader
i -= middle_len;
- /* Check some expected things before we go on */
+ // Check some expected things before we go on
if (i >= 0 && lead_end[end_len - 1] == end_comment_pending)
{
- /* Backspace over all the stuff we want to replace */
+ // Backspace over all the stuff we want to replace
backspace_until_column(i);
- /*
- * Insert the end-comment string, except for the last
- * character, which will get inserted as normal later.
- */
+ // Insert the end-comment string, except for the last
+ // character, which will get inserted as normal later.
ins_bytes_len(lead_end, end_len - 1);
}
}
}
end_comment_pending = NUL;
-#endif
did_ai = FALSE;
#ifdef FEAT_SMARTINDENT
@@ -2518,11 +2512,9 @@ internal_format(
int fo_multibyte = has_format_option(FO_MBYTE_BREAK);
int fo_white_par = has_format_option(FO_WHITE_PAR);
int first_line = TRUE;
-#ifdef FEAT_COMMENTS
colnr_T leader_len;
int no_leader = FALSE;
int do_comments = (flags & INSCHAR_DO_COM);
-#endif
#ifdef FEAT_LINEBREAK
int has_lbr = curwin->w_p_lbr;
@@ -2566,7 +2558,6 @@ internal_format(
if (virtcol <= (colnr_T)textwidth)
break;
-#ifdef FEAT_COMMENTS
if (no_leader)
do_comments = FALSE;
else if (!(flags & INSCHAR_FORMAT)
@@ -2585,11 +2576,8 @@ internal_format(
* to start with %. */
if (leader_len == 0)
no_leader = TRUE;
-#endif
if (!(flags & INSCHAR_FORMAT)
-#ifdef FEAT_COMMENTS
&& leader_len == 0
-#endif
&& !has_format_option(FO_WRAP))
break;
@@ -2641,21 +2629,17 @@ internal_format(
if (has_format_option(FO_PERIOD_ABBR) && cc == '.' && wcc < 2)
continue;
-#ifdef FEAT_COMMENTS
/* Don't break until after the comment leader */
if (curwin->w_cursor.col < leader_len)
break;
-#endif
if (has_format_option(FO_ONE_LETTER))
{
/* do not break after one-letter words */
if (curwin->w_cursor.col == 0)
break; /* one-letter word at begin */
-#ifdef FEAT_COMMENTS
/* do not break "#a b" when 'tw' is 2 */
if (curwin->w_cursor.col <= leader_len)
break;
-#endif
col = curwin->w_cursor.col;
dec_cursor();
cc = gchar_cursor();
@@ -2677,11 +2661,9 @@ internal_format(
/* Break after or before a multi-byte character. */
if (curwin->w_cursor.col != startcol)
{
-#ifdef FEAT_COMMENTS
/* Don't break until after the comment leader */
if (curwin->w_cursor.col < leader_len)
break;
-#endif
col = curwin->w_cursor.col;
inc_cursor();
/* Don't change end_foundcol if already set. */
@@ -2705,11 +2687,9 @@ internal_format(
if (WHITECHAR(cc))
continue; /* break with space */
-#ifdef FEAT_COMMENTS
/* Don't break until after the comment leader */
if (curwin->w_cursor.col < leader_len)
break;
-#endif
curwin->w_cursor.col = col;
@@ -2783,10 +2763,8 @@ internal_format(
*/
open_line(FORWARD, OPENLINE_DELSPACES + OPENLINE_MARKFIX
+ (fo_white_par ? OPENLINE_KEEPTRAIL : 0)
-#ifdef FEAT_COMMENTS
+ (do_comments ? OPENLINE_DO_COM : 0)
+ ((flags & INSCHAR_COM_LIST) ? OPENLINE_COM_LIST : 0)
-#endif
, ((flags & INSCHAR_COM_LIST) ? second_indent : old_indent));
if (!(flags & INSCHAR_COM_LIST))
old_indent = 0;
@@ -2812,7 +2790,6 @@ internal_format(
change_indent(INDENT_SET, second_indent,
FALSE, NUL, TRUE);
else
-#ifdef FEAT_COMMENTS
if (leader_len > 0 && second_indent - leader_len > 0)
{
int i;
@@ -2829,11 +2806,8 @@ internal_format(
}
else
{
-#endif
(void)set_indent(second_indent, SIN_CHANGED);
-#ifdef FEAT_COMMENTS
}
-#endif
}
}
first_line = FALSE;
@@ -2937,13 +2911,11 @@ auto_format(
curwin->w_cursor = pos;
}
-#ifdef FEAT_COMMENTS
/* With the 'c' flag in 'formatoptions' and 't' missing: only format
* comments. */
if (has_format_option(FO_WRAP_COMS) && !has_format_option(FO_WRAP)
- && get_leader_len(old, NULL, FALSE, TRUE) == 0)
+ && get_leader_len(old, NULL, FALSE, TRUE) == 0)
return;
-#endif
/*
* May start formatting in a previous line, so that after "x" a word is
@@ -4796,9 +4768,7 @@ ins_bs(
if (in_indent)
can_cindent = FALSE;
#endif
-#ifdef FEAT_COMMENTS
end_comment_pending = NUL; /* After BS, don't auto-end comment */
-#endif
#ifdef FEAT_RIGHTLEFT
if (revins_on) /* put cursor after last inserted char */
inc_cursor();
@@ -5912,10 +5882,7 @@ ins_eol(int c)
AppendToRedobuff(NL_STR);
i = open_line(FORWARD,
-#ifdef FEAT_COMMENTS
- has_format_option(FO_RET_COMS) ? OPENLINE_DO_COM :
-#endif
- 0, old_indent);
+ has_format_option(FO_RET_COMS) ? OPENLINE_DO_COM : 0, old_indent);
old_indent = 0;
#ifdef FEAT_CINDENT
can_cindent = TRUE;
diff --git a/src/evalfunc.c b/src/evalfunc.c
index c9d928754..159b874bf 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -3315,9 +3315,7 @@ f_has(typval_T *argvars, typval_T *rettv)
#endif
"cmdline_compl",
"cmdline_hist",
-#ifdef FEAT_COMMENTS
"comments",
-#endif
#ifdef FEAT_CONCEAL
"conceal",
#endif
diff --git a/src/feature.h b/src/feature.h
index dc5accc7a..b2ba1623e 100644
--- a/src/feature.h
+++ b/src/feature.h
@@ -108,6 +108,7 @@
* +cmdline_compl completion of mappings/abbreviations in cmdline mode.
* +insert_expand CTRL-N/CTRL-P/CTRL-X in insert mode.
* +modify_fname modifiers for file name. E.g., "%:p:h".
+ * +comments 'comments' option.
*
* Obsolete:
* +tag_old_static Old style static tags: "file:tag file ..".
@@ -496,13 +497,6 @@
#endif
/*
- * +comments 'comments' option.
- */
-#ifdef FEAT_NORMAL
-# define FEAT_COMMENTS
-#endif
-
-/*
* +cryptv Encryption (by Mohsin Ahmed <mosh@sasi.com>).
*/
#if defined(FEAT_NORMAL) && !defined(FEAT_CRYPT) || defined(PROTO)
diff --git a/src/fold.c b/src/fold.c
index 14c664042..8cadd4327 100644
--- a/src/fold.c
+++ b/src/fold.c
@@ -1773,10 +1773,8 @@ foldAddMarker(linenr_T lnum, char_u *marker, int markerlen)
if (u_save(lnum - 1, lnum + 1) == OK)
{
-#if defined(FEAT_COMMENTS)
/* Check if the line ends with an unclosed comment */
(void)skip_comment(line, FALSE, FALSE, &line_is_comment);
-#endif
newline = alloc(line_len + markerlen + STRLEN(cms) + 1);
if (newline == NULL)
return;
diff --git a/src/globals.h b/src/globals.h
index 1dcda8f0b..ac6bd8d81 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -800,7 +800,6 @@ EXTERN int did_ai INIT(= FALSE);
*/
EXTERN colnr_T ai_col INIT(= 0);
-#ifdef FEAT_COMMENTS
/*
* This is a character which will end a start-middle-end comment when typed as
* the first character on a new line. It is taken from the last character of
@@ -808,7 +807,6 @@ EXTERN colnr_T ai_col INIT(= 0);
* comment end in 'comments'. It is only valid when did_ai is TRUE.
*/
EXTERN int end_comment_pending INIT(= NUL);
-#endif
/*
* This flag is set after a ":syncbind" to let the check_scrollbind() function
diff --git a/src/insexpand.c b/src/insexpand.c
index eecc7f684..644542e94 100644
--- a/src/insexpand.c
+++ b/src/insexpand.c
@@ -3861,17 +3861,13 @@ ins_complete(int c, int enable_pum)
if (ctrl_x_mode_line_or_eval())
{
// Insert a new line, keep indentation but ignore 'comments'
-#ifdef FEAT_COMMENTS
char_u *old = curbuf->b_p_com;
curbuf->b_p_com = (char_u *)"";
-#endif
compl_startpos.lnum = curwin->w_cursor.lnum;
compl_startpos.col = compl_col;
ins_eol('\r');
-#ifdef FEAT_COMMENTS
curbuf->b_p_com = old;
-#endif
compl_length = 0;
compl_col = curwin->w_cursor.col;
}
diff --git a/src/misc1.c b/src/misc1.c
index 4566ca2a9..d43de06c1 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -466,11 +466,10 @@ get_number_indent(linenr_T lnum)
return -1;
pos.lnum = 0;
-#ifdef FEAT_COMMENTS
/* In format_lines() (i.e. not insert mode), fo+=q is needed too... */
if ((State & INSERT) || has_format_option(FO_Q_COMS))
lead_len = get_leader_len(ml_get(lnum), NULL, FALSE, TRUE);
-#endif
+
regmatch.regprog = vim_regcomp(curbuf->b_p_flp, RE_MAGIC);
if (regmatch.regprog != NULL)
{
@@ -561,7 +560,6 @@ get_breakindent_win(
}
#endif
-#if defined(FEAT_COMMENTS) || defined(PROTO)
/*
* get_leader_len() returns the length in bytes of the prefix of the given
* string which introduces a comment. If this string is not a comment then
@@ -862,7 +860,6 @@ get_last_leader_offset(char_u *line, char_u **flags)
}
return result;
}
-#endif
/*
* Return the number of window lines occupied by buffer line "lnum".
@@ -1548,8 +1545,6 @@ prompt_for_number(int *mouse_used)
if (msg_row > 0)
cmdline_row = msg_row - 1;
need_wait_return = FALSE;
- msg_didany = FALSE;
- msg_didout = FALSE;
}
else
cmdline_row = save_cmdline_row;
diff --git a/src/normal.c b/src/normal.c
index 4db90d658..98ec9ef84 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -3281,7 +3281,6 @@ find_decl(
}
break;
}
-#ifdef FEAT_COMMENTS
if (get_leader_len(ml_get_curline(), NULL, FALSE, TRUE) > 0)
{
/* Ignore this line, continue at start of next line. */
@@ -3289,7 +3288,6 @@ find_decl(
curwin->w_cursor.col = 0;
continue;
}
-#endif
valid = is_ident(ml_get_curline(), curwin->w_cursor.col);
/* If the current position is not a valid identifier and a previous
@@ -7228,10 +7226,8 @@ n_opencmd(cmdarg_T *cap)
(cap->cmdchar == 'o' ? 1 : 0))
) == OK
&& open_line(cap->cmdchar == 'O' ? BACKWARD : FORWARD,
-#ifdef FEAT_COMMENTS
- has_format_option(FO_OPEN_COMS) ? OPENLINE_DO_COM :
-#endif
- 0, 0) == OK)
+ has_format_option(FO_OPEN_COMS) ? OPENLINE_DO_COM : 0,
+ 0) == OK)
{
#ifdef FEAT_CONCEAL
if (curwin->w_p_cole > 0 && oldline != curwin->w_cursor.lnum)
diff --git a/src/ops.c b/src/ops.c
index 85a375812..df765ef2f 100644
--- a/src/ops.c
+++ b/src/ops.c
@@ -18,11 +18,7 @@ static void shift_block(oparg_T *oap, int amount);
static void mb_adjust_opend(oparg_T *oap);
static int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1);
static int ends_in_white(linenr_T lnum);
-#ifdef FEAT_COMMENTS
static int fmt_check_par(linenr_T, int *, char_u **, int do_comments);
-#else
-static int fmt_check_par(linenr_T);
-#endif
// Flags for third item in "opchars".
#define OPF_LINES 1 // operator always works on lines
@@ -229,19 +225,19 @@ shift_line(
int left,
int round,
int amount,
- int call_changed_bytes) /* call changed_bytes() */
+ int call_changed_bytes) // call changed_bytes()
{
int count;
int i, j;
int sw_val = (int)get_sw_value_indent(curbuf);
- count = get_indent(); /* get current indent */
+ count = get_indent(); // get current indent
- if (round) /* round off indent */
+ if (round) // round off indent
{
- i = count / sw_val; /* number of p_sw rounded down */
- j = count % sw_val; /* extra spaces */
- if (j && left) /* first remove extra spaces */
+ i = count / sw_val; // number of 'shiftwidth' rounded down
+ j = count % sw_val; // extra spaces
+ if (j && left) // first remove extra spaces
--amount;
if (left)
{
@@ -253,7 +249,7 @@ shift_line(
i += amount;
count = i * sw_val;
}
- else /* original vi indent */
+ else // original vi indent
{
if (left)
{
@@ -265,7 +261,7 @@ shift_line(
count += sw_val * amount;
}
- /* Set new indent */
+ // Set new indent
if (State & VREPLACE_FLAG)
change_indent(INDENT_SET, count, FALSE, NUL, call_changed_bytes);
else
@@ -1944,7 +1940,6 @@ preprocs_left(void)
}
#endif
-#if defined(FEAT_COMMENTS) || defined(PROTO)
/*
* If "process" is TRUE and the line begins with a comment leader (possibly
* after some white space), return a pointer to the text after it. Put a boolean
@@ -2015,7 +2010,6 @@ skip_comment(
return line;
}
-#endif
/*
* Join 'count' lines (minimal 2) at cursor position.
@@ -2047,12 +2041,10 @@ do_join(
linenr_T t;
colnr_T col = 0;
int ret = OK;
-#if defined(FEAT_COMMENTS) || defined(PROTO)
int *comments = NULL;
int remove_comments = (use_formatoptions == TRUE)
&& has_format_option(FO_REMOVE_COMS);
int prev_was_comment;
-#endif
#ifdef FEAT_TEXT_PROP
textprop_T **prop_lines = NULL;
int *prop_lengths = NULL;
@@ -2068,7 +2060,6 @@ do_join(
spaces = lalloc_clear(count, TRUE);
if (spaces == NULL)
return FAIL;
-#if defined(FEAT_COMMENTS) || defined(PROTO)
if (remove_comments)
{
comments = lalloc_clear(count * sizeof(int), TRUE);
@@ -2078,7 +2069,6 @@ do_join(
return FAIL;
}
}
-#endif
/*
* Don't move anything yet, just compute the final line length
@@ -2094,7 +2084,6 @@ do_join(
curwin->w_buffer->b_op_start.lnum = curwin->w_cursor.lnum;
curwin->w_buffer->b_op_start.col = (colnr_T)STRLEN(curr);
}
-#if defined(FEAT_COMMENTS) || defined(PROTO)
if (remove_comments)
{
/* We don't want to remove the comment leader if the
@@ -2111,7 +2100,6 @@ do_join(
curr = skip_comment(curr, FALSE, insert_space,
&prev_was_comment);
}
-#endif
if (insert_space && t > 0)
{
@@ -2230,10 +2218,8 @@ do_join(
#endif
curr = curr_start = ml_get((linenr_T)(curwin->w_cursor.lnum + t - 1));
-#if defined(FEAT_COMMENTS)
if (remove_comments)
curr += comments[t - 1];
-#endif
if (insert_space && t > 1)
curr = skipwhite(curr);
currsize = (int)STRLEN(curr);
@@ -2282,14 +2268,11 @@ do_join(
theend:
vim_free(spaces);
-#if defined(FEAT_COMMENTS) || defined(PROTO)
if (remove_comments)
vim_free(comments);
-#endif
return ret;
}
-#ifdef FEAT_COMMENTS
/*
* Return TRUE if the two comment leaders given are the same. "lnum" is
* the first line. White-space is ignored. Note that the whole of
@@ -2365,7 +2348,6 @@ same_leader(
}
return (idx2 == leader2_len && idx1 == leader1_len);
}
-#endif
/*
* Implementation of the format operator 'gq'.
@@ -2513,14 +2495,12 @@ format_lines(
int is_end_par; /* at end of paragraph */
int prev_is_end_par = FALSE;/* prev. line not part of parag. */
int next_is_start_par = FALSE;
-#ifdef FEAT_COMMENTS
int leader_len = 0; /* leader len of current line */
int next_leader_len; /* leader len of next line */
char_u *leader_flags = NULL; /* flags for leader of current line */
char_u *next_leader_flags; /* flags for leader of next line */
int do_comments; /* format comments */
int do_comments_list = 0; /* format comments with 'n' or '2' */
-#endif
int advance = TRUE;
int second_indent = -1; /* indent for second line (comment
* aware) */
@@ -2538,9 +2518,7 @@ format_lines(
max_len = comp_textwidth(TRUE) * 3;
/* check for 'q', '2' and '1' in 'formatoptions' */
-#ifdef FEAT_COMMENTS
do_comments = has_format_option(FO_Q_COMS);
-#endif
do_second_indent = has_format_option(FO_Q_SECOND);
do_number_indent = has_format_option(FO_Q_NUMBER);
do_trail_white = has_format_option(FO_WHITE_PAR);
@@ -2550,17 +2528,11 @@ format_lines(
*/
if (curwin->w_cursor.lnum > 1)
is_not_par = fmt_check_par(curwin->w_cursor.lnum - 1
-#ifdef FEAT_COMMENTS
- , &leader_len, &leader_flags, do_comments
-#endif
- );
+ , &leader_len, &leader_flags, do_comments);
else
is_not_par = TRUE;
next_is_not_par = fmt_check_par(curwin->w_cursor.lnum
-#ifdef FEAT_COMMENTS
- , &next_leader_len, &next_leader_flags, do_comments
-#endif
- );
+ , &next_leader_len, &next_leader_flags, do_comments);
is_end_par = (is_not_par || next_is_not_par);
if (!is_end_par && do_trail_white)
is_end_par = !ends_in_white(curwin->w_cursor.lnum - 1);
@@ -2576,10 +2548,8 @@ format_lines(
curwin->w_cursor.lnum++;
prev_is_end_par = is_end_par;
is_not_par = next_is_not_par;
-#ifdef FEAT_COMMENTS
leader_len = next_leader_len;
leader_flags = next_leader_flags;
-#endif
}
/*
@@ -2588,18 +2558,13 @@ format_lines(
if (count == 1 || curwin->w_cursor.lnum == curbuf->b_ml.ml_line_count)
{
next_is_not_par = TRUE;
-#ifdef FEAT_COMMENTS
next_leader_len = 0;
next_leader_flags = NULL;
-#endif
}
else
{
next_is_not_par = fmt_check_par(curwin->w_cursor.lnum + 1
-#ifdef FEAT_COMMENTS
- , &next_leader_len, &next_leader_flags, do_comments
-#endif
- );
+ , &next_leader_len, &next_leader_flags, do_comments);
if (do_number_indent)
next_is_start_par =
(get_number_indent(curwin->w_cursor.lnum + 1) > 0);
@@ -2630,32 +2595,25 @@ format_lines(
{
if (do_second_indent && !LINEEMPTY(curwin->w_cursor.lnum + 1))
{
-#ifdef FEAT_COMMENTS
if (leader_len == 0 && next_leader_len == 0)
{
/* no comment found */
-#endif
second_indent =
get_indent_lnum(curwin->w_cursor.lnum + 1);
-#ifdef FEAT_COMMENTS
}
else
{
second_indent = next_leader_len;
do_comments_list = 1;
}
-#endif
}
else if (do_number_indent)
{
-#ifdef FEAT_COMMENTS
if (leader_len == 0 && next_leader_len == 0)
{
/* no comment found */
-#endif
second_indent =
get_number_indent(curwin->w_cursor.lnum);
-#ifdef FEAT_COMMENTS
}
else
{
@@ -2664,7 +2622,6 @@ format_lines(
get_number_indent(curwin->w_cursor.lnum);
do_comments_list = 1;
}
-#endif
}
}
@@ -2672,12 +2629,9 @@ format_lines(
* When the comment leader changes, it's the end of the paragraph.
*/
if (curwin->w_cursor.lnum >= curbuf->b_ml.ml_line_count
-#ifdef FEAT_COMMENTS
|| !same_leader(curwin->w_cursor.lnum,
leader_len, leader_flags,
- next_leader_len, next_leader_flags)
-#endif
- )
+ next_leader_len, next_leader_flags))
is_end_par = TRUE;
/*
@@ -2702,11 +2656,9 @@ format_lines(
smd_save = p_smd;
p_smd = FALSE;
insertchar(NUL, INSCHAR_FORMAT
-#ifdef FEAT_COMMENTS
+ (do_comments ? INSCHAR_DO_COM : 0)
+ (do_comments && do_comments_list
? INSCHAR_COM_LIST : 0)
-#endif
+ (avoid_fex ? INSCHAR_NO_FEX : 0), second_indent);
State = old_State;
p_smd = smd_save;
@@ -2735,15 +2687,13 @@ format_lines(
curwin->w_cursor.col = 0;
if (line_count < 0 && u_save_cursor() == FAIL)
break;
-#ifdef FEAT_COMMENTS
if (next_leader_len > 0)
{
(void)del_bytes((long)next_leader_len, FALSE, FALSE);
mark_col_adjust(curwin->w_cursor.lnum, (colnr_T)0, 0L,
- (long)-next_leader_len, 0);
- } else
-#endif
- if (second_indent > 0) /* the "leader" for FO_Q_SECOND */
+ (long)-next_leader_len, 0);
+ }
+ else if (second_indent > 0) // the "leader" for FO_Q_SECOND
{
int indent = getwhitecols_curline();
@@ -2797,7 +2747,6 @@ ends_in_white(linenr_T lnum)
* previous line. A new paragraph starts after a blank line, or when the
* comment leader changes -- webb.
*/
-#ifdef FEAT_COMMENTS
static int
fmt_check_par(
linenr_T lnum,
@@ -2828,13 +2777,6 @@ fmt_check_par(
|| (*leader_len > 0 && *flags == COM_END)
|| startPS(lnum, NUL, FALSE));
}
-#else
- static int
-fmt_check_par(linenr_T lnum)
-{
- return (*skipwhite(ml_get(lnum)) == NUL || startPS(lnum, NUL, FALSE));
-}
-#endif
/*
* Return TRUE when a paragraph starts in line "lnum". Return FALSE when the
@@ -2844,13 +2786,11 @@ fmt_check_par(linenr_T lnum)
paragraph_start(linenr_T lnum)
{
char_u *p;
-#ifdef FEAT_COMMENTS
int leader_len = 0; /* leader len of current line */
char_u *leader_flags = NULL; /* flags for leader of current line */
int next_leader_len; /* leader len of next line */
char_u *next_leader_flags; /* flags for leader of next line */
int do_comments; /* format comments */
-#endif
if (lnum <= 1)
return TRUE; /* start of the file */
@@ -2859,21 +2799,11 @@ paragraph_start(linenr_T lnum)
if (*p == NUL)
return TRUE; /* after empty line */
-#ifdef FEAT_COMMENTS
do_comments = has_format_option(FO_Q_COMS);
-#endif
- if (fmt_check_par(lnum - 1
-#ifdef FEAT_COMMENTS
- , &leader_len, &leader_flags, do_comments
-#endif
- ))
+ if (fmt_check_par(lnum - 1, &leader_len, &leader_flags, do_comments))
return TRUE; /* after non-paragraph line */
- if (fmt_check_par(lnum
-#ifdef FEAT_COMMENTS
- , &next_leader_len, &next_leader_flags, do_comments
-#endif
- ))
+ if (fmt_check_par(lnum, &next_leader_len, &next_leader_flags, do_comments))
return TRUE; /* "lnum" is not a paragraph line */
if (has_format_option(FO_WHITE_PAR) && !ends_in_white(lnum - 1))
@@ -2882,11 +2812,9 @@ paragraph_start(linenr_T lnum)
if (has_format_option(FO_Q_NUMBER) && (get_number_indent(lnum) > 0))
return TRUE; /* numbered item starts in "lnum". */
-#ifdef FEAT_COMMENTS
if (!same_leader(lnum - 1, leader_len, leader_flags,
next_leader_len, next_leader_flags))
return TRUE; /* change of comment leader. */
-#endif
return FALSE;
}
diff --git a/src/option.c b/src/option.c
index cd2cdceaf..51e75c330 100644
--- a/src/option.c
+++ b/src/option.c
@@ -5386,9 +5386,7 @@ get_varp(struct vimoption *p)
#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
case PV_CINW: return (char_u *)&(curbuf->b_p_cinw);
#endif
-#ifdef FEAT_COMMENTS
case PV_COM: return (char_u *)&(curbuf->b_p_com);
-#endif
#ifdef FEAT_FOLDING
case PV_CMS: return (char_u *)&(curbuf->b_p_cms);
#endif
@@ -5844,9 +5842,7 @@ buf_copy_options(buf_T *buf, int flags)
? vim_strsave(p_vsts_nopaste) : NULL;
#endif
buf->b_p_sn = p_sn;
-#ifdef FEAT_COMMENTS
buf->b_p_com = vim_strsave(p_com);
-#endif
#ifdef FEAT_FOLDING
buf->b_p_cms = vim_strsave(p_cms);
#endif
diff --git a/src/option.h b/src/option.h
index 35efcabf3..aaa944377 100644
--- a/src/option.h
+++ b/src/option.h
@@ -478,9 +478,7 @@ EXTERN char_u *p_csl; // 'completeslash'
#endif
EXTERN long p_ph; // 'pumheight'
EXTERN long p_pw; // 'pumwidth'
-#ifdef FEAT_COMMENTS
EXTERN char_u *p_com; // 'comments'
-#endif
EXTERN char_u *p_cpo; // 'cpoptions'
#ifdef FEAT_CSCOPE
EXTERN char_u *p_csprg; // 'cscopeprg'
@@ -1094,9 +1092,7 @@ enum
#ifdef FEAT_FOLDING
, BV_CMS
#endif
-#ifdef FEAT_COMMENTS
, BV_COM
-#endif
, BV_CPT
, BV_DICT
, BV_TSR
diff --git a/src/optiondefs.h b/src/optiondefs.h
index c21c8f6a9..3745d07ce 100644
--- a/src/optiondefs.h
+++ b/src/optiondefs.h
@@ -52,9 +52,7 @@
#ifdef FEAT_FOLDING
# define PV_CMS OPT_BUF(BV_CMS)
#endif
-#ifdef FEAT_COMMENTS
-# define PV_COM OPT_BUF(BV_COM)
-#endif
+#define PV_COM OPT_BUF(BV_COM)
#define PV_CPT OPT_BUF(BV_CPT)
#define PV_DICT OPT_BOTH(OPT_BUF(BV_DICT))
#define PV_TSR OPT_BOTH(OPT_BUF(BV_TSR))
@@ -634,14 +632,9 @@ static struct vimoption options[] =
{(char_u *)80L, (char_u *)0L} SCTX_INIT},
{"comments", "com", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
|P_NODUP|P_CURSWANT,
-#ifdef FEAT_COMMENTS
(char_u *)&p_com, PV_COM,
{(char_u *)"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-",
(char_u *)0L}
-#else
- (char_u *)NULL, PV_NONE,
- {(char_u *)0L, (char_u *)0L}
-#endif
SCTX_INIT},
{"commentstring", "cms", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
#ifdef FEAT_FOLDING
diff --git a/src/optionstr.c b/src/optionstr.c
index 44f0759a9..925ea592d 100644
--- a/src/optionstr.c
+++ b/src/optionstr.c
@@ -231,9 +231,7 @@ check_buf_options(buf_T *buf)
check_string_option(&buf->b_p_fo);
check_string_option(&buf->b_p_flp);
check_string_option(&buf->b_p_isk);
-#ifdef FEAT_COMMENTS
check_string_option(&buf->b_p_com);
-#endif
#ifdef FEAT_FOLDING
check_string_option(&buf->b_p_cms);
#endif
@@ -1263,7 +1261,6 @@ did_set_string_option(
}
}
-#ifdef FEAT_COMMENTS
// 'comments'
else if (gvarp == &p_com)
{
@@ -1294,7 +1291,6 @@ did_set_string_option(
s = skip_to_option_part(s);
}
}
-#endif
// 'listchars'
else if (varp == &p_lcs)
diff --git a/src/search.c b/src/search.c
index abf32d685..63171a92c 100644
--- a/src/search.c
+++ b/src/search.c
@@ -5393,7 +5393,6 @@ search_line:
*/
if (!define_matched && skip_comments)
{
-#ifdef FEAT_COMMENTS
if ((*line != '#' ||
STRNCMP(skipwhite(line + 1), "define", 6) != 0)
&& get_leader_len(line, NULL, FALSE, TRUE))
@@ -5408,7 +5407,6 @@ search_line:
p = skipwhite(line);
if (matched
|| (p[0] == '/' && p[1] == '*') || p[0] == '*')
-#endif
for (p = line; *p && p < startp; ++p)
{
if (matched
diff --git a/src/structs.h b/src/structs.h
index adbb82085..9e6900120 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -2429,9 +2429,7 @@ struct file_buffer
#if defined(FEAT_CINDENT) || defined(FEAT_SMARTINDENT)
char_u *b_p_cinw; // 'cinwords'
#endif
-#ifdef FEAT_COMMENTS
char_u *b_p_com; // 'comments'
-#endif
#ifdef FEAT_FOLDING
char_u *b_p_cms; // 'commentstring'
#endif
diff --git a/src/version.c b/src/version.c
index 32ddda81b..88901935a 100644
--- a/src/version.c
+++ b/src/version.c
@@ -165,11 +165,7 @@ static char *(features[]) =
#else
"-cmdline_info",
#endif
-#ifdef FEAT_COMMENTS
"+comments",
-#else
- "-comments",
-#endif
#ifdef FEAT_CONCEAL
"+conceal",
#else
@@ -758,6 +754,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2096,
+/**/
2095,
/**/
2094,