aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordundargoc <33953936+dundargoc@users.noreply.github.com>2021-09-24 14:03:15 +0200
committerGitHub <noreply@github.com>2021-09-24 05:03:15 -0700
commit7a26eb8a567cbc831d4f629f9eccb767a44436b8 (patch)
tree6677db970252f95ff4d1fd9ce017853c1aa568a1 /src
parent433bda405e1fa82db23660a73f275cac5ecca95e (diff)
downloadrneovim-7a26eb8a567cbc831d4f629f9eccb767a44436b8.tar.gz
rneovim-7a26eb8a567cbc831d4f629f9eccb767a44436b8.tar.bz2
rneovim-7a26eb8a567cbc831d4f629f9eccb767a44436b8.zip
refactor: format with uncrustify #15755
Diffstat (limited to 'src')
-rw-r--r--src/nvim/option.c1451
-rw-r--r--src/nvim/os_unix.c26
-rw-r--r--src/nvim/path.c392
-rw-r--r--src/nvim/plines.c25
-rw-r--r--src/nvim/popupmnu.c41
-rw-r--r--src/nvim/profile.c13
-rw-r--r--src/nvim/quickfix.c927
-rw-r--r--src/nvim/rbuffer.c4
-rw-r--r--src/nvim/runtime.c30
-rw-r--r--src/uncrustify.cfg2
10 files changed, 1479 insertions, 1432 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 4073ab08d9..310f382db7 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -22,50 +22,50 @@
#define IN_OPTION_C
#include <assert.h>
#include <inttypes.h>
+#include <limits.h>
#include <stdbool.h>
-#include <string.h>
#include <stdlib.h>
-#include <limits.h>
+#include <string.h>
-#include "nvim/vim.h"
-#include "nvim/macros.h"
#include "nvim/ascii.h"
-#include "nvim/edit.h"
-#include "nvim/option.h"
#include "nvim/buffer.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
+#include "nvim/cursor_shape.h"
#include "nvim/diff.h"
#include "nvim/digraph.h"
+#include "nvim/edit.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
#include "nvim/ex_cmds2.h"
#include "nvim/ex_docmd.h"
#include "nvim/ex_getln.h"
+#include "nvim/ex_session.h"
#include "nvim/fileio.h"
#include "nvim/fold.h"
+#include "nvim/garray.h"
#include "nvim/getchar.h"
#include "nvim/hardcopy.h"
#include "nvim/highlight.h"
#include "nvim/indent_c.h"
+#include "nvim/keymap.h"
+#include "nvim/macros.h"
#include "nvim/mbyte.h"
#include "nvim/memfile.h"
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/misc1.h"
-#include "nvim/runtime.h"
-#include "nvim/keymap.h"
-#include "nvim/garray.h"
-#include "nvim/cursor_shape.h"
-#include "nvim/move.h"
#include "nvim/mouse.h"
+#include "nvim/move.h"
#include "nvim/normal.h"
+#include "nvim/option.h"
+#include "nvim/os/os.h"
#include "nvim/os_unix.h"
#include "nvim/path.h"
#include "nvim/popupmnu.h"
#include "nvim/regexp.h"
-#include "nvim/ex_session.h"
+#include "nvim/runtime.h"
#include "nvim/screen.h"
#include "nvim/spell.h"
#include "nvim/spellfile.h"
@@ -74,13 +74,13 @@
#include "nvim/ui.h"
#include "nvim/ui_compositor.h"
#include "nvim/undo.h"
+#include "nvim/vim.h"
#include "nvim/window.h"
-#include "nvim/os/os.h"
#ifdef WIN32
# include "nvim/os/pty_conpty_win.h"
#endif
-#include "nvim/lua/executor.h"
#include "nvim/api/private/helpers.h"
+#include "nvim/lua/executor.h"
#include "nvim/os/input.h"
#include "nvim/os/lang.h"
#include "nvim/quickfix.h"
@@ -124,64 +124,64 @@ static char *p_ttytype = NULL;
static int p_ai;
static int p_bin;
static int p_bomb;
-static char_u *p_bh;
-static char_u *p_bt;
+static char_u *p_bh;
+static char_u *p_bt;
static int p_bl;
static long p_channel;
static int p_ci;
static int p_cin;
-static char_u *p_cink;
-static char_u *p_cino;
-static char_u *p_cinw;
-static char_u *p_com;
-static char_u *p_cms;
-static char_u *p_cpt;
-static char_u *p_cfu;
-static char_u *p_ofu;
-static char_u *p_tfu;
+static char_u *p_cink;
+static char_u *p_cino;
+static char_u *p_cinw;
+static char_u *p_com;
+static char_u *p_cms;
+static char_u *p_cpt;
+static char_u *p_cfu;
+static char_u *p_ofu;
+static char_u *p_tfu;
static int p_eol;
static int p_fixeol;
static int p_et;
-static char_u *p_fenc;
-static char_u *p_ff;
-static char_u *p_fo;
-static char_u *p_flp;
-static char_u *p_ft;
+static char_u *p_fenc;
+static char_u *p_ff;
+static char_u *p_fo;
+static char_u *p_flp;
+static char_u *p_ft;
static long p_iminsert;
static long p_imsearch;
-static char_u *p_inex;
-static char_u *p_inde;
-static char_u *p_indk;
-static char_u *p_fex;
+static char_u *p_inex;
+static char_u *p_inde;
+static char_u *p_indk;
+static char_u *p_fex;
static int p_inf;
-static char_u *p_isk;
+static char_u *p_isk;
static int p_lisp;
static int p_ml;
static int p_ma;
static int p_mod;
-static char_u *p_mps;
-static char_u *p_nf;
+static char_u *p_mps;
+static char_u *p_nf;
static int p_pi;
-static char_u *p_qe;
+static char_u *p_qe;
static int p_ro;
static int p_si;
static long p_sts;
-static char_u *p_sua;
+static char_u *p_sua;
static long p_sw;
static int p_swf;
static long p_smc;
-static char_u *p_syn;
-static char_u *p_spc;
-static char_u *p_spf;
-static char_u *p_spl;
-static char_u *p_spo;
+static char_u *p_syn;
+static char_u *p_spc;
+static char_u *p_spf;
+static char_u *p_spl;
+static char_u *p_spo;
static long p_ts;
static long p_tw;
static int p_udf;
static long p_wm;
static char_u *p_vsts;
static char_u *p_vts;
-static char_u *p_keymap;
+static char_u *p_keymap;
// Saved values for when 'bin' is set.
static int p_et_nobin;
@@ -198,15 +198,15 @@ static long p_wm_nopaste;
static char_u *p_vsts_nopaste;
typedef struct vimoption {
- char *fullname; // full option name
- char *shortname; // permissible abbreviation
+ char *fullname; // full option name
+ char *shortname; // permissible abbreviation
uint32_t flags; // see below
- char_u *var; // global option: pointer to variable;
- // window-local option: VAR_WIN;
- // buffer-local option: global value
+ char_u *var; // global option: pointer to variable;
+ // window-local option: VAR_WIN;
+ // buffer-local option: global value
idopt_T indir; // global option: PV_NONE;
// local option: indirect option index
- char_u *def_val; // default values for variable (neovim!!)
+ char_u *def_val; // default values for variable (neovim!!)
LastSet last_set; // script in which the option was last set
} vimoption_T;
@@ -314,12 +314,15 @@ static char *(p_csl_values[]) = { "slash", "backslash", NULL };
#endif
static char *(p_icm_values[]) = { "nosplit", "split", NULL };
static char *(p_scl_values[]) = { "yes", "no", "auto", "auto:1", "auto:2",
- "auto:3", "auto:4", "auto:5", "auto:6", "auto:7", "auto:8", "auto:9",
- "yes:1", "yes:2", "yes:3", "yes:4", "yes:5", "yes:6", "yes:7", "yes:8",
- "yes:9", "number", NULL };
+ "auto:3", "auto:4", "auto:5", "auto:6", "auto:7", "auto:8",
+ "auto:9",
+ "yes:1", "yes:2", "yes:3", "yes:4", "yes:5", "yes:6",
+ "yes:7", "yes:8",
+ "yes:9", "number", NULL };
static char *(p_fdc_values[]) = { "auto", "auto:1", "auto:2",
- "auto:3", "auto:4", "auto:5", "auto:6", "auto:7", "auto:8", "auto:9",
- "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL };
+ "auto:3", "auto:4", "auto:5", "auto:6", "auto:7", "auto:8",
+ "auto:9",
+ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL };
/// All possible flags for 'shm'.
static char_u SHM_ALL[] = {
@@ -372,9 +375,9 @@ void set_init_1(bool clean_arg)
*/
{
# ifdef UNIX
- static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"};
+ static char *(names[4]) = { "", "TMPDIR", "TEMP", "TMP" };
# else
- static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"};
+ static char *(names[3]) = { "TMPDIR", "TEMP", "TMP" };
# endif
garray_T ga;
opt_idx = findoption("backupskip");
@@ -426,8 +429,8 @@ void set_init_1(bool clean_arg)
}
{
- char_u *cdpath;
- char_u *buf;
+ char_u *cdpath;
+ char_u *buf;
int i;
int j;
@@ -470,13 +473,13 @@ void set_init_1(bool clean_arg)
set_string_default("printexpr",
#ifdef UNIX
"system(['lpr'] "
- "+ (empty(&printdevice)?[]:['-P', &printdevice]) "
- "+ [v:fname_in])"
+ "+ (empty(&printdevice)?[]:['-P', &printdevice]) "
+ "+ [v:fname_in])"
". delete(v:fname_in)"
"+ v:shell_error",
#elif defined(MSWIN)
"system(['copy', v:fname_in, "
- "empty(&printdevice)?'LPT1':&printdevice])"
+ "empty(&printdevice)?'LPT1':&printdevice])"
". delete(v:fname_in)",
#else
"",
@@ -550,7 +553,7 @@ void set_init_1(bool clean_arg)
&& options[opt_idx].var != NULL) {
p = _(*(char **)options[opt_idx].var);
} else {
- p = (char *) option_expand(opt_idx, NULL);
+ p = (char *)option_expand(opt_idx, NULL);
}
if (p != NULL) {
p = xstrdup(p);
@@ -584,8 +587,8 @@ void set_init_1(bool clean_arg)
// in 'fileencodings'
char_u *p = enc_locale();
if (p == NULL) {
- // use utf-8 as 'default' if locale encoding can't be detected.
- p = (char_u *)xmemdupz(S_LEN("utf-8"));
+ // use utf-8 as 'default' if locale encoding can't be detected.
+ p = (char_u *)xmemdupz(S_LEN("utf-8"));
}
fenc_default = p;
@@ -605,7 +608,7 @@ void set_init_1(bool clean_arg)
/// @param opt_flags OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL
static void set_option_default(int opt_idx, int opt_flags)
{
- char_u *varp; // pointer to variable for current option
+ char_u *varp; // pointer to variable for current option
int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags);
@@ -624,7 +627,7 @@ static void set_option_default(int opt_idx, int opt_flags)
*(char_u **)varp = options[opt_idx].def_val;
options[opt_idx].flags &= ~P_ALLOCED;
}
- } else if (flags & P_NUM) {
+ } else if (flags & P_NUM) {
if (options[opt_idx].indir == PV_SCROLL) {
win_comp_scroll(curwin);
} else {
@@ -667,10 +670,9 @@ static void set_option_default(int opt_idx, int opt_flags)
}
/// Set all options (except terminal options) to their default value.
-static void
-set_options_default(
- int opt_flags // OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL
-)
+///
+/// @param opt_flags OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL
+static void set_options_default(int opt_flags)
{
for (int i = 0; options[i].fullname; i++) {
if (!(options[i].flags & P_NODEFAULT)) {
@@ -710,8 +712,7 @@ static void set_string_default(const char *name, char *val, bool allocated)
// For an option value that contains comma separated items, find "newval" in
// "origval". Return NULL if not found.
-static char_u *find_dup_item(char_u *origval, const char_u *newval,
- uint32_t flags)
+static char_u *find_dup_item(char_u *origval, const char_u *newval, uint32_t flags)
FUNC_ATTR_NONNULL_ARG(2)
{
int bs = 0;
@@ -827,9 +828,8 @@ void set_init_3(void)
// Default for p_sp is "| tee", for p_srr is ">".
// For known shells it is changed here to include stderr.
//
- if ( fnamecmp(p, "csh") == 0
- || fnamecmp(p, "tcsh") == 0
- ) {
+ if (fnamecmp(p, "csh") == 0
+ || fnamecmp(p, "tcsh") == 0) {
if (do_sp) {
p_sp = (char_u *)"|& tee";
options[idx_sp].def_val = p_sp;
@@ -847,8 +847,7 @@ void set_init_3(void)
|| fnamecmp(p, "bash") == 0
|| fnamecmp(p, "fish") == 0
|| fnamecmp(p, "ash") == 0
- || fnamecmp(p, "dash") == 0
- ) {
+ || fnamecmp(p, "dash") == 0) {
// Always use POSIX shell style redirection if we reach this
if (do_sp) {
p_sp = (char_u *)"2>&1| tee";
@@ -933,28 +932,27 @@ void set_title_defaults(void)
}
}
-// Parse 'arg' for option settings.
-//
-// 'arg' may be IObuff, but only when no errors can be present and option
-// does not need to be expanded with option_expand().
-// "opt_flags":
-// 0 for ":set"
-// OPT_GLOBAL for ":setglobal"
-// OPT_LOCAL for ":setlocal" and a modeline
-// OPT_MODELINE for a modeline
-// OPT_WINONLY to only set window-local options
-// OPT_NOWIN to skip setting window-local options
-//
-// returns FAIL if an error is detected, OK otherwise
-int do_set(
- char_u *arg, // option string (may be written to!)
- int opt_flags
-)
+/// Parse 'arg' for option settings.
+///
+/// 'arg' may be IObuff, but only when no errors can be present and option
+/// does not need to be expanded with option_expand().
+/// "opt_flags":
+/// 0 for ":set"
+/// OPT_GLOBAL for ":setglobal"
+/// OPT_LOCAL for ":setlocal" and a modeline
+/// OPT_MODELINE for a modeline
+/// OPT_WINONLY to only set window-local options
+/// OPT_NOWIN to skip setting window-local options
+///
+/// @param arg option string (may be written to!)
+///
+/// @return FAIL if an error is detected, OK otherwise
+int do_set(char_u *arg, int opt_flags)
{
int opt_idx;
- char_u *errmsg;
+ char_u *errmsg;
char_u errbuf[80];
- char_u *startarg;
+ char_u *startarg;
int prefix; // 1: nothing, 0: "no", 2: "inv" in front of name
char_u nextchar; // next non-white char after option name
int afterchar; // character just after option name
@@ -963,7 +961,7 @@ int do_set(
varnumber_T value;
int key;
uint32_t flags; // flags for current option
- char_u *varp = NULL; // pointer to variable for current option
+ char_u *varp = NULL; // pointer to variable for current option
int did_show = false; // already showed one value
int adding; // "opt+=arg"
int prepending; // "opt^=arg"
@@ -1099,8 +1097,9 @@ int do_set(
/* Skip all options that are not window-local (used when showing
* an already loaded buffer in a window). */
if ((opt_flags & OPT_WINONLY)
- && (opt_idx < 0 || options[opt_idx].var != VAR_WIN))
+ && (opt_idx < 0 || options[opt_idx].var != VAR_WIN)) {
goto skip;
+ }
// Skip all options that are window-local (used for :vimgrep).
if ((opt_flags & OPT_NOWIN) && opt_idx >= 0
@@ -1115,8 +1114,7 @@ int do_set(
goto skip;
}
if ((flags & P_MLE) && !p_mle) {
- errmsg = (char_u *)N_(
- "E992: Not allowed in a modeline when 'modelineexpr' is off");
+ errmsg = (char_u *)N_("E992: Not allowed in a modeline when 'modelineexpr' is off");
goto skip;
}
// In diff mode some options are overruled. This avoids that
@@ -1177,10 +1175,10 @@ int do_set(
option_last_set_msg(options[opt_idx].last_set);
} else if ((int)options[opt_idx].indir & PV_WIN) {
option_last_set_msg(curwin->w_p_script_ctx[
- (int)options[opt_idx].indir & PV_MASK]);
+ (int)options[opt_idx].indir & PV_MASK]);
} else if ((int)options[opt_idx].indir & PV_BUF) {
option_last_set_msg(curbuf->b_p_script_ctx[
- (int)options[opt_idx].indir & PV_MASK]);
+ (int)options[opt_idx].indir & PV_MASK]);
}
}
} else {
@@ -1188,8 +1186,9 @@ int do_set(
goto skip;
}
if (nextchar != '?'
- && nextchar != NUL && !ascii_iswhite(afterchar))
+ && nextchar != NUL && !ascii_iswhite(afterchar)) {
errmsg = e_trailing;
+ }
} else {
int value_is_replaced = !prepending && !adding && !removing;
int value_checked = false;
@@ -1260,8 +1259,7 @@ int do_set(
if ((long *)varp == &curbuf->b_p_ul && opt_flags == OPT_LOCAL) {
value = NO_LOCAL_UNDOLEVEL;
} else {
- value = *(long *)get_varp_scope(
- &(options[opt_idx]), OPT_GLOBAL);
+ value = *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
}
} else if (((long *)varp == &p_wc
|| (long *)varp == &p_wcm)
@@ -1299,11 +1297,11 @@ int do_set(
errbuf, sizeof(errbuf),
opt_flags);
} else if (opt_idx >= 0) { // String.
- char_u *save_arg = NULL;
- char_u *s = NULL;
- char_u *oldval = NULL; // previous value if *varp
- char_u *newval;
- char_u *origval = NULL;
+ char_u *save_arg = NULL;
+ char_u *s = NULL;
+ char_u *oldval = NULL; // previous value if *varp
+ char_u *newval;
+ char_u *origval = NULL;
char *saved_origval = NULL;
char *saved_newval = NULL;
unsigned newlen;
@@ -1314,8 +1312,9 @@ int do_set(
* with a local value the local value will be
* reset, use the global value here. */
if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
- && ((int)options[opt_idx].indir & PV_BOTH))
+ && ((int)options[opt_idx].indir & PV_BOTH)) {
varp = options[opt_idx].var;
+ }
/* The old value is kept until we are sure that the
* new value is valid. */
@@ -1349,8 +1348,7 @@ int do_set(
newval = (char_u *)xstrdup((char *)newval);
}
} else if (nextchar == '<') { // set to global val
- newval = vim_strsave(*(char_u **)get_varp_scope(
- &(options[opt_idx]), OPT_GLOBAL));
+ newval = vim_strsave(*(char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL));
new_value_alloced = true;
} else {
arg++; // jump to after the '=' or ':'
@@ -1378,16 +1376,13 @@ int do_set(
*(char_u **)varp = empty_option;
break;
case 1:
- *(char_u **)varp = vim_strsave(
- (char_u *)"indent,eol");
+ *(char_u **)varp = vim_strsave((char_u *)"indent,eol");
break;
case 2:
- *(char_u **)varp = vim_strsave(
- (char_u *)"indent,eol,start");
+ *(char_u **)varp = vim_strsave((char_u *)"indent,eol,start");
break;
case 3:
- *(char_u **)varp = vim_strsave(
- (char_u *)"indent,eol,nostop");
+ *(char_u **)varp = vim_strsave((char_u *)"indent,eol,nostop");
break;
}
xfree(oldval);
@@ -1427,9 +1422,9 @@ int do_set(
* Remove '>' before 'dir' and 'bdir', for
* backwards compatibility with version 3.0
*/
- else if ( *arg == '>'
- && (varp == (char_u *)&p_dir
- || varp == (char_u *)&p_bdir)) {
+ else if (*arg == '>'
+ && (varp == (char_u *)&p_dir
+ || varp == (char_u *)&p_bdir)) {
arg++;
}
@@ -1464,8 +1459,9 @@ int do_set(
|| (s == newval
&& arg[2] != '\\')))
#endif
- )
+ ) {
arg++; // remove backslash
+ }
i = utfc_ptr2len(arg);
if (i > 1) {
// copy multibyte char
@@ -1533,7 +1529,7 @@ int do_set(
i--;
}
memmove(newval + i + comma, newval,
- STRLEN(newval) + 1);
+ STRLEN(newval) + 1);
memmove(newval, origval, (size_t)i);
} else {
i = (int)STRLEN(newval);
@@ -1650,7 +1646,6 @@ int do_set(
if (errmsg != NULL) {
goto skip;
}
-
} else {
// key code option(FIXME(tarruda): Show a warning or something
// similar)
@@ -1719,15 +1714,13 @@ theend:
return OK;
}
-// Call this when an option has been given a new value through a user command.
-// Sets the P_WAS_SET flag and takes care of the P_INSECURE flag.
-static void did_set_option(
- int opt_idx,
- int opt_flags, // possibly with OPT_MODELINE
- int new_value, // value was replaced completely
- int value_checked // value was checked to be safe, no need to
- // set P_INSECURE
-)
+/// Call this when an option has been given a new value through a user command.
+/// Sets the P_WAS_SET flag and takes care of the P_INSECURE flag.
+///
+/// @param opt_flags possibly with OPT_MODELINE
+/// @param new_value value was replaced completely
+/// @param value_checked value was checked to be safe, no need to set P_INSECURE
+static void did_set_option(int opt_idx, int opt_flags, int new_value, int value_checked)
{
options[opt_idx].flags |= P_WAS_SET;
@@ -1796,12 +1789,10 @@ static void did_set_title(void)
}
}
-// set_options_bin - called when 'bin' changes value.
-void set_options_bin(
- int oldval,
- int newval,
- int opt_flags // OPT_LOCAL and/or OPT_GLOBAL
-)
+/// set_options_bin - called when 'bin' changes value.
+///
+/// @param opt_flags OPT_LOCAL and/or OPT_GLOBAL
+void set_options_bin(int oldval, int newval, int opt_flags)
{
/*
* The option values that are changed when 'bin' changes are
@@ -1859,7 +1850,7 @@ void set_options_bin(
/// number, return -1.
int get_shada_parameter(int type)
{
- char_u *p;
+ char_u *p;
p = find_shada_parameter(type);
if (p != NULL && ascii_isdigit(*p)) {
@@ -1873,7 +1864,7 @@ int get_shada_parameter(int type)
/// Return NULL if the parameter is not specified in the string.
char_u *find_shada_parameter(int type)
{
- char_u *p;
+ char_u *p;
for (p = p_shada; *p; p++) {
if (*p == type) {
@@ -2102,12 +2093,18 @@ static uint32_t *insecure_flag(win_T *const wp, int opt_idx, int opt_flags)
if (opt_flags & OPT_LOCAL) {
assert(wp != NULL);
switch ((int)options[opt_idx].indir) {
- case PV_STL: return &wp->w_p_stl_flags;
- case PV_FDE: return &wp->w_p_fde_flags;
- case PV_FDT: return &wp->w_p_fdt_flags;
- case PV_INDE: return &wp->w_buffer->b_p_inde_flags;
- case PV_FEX: return &wp->w_buffer->b_p_fex_flags;
- case PV_INEX: return &wp->w_buffer->b_p_inex_flags;
+ case PV_STL:
+ return &wp->w_p_stl_flags;
+ case PV_FDE:
+ return &wp->w_p_fde_flags;
+ case PV_FDT:
+ return &wp->w_p_fdt_flags;
+ case PV_INDE:
+ return &wp->w_buffer->b_p_inde_flags;
+ case PV_FEX:
+ return &wp->w_buffer->b_p_fex_flags;
+ case PV_INEX:
+ return &wp->w_buffer->b_p_inex_flags;
}
}
@@ -2125,23 +2122,19 @@ static void redraw_titles(void)
static int shada_idx = -1;
-// Set a string option to a new value (without checking the effect).
-// The string is copied into allocated memory.
-// if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
-// When "set_sid" is zero set the scriptID to current_sctx.sc_sid. When
-// "set_sid" is SID_NONE don't set the scriptID. Otherwise set the scriptID to
-// "set_sid".
-void
-set_string_option_direct(
- const char *name,
- int opt_idx,
- const char_u *val,
- int opt_flags, // OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL
- int set_sid
-)
-{
- char_u *s;
- char_u **varp;
+/// Set a string option to a new value (without checking the effect).
+/// The string is copied into allocated memory.
+/// if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
+/// When "set_sid" is zero set the scriptID to current_sctx.sc_sid. When
+/// "set_sid" is SID_NONE don't set the scriptID. Otherwise set the scriptID to
+/// "set_sid".
+///
+/// @param opt_flags OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL
+void set_string_option_direct(const char *name, int opt_idx, const char_u *val, int opt_flags,
+ int set_sid)
+{
+ char_u *s;
+ char_u **varp;
int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
int idx = opt_idx;
@@ -2158,7 +2151,7 @@ set_string_option_direct(
return;
}
- assert((void *) options[idx].var != (void *) &p_shada);
+ assert((void *)options[idx].var != (void *)&p_shada);
s = vim_strsave(val);
{
@@ -2198,13 +2191,12 @@ set_string_option_direct(
}
/// Set global value for string option when it's a local option.
-static void
-set_string_option_global(
- int opt_idx, // option index
- char_u **varp // pointer to option variable
-)
+///
+/// @param opt_idx option index
+/// @param varp pointer to option variable
+static void set_string_option_global(int opt_idx, char_u **varp)
{
- char_u **p, *s;
+ char_u **p, *s;
// the global value is always allocated
if (options[opt_idx].var == VAR_WIN) {
@@ -2227,8 +2219,7 @@ set_string_option_global(
/// #OPT_GLOBAL.
///
/// @return NULL on success, error message on error.
-static char *set_string_option(const int opt_idx, const char *const value,
- const int opt_flags)
+static char *set_string_option(const int opt_idx, const char *const value, const int opt_flags)
FUNC_ATTR_NONNULL_ARG(2) FUNC_ATTR_WARN_UNUSED_RESULT
{
if (options[opt_idx].var == NULL) { // don't set hidden option
@@ -2236,12 +2227,11 @@ static char *set_string_option(const int opt_idx, const char *const value,
}
char *const s = xstrdup(value);
- char **const varp = (char **)get_varp_scope(
- &(options[opt_idx]),
- ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
+ char **const varp = (char **)get_varp_scope(&(options[opt_idx]),
+ ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
? (((int)options[opt_idx].indir & PV_BOTH)
? OPT_GLOBAL : OPT_LOCAL)
- : opt_flags));
+ : opt_flags));
char *const oldval = *varp;
*varp = s;
@@ -2249,9 +2239,9 @@ static char *set_string_option(const int opt_idx, const char *const value,
char *const saved_newval = xstrdup(s);
int value_checked = false;
- char *const r = (char *)did_set_string_option(
- opt_idx, (char_u **)varp, (int)true, (char_u *)oldval,
- NULL, 0, opt_flags, &value_checked);
+ char *const r = (char *)did_set_string_option(opt_idx, (char_u **)varp, (int)true,
+ (char_u *)oldval,
+ NULL, 0, opt_flags, &value_checked);
if (r == NULL) {
did_set_option(opt_idx, opt_flags, true, value_checked);
}
@@ -2315,23 +2305,23 @@ static bool valid_spellfile(const char_u *val)
/// Handle string options that need some action to perform when changed.
/// Returns NULL for success, or an error message for an error.
-static char_u *
-did_set_string_option(
- int opt_idx, // index in options[] table
- char_u **varp, // pointer to the option variable
- bool new_value_alloced, // new value was allocated
- char_u *oldval, // previous value of the option
- char_u *errbuf, // buffer for errors, or NULL
- size_t errbuflen, // length of errors buffer
- int opt_flags, // OPT_LOCAL and/or OPT_GLOBAL
- int *value_checked // value was checked to be safe, no
- // need to set P_INSECURE
-)
-{
- char_u *errmsg = NULL;
- char_u *s, *p;
+///
+/// @param opt_idx index in options[] table
+/// @param varp pointer to the option variable
+/// @param new_value_alloced new value was allocated
+/// @param oldval previous value of the option
+/// @param errbuf buffer for errors, or NULL
+/// @param errbuflen length of errors buffer
+/// @param opt_flags OPT_LOCAL and/or OPT_GLOBAL
+/// @param value_checked value was checked to be safe, no need to set P_INSECURE
+static char_u *did_set_string_option(int opt_idx, char_u **varp, bool new_value_alloced,
+ char_u *oldval, char_u *errbuf, size_t errbuflen,
+ int opt_flags, int *value_checked)
+{
+ char_u *errmsg = NULL;
+ char_u *s, *p;
int did_chartab = false;
- char_u **gvarp;
+ char_u **gvarp;
bool free_oldval = (options[opt_idx].flags & P_ALLOCED);
bool value_changed = false;
@@ -2345,7 +2335,7 @@ did_set_string_option(
errmsg = e_secure;
} else if (((options[opt_idx].flags & P_NFNAME)
&& vim_strpbrk(*varp, (char_u *)(secure ? "/\\*?[|;&<>\r\n"
- : "/\\*?[<>\r\n")) != NULL)
+ : "/\\*?[<>\r\n")) != NULL)
|| ((options[opt_idx].flags & P_NDNAME)
&& vim_strpbrk(*varp, (char_u *)"*?[|;&<>\r\n") != NULL)) {
// Check for a "normal" directory or file name in some options. Disallow a
@@ -2353,7 +2343,7 @@ did_set_string_option(
// are often illegal in a file name. Be more permissive if "secure" is off.
errmsg = e_invarg;
} else if (gvarp == &p_bkc) { // 'backupcopy'
- char_u *bkc = p_bkc;
+ char_u *bkc = p_bkc;
unsigned int *flags = &bkc_flags;
if (opt_flags & OPT_LOCAL) {
@@ -2493,13 +2483,14 @@ ambw_end:
check_string_option(&p_bg);
init_highlight(false, false);
}
- } else
+ } else {
errmsg = e_invarg;
+ }
} else if (varp == &p_wim) { // 'wildmode'
if (check_opt_wim() == FAIL) {
errmsg = e_invarg;
}
- // 'wildoptions'
+ // 'wildoptions'
} else if (varp == &p_wop) {
if (opt_strings_flags(p_wop, p_wop_values, &wop_flags, true) != OK) {
errmsg = e_invarg;
@@ -2513,7 +2504,7 @@ ambw_end:
if (check_ei() == FAIL) {
errmsg = e_invarg;
}
- // 'encoding', 'fileencoding' and 'makeencoding'
+ // 'encoding', 'fileencoding' and 'makeencoding'
} else if (varp == &p_enc || gvarp == &p_fenc || gvarp == &p_menc) {
if (gvarp == &p_fenc) {
if (!MODIFIABLE(curbuf) && opt_flags != OPT_GLOBAL) {
@@ -2684,7 +2675,7 @@ ambw_end:
if (*p_vfile != NUL && verbose_open() == FAIL) {
errmsg = e_invarg;
}
- // 'shada'
+ // 'shada'
} else if (varp == &p_shada) {
// TODO(ZyX-I): Remove this code in the future, alongside with &viminfo
// option.
@@ -2692,7 +2683,7 @@ ambw_end:
? (shada_idx == -1
? ((shada_idx = findoption("shada")))
: shada_idx)
- : opt_idx);
+ : opt_idx);
// Update free_oldval now that we have the opt_idx for 'shada', otherwise
// there would be a disconnect between the check for P_ALLOCED at the start
// of the function and the set of P_ALLOCED at the end of the function.
@@ -2721,8 +2712,9 @@ ambw_end:
_("E526: Missing number after <%s>"),
transchar_byte(*(s - 1)));
errmsg = errbuf;
- } else
+ } else {
errmsg = (char_u *)"";
+ }
break;
}
}
@@ -2743,8 +2735,7 @@ ambw_end:
} else if (gvarp == &p_sbr) { // 'showbreak'
for (s = *varp; *s; ) {
if (ptr2cells(s) != 1) {
- errmsg = (char_u *)N_(
- "E595: 'showbreak' contains unprintable or wide character");
+ errmsg = (char_u *)N_("E595: 'showbreak' contains unprintable or wide character");
}
MB_PTR_ADV(s);
}
@@ -2769,7 +2760,6 @@ ambw_end:
stl_syntax &= ~flagval;
}
did_set_title();
-
} else if (varp == &p_sel) { // 'selection'
if (*p_sel == NUL
|| check_opt_strings(p_sel, p_sel_values, false) != OK) {
@@ -2888,8 +2878,9 @@ ambw_end:
} else if (gvarp == &p_cpt) {
// check if it is a valid value for 'complete' -- Acevedo
for (s = *varp; *s; ) {
- while (*s == ',' || *s == ' ')
+ while (*s == ',' || *s == ' ') {
s++;
+ }
if (!*s) {
break;
}
@@ -2912,8 +2903,9 @@ ambw_end:
_("E535: Illegal character after <%c>"),
*--s);
errmsg = errbuf;
- } else
+ } else {
errmsg = (char_u *)"";
+ }
break;
}
}
@@ -3024,8 +3016,7 @@ ambw_end:
}
} else if (gvarp == &p_cms) { // 'commentstring'
if (**varp != NUL && strstr((char *)(*varp), "%s") == NULL) {
- errmsg = (char_u *)N_(
- "E537: 'commentstring' must be empty or contain %s");
+ errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s");
}
} else if (varp == &p_fdo) { // 'foldopen'
if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, true) != OK) {
@@ -3068,11 +3059,11 @@ ambw_end:
} else if