Problem: Various code not used when features are disabled.
Solution: Add #ifdefs. (Dominique Pellé, closes #9491)
return lalloc(size, TRUE);
}
+#if defined(FEAT_QUICKFIX) || defined(PROTO)
/*
* alloc() with an ID for alloc_fail().
*/
#endif
return lalloc(size, TRUE);
}
+#endif
/*
* Allocate memory and set all bytes to zero.
return p;
}
+#if defined(FEAT_SIGNS) || defined(PROTO)
/*
* Same as alloc_clear() but with allocation id for testing
*/
#endif
return alloc_clear(size);
}
+#endif
/*
* Allocate memory like lalloc() and set all bytes to zero.
ga_clear(gap);
}
+#if defined(FEAT_EVAL) || defined(PROTO)
/*
* Copy a growing array that contains a list of strings.
*/
to->ga_len = from->ga_len;
return OK;
}
+#endif
/*
* Initialize a growing array. Don't forget to set ga_itemsize and
return retval;
}
+#if defined(FEAT_EVAL) || defined(PROTO)
/*
* Ensure buffer "buf" is loaded. Does not trigger the swap-exists action.
*/
aucmd_restbuf(&aco);
}
}
+#endif
/*
* Open current buffer, that is: open the memfile and read the file into
return buf != NULL && buf->b_p_bt[0] == 'p' && buf->b_p_bt[1] == 'r';
}
+#if defined(FEAT_PROP_POPUP) || defined(PROTO)
/*
* Return TRUE if "buf" is a buffer for a popup window.
*/
return buf != NULL && buf->b_p_bt != NULL
&& buf->b_p_bt[0] == 'p' && buf->b_p_bt[1] == 'o';
}
+#endif
/*
* Return TRUE if "buf" is a "nofile", "acwrite", "terminal" or "prompt"
|| buf->b_p_bt[0] == 'p');
}
+#if defined(FEAT_QUICKFIX) || defined(PROTO)
/*
* Return TRUE if "buf" has 'buftype' set to "nofile".
*/
{
return buf != NULL && buf->b_p_bt[0] == 'n' && buf->b_p_bt[2] == 'f';
}
+#endif
/*
* Return TRUE if "buf" is a "nowrite", "nofile", "terminal" or "prompt"
return p;
}
+#if defined(FEAT_EVAL) || defined(PROTO)
/*
* skip over ' ', '\t' and '\n'.
*/
++p;
return p;
}
+#endif
/*
* getwhitecols: return the number of whitespace
/*
* Property callback to get a timestamp for XtOwnSelection.
*/
+# if (defined(FEAT_X11) && defined(FEAT_XCLIPBOARD)) || defined(PROTO)
static void
clip_x11_timestamp_cb(
Widget w,
XtAddEventHandler(w, PropertyChangeMask, False,
/*(XtEventHandler)*/clip_x11_timestamp_cb, (XtPointer)NULL);
}
+# endif
static void
clip_x11_request_selection_cb(
return history[hist_type];
}
+#if defined(FEAT_VIMINFO) || defined(PROTO)
void
set_histentry(int hist_type, histentry_T *entry)
{
history[hist_type] = entry;
}
+#endif
int *
get_hisidx(int hist_type)
return &hisidx[hist_type];
}
+#if defined(FEAT_VIMINFO) || defined(PROTO)
int *
get_hisnum(int hist_type)
{
return &hisnum[hist_type];
}
+#endif
/*
* Translate a history character to the associated type number.
}
+#if defined(FEAT_SODIUM) || defined(PROTO)
/*
* Get maximum crypt method specific length of the file header in bytes.
*/
}
return max;
}
+#endif
/*
* Set the crypt method for buffer "buf" to "method_nr" using the int value as
}
}
+#if defined(FEAT_JOB_CHANNEL) || defined(PROTO)
/*
* Set the insert start position for when using a prompt buffer.
*/
Insstart_blank_vcol = MAXCOL;
arrow_used = FALSE;
}
+#endif
/*
* Undo the previous edit_putchar().
return ret;
}
-/*
- * Call Vim script function "func" and return the result as a number.
- * Returns -1 when calling the function fails.
- * Uses argv[0] to argv[argc - 1] for the function arguments. argv[argc] should
- * have type VAR_UNKNOWN.
- */
- varnumber_T
-call_func_retnr(
- char_u *func,
- int argc,
- typval_T *argv)
-{
- typval_T rettv;
- varnumber_T retval;
-
- if (call_vim_function(func, argc, argv, &rettv) == FAIL)
- return -1;
-
- retval = tv_get_number_chk(&rettv, NULL);
- clear_tv(&rettv);
- return retval;
-}
-
-/*
- * Call Vim script function like call_func_retnr() and drop the result.
- * Returns FAIL when calling the function fails.
- */
- int
-call_func_noret(
- char_u *func,
- int argc,
- typval_T *argv)
-{
- typval_T rettv;
-
- if (call_vim_function(func, argc, argv, &rettv) == FAIL)
- return FAIL;
- clear_tv(&rettv);
- return OK;
-}
-
/*
* Call Vim script function "func" and return the result as a string.
- * Uses "argv" and "argc" as call_func_retnr().
+ * Uses "argv[0]" to "argv[argc - 1]" for the function arguments. "argv[argc]"
+ * should have type VAR_UNKNOWN.
* Returns NULL when calling the function fails.
*/
void *
/*
* Call Vim script function "func" and return the result as a List.
- * Uses "argv" and "argc" as call_func_retnr().
+ * Uses "argv" and "argc" as call_func_retstr().
* Returns NULL when there is something wrong.
*/
void *
return abort;
}
+#if defined(FEAT_LUA) || defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) \
+ || defined(PROTO)
/*
* Mark a dict and its items with "copyID".
* Returns TRUE if setting references failed somehow.
}
return FALSE;
}
+#endif
/*
* Mark a list and its items with "copyID".
}
#endif // FEAT_EVAL
-#if defined(FEAT_JOB_CHANNEL) \
- || defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) \
- || defined(PROTO)
+#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO)
/*
* Make "buf" the current buffer. restore_buffer() MUST be called to undo.
* No autocommands will be executed. Use aucmd_prepbuf() if there are any.
}
}
+#if defined(FEAT_LUA) || defined(PROTO)
/*
* Get next line from a string containing NL separated lines.
* Called by do_cmdline() to get the next line.
do_cmdline(NULL, get_str_line, (void *)&str,
DOCMD_NOWAIT|DOCMD_VERBOSE|DOCMD_REPEAT|DOCMD_KEYTYPED);
}
+#endif
/*
* Get next line from a list.
return OK;
}
+#if defined(FEAT_EVAL) || defined(PROTO)
/*
* Return TRUE if "cmod" has anything set.
*/
}
return FALSE;
}
+#endif
/*
* Apply the command modifiers. Saves current state in "cmdmod", call
*d = NUL;
}
+#if defined(FEAT_EVAL) || defined(PROTO)
/*
* If "start" points "&opt", "&l:opt", "&g:opt" or "$ENV" return a pointer to
* the name. Otherwise just return "start".
name += 1;
return name;
}
+#endif
/*
* Find an Ex command by its name, either built-in or user.
#endif
+#ifdef FEAT_EVAL
EXTERN int did_source_packages INIT(= FALSE);
+#endif
// Magic number used for hashitem "hi_key" value indicating a deleted item.
// Only the address is used.
EXTERN cmdmod_T cmdmod; // Ex command modifiers
+#ifdef FEAT_EVAL
EXTERN int is_export INIT(= FALSE); // :export {cmd}
+#endif
EXTERN int msg_silent INIT(= 0); // don't print messages
EXTERN int emsg_silent INIT(= 0); // don't print error messages
#endif
;
EXTERN int ex_normal_busy INIT(= 0); // recursiveness of ex_normal()
+#ifdef FEAT_EVAL
EXTERN int in_feedkeys INIT(= 0); // ex_normal_busy set in feedkeys()
+#endif
EXTERN int ex_normal_lock INIT(= 0); // forbid use of ex_normal()
#ifdef FEAT_EVAL
EXTERN long sub_nsubs; // total number of substitutions
EXTERN linenr_T sub_nlines; // total number of lines changed
+#ifdef FEAT_EVAL
// Used when a compiled :substitute has an expression.
EXTERN struct subs_expr_S *substitute_instr INIT(= NULL);
+#endif
// table to store parsed 'wildmode'
EXTERN char_u wim_flags[4];
EXTERN char top_bot_msg[] INIT(= N_("search hit TOP, continuing at BOTTOM"));
EXTERN char bot_top_msg[] INIT(= N_("search hit BOTTOM, continuing at TOP"));
+#ifdef FEAT_EVAL
EXTERN char line_msg[] INIT(= N_(" line "));
+#endif
#ifdef FEAT_CRYPT
EXTERN char need_key_msg[] INIT(= N_("Need encryption key for \"%s\""));
}
#endif
+#if defined(FEAT_EVAL) || defined(PROTO)
/*
* Mark the global 'imactivatefunc' and 'imstatusfunc' callbacks with 'copyID'
* so that they are not garbage collected.
{
int abort = FALSE;
-#if defined(FEAT_EVAL) && \
- (defined(FEAT_XIM) || defined(IME_WITHOUT_XIM) || defined(VIMDLL))
+# if defined(FEAT_XIM) || defined(IME_WITHOUT_XIM) || defined(VIMDLL)
abort = set_ref_in_callback(&imaf_cb, copyID);
abort = abort || set_ref_in_callback(&imsf_cb, copyID);
-#endif
+# endif
return abort;
}
+#endif
#if defined(FEAT_XIM) || defined(PROTO)
++ht->ht_locked;
}
+#if defined(FEAT_PROP_POPUP) || defined(PROTO)
/*
* Lock a hashtable at the specified number of entries.
* Caller must make sure no more than "size" entries will be added.
(void)hash_may_resize(ht, size);
++ht->ht_locked;
}
+#endif
/*
* Unlock a hashtable: allow ht_array changes again.
NULL
};
+#if defined(FEAT_SYN_HL) || defined(PROTO)
/*
* Returns the number of highlight groups.
*/
{
return HL_TABLE()[id].sg_link;
}
+#endif
void
init_highlight(
/*
* Functions to check the current CTRL-X mode.
*/
+#ifdef FEAT_CINDENT
int ctrl_x_mode_none(void) { return ctrl_x_mode == 0; }
+#endif
int ctrl_x_mode_normal(void) { return ctrl_x_mode == CTRL_X_NORMAL; }
int ctrl_x_mode_scroll(void) { return ctrl_x_mode == CTRL_X_SCROLL; }
int ctrl_x_mode_whole_line(void) { return ctrl_x_mode == CTRL_X_WHOLE_LINE; }
was_safe = FALSE;
}
+#if defined(FEAT_EVAL) || defined(MESSAGE_QUEUE) || defined(PROTO)
int
get_was_safe_state(void)
{
return was_safe;
}
+#endif
+#if defined(MESSAGE_QUEUE) || defined(PROTO)
/*
* Invoked when leaving code that invokes callbacks. Then trigger
* SafeStateAgain, if it was safe when starting to wait for a character.
"SafeState: back to waiting, not triggering SafeStateAgain");
#endif
}
+#endif
/*
}
#endif
+#if defined(FEAT_VIMINFO) || defined(PROTO)
/*
* Return a pointer to the named file marks.
*/
{
return namedfm;
}
+#endif
#if defined(FEAT_EVAL) || defined(PROTO)
/*
siemsg(_(e_internal_error_str), where);
}
+#if defined(FEAT_EVAL) || defined(PROTO)
/*
* Like internal_error() but do not call abort(), to avoid tests using
* test_unknown() and test_void() causing Vim to exit.
{
semsg(_(e_internal_error_str), where);
}
+#endif
// emsg3() and emsgn() are in misc2.c to avoid warnings for the prototypes.
semsg(_(e_invalid_register_name_str), transchar(name));
}
+#if defined(FEAT_EVAL) || defined(PROTO)
/*
* Give an error message which contains %s for "name[len]".
*/
semsg(msg, copy == NULL ? "NULL" : (char *)copy);
vim_free(copy);
}
+#endif
/*
* Like msg(), but truncate to a single line if p_shm contains 't', or when
vim_setenv(var, (char_u *)"");
#endif
}
-#endif
/*
&& STRICMP(name, "VIMRUNTIME") == 0)
didset_vimruntime = FALSE;
}
+#endif
/*
* Our portable version of setenv.
}
}
+# if defined(FEAT_SPELL) || defined(PROTO)
/*
* Like line_breakcheck() but check 100 times less often.
*/
ui_breakcheck();
}
}
+#endif
#if defined(VIM_BACKTICK) || defined(FEAT_EVAL) \
|| (defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \
return OK;
}
+#if defined(EXITFREE) || defined(PROTOS)
/*
* Free the memory allocated by get_user_name()
*/
{
vim_free(username);
}
+#endif
#ifndef HAVE_QSORT
/*
}
#endif
+#if defined(FEAT_EVAL) || defined(PROTO)
/*
* Mark the global 'operatorfunc' callback with 'copyID' so that it is not
* garbage collected.
{
int abort = FALSE;
-#ifdef FEAT_EVAL
abort = set_ref_in_callback(&opfunc_cb, copyID);
-#endif
return abort;
}
+#endif
/*
* Handle the "g@" operator: call 'operatorfunc'.
options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
}
+#if defined(FEAT_PROP_POPUP) || defined(PROTO)
/*
* Set all window-local and buffer-local options to the Vim default.
* local-global options will use the global value.
curwin = save_curwin;
curbuf = curwin->w_buffer;
}
+#endif
#if defined(EXITFREE) || defined(PROTO)
/*
return options[opt_idx].var;
}
+#if defined(FEAT_EVAL) || defined(PROTO)
/*
* Return the full name of the option at 'opt_idx'
*/
{
return (char_u *)options[opt_idx].fullname;
}
+#endif
/*
* Get the value of 'equalprg', either the buffer-local one or the global one.
EXTERN char_u *p_ccv; // 'charconvert'
#endif
EXTERN int p_cdh; // 'cdhome'
+#ifdef FEAT_CINDENT
EXTERN char_u *p_cino; // 'cinoptions'
+#endif
#ifdef FEAT_CMDWIN
EXTERN char_u *p_cedit; // 'cedit'
EXTERN long p_cwh; // 'cmdwinheight'
EXTERN char_u *p_mp; // 'makeprg'
#endif
EXTERN char_u *p_mps; // 'matchpairs'
-#ifdef FEAT_SIGNS
-EXTERN char_u *p_scl; // signcolumn
-#endif
-#ifdef FEAT_SYN_HL
-EXTERN char_u *p_cc; // 'colorcolumn'
-EXTERN int p_cc_cols[256]; // array for 'colorcolumn' columns
-#endif
EXTERN long p_mat; // 'matchtime'
EXTERN long p_mco; // 'maxcombine'
#ifdef FEAT_EVAL
EXTERN char_u *p_ruf; // 'rulerformat'
#endif
EXTERN char_u *p_pp; // 'packpath'
+#ifdef FEAT_QUICKFIX
EXTERN char_u *p_qftf; // 'quickfixtextfunc'
+#endif
EXTERN char_u *p_rtp; // 'runtimepath'
EXTERN long p_sj; // 'scrolljump'
#if defined(MSWIN) && defined(FEAT_GUI)
#define SWB_NEWTAB 0x008
#define SWB_VSPLIT 0x010
#define SWB_USELAST 0x020
+#ifdef FEAT_SYN_HL
EXTERN char_u *p_syn; // 'syntax'
+#endif
EXTERN long p_ts; // 'tabstop'
EXTERN int p_tbs; // 'tagbsearch'
EXTERN char_u *p_tc; // 'tagcase'
# define TTYM_URXVT 0x40
# define TTYM_SGR 0x80
#endif
-EXTERN char_u *p_udir; // 'undodir'
#ifdef FEAT_PERSISTENT_UNDO
+EXTERN char_u *p_udir; // 'undodir'
EXTERN int p_udf; // 'undofile'
#endif
EXTERN long p_ul; // 'undolevels'
unblock_autocmds();
}
+#if defined(FEAT_PROP_POPUP) || defined(PROTO)
/*
* Like set_string_option_direct(), but for a buffer-local option in "buf".
* Blocks autocommands to avoid the old curbuf becoming invalid.
curwin->w_buffer = curbuf;
unblock_autocmds();
}
+#endif
/*
* Set a string option to a new value, and handle the effects.
#endif
static void dis_msg(char_u *p, int skip_esc);
+#if defined(FEAT_VIMINFO) || defined(PROTO)
yankreg_T *
get_y_regs(void)
{
return y_regs;
}
+#endif
+#if defined(FEAT_CLIPBOARD) || defined(PROTO)
yankreg_T *
get_y_register(int reg)
{
return &y_regs[reg];
}
+#endif
+#if defined(FEAT_CLIPBOARD) || defined(FEAT_VIMINFO) || defined(FEAT_EVAL) || defined(PROTO)
yankreg_T *
get_y_current(void)
{
return y_current;
}
+#endif
+#if defined(FEAT_CLIPBOARD) || defined(FEAT_VIMINFO) || defined(PROTO)
yankreg_T *
get_y_previous(void)
{
return y_previous;
}
+#endif
+#if defined(FEAT_CLIPBOARD) || defined(PROTO)
void
set_y_current(yankreg_T *yreg)
{
y_current = yreg;
}
+#endif
+#if defined(FEAT_CLIPBOARD) || defined(FEAT_VIMINFO) || defined(PROTO)
void
set_y_previous(yankreg_T *yreg)
{
y_previous = yreg;
}
+#endif
void
reset_y_append(void)
*/
static int execreg_lastc = NUL;
+#if defined(FEAT_VIMINFO) || defined(PROTO)
int
get_execreg_lastc(void)
{
{
execreg_lastc = lastc;
}
+#endif
/*
* When executing a register as a series of ex-commands, if the
}
}
+#if defined(FEAT_EVAL) || defined(PROTO)
/*
* Return the index of the register "" points to.
*/
{
return y_previous == NULL ? -1 : y_previous - &y_regs[0];
}
+#endif
/*
* ":dis" and ":registers": Display the contents of the yank registers.
}
# endif
-#endif
-
linenr_T
get_sourced_lnum(
char_u *(*fgetline)(int, void *, int, getline_opt_T),
? ((source_cookie_T *)cookie)->sourcing_lnum
: SOURCING_LNUM;
}
+#endif
static char_u *
get_one_sourceline(source_cookie_T *sp)
// Used instead of NUL to separate tag fields in the growarrays.
#define TAG_SEP 0x02
+#if defined(FEAT_EVAL) || defined(PROTO)
/*
* Reads the 'tagfunc' option value and convert that to a callback value.
* Invoked when the 'tagfunc' option is set. The option value can be a name of
return OK;
}
+#endif
-#if defined(EXITFREE) || defined(PROTO)
+# if defined(EXITFREE) || defined(PROTO)
void
free_tagfunc_option(void)
{
free_callback(&tfu_cb);
# endif
}
-#endif
+# endif
+#if defined(FEAT_EVAL) || defined(PROTO)
/*
* Mark the global 'tagfunc' callback with 'copyID' so that it is not garbage
* collected.
{
int abort = FALSE;
-#ifdef FEAT_EVAL
abort = set_ref_in_callback(&tfu_cb, copyID);
-#endif
return abort;
}
void
set_buflocal_tfu_callback(buf_T *buf UNUSED)
{
-#ifdef FEAT_EVAL
free_callback(&buf->b_tfu_cb);
if (tfu_cb.cb_name != NULL && *tfu_cb.cb_name != NUL)
copy_callback(&buf->b_tfu_cb, &tfu_cb);
-#endif
}
+#endif
/*
* Jump to tag; handling of tag commands and tag stack
}
}
+#ifdef FEAT_GUI
/*
* Check whether the cursor is invisible due to an ongoing cursor-less sleep
*/
{
return cursor_is_asleep;
}
+#endif
/*
* Disable the cursor and mark it disabled by cursor-less sleep
|| check_for_dict_arg(args, idx) != FAIL);
}
+#if defined(FEAT_JOB_CHANNEL) || defined(PROTO)
/*
* Give an error and return FAIL unless "args[idx]" is a channel or a job.
*/
return (args[idx].v_type == VAR_UNKNOWN
|| check_for_job_arg(args, idx) != FAIL);
}
+#endif
/*
* Give an error and return FAIL unless "args[idx]" is a string or
|| check_for_lnum_arg(args, idx));
}
+#if defined(FEAT_JOB_CHANNEL) || defined(PROTO)
/*
* Give an error and return FAIL unless "args[idx]" is a string or a blob.
*/
}
return OK;
}
+#endif
/*
* Give an error and return FAIL unless "args[idx]" is a string or a list.
return NULL;
}
+#ifdef FEAT_EVAL
/*
* Get the name of user command "idx". "cmdidx" can be CMD_USER or
* CMD_USER_BUF.
}
return NULL;
}
+#endif
/*
* Function given to ExpandGeneric() to obtain the list of user address type
return (char_u *)command_complete[idx].name;
}
+#ifdef FEAT_EVAL
int
cmdcomplete_str_to_type(char_u *complete_str)
{
return EXPAND_NOTHING;
}
+#endif
/*
* List user commands starting with "name[name_len]".
hash_init(&func_hashtab);
}
+#if defined(FEAT_PROFILE) || defined(PROTO)
/*
* Return the function hash table
*/
{
return &func_hashtab;
}
+#endif
/*
* Get one function argument.
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 4038,
/**/
4037,
/**/
#endif
}
+#if defined(FEAT_EVAL) || defined(PROTO)
/*
* When in Vim9 script give an error and return FAIL.
*/
}
return FALSE;
}
+#endif
/*
* Return TRUE if "p" points at a "#" not followed by one '{'.
return res;
}
- void
-type_mismatch(type_T *expected, type_T *actual)
-{
- arg_type_mismatch(expected, actual, 0);
-}
-
void
arg_type_mismatch(type_T *expected, type_T *actual, int arg_idx)
{