aboutsummaryrefslogtreecommitdiff
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
parent433bda405e1fa82db23660a73f275cac5ecca95e (diff)
downloadrneovim-7a26eb8a567cbc831d4f629f9eccb767a44436b8.tar.gz
rneovim-7a26eb8a567cbc831d4f629f9eccb767a44436b8.tar.bz2
rneovim-7a26eb8a567cbc831d4f629f9eccb767a44436b8.zip
refactor: format with uncrustify #15755
-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 (gvarp == &p_cino) { // 'cinoptions'
// TODO(vim): recognize errors
parse_cino(curbuf);
- // inccommand
+ // inccommand
} else if (varp == &p_icm) {
- if (check_opt_strings(p_icm, p_icm_values, false) != OK) {
- errmsg = e_invarg;
- }
+ if (check_opt_strings(p_icm, p_icm_values, false) != OK) {
+ errmsg = e_invarg;
+ }
} else if (gvarp == &p_ft) {
if (!valid_filetype(*varp)) {
errmsg = e_invarg;
@@ -3274,7 +3265,7 @@ ambw_end:
}
if (varp == &(curwin->w_s->b_p_spl)) {
char_u fname[200];
- char_u *q = curwin->w_s->b_p_spl;
+ char_u *q = curwin->w_s->b_p_spl;
// Skip the first name if it is "cjk".
if (STRNCMP(q, "cjk,", 4) == 0) {
@@ -3305,8 +3296,9 @@ ambw_end:
}
if (curwin->w_curswant != MAXCOL
- && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
+ && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) {
curwin->w_set_curswant = true;
+ }
check_redraw(options[opt_idx].flags);
@@ -3334,8 +3326,7 @@ int check_signcolumn(char_u *val)
&& !STRNCMP(val, "auto:", 5)
&& ascii_isdigit(val[5])
&& val[6] == '-'
- && ascii_isdigit(val[7])
- ) {
+ && ascii_isdigit(val[7])) {
int min = val[5] - '0';
int max = val[7] - '0';
if (min < 1 || max < 2 || min > 8 || max > 9 || min >= max) {
@@ -3352,7 +3343,7 @@ int check_signcolumn(char_u *val)
/// @return error message, NULL if it's OK.
char_u *check_colorcolumn(win_T *wp)
{
- char_u *s;
+ char_u *s;
int col;
unsigned int count = 0;
int color_cols[256];
@@ -3446,8 +3437,8 @@ static char_u *set_chars_option(win_T *wp, char_u **varp, bool set)
int multispace_len = 0; // Length of lcs-multispace string
struct chars_tab {
- int *cp; ///< char value
- char *name; ///< char id
+ int *cp; ///< char value
+ char *name; ///< char id
int def; ///< default value
};
struct chars_tab *tab;
@@ -3658,8 +3649,9 @@ char_u *check_stl_option(char_u *s)
}
if (*s == '.') {
s++;
- while (*s && ascii_isdigit(*s))
+ while (*s && ascii_isdigit(*s)) {
s++;
+ }
}
if (*s == '(') {
groupdepth++;
@@ -3687,7 +3679,7 @@ char_u *check_stl_option(char_u *s)
static char_u *did_set_spell_option(bool is_spellfile)
{
- char_u *errmsg = NULL;
+ char_u *errmsg = NULL;
if (is_spellfile) {
int l = (int)STRLEN(curwin->w_s->b_p_spf);
@@ -3714,8 +3706,8 @@ static char_u *did_set_spell_option(bool is_spellfile)
static char_u *compile_cap_prog(synblock_T *synblock)
FUNC_ATTR_NONNULL_ALL
{
- regprog_T *rp = synblock->b_cap_prog;
- char_u *re;
+ regprog_T *rp = synblock->b_cap_prog;
+ char_u *re;
if (synblock->b_p_spc == NULL || *synblock->b_p_spc == NUL) {
synblock->b_cap_prog = NULL;
@@ -3814,8 +3806,7 @@ static void set_option_sctx_idx(int opt_idx, int opt_flags, sctx_T script_ctx)
/// @param[in] opt_flags OPT_LOCAL and/or OPT_GLOBAL.
///
/// @return NULL on success, error message on error.
-static char *set_bool_option(const int opt_idx, char_u *const varp,
- const int value,
+static char *set_bool_option(const int opt_idx, char_u *const varp, const int value,
const int opt_flags)
{
int old_value = *(int *)varp;
@@ -3840,7 +3831,7 @@ static char *set_bool_option(const int opt_idx, char_u *const varp,
if ((int *)varp == &p_force_on && p_force_on == false) {
p_force_on = true;
return (char *)e_unsupportedoption;
- // Ensure that options set to p_force_off cannot be enabled.
+ // Ensure that options set to p_force_off cannot be enabled.
} else if ((int *)varp == &p_force_off && p_force_off == true) {
p_force_off = false;
return (char *)e_unsupportedoption;
@@ -3853,7 +3844,7 @@ static char *set_bool_option(const int opt_idx, char_u *const varp,
} else if ((int *)varp == &curwin->w_p_cul && !value && old_value) {
// 'cursorline'
reset_cursorline();
- // 'undofile'
+ // 'undofile'
} else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf) {
// Only take action when the option was set. When reset we do not
// delete the undo file, the option may be set again without making
@@ -3917,7 +3908,7 @@ static char *set_bool_option(const int opt_idx, char_u *const varp,
}
} else if ((int *)varp == &p_terse) {
// when 'terse' is set change 'shortmess'
- char_u *p;
+ char_u *p;
p = vim_strchr(p_shm, SHM_SEARCH);
@@ -3954,8 +3945,8 @@ static char *set_bool_option(const int opt_idx, char_u *const varp,
// when 'hlsearch' is set or reset: reset no_hlsearch
set_no_hlsearch(false);
} else if ((int *)varp == &curwin->w_p_scb) {
- // when 'scrollbind' is set: snapshot the current position to avoid a jump
- // at the end of normal_cmd()
+ // when 'scrollbind' is set: snapshot the current position to avoid a jump
+ // at the end of normal_cmd()
if (curwin->w_p_scb) {
do_check_scrollbind(false);
curwin->w_scbind_pos = curwin->w_topline;
@@ -4025,7 +4016,7 @@ static char *set_bool_option(const int opt_idx, char_u *const varp,
}
} else if ((int *)varp == &curwin->w_p_spell) { // 'spell'
if (curwin->w_p_spell) {
- char_u *errmsg = did_set_spelllang(curwin);
+ char_u *errmsg = did_set_spelllang(curwin);
if (errmsg != NULL) {
EMSG(_(errmsg));
}
@@ -4054,8 +4045,7 @@ static char *set_bool_option(const int opt_idx, char_u *const varp,
/* Arabic requires a utf-8 encoding, inform the user if its not
* set. */
if (STRCMP(p_enc, "utf-8") != 0) {
- static char *w_arabic = N_(
- "W17: Arabic requires UTF-8, do ':set encoding=utf-8'");
+ static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'");
msg_source(HL_ATTR(HLF_W));
msg_attr(_(w_arabic), HL_ATTR(HLF_W));
@@ -4115,7 +4105,7 @@ static char *set_bool_option(const int opt_idx, char_u *const varp,
set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
apply_autocmds(EVENT_OPTIONSET,
- (char_u *) options[opt_idx].fullname,
+ (char_u *)options[opt_idx].fullname,
NULL, false, NULL);
reset_v_option_vars();
}
@@ -4145,13 +4135,13 @@ static char *set_bool_option(const int opt_idx, char_u *const varp,
/// @param[in] opt_flags OPT_LOCAL, OPT_GLOBAL or OPT_MODELINE.
///
/// @return NULL on success, error message on error.
-static char *set_num_option(int opt_idx, char_u *varp, long value,
- char_u *errbuf, size_t errbuflen, int opt_flags)
+static char *set_num_option(int opt_idx, char_u *varp, long value, char_u *errbuf, size_t errbuflen,
+ int opt_flags)
{
- char_u *errmsg = NULL;
+ char_u *errmsg = NULL;
long old_value = *(long *)varp;
long old_Rows = Rows; // remember old Rows
- long *pp = (long *)varp;
+ long *pp = (long *)varp;
// Disallow changing some options from secure mode.
if ((secure || sandbox != 0)
@@ -4161,7 +4151,7 @@ static char *set_num_option(int opt_idx, char_u *varp, long value,
// Many number options assume their value is in the signed int range.
if (value < INT_MIN || value > INT_MAX) {
- return (char *)e_invarg;
+ return (char *)e_invarg;
}
// Options that need some validation.
@@ -4425,7 +4415,7 @@ static char *set_num_option(int opt_idx, char_u *varp, long value,
if (p_lines < min_rows() && full_screen) {
if (errbuf != NULL) {
vim_snprintf((char *)errbuf, errbuflen,
- _("E593: Need at least %d lines"), min_rows());
+ _("E593: Need at least %d lines"), min_rows());
errmsg = errbuf;
}
p_lines = min_rows();
@@ -4433,7 +4423,7 @@ static char *set_num_option(int opt_idx, char_u *varp, long value,
if (p_columns < MIN_COLUMNS && full_screen) {
if (errbuf != NULL) {
vim_snprintf((char *)errbuf, errbuflen,
- _("E594: Need at least %d columns"), MIN_COLUMNS);
+ _("E594: Need at least %d columns"), MIN_COLUMNS);
errmsg = errbuf;
}
p_columns = MIN_COLUMNS;
@@ -4478,7 +4468,7 @@ static char *set_num_option(int opt_idx, char_u *varp, long value,
}
win_comp_scroll(curwin);
} else if (curwin->w_p_scr <= 0) {
- // If 'scroll' became invalid because of a side effect silently adjust it.
+ // If 'scroll' became invalid because of a side effect silently adjust it.
curwin->w_p_scr = 1;
} else { // curwin->w_p_scr > curwin->w_height
curwin->w_p_scr = curwin->w_height;
@@ -4514,7 +4504,7 @@ static char *set_num_option(int opt_idx, char_u *varp, long value,
set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
apply_autocmds(EVENT_OPTIONSET,
- (char_u *) options[opt_idx].fullname,
+ (char_u *)options[opt_idx].fullname,
NULL, false, NULL);
reset_v_option_vars();
}
@@ -4534,8 +4524,7 @@ static char *set_num_option(int opt_idx, char_u *varp, long value,
return (char *)errmsg;
}
-static void trigger_optionsset_string(int opt_idx, int opt_flags,
- char *oldval, char *newval)
+static void trigger_optionsset_string(int opt_idx, int opt_flags, char *oldval, char *newval)
{
// Don't do this recursively.
if (oldval != NULL
@@ -4658,8 +4647,8 @@ bool is_tty_option(const char *name)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
return (name[0] == 't' && name[1] == '_')
- || strequal(name, "term")
- || strequal(name, "ttytype");
+ || strequal(name, "term")
+ || strequal(name, "ttytype");
}
#define TCO_BUFFER_SIZE 8
@@ -4738,18 +4727,15 @@ static int findoption(const char *const arg)
/// Gets the value for an option.
///
+/// @param stringval NULL when only checking existence
+///
/// @returns:
/// Number or Toggle option: 1, *numval gets value.
/// String option: 0, *stringval gets allocated string.
/// Hidden Number or Toggle option: -1.
/// hidden String option: -2.
/// unknown option: -3.
-int get_option_value(
- const char *name,
- long *numval,
- char_u **stringval, ///< NULL when only checking existence
- int opt_flags
-)
+int get_option_value(const char *name, long *numval, char_u **stringval, int opt_flags)
{
if (get_tty_option(name, (char **)stringval)) {
return 0;
@@ -4783,7 +4769,7 @@ int get_option_value(
if ((int *)varp == &curbuf->b_changed) {
*numval = curbufIsChanged();
} else {
- *numval = (long) *(int *)varp; // NOLINT(whitespace/cast)
+ *numval = (long)*(int *)varp; // NOLINT(whitespace/cast)
}
}
return 1;
@@ -4805,11 +4791,7 @@ int get_option_value(
// see SOPT_* in option_defs.h for other flags
//
// Possible opt_type values: see SREQ_* in option_defs.h
-int get_option_value_strict(char *name,
- int64_t *numval,
- char **stringval,
- int opt_type,
- void *from)
+int get_option_value_strict(char *name, int64_t *numval, char **stringval, int opt_type, void *from)
{
if (get_tty_option(name, stringval)) {
return SOPT_STRING | SOPT_GLOBAL;
@@ -4925,8 +4907,8 @@ int get_option_value_strict(char *name,
/// @param[in] opt_flags Flags: OPT_LOCAL, OPT_GLOBAL, or 0 (both).
///
/// @return NULL on success, error message on error.
-char *set_option_value(const char *const name, const long number,
- const char *const string, const int opt_flags)
+char *set_option_value(const char *const name, const long number, const char *const string,
+ const int opt_flags)
FUNC_ATTR_NONNULL_ARG(1)
{
if (is_tty_option(name)) {
@@ -4934,7 +4916,7 @@ char *set_option_value(const char *const name, const long number,
}
int opt_idx;
- char_u *varp;
+ char_u *varp;
opt_idx = findoption(name);
if (opt_idx < 0) {
@@ -4994,7 +4976,7 @@ int find_key_option_len(const char_u *arg_arg, size_t len, bool has_lt)
// add_termcap_entry().
if (len >= 4 && arg[0] == 't' && arg[1] == '_') {
key = TERMCAP2KEY(arg[2], arg[3]);
- } else if (has_lt) {
+ } else if (has_lt) {
arg--; // put arg at the '<'
modifiers = 0;
key = find_special_key(&arg, len + 1, &modifiers, true, true, false);
@@ -5012,15 +4994,13 @@ static int find_key_option(const char_u *arg, bool has_lt)
/// if 'all' == 0: show changed options
/// if 'all' == 1: show all normal options
-static void
-showoptions(
- int all,
- int opt_flags // OPT_LOCAL and/or OPT_GLOBAL
-)
+///
+/// @param opt_flags OPT_LOCAL and/or OPT_GLOBAL
+static void showoptions(int all, int opt_flags)
{
- vimoption_T *p;
+ vimoption_T *p;
int col;
- char_u *varp;
+ char_u *varp;
int item_count;
int run;
int row, rows;
@@ -5155,13 +5135,11 @@ void ui_refresh_options(void)
/// showoneopt: show the value of one option
/// must not be called with a hidden option!
-static void
-showoneopt(
- vimoption_T *p,
- int opt_flags // OPT_LOCAL or OPT_GLOBAL
-)
+///
+/// @param opt_flags OPT_LOCAL or OPT_GLOBAL
+static void showoneopt(vimoption_T *p, int opt_flags)
{
- char_u *varp;
+ char_u *varp;
int save_silent = silent_mode;
silent_mode = false;
@@ -5212,11 +5190,11 @@ showoneopt(
/// Return FAIL on error, OK otherwise.
int makeset(FILE *fd, int opt_flags, int local_only)
{
- vimoption_T *p;
- char_u *varp; // currently used value
- char_u *varp_fresh; // local value
- char_u *varp_local = NULL; // fresh value
- char *cmd;
+ vimoption_T *p;
+ char_u *varp; // currently used value
+ char_u *varp_fresh; // local value
+ char_u *varp_local = NULL; // fresh value
+ char *cmd;
int round;
int pri;
@@ -5340,21 +5318,20 @@ int makefoldset(FILE *fd)
|| put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL
|| put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL
|| put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL
- || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL
- ) {
+ || put_setbool(fd, "setlocal", "fen",
+ curwin->w_p_fen) == FAIL) {
return FAIL;
}
return OK;
}
-static int put_setstring(FILE *fd, char *cmd, char *name,
- char_u **valuep, uint64_t flags)
+static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, uint64_t flags)
{
- char_u *s;
- char_u *buf = NULL;
- char_u *part = NULL;
- char_u *p;
+ char_u *s;
+ char_u *buf = NULL;
+ char_u *part = NULL;
+ char_u *p;
if (fprintf(fd, "%s %s=", cmd, name) < 0) {
return FAIL;
@@ -5392,15 +5369,15 @@ static int put_setstring(FILE *fd, char *cmd, char *name,
}
p = buf;
while (*p != NUL) {
- // for each comma separated option part, append value to
- // the option, :set rtp+=value
- if (fprintf(fd, "%s %s+=", cmd, name) < 0) {
- goto fail;
- }
- (void)copy_option_part(&p, part, size, ",");
- if (put_escstr(fd, part, 2) == FAIL || put_eol(fd) == FAIL) {
- goto fail;
- }
+ // for each comma separated option part, append value to
+ // the option, :set rtp+=value
+ if (fprintf(fd, "%s %s+=", cmd, name) < 0) {
+ goto fail;
+ }
+ (void)copy_option_part(&p, part, size, ",");
+ if (put_escstr(fd, part, 2) == FAIL || put_eol(fd) == FAIL) {
+ goto fail;
+ }
}
xfree(buf);
xfree(part);
@@ -5516,124 +5493,149 @@ void unset_global_local_option(char *name, void *from)
switch ((int)p->indir)
{
- // global option with local value: use local value if it's been set
+ // global option with local value: use local value if it's been set
+ case PV_EP:
+ clear_string_option(&buf->b_p_ep);
+ break;
+ case PV_KP:
+ clear_string_option(&buf->b_p_kp);
+ break;
+ case PV_PATH:
+ clear_string_option(&buf->b_p_path);
+ break;
+ case PV_AR:
+ buf->b_p_ar = -1;
+ break;
+ case PV_BKC:
+ clear_string_option(&buf->b_p_bkc);
+ buf->b_bkc_flags = 0;
+ break;
+ case PV_TAGS:
+ clear_string_option(&buf->b_p_tags);
+ break;
+ case PV_TC:
+ clear_string_option(&buf->b_p_tc);
+ buf->b_tc_flags = 0;
+ break;
+ case PV_SISO:
+ curwin->w_p_siso = -1;
+ break;
+ case PV_SO:
+ curwin->w_p_so = -1;
+ break;
+ case PV_DEF:
+ clear_string_option(&buf->b_p_def);
+ break;
+ case PV_INC:
+ clear_string_option(&buf->b_p_inc);
+ break;
+ case PV_DICT:
+ clear_string_option(&buf->b_p_dict);
+ break;
+ case PV_TSR:
+ clear_string_option(&buf->b_p_tsr);
+ break;
+ case PV_FP:
+ clear_string_option(&buf->b_p_fp);
+ break;
+ case PV_EFM:
+ clear_string_option(&buf->b_p_efm);
+ break;
+ case PV_GP:
+ clear_string_option(&buf->b_p_gp);
+ break;
+ case PV_MP:
+ clear_string_option(&buf->b_p_mp);
+ break;
+ case PV_SBR:
+ clear_string_option(&((win_T *)from)->w_p_sbr);
+ break;
+ case PV_STL:
+ clear_string_option(&((win_T *)from)->w_p_stl);
+ break;
+ case PV_UL:
+ buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
+ break;
+ case PV_LW:
+ clear_string_option(&buf->b_p_lw);
+ break;
+ case PV_MENC:
+ clear_string_option(&buf->b_p_menc);
+ break;
+ case PV_LCS:
+ clear_string_option(&((win_T *)from)->w_p_lcs);
+ set_chars_option((win_T *)from, &((win_T *)from)->w_p_lcs, true);
+ redraw_later((win_T *)from, NOT_VALID);
+ break;
+ case PV_FCS:
+ clear_string_option(&((win_T *)from)->w_p_fcs);
+ set_chars_option((win_T *)from, &((win_T *)from)->w_p_fcs, true);
+ redraw_later((win_T *)from, NOT_VALID);
+ break;
+ }
+}
+
+/// Get pointer to option variable, depending on local or global scope.
+static char_u *get_varp_scope(vimoption_T *p, int opt_flags)
+{
+ if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE) {
+ if (p->var == VAR_WIN) {
+ return (char_u *)GLOBAL_WO(get_varp(p));
+ }
+ return p->var;
+ }
+ if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH)) {
+ switch ((int)p->indir) {
+ case PV_FP:
+ return (char_u *)&(curbuf->b_p_fp);
+ case PV_EFM:
+ return (char_u *)&(curbuf->b_p_efm);
+ case PV_GP:
+ return (char_u *)&(curbuf->b_p_gp);
+ case PV_MP:
+ return (char_u *)&(curbuf->b_p_mp);
case PV_EP:
- clear_string_option(&buf->b_p_ep);
- break;
+ return (char_u *)&(curbuf->b_p_ep);
case PV_KP:
- clear_string_option(&buf->b_p_kp);
- break;
+ return (char_u *)&(curbuf->b_p_kp);
case PV_PATH:
- clear_string_option(&buf->b_p_path);
- break;
+ return (char_u *)&(curbuf->b_p_path);
case PV_AR:
- buf->b_p_ar = -1;
- break;
- case PV_BKC:
- clear_string_option(&buf->b_p_bkc);
- buf->b_bkc_flags = 0;
- break;
+ return (char_u *)&(curbuf->b_p_ar);
case PV_TAGS:
- clear_string_option(&buf->b_p_tags);
- break;
+ return (char_u *)&(curbuf->b_p_tags);
case PV_TC:
- clear_string_option(&buf->b_p_tc);
- buf->b_tc_flags = 0;
- break;
+ return (char_u *)&(curbuf->b_p_tc);
case PV_SISO:
- curwin->w_p_siso = -1;
- break;
+ return (char_u *)&(curwin->w_p_siso);
case PV_SO:
- curwin->w_p_so = -1;
- break;
+ return (char_u *)&(curwin->w_p_so);
case PV_DEF:
- clear_string_option(&buf->b_p_def);
- break;
+ return (char_u *)&(curbuf->b_p_def);
case PV_INC:
- clear_string_option(&buf->b_p_inc);
- break;
+ return (char_u *)&(curbuf->b_p_inc);
case PV_DICT:
- clear_string_option(&buf->b_p_dict);
- break;
+ return (char_u *)&(curbuf->b_p_dict);
case PV_TSR:
- clear_string_option(&buf->b_p_tsr);
- break;
- case PV_FP:
- clear_string_option(&buf->b_p_fp);
- break;
- case PV_EFM:
- clear_string_option(&buf->b_p_efm);
- break;
- case PV_GP:
- clear_string_option(&buf->b_p_gp);
- break;
- case PV_MP:
- clear_string_option(&buf->b_p_mp);
- break;
+ return (char_u *)&(curbuf->b_p_tsr);
+ case PV_TFU:
+ return (char_u *)&(curbuf->b_p_tfu);
case PV_SBR:
- clear_string_option(&((win_T *)from)->w_p_sbr);
- break;
+ return (char_u *)&(curwin->w_p_sbr);
case PV_STL:
- clear_string_option(&((win_T *)from)->w_p_stl);
- break;
+ return (char_u *)&(curwin->w_p_stl);
case PV_UL:
- buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
- break;
+ return (char_u *)&(curbuf->b_p_ul);
case PV_LW:
- clear_string_option(&buf->b_p_lw);
- break;
+ return (char_u *)&(curbuf->b_p_lw);
+ case PV_BKC:
+ return (char_u *)&(curbuf->b_p_bkc);
case PV_MENC:
- clear_string_option(&buf->b_p_menc);
- break;
- case PV_LCS:
- clear_string_option(&((win_T *)from)->w_p_lcs);
- set_chars_option((win_T *)from, &((win_T *)from)->w_p_lcs, true);
- redraw_later((win_T *)from, NOT_VALID);
- break;
+ return (char_u *)&(curbuf->b_p_menc);
case PV_FCS:
- clear_string_option(&((win_T *)from)->w_p_fcs);
- set_chars_option((win_T *)from, &((win_T *)from)->w_p_fcs, true);
- redraw_later((win_T *)from, NOT_VALID);
- break;
- }
-}
-
-/// Get pointer to option variable, depending on local or global scope.
-static char_u *get_varp_scope(vimoption_T *p, int opt_flags)
-{
- if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE) {
- if (p->var == VAR_WIN) {
- return (char_u *)GLOBAL_WO(get_varp(p));
- }
- return p->var;
- }
- if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH)) {
- switch ((int)p->indir) {
- case PV_FP: return (char_u *)&(curbuf->b_p_fp);
- case PV_EFM: return (char_u *)&(curbuf->b_p_efm);
- case PV_GP: return (char_u *)&(curbuf->b_p_gp);
- case PV_MP: return (char_u *)&(curbuf->b_p_mp);
- case PV_EP: return (char_u *)&(curbuf->b_p_ep);
- case PV_KP: return (char_u *)&(curbuf->b_p_kp);
- case PV_PATH: return (char_u *)&(curbuf->b_p_path);
- case PV_AR: return (char_u *)&(curbuf->b_p_ar);
- case PV_TAGS: return (char_u *)&(curbuf->b_p_tags);
- case PV_TC: return (char_u *)&(curbuf->b_p_tc);
- case PV_SISO: return (char_u *)&(curwin->w_p_siso);
- case PV_SO: return (char_u *)&(curwin->w_p_so);
- case PV_DEF: return (char_u *)&(curbuf->b_p_def);
- case PV_INC: return (char_u *)&(curbuf->b_p_inc);
- case PV_DICT: return (char_u *)&(curbuf->b_p_dict);
- case PV_TSR: return (char_u *)&(curbuf->b_p_tsr);
- case PV_TFU: return (char_u *)&(curbuf->b_p_tfu);
- case PV_SBR: return (char_u *)&(curwin->w_p_sbr);
- case PV_STL: return (char_u *)&(curwin->w_p_stl);
- case PV_UL: return (char_u *)&(curbuf->b_p_ul);
- case PV_LW: return (char_u *)&(curbuf->b_p_lw);
- case PV_BKC: return (char_u *)&(curbuf->b_p_bkc);
- case PV_MENC: return (char_u *)&(curbuf->b_p_menc);
- case PV_FCS: return (char_u *)&(curwin->w_p_fcs);
- case PV_LCS: return (char_u *)&(curwin->w_p_lcs);
+ return (char_u *)&(curwin->w_p_fcs);
+ case PV_LCS:
+ return (char_u *)&(curwin->w_p_lcs);
}
return NULL; // "cannot happen"
}
@@ -5649,163 +5651,290 @@ static char_u *get_varp(vimoption_T *p)
}
switch ((int)p->indir) {
- case PV_NONE: return p->var;
+ case PV_NONE:
+ return p->var;
// global option with local value: use local value if it's been set
- case PV_EP: return *curbuf->b_p_ep != NUL
+ case PV_EP:
+ return *curbuf->b_p_ep != NUL
? (char_u *)&curbuf->b_p_ep : p->var;
- case PV_KP: return *curbuf->b_p_kp != NUL
+ case PV_KP:
+ return *curbuf->b_p_kp != NUL
? (char_u *)&curbuf->b_p_kp : p->var;
- case PV_PATH: return *curbuf->b_p_path != NUL
+ case PV_PATH:
+ return *curbuf->b_p_path != NUL
? (char_u *)&(curbuf->b_p_path) : p->var;
- case PV_AR: return curbuf->b_p_ar >= 0
+ case PV_AR:
+ return curbuf->b_p_ar >= 0
? (char_u *)&(curbuf->b_p_ar) : p->var;
- case PV_TAGS: return *curbuf->b_p_tags != NUL
+ case PV_TAGS:
+ return *curbuf->b_p_tags != NUL
? (char_u *)&(curbuf->b_p_tags) : p->var;
- case PV_TC: return *curbuf->b_p_tc != NUL
+ case PV_TC:
+ return *curbuf->b_p_tc != NUL
? (char_u *)&(curbuf->b_p_tc) : p->var;
- case PV_SISO: return curwin->w_p_siso >= 0
+ case PV_SISO:
+ return curwin->w_p_siso >= 0
? (char_u *)&(curwin->w_p_siso) : p->var;
- case PV_SO: return curwin->w_p_so >= 0
+ case PV_SO:
+ return curwin->w_p_so >= 0
? (char_u *)&(curwin->w_p_so) : p->var;
- case PV_BKC: return *curbuf->b_p_bkc != NUL
+ case PV_BKC:
+ return *curbuf->b_p_bkc != NUL
? (char_u *)&(curbuf->b_p_bkc) : p->var;
- case PV_DEF: return *curbuf->b_p_def != NUL
+ case PV_DEF:
+ return *curbuf->b_p_def != NUL
? (char_u *)&(curbuf->b_p_def) : p->var;
- case PV_INC: return *curbuf->b_p_inc != NUL
+ case PV_INC:
+ return *curbuf->b_p_inc != NUL
? (char_u *)&(curbuf->b_p_inc) : p->var;
- case PV_DICT: return *curbuf->b_p_dict != NUL
+ case PV_DICT:
+ return *curbuf->b_p_dict != NUL
? (char_u *)&(curbuf->b_p_dict) : p->var;
- case PV_TSR: return *curbuf->b_p_tsr != NUL
+ case PV_TSR:
+ return *curbuf->b_p_tsr != NUL
? (char_u *)&(curbuf->b_p_tsr) : p->var;
- case PV_FP: return *curbuf->b_p_fp != NUL
+ case PV_FP:
+ return *curbuf->b_p_fp != NUL
? (char_u *)&(curbuf->b_p_fp) : p->var;
- case PV_EFM: return *curbuf->b_p_efm != NUL
+ case PV_EFM:
+ return *curbuf->b_p_efm != NUL
? (char_u *)&(curbuf->b_p_efm) : p->var;
- case PV_GP: return *curbuf->b_p_gp != NUL
+ case PV_GP:
+ return *curbuf->b_p_gp != NUL
? (char_u *)&(curbuf->b_p_gp) : p->var;
- case PV_MP: return *curbuf->b_p_mp != NUL
+ case PV_MP:
+ return *curbuf->b_p_mp != NUL
? (char_u *)&(curbuf->b_p_mp) : p->var;
- case PV_SBR: return *curwin->w_p_sbr != NUL
+ case PV_SBR:
+ return *curwin->w_p_sbr != NUL
? (char_u *)&(curwin->w_p_sbr) : p->var;
- case PV_STL: return *curwin->w_p_stl != NUL
+ case PV_STL:
+ return *curwin->w_p_stl != NUL
? (char_u *)&(curwin->w_p_stl) : p->var;
- case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL
+ case PV_UL:
+ return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL
? (char_u *)&(curbuf->b_p_ul) : p->var;
- case PV_LW: return *curbuf->b_p_lw != NUL
+ case PV_LW:
+ return *curbuf->b_p_lw != NUL
? (char_u *)&(curbuf->b_p_lw) : p->var;
- case PV_MENC: return *curbuf->b_p_menc != NUL
+ case PV_MENC:
+ return *curbuf->b_p_menc != NUL
? (char_u *)&(curbuf->b_p_menc) : p->var;
- case PV_FCS: return *curwin->w_p_fcs != NUL
+ case PV_FCS:
+ return *curwin->w_p_fcs != NUL
? (char_u *)&(curwin->w_p_fcs) : p->var;
- case PV_LCS: return *curwin->w_p_lcs != NUL
+ case PV_LCS:
+ return *curwin->w_p_lcs != NUL
? (char_u *)&(curwin->w_p_lcs) : p->var;
- case PV_ARAB: return (char_u *)&(curwin->w_p_arab);
- case PV_LIST: return (char_u *)&(curwin->w_p_list);
- case PV_SPELL: return (char_u *)&(curwin->w_p_spell);
- case PV_CUC: return (char_u *)&(curwin->w_p_cuc);
- case PV_CUL: return (char_u *)&(curwin->w_p_cul);
- case PV_CULOPT: return (char_u *)&(curwin->w_p_culopt);
- case PV_CC: return (char_u *)&(curwin->w_p_cc);
- case PV_DIFF: return (char_u *)&(curwin->w_p_diff);
- case PV_FDC: return (char_u *)&(curwin->w_p_fdc);
- case PV_FEN: return (char_u *)&(curwin->w_p_fen);
- case PV_FDI: return (char_u *)&(curwin->w_p_fdi);
- case PV_FDL: return (char_u *)&(curwin->w_p_fdl);
- case PV_FDM: return (char_u *)&(curwin->w_p_fdm);
- case PV_FML: return (char_u *)&(curwin->w_p_fml);
- case PV_FDN: return (char_u *)&(curwin->w_p_fdn);
- case PV_FDE: return (char_u *)&(curwin->w_p_fde);
- case PV_FDT: return (char_u *)&(curwin->w_p_fdt);
- case PV_FMR: return (char_u *)&(curwin->w_p_fmr);
- case PV_NU: return (char_u *)&(curwin->w_p_nu);
- case PV_RNU: return (char_u *)&(curwin->w_p_rnu);
- case PV_NUW: return (char_u *)&(curwin->w_p_nuw);
- case PV_WFH: return (char_u *)&(curwin->w_p_wfh);
- case PV_WFW: return (char_u *)&(curwin->w_p_wfw);
- case PV_PVW: return (char_u *)&(curwin->w_p_pvw);
- case PV_RL: return (char_u *)&(curwin->w_p_rl);
- case PV_RLC: return (char_u *)&(curwin->w_p_rlc);
- case PV_SCROLL: return (char_u *)&(curwin->w_p_scr);
- case PV_WRAP: return (char_u *)&(curwin->w_p_wrap);
- case PV_LBR: return (char_u *)&(curwin->w_p_lbr);
- case PV_BRI: return (char_u *)&(curwin->w_p_bri);
- case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt);
- case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
- case PV_CRBIND: return (char_u *)&(curwin->w_p_crb);
- case PV_COCU: return (char_u *)&(curwin->w_p_cocu);
- case PV_COLE: return (char_u *)&(curwin->w_p_cole);
-
- case PV_AI: return (char_u *)&(curbuf->b_p_ai);
- case PV_BIN: return (char_u *)&(curbuf->b_p_bin);
- case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
- case PV_BH: return (char_u *)&(curbuf->b_p_bh);
- case PV_BT: return (char_u *)&(curbuf->b_p_bt);
- case PV_BL: return (char_u *)&(curbuf->b_p_bl);
- case PV_CHANNEL:return (char_u *)&(curbuf->b_p_channel);
- case PV_CI: return (char_u *)&(curbuf->b_p_ci);
- case PV_CIN: return (char_u *)&(curbuf->b_p_cin);
- case PV_CINK: return (char_u *)&(curbuf->b_p_cink);
- case PV_CINO: return (char_u *)&(curbuf->b_p_cino);
- case PV_CINW: return (char_u *)&(curbuf->b_p_cinw);
- case PV_COM: return (char_u *)&(curbuf->b_p_com);
- case PV_CMS: return (char_u *)&(curbuf->b_p_cms);
- case PV_CPT: return (char_u *)&(curbuf->b_p_cpt);
+ case PV_ARAB:
+ return (char_u *)&(curwin->w_p_arab);
+ case PV_LIST:
+ return (char_u *)&(curwin->w_p_list);
+ case PV_SPELL:
+ return (char_u *)&(curwin->w_p_spell);
+ case PV_CUC:
+ return (char_u *)&(curwin->w_p_cuc);
+ case PV_CUL:
+ return (char_u *)&(curwin->w_p_cul);
+ case PV_CULOPT:
+ return (char_u *)&(curwin->w_p_culopt);
+ case PV_CC:
+ return (char_u *)&(curwin->w_p_cc);
+ case PV_DIFF:
+ return (char_u *)&(curwin->w_p_diff);
+ case PV_FDC:
+ return (char_u *)&(curwin->w_p_fdc);
+ case PV_FEN:
+ return (char_u *)&(curwin->w_p_fen);
+ case PV_FDI:
+ return (char_u *)&(curwin->w_p_fdi);
+ case PV_FDL:
+ return (char_u *)&(curwin->w_p_fdl);
+ case PV_FDM:
+ return (char_u *)&(curwin->w_p_fdm);
+ case PV_FML:
+ return (char_u *)&(curwin->w_p_fml);
+ case PV_FDN:
+ return (char_u *)&(curwin->w_p_fdn);
+ case PV_FDE:
+ return (char_u *)&(curwin->w_p_fde);
+ case PV_FDT:
+ return (char_u *)&(curwin->w_p_fdt);
+ case PV_FMR:
+ return (char_u *)&(curwin->w_p_fmr);
+ case PV_NU:
+ return (char_u *)&(curwin->w_p_nu);
+ case PV_RNU:
+ return (char_u *)&(curwin->w_p_rnu);
+ case PV_NUW:
+ return (char_u *)&(curwin->w_p_nuw);
+ case PV_WFH:
+ return (char_u *)&(curwin->w_p_wfh);
+ case PV_WFW:
+ return (char_u *)&(curwin->w_p_wfw);
+ case PV_PVW:
+ return (char_u *)&(curwin->w_p_pvw);
+ case PV_RL:
+ return (char_u *)&(curwin->w_p_rl);
+ case PV_RLC:
+ return (char_u *)&(curwin->w_p_rlc);
+ case PV_SCROLL:
+ return (char_u *)&(curwin->w_p_scr);
+ case PV_WRAP:
+ return (char_u *)&(curwin->w_p_wrap);
+ case PV_LBR:
+ return (char_u *)&(curwin->w_p_lbr);
+ case PV_BRI:
+ return (char_u *)&(curwin->w_p_bri);
+ case PV_BRIOPT:
+ return (char_u *)&(curwin->w_p_briopt);
+ case PV_SCBIND:
+ return (char_u *)&(curwin->w_p_scb);
+ case PV_CRBIND:
+ return (char_u *)&(curwin->w_p_crb);
+ case PV_COCU:
+ return (char_u *)&(curwin->w_p_cocu);
+ case PV_COLE:
+ return (char_u *)&(curwin->w_p_cole);
+
+ case PV_AI:
+ return (char_u *)&(curbuf->b_p_ai);
+ case PV_BIN:
+ return (char_u *)&(curbuf->b_p_bin);
+ case PV_BOMB:
+ return (char_u *)&(curbuf->b_p_bomb);
+ case PV_BH:
+ return (char_u *)&(curbuf->b_p_bh);
+ case PV_BT:
+ return (char_u *)&(curbuf->b_p_bt);
+ case PV_BL:
+ return (char_u *)&(curbuf->b_p_bl);
+ case PV_CHANNEL:
+ return (char_u *)&(curbuf->b_p_channel);
+ case PV_CI:
+ return (char_u *)&(curbuf->b_p_ci);
+ case PV_CIN:
+ return (char_u *)&(curbuf->b_p_cin);
+ case PV_CINK:
+ return (char_u *)&(curbuf->b_p_cink);
+ case PV_CINO:
+ return (char_u *)&(curbuf->b_p_cino);
+ case PV_CINW:
+ return (char_u *)&(curbuf->b_p_cinw);
+ case PV_COM:
+ return (char_u *)&(curbuf->b_p_com);
+ case PV_CMS:
+ return (char_u *)&(curbuf->b_p_cms);
+ case PV_CPT:
+ return (char_u *)&(curbuf->b_p_cpt);
# ifdef BACKSLASH_IN_FILENAME
- case PV_CSL: return (char_u *)&(curbuf->b_p_csl);
+ case PV_CSL:
+ return (char_u *)&(curbuf->b_p_csl);
# endif
- case PV_CFU: return (char_u *)&(curbuf->b_p_cfu);
- case PV_OFU: return (char_u *)&(curbuf->b_p_ofu);
- case PV_EOL: return (char_u *)&(curbuf->b_p_eol);
- case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol);
- case PV_ET: return (char_u *)&(curbuf->b_p_et);
- case PV_FENC: return (char_u *)&(curbuf->b_p_fenc);
- case PV_FF: return (char_u *)&(curbuf->b_p_ff);
- case PV_FT: return (char_u *)&(curbuf->b_p_ft);
- case PV_FO: return (char_u *)&(curbuf->b_p_fo);
- case PV_FLP: return (char_u *)&(curbuf->b_p_flp);
- case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert);
- case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch);
- case PV_INF: return (char_u *)&(curbuf->b_p_inf);
- case PV_ISK: return (char_u *)&(curbuf->b_p_isk);
- case PV_INEX: return (char_u *)&(curbuf->b_p_inex);
- case PV_INDE: return (char_u *)&(curbuf->b_p_inde);
- case PV_INDK: return (char_u *)&(curbuf->b_p_indk);
- case PV_FEX: return (char_u *)&(curbuf->b_p_fex);
- case PV_LISP: return (char_u *)&(curbuf->b_p_lisp);
- case PV_ML: return (char_u *)&(curbuf->b_p_ml);
- case PV_MPS: return (char_u *)&(curbuf->b_p_mps);
- case PV_MA: return (char_u *)&(curbuf->b_p_ma);
- case PV_MOD: return (char_u *)&(curbuf->b_changed);
- case PV_NF: return (char_u *)&(curbuf->b_p_nf);
- case PV_PI: return (char_u *)&(curbuf->b_p_pi);
- case PV_QE: return (char_u *)&(curbuf->b_p_qe);
- case PV_RO: return (char_u *)&(curbuf->b_p_ro);
- case PV_SCBK: return (char_u *)&(curbuf->b_p_scbk);
- case PV_SI: return (char_u *)&(curbuf->b_p_si);
- case PV_STS: return (char_u *)&(curbuf->b_p_sts);
- case PV_SUA: return (char_u *)&(curbuf->b_p_sua);
- case PV_SWF: return (char_u *)&(curbuf->b_p_swf);
- case PV_SMC: return (char_u *)&(curbuf->b_p_smc);
- case PV_SYN: return (char_u *)&(curbuf->b_p_syn);
- case PV_SPC: return (char_u *)&(curwin->w_s->b_p_spc);
- case PV_SPF: return (char_u *)&(curwin->w_s->b_p_spf);
- case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl);
- case PV_SPO: return (char_u *)&(curwin->w_s->b_p_spo);
- case PV_SW: return (char_u *)&(curbuf->b_p_sw);
- case PV_TFU: return (char_u *)&(curbuf->b_p_tfu);
- case PV_TS: return (char_u *)&(curbuf->b_p_ts);
- case PV_TW: return (char_u *)&(curbuf->b_p_tw);
- case PV_UDF: return (char_u *)&(curbuf->b_p_udf);
- case PV_WM: return (char_u *)&(curbuf->b_p_wm);
- case PV_VSTS: return (char_u *)&(curbuf->b_p_vsts);
- case PV_VTS: return (char_u *)&(curbuf->b_p_vts);
- case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap);
- case PV_SCL: return (char_u *)&(curwin->w_p_scl);
- case PV_WINHL: return (char_u *)&(curwin->w_p_winhl);
- case PV_WINBL: return (char_u *)&(curwin->w_p_winbl);
- default: IEMSG(_("E356: get_varp ERROR"));
+ case PV_CFU:
+ return (char_u *)&(curbuf->b_p_cfu);
+ case PV_OFU:
+ return (char_u *)&(curbuf->b_p_ofu);
+ case PV_EOL:
+ return (char_u *)&(curbuf->b_p_eol);
+ case PV_FIXEOL:
+ return (char_u *)&(curbuf->b_p_fixeol);
+ case PV_ET:
+ return (char_u *)&(curbuf->b_p_et);
+ case PV_FENC:
+ return (char_u *)&(curbuf->b_p_fenc);
+ case PV_FF:
+ return (char_u *)&(curbuf->b_p_ff);
+ case PV_FT:
+ return (char_u *)&(curbuf->b_p_ft);
+ case PV_FO:
+ return (char_u *)&(curbuf->b_p_fo);
+ case PV_FLP:
+ return (char_u *)&(curbuf->b_p_flp);
+ case PV_IMI:
+ return (char_u *)&(curbuf->b_p_iminsert);
+ case PV_IMS:
+ return (char_u *)&(curbuf->b_p_imsearch);
+ case PV_INF:
+ return (char_u *)&(curbuf->b_p_inf);
+ case PV_ISK:
+ return (char_u *)&(curbuf->b_p_isk);
+ case PV_INEX:
+ return (char_u *)&(curbuf->b_p_inex);
+ case PV_INDE:
+ return (char_u *)&(curbuf->b_p_inde);
+ case PV_INDK:
+ return (char_u *)&(curbuf->b_p_indk);
+ case PV_FEX:
+ return (char_u *)&(curbuf->b_p_fex);
+ case PV_LISP:
+ return (char_u *)&(curbuf->b_p_lisp);
+ case PV_ML:
+ return (char_u *)&(curbuf->b_p_ml);
+ case PV_MPS:
+ return (char_u *)&(curbuf->b_p_mps);
+ case PV_MA:
+ return (char_u *)&(curbuf->b_p_ma);
+ case PV_MOD:
+ return (char_u *)&(curbuf->b_changed);
+ case PV_NF:
+ return (char_u *)&(curbuf->b_p_nf);
+ case PV_PI:
+ return (char_u *)&(curbuf->b_p_pi);
+ case PV_QE:
+ return (char_u *)&(curbuf->b_p_qe);
+ case PV_RO:
+ return (char_u *)&(curbuf->b_p_ro);
+ case PV_SCBK:
+ return (char_u *)&(curbuf->b_p_scbk);
+ case PV_SI:
+ return (char_u *)&(curbuf->b_p_si);
+ case PV_STS:
+ return (char_u *)&(curbuf->b_p_sts);
+ case PV_SUA:
+ return (char_u *)&(curbuf->b_p_sua);
+ case PV_SWF:
+ return (char_u *)&(curbuf->b_p_swf);
+ case PV_SMC:
+ return (char_u *)&(curbuf->b_p_smc);
+ case PV_SYN:
+ return (char_u *)&(curbuf->b_p_syn);
+ case PV_SPC:
+ return (char_u *)&(curwin->w_s->b_p_spc);
+ case PV_SPF:
+ return (char_u *)&(curwin->w_s->b_p_spf);
+ case PV_SPL:
+ return (char_u *)&(curwin->w_s->b_p_spl);
+ case PV_SPO:
+ return (char_u *)&(curwin->w_s->b_p_spo);
+ case PV_SW:
+ return (char_u *)&(curbuf->b_p_sw);
+ case PV_TFU:
+ return (char_u *)&(curbuf->b_p_tfu);
+ case PV_TS:
+ return (char_u *)&(curbuf->b_p_ts);
+ case PV_TW:
+ return (char_u *)&(curbuf->b_p_tw);
+ case PV_UDF:
+ return (char_u *)&(curbuf->b_p_udf);
+ case PV_WM:
+ return (char_u *)&(curbuf->b_p_wm);
+ case PV_VSTS:
+ return (char_u *)&(curbuf->b_p_vsts);
+ case PV_VTS:
+ return (char_u *)&(curbuf->b_p_vts);
+ case PV_KMAP:
+ return (char_u *)&(curbuf->b_p_keymap);
+ case PV_SCL:
+ return (char_u *)&(curwin->w_p_scl);
+ case PV_WINHL:
+ return (char_u *)&(curwin->w_p_winhl);
+ case PV_WINBL:
+ return (char_u *)&(curwin->w_p_winbl);
+ default:
+ IEMSG(_("E356: get_varp ERROR"));
}
// always return a valid pointer to avoid a crash!
return (char_u *)&(curbuf->b_p_wm);
@@ -5963,7 +6092,7 @@ void didset_window_options(win_T *wp)
void buf_copy_options(buf_T *buf, int flags)
{
int should_copy = true;
- char_u *save_p_isk = NULL; // init for GCC
+ char_u *save_p_isk = NULL; // init for GCC
int dont_do_help;
int did_isk = false;
@@ -6008,22 +6137,18 @@ void buf_copy_options(buf_T *buf, int flags)
buf->b_p_ro = false; // don't copy readonly
buf->b_p_fenc = vim_strsave(p_fenc);
switch (*p_ffs) {
- case 'm': {
- buf->b_p_ff = vim_strsave((char_u *)FF_MAC);
- break;
- }
- case 'd': {
- buf->b_p_ff = vim_strsave((char_u *)FF_DOS);
- break;
- }
- case 'u': {
- buf->b_p_ff = vim_strsave((char_u *)FF_UNIX);
- break;
- }
- default: {
- buf->b_p_ff = vim_strsave(p_ff);
- break;
- }
+ case 'm':
+ buf->b_p_ff = vim_strsave((char_u *)FF_MAC);
+ break;
+ case 'd':
+ buf->b_p_ff = vim_strsave((char_u *)FF_DOS);
+ break;
+ case 'u':
+ buf->b_p_ff = vim_strsave((char_u *)FF_UNIX);
+ break;
+ default:
+ buf->b_p_ff = vim_strsave(p_ff);
+ break;
}
buf->b_p_bh = empty_option;
buf->b_p_bt = empty_option;
@@ -6204,21 +6329,17 @@ void set_imsearch_global(void)
}
static int expand_option_idx = -1;
-static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL};
+static char_u expand_option_name[5] = { 't', '_', NUL, NUL, NUL };
static int expand_option_flags = 0;
-void
-set_context_in_set_cmd(
- expand_T *xp,
- char_u *arg,
- int opt_flags // OPT_GLOBAL and/or OPT_LOCAL
-)
+/// @param opt_flags OPT_GLOBAL and/or OPT_LOCAL
+void set_context_in_set_cmd(expand_T *xp, char_u *arg, int opt_flags)
{
char_u nextchar;
uint32_t flags = 0; // init for GCC
int opt_idx = 0; // init for GCC
- char_u *p;
- char_u *s;
+ char_u *p;
+ char_u *s;
int is_term_option = false;
int key;
@@ -6342,15 +6463,14 @@ set_context_in_set_cmd(
|| p == (char_u *)&p_pp
|| p == (char_u *)&p_rtp
|| p == (char_u *)&p_cdpath
- || p == (char_u *)&p_vdir
- ) {
+ || p == (char_u *)&p_vdir) {
xp->xp_context = EXPAND_DIRECTORIES;
if (p == (char_u *)&p_path
- || p == (char_u *)&p_cdpath
- )
+ || p == (char_u *)&p_cdpath) {
xp->xp_backslash = XP_BS_THREE;
- else
+ } else {
xp->xp_backslash = XP_BS_ONE;
+ }
} else if (p == (char_u *)&p_ft) {
xp->xp_context = EXPAND_FILETYPE;
} else {
@@ -6396,7 +6516,7 @@ int ExpandSettings(expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***
int num_normal = 0; // Nr of matching non-term-code settings
int match;
int count = 0;
- char_u *str;
+ char_u *str;
int loop;
static char *(names[]) = { "all" };
int ic = regmatch->rm_ic; // remember the ignore-case flag
@@ -6440,8 +6560,9 @@ int ExpandSettings(expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***
if (match) {
if (loop == 0) {
num_normal++;
- } else
+ } else {
(*file)[count++] = vim_strsave(str);
+ }
}
}
@@ -6503,13 +6624,11 @@ void ExpandOldSetting(int *num_file, char_u ***file)
/// Get the value for the numeric or string option///opp in a nice format into
/// NameBuff[]. Must not be called with a hidden option!
-static void
-option_value2string(
- vimoption_T *opp,
- int opt_flags // OPT_GLOBAL and/or OPT_LOCAL
-)
+///
+/// @param opt_flags OPT_GLOBAL and/or OPT_LOCAL
+static void option_value2string(vimoption_T *opp, int opt_flags)
{
- char_u *varp;
+ char_u *varp;
varp = get_varp_scope(opp, opt_flags);
@@ -6532,7 +6651,7 @@ option_value2string(
NameBuff[0] = NUL;
} else if (opp->flags & P_EXPAND) {
home_replace(NULL, varp, NameBuff, MAXPATHL, false);
- // Translate 'pastetoggle' into special key names.
+ // Translate 'pastetoggle' into special key names.
} else if ((char_u **)opp->var == &p_pt) {
str2specialbuf((const char *)p_pt, (char *)NameBuff, MAXPATHL);
} else {
@@ -6645,8 +6764,8 @@ static void langmap_init(void)
/// changed at any time!
static void langmap_set(void)
{
- char_u *p;
- char_u *p2;
+ char_u *p;
+ char_u *p2;
int from, to;
ga_clear(&langmap_mapga); // clear the previous map first
@@ -6692,7 +6811,7 @@ static void langmap_set(void)
}
if (to == NUL) {
EMSG2(_("E357: 'langmap': Matching character missing for %s"),
- transchar(from));
+ transchar(from));
return;
}
@@ -6711,9 +6830,8 @@ static void langmap_set(void)
p = p2;
if (p[0] != NUL) {
if (p[0] != ',') {
- EMSG2(_(
- "E358: 'langmap': Extra characters after semicolon: %s"),
- p);
+ EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"),
+ p);
return;
}
p++;
@@ -6938,7 +7056,7 @@ void reset_option_was_set(const char *name)
/// fill_breakat_flags() -- called when 'breakat' changes value.
static void fill_breakat_flags(void)
{
- char_u *p;
+ char_u *p;
int i;
for (i = 0; i < 256; i++) {
@@ -6997,13 +7115,10 @@ static int fill_culopt_flags(char_u *val, win_T *wp)
/// Check an option that can be a range of string values.
///
-/// Return OK for correct value, FAIL otherwise.
-/// Empty is always OK.
-static int check_opt_strings(
- char_u *val,
- char **values,
- int list // when true: accept a list of values
-)
+/// @param list when true: accept a list of values
+///
+/// @return OK for correct value, FAIL otherwise. Empty is always OK.
+static int check_opt_strings(char_u *val, char **values, int list)
{
return opt_strings_flags(val, values, NULL, list);
}
@@ -7011,14 +7126,12 @@ static int check_opt_strings(
/// Handle an option that can be a range of string values.
/// Set a flag in "*flagp" for each string present.
///
-/// Return OK for correct value, FAIL otherwise.
-/// Empty is always OK.
-static int opt_strings_flags(
- char_u *val, // new value
- char **values, // array of valid string values
- unsigned *flagp,
- bool list // when true: accept a list of values
-)
+/// @param val new value
+/// @param values array of valid string values
+/// @param list when true: accept a list of values
+///
+/// @return OK for correct value, FAIL otherwise. Empty is always OK.
+static int opt_strings_flags(char_u *val, char **values, unsigned *flagp, bool list)
{
unsigned int new_flags = 0;
@@ -7049,7 +7162,7 @@ static int opt_strings_flags(
static int check_opt_wim(void)
{
char_u new_wim_flags[4];
- char_u *p;
+ char_u *p;
int i;
int idx = 0;
@@ -7106,10 +7219,14 @@ bool can_bs(int what)
return false;
}
switch (*p_bs) {
- case '3': return true;
- case '2': return what != BS_NOSTOP;
- case '1': return what != BS_START;
- case '0': return false;
+ case '3':
+ return true;
+ case '2':
+ return what != BS_NOSTOP;
+ case '1':
+ return what != BS_START;
+ case '0':
+ return false;
}
return vim_strchr(p_bs, what) != NULL;
}
@@ -7306,11 +7423,7 @@ colnr_T tabstop_start(colnr_T col, long ts, long *vts)
// Find the number of tabs and spaces necessary to get from one column
// to another.
-void tabstop_fromto(colnr_T start_col,
- colnr_T end_col,
- long ts_arg,
- long *vts,
- int *ntabs,
+void tabstop_fromto(colnr_T start_col, colnr_T end_col, long ts_arg, long *vts, int *ntabs,
int *nspcs)
{
int spaces = end_col - start_col;
@@ -7486,18 +7599,13 @@ static bool briopt_check(win_T *wp)
while (*p != NUL)
{
if (STRNCMP(p, "shift:", 6) == 0
- && ((p[6] == '-' && ascii_isdigit(p[7])) || ascii_isdigit(p[6])))
- {
+ && ((p[6] == '-' && ascii_isdigit(p[7])) || ascii_isdigit(p[6]))) {
p += 6;
bri_shift = getdigits_int(&p, true, 0);
- }
- else if (STRNCMP(p, "min:", 4) == 0 && ascii_isdigit(p[4]))
- {
+ } else if (STRNCMP(p, "min:", 4) == 0 && ascii_isdigit(p[4])) {
p += 4;
bri_min = getdigits_int(&p, true, 0);
- }
- else if (STRNCMP(p, "sbr", 3) == 0)
- {
+ } else if (STRNCMP(p, "sbr", 3) == 0) {
p += 3;
bri_sbr = true;
} else if (STRNCMP(p, "list:", 5) == 0) {
@@ -7590,8 +7698,10 @@ int get_fileformat_force(const buf_T *buf, const exarg_T *eap)
int default_fileformat(void)
{
switch (*p_ffs) {
- case 'm': return EOL_MAC;
- case 'd': return EOL_DOS;
+ case 'm':
+ return EOL_MAC;
+ case 'd':
+ return EOL_DOS;
}
return EOL_UNIX;
}
@@ -7607,15 +7717,15 @@ void set_fileformat(int eol_style, int opt_flags)
char *p = NULL;
switch (eol_style) {
- case EOL_UNIX:
- p = FF_UNIX;
- break;
- case EOL_MAC:
- p = FF_MAC;
- break;
- case EOL_DOS:
- p = FF_DOS;
- break;
+ case EOL_UNIX:
+ p = FF_UNIX;
+ break;
+ case EOL_MAC:
+ p = FF_MAC;
+ break;
+ case EOL_DOS:
+ p = FF_DOS;
+ break;
}
// p is NULL if "eol_style" is EOL_UNKNOWN.
@@ -7653,11 +7763,10 @@ char_u *skip_to_option_part(const char_u *p)
/// @param[in] sep_chars chars that separate the option parts
///
/// @return length of `*option`
-size_t copy_option_part(char_u **option, char_u *buf, size_t maxlen,
- char *sep_chars)
+size_t copy_option_part(char_u **option, char_u *buf, size_t maxlen, char *sep_chars)
{
size_t len = 0;
- char_u *p = *option;
+ char_u *p = *option;
// skip '.' at start of option part, for 'suffixes'
if (*p == '.') {
@@ -7820,52 +7929,52 @@ Dictionary get_all_vimoptions(void)
static Dictionary vimoption2dict(vimoption_T *opt)
{
- Dictionary dict = ARRAY_DICT_INIT;
+ Dictionary dict = ARRAY_DICT_INIT;
- PUT(dict, "name", CSTR_TO_OBJ(opt->fullname));
- PUT(dict, "shortname", CSTR_TO_OBJ(opt->shortname));
+ PUT(dict, "name", CSTR_TO_OBJ(opt->fullname));
+ PUT(dict, "shortname", CSTR_TO_OBJ(opt->shortname));
- const char *scope;
- if (opt->indir & PV_BUF) {
- scope = "buf";
- } else if (opt->indir & PV_WIN) {
- scope = "win";
- } else {
- scope = "global";
- }
-
- PUT(dict, "scope", CSTR_TO_OBJ(scope));
-
- // welcome to the jungle
- PUT(dict, "global_local", BOOL(opt->indir & PV_BOTH));
- PUT(dict, "commalist", BOOL(opt->flags & P_COMMA));
- PUT(dict, "flaglist", BOOL(opt->flags & P_FLAGLIST));
-
- PUT(dict, "was_set", BOOL(opt->flags & P_WAS_SET));
-
- PUT(dict, "last_set_sid", INTEGER_OBJ(opt->last_set.script_ctx.sc_sid));
- PUT(dict, "last_set_linenr", INTEGER_OBJ(opt->last_set.script_ctx.sc_lnum));
- PUT(dict, "last_set_chan", INTEGER_OBJ((int64_t)opt->last_set.channel_id));
-
- const char *type;
- Object def;
- // TODO(bfredl): do you even nocp?
- char_u *def_val = opt->def_val;
- if (opt->flags & P_STRING) {
- type = "string";
- def = CSTR_TO_OBJ(def_val ? (char *)def_val : "");
- } else if (opt->flags & P_NUM) {
- type = "number";
- def = INTEGER_OBJ((Integer)(intptr_t)def_val);
- } else if (opt->flags & P_BOOL) {
- type = "boolean";
- def = BOOL((intptr_t)def_val);
- } else {
- type = ""; def = NIL;
- }
- PUT(dict, "type", CSTR_TO_OBJ(type));
- PUT(dict, "default", def);
- PUT(dict, "allows_duplicates", BOOL(!(opt->flags & P_NODUP)));
+ const char *scope;
+ if (opt->indir & PV_BUF) {
+ scope = "buf";
+ } else if (opt->indir & PV_WIN) {
+ scope = "win";
+ } else {
+ scope = "global";
+ }
+
+ PUT(dict, "scope", CSTR_TO_OBJ(scope));
+
+ // welcome to the jungle
+ PUT(dict, "global_local", BOOL(opt->indir & PV_BOTH));
+ PUT(dict, "commalist", BOOL(opt->flags & P_COMMA));
+ PUT(dict, "flaglist", BOOL(opt->flags & P_FLAGLIST));
+
+ PUT(dict, "was_set", BOOL(opt->flags & P_WAS_SET));
+
+ PUT(dict, "last_set_sid", INTEGER_OBJ(opt->last_set.script_ctx.sc_sid));
+ PUT(dict, "last_set_linenr", INTEGER_OBJ(opt->last_set.script_ctx.sc_lnum));
+ PUT(dict, "last_set_chan", INTEGER_OBJ((int64_t)opt->last_set.channel_id));
+
+ const char *type;
+ Object def;
+ // TODO(bfredl): do you even nocp?
+ char_u *def_val = opt->def_val;
+ if (opt->flags & P_STRING) {
+ type = "string";
+ def = CSTR_TO_OBJ(def_val ? (char *)def_val : "");
+ } else if (opt->flags & P_NUM) {
+ type = "number";
+ def = INTEGER_OBJ((Integer)(intptr_t)def_val);
+ } else if (opt->flags & P_BOOL) {
+ type = "boolean";
+ def = BOOL((intptr_t)def_val);
+ } else {
+ type = ""; def = NIL;
+ }
+ PUT(dict, "type", CSTR_TO_OBJ(type));
+ PUT(dict, "default", def);
+ PUT(dict, "allows_duplicates", BOOL(!(opt->flags & P_NODUP)));
- return dict;
+ return dict;
}
diff --git a/src/nvim/os_unix.c b/src/nvim/os_unix.c
index 44274e8f1d..9396a5896a 100644
--- a/src/nvim/os_unix.c
+++ b/src/nvim/os_unix.c
@@ -7,14 +7,13 @@
#include <stdbool.h>
#include <string.h>
-#include "nvim/vim.h"
#include "nvim/ascii.h"
-#include "nvim/os_unix.h"
#include "nvim/buffer.h"
#include "nvim/charset.h"
#include "nvim/eval.h"
#include "nvim/ex_cmds.h"
#include "nvim/fileio.h"
+#include "nvim/garray.h"
#include "nvim/getchar.h"
#include "nvim/main.h"
#include "nvim/mbyte.h"
@@ -23,19 +22,20 @@
#include "nvim/message.h"
#include "nvim/misc1.h"
#include "nvim/mouse.h"
-#include "nvim/garray.h"
+#include "nvim/msgpack_rpc/helpers.h"
+#include "nvim/os/input.h"
+#include "nvim/os/os.h"
+#include "nvim/os/shell.h"
+#include "nvim/os/signal.h"
+#include "nvim/os/time.h"
+#include "nvim/os_unix.h"
#include "nvim/path.h"
#include "nvim/screen.h"
#include "nvim/strings.h"
#include "nvim/syntax.h"
-#include "nvim/ui.h"
#include "nvim/types.h"
-#include "nvim/os/os.h"
-#include "nvim/os/time.h"
-#include "nvim/os/input.h"
-#include "nvim/os/shell.h"
-#include "nvim/os/signal.h"
-#include "nvim/msgpack_rpc/helpers.h"
+#include "nvim/ui.h"
+#include "nvim/vim.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "os_unix.c.generated.h"
@@ -61,13 +61,15 @@ vim_acl_T mch_get_acl(const char_u *fname)
// Set the ACL of file "fname" to "acl" (unless it's NULL).
void mch_set_acl(const char_u *fname, vim_acl_T aclent)
{
- if (aclent == NULL)
+ if (aclent == NULL) {
return;
+ }
}
void mch_free_acl(vim_acl_T aclent)
{
- if (aclent == NULL)
+ if (aclent == NULL) {
return;
+ }
}
#endif
diff --git a/src/nvim/path.c b/src/nvim/path.c
index 5d14eba0a5..60c7ea7fa4 100644
--- a/src/nvim/path.c
+++ b/src/nvim/path.c
@@ -6,15 +6,13 @@
#include <stdbool.h>
#include <stdlib.h>
-#include "nvim/vim.h"
#include "nvim/ascii.h"
-#include "nvim/path.h"
#include "nvim/charset.h"
#include "nvim/eval.h"
#include "nvim/ex_docmd.h"
#include "nvim/ex_getln.h"
-#include "nvim/fileio.h"
#include "nvim/file_search.h"
+#include "nvim/fileio.h"
#include "nvim/garray.h"
#include "nvim/memfile.h"
#include "nvim/memline.h"
@@ -22,20 +20,22 @@
#include "nvim/message.h"
#include "nvim/misc1.h"
#include "nvim/option.h"
+#include "nvim/os/input.h"
#include "nvim/os/os.h"
#include "nvim/os/shell.h"
#include "nvim/os_unix.h"
+#include "nvim/path.h"
#include "nvim/quickfix.h"
#include "nvim/regexp.h"
#include "nvim/screen.h"
#include "nvim/strings.h"
#include "nvim/tag.h"
#include "nvim/types.h"
-#include "nvim/os/input.h"
+#include "nvim/vim.h"
#include "nvim/window.h"
-#define URL_SLASH 1 /* path_is_url() has found "://" */
-#define URL_BACKSLASH 2 /* path_is_url() has found ":\\" */
+#define URL_SLASH 1 // path_is_url() has found "://"
+#define URL_BACKSLASH 2 // path_is_url() has found ":\\"
#ifdef gen_expand_wildcards
# undef gen_expand_wildcards
@@ -53,8 +53,8 @@
/// @param checkname When both files don't exist, only compare their names.
/// @param expandenv Whether to expand environment variables in file names.
/// @return Enum of type FileComparison. @see FileComparison.
-FileComparison path_full_compare(char_u *const s1, char_u *const s2,
- const bool checkname, const bool expandenv)
+FileComparison path_full_compare(char_u *const s1, char_u *const s2, const bool checkname,
+ const bool expandenv)
{
assert(s1 && s2);
char_u exp1[MAXPATHL];
@@ -63,9 +63,9 @@ FileComparison path_full_compare(char_u *const s1, char_u *const s2,
FileID file_id_1, file_id_2;
if (expandenv) {
- expand_env(s1, exp1, MAXPATHL);
+ expand_env(s1, exp1, MAXPATHL);
} else {
- xstrlcpy((char *)exp1, (const char *)s1, MAXPATHL);
+ xstrlcpy((char *)exp1, (const char *)s1, MAXPATHL);
}
bool id_ok_1 = os_fileid((char *)exp1, &file_id_1);
bool id_ok_2 = os_fileid((char *)s2, &file_id_2);
@@ -146,7 +146,7 @@ char_u *path_tail_with_sep(char_u *fname)
const char_u *invocation_path_tail(const char_u *invocation, size_t *len)
FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_ARG(1)
{
- const char_u *tail = get_past_head((char_u *) invocation);
+ const char_u *tail = get_past_head((char_u *)invocation);
const char_u *p = tail;
while (*p != NUL && *p != ' ') {
bool was_sep = vim_ispathsep_nocolon(*p);
@@ -266,7 +266,7 @@ int vim_ispathlistsep(int c)
#ifdef UNIX
return c == ':';
#else
- return c == ';'; /* might not be right for every system... */
+ return c == ';'; // might not be right for every system...
#endif
}
@@ -280,11 +280,12 @@ char_u *shorten_dir(char_u *str)
char_u *d = str;
bool skip = false;
for (char_u *s = str;; ++s) {
- if (s >= tail) { /* copy the whole tail */
+ if (s >= tail) { // copy the whole tail
*d++ = *s;
- if (*s == NUL)
+ if (*s == NUL) {
break;
- } else if (vim_ispathsep(*s)) { /* copy '/' and next char */
+ }
+ } else if (vim_ispathsep(*s)) { // copy '/' and next char
*d++ = *s;
skip = false;
} else if (!skip) {
@@ -348,8 +349,7 @@ int path_fnamecmp(const char *fname1, const char *fname2)
/// @param[in] len Compare at most len bytes.
///
/// @return 0 if they are equal, non-zero otherwise.
-int path_fnamencmp(const char *const fname1, const char *const fname2,
- size_t len)
+int path_fnamencmp(const char *const fname1, const char *const fname2, size_t len)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
#ifdef BACKSLASH_IN_FILENAME
@@ -389,9 +389,8 @@ int path_fnamencmp(const char *const fname1, const char *const fname2,
/// add a path separator before fname2.
///
/// @return fname1
-static inline char *do_concat_fnames(char *fname1, const size_t len1,
- const char *fname2, const size_t len2,
- const bool sep)
+static inline char *do_concat_fnames(char *fname1, const size_t len1, const char *fname2,
+ const size_t len2, const bool sep)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET
{
if (sep && *fname1 && !after_pathsep(fname1, fname1 + len1)) {
@@ -548,7 +547,7 @@ bool path_has_exp_wildcard(const char_u *p)
#else
const char *wildcards = "*?["; // Windows.
#endif
- if (vim_strchr((char_u *) wildcards, *p) != NULL) {
+ if (vim_strchr((char_u *)wildcards, *p) != NULL) {
return true;
}
}
@@ -590,8 +589,8 @@ static const char *scandir_next_with_dots(Directory *dir)
/// Implementation of path_expand().
///
/// Chars before `path + wildoff` do not get expanded.
-static size_t do_path_expand(garray_T *gap, const char_u *path,
- size_t wildoff, int flags, bool didstar)
+static size_t do_path_expand(garray_T *gap, const char_u *path, size_t wildoff, int flags,
+ bool didstar)
FUNC_ATTR_NONNULL_ALL
{
int start_len = gap->ga_len;
@@ -599,11 +598,12 @@ static size_t do_path_expand(garray_T *gap, const char_u *path,
bool starstar = false;
static int stardepth = 0; // depth for "**" expansion
- /* Expanding "**" may take a long time, check for CTRL-C. */
+ // Expanding "**" may take a long time, check for CTRL-C.
if (stardepth > 0) {
os_breakcheck();
- if (got_int)
+ if (got_int) {
return 0;
+ }
}
// Make room for file name. When doing encoding conversion the actual
@@ -633,7 +633,7 @@ static size_t do_path_expand(garray_T *gap, const char_u *path,
|| (!p_fic && (flags & EW_ICASE)
&& isalpha(PTR2CHAR(path_end)))
#endif
- )) {
+ )) {
e = p;
}
len = (size_t)(utfc_ptr2len(path_end));
@@ -644,20 +644,23 @@ static size_t do_path_expand(garray_T *gap, const char_u *path,
e = p;
*e = NUL;
- /* Now we have one wildcard component between "s" and "e". */
+ // Now we have one wildcard component between "s" and "e".
/* Remove backslashes between "wildoff" and the start of the wildcard
* component. */
- for (p = buf + wildoff; p < s; ++p)
+ for (p = buf + wildoff; p < s; ++p) {
if (rem_backslash(p)) {
STRMOVE(p, p + 1);
--e;
--s;
}
+ }
- /* Check for "**" between "s" and "e". */
- for (p = s; p < e; ++p)
- if (p[0] == '*' && p[1] == '*')
+ // Check for "**" between "s" and "e".
+ for (p = s; p < e; ++p) {
+ if (p[0] == '*' && p[1] == '*') {
starstar = true;
+ }
+ }
// convert the file pattern to a regexp pattern
int starts_with_dot = *s == '.';
@@ -675,11 +678,13 @@ static size_t do_path_expand(garray_T *gap, const char_u *path,
#else
regmatch.rm_ic = true; // Always ignore case on Windows.
#endif
- if (flags & (EW_NOERROR | EW_NOTWILD))
+ if (flags & (EW_NOERROR | EW_NOTWILD)) {
++emsg_silent;
+ }
regmatch.regprog = vim_regcomp(pat, RE_MAGIC);
- if (flags & (EW_NOERROR | EW_NOTWILD))
+ if (flags & (EW_NOERROR | EW_NOTWILD)) {
--emsg_silent;
+ }
xfree(pat);
if (regmatch.regprog == NULL && (flags & EW_NOTWILD) == 0) {
@@ -727,9 +732,9 @@ static size_t do_path_expand(garray_T *gap, const char_u *path,
}
STRCPY(buf + len, path_end);
- if (path_has_exp_wildcard(path_end)) { /* handle more wildcards */
- /* need to expand another component of the path */
- /* remove backslashes for the remaining components only */
+ if (path_has_exp_wildcard(path_end)) { // handle more wildcards
+ // need to expand another component of the path
+ // remove backslashes for the remaining components only
(void)do_path_expand(gap, buf, len + 1, flags, false);
} else {
FileInfo file_info;
@@ -741,7 +746,7 @@ static size_t do_path_expand(garray_T *gap, const char_u *path,
}
// add existing file or symbolic link
if ((flags & EW_ALLLINKS) ? os_fileinfo_link((char *)buf, &file_info)
- : os_path_exists(buf)) {
+ : os_path_exists(buf)) {
addfile(gap, buf, flags);
}
}
@@ -767,14 +772,16 @@ static size_t do_path_expand(garray_T *gap, const char_u *path,
*/
static int find_previous_pathsep(char_u *path, char_u **psep)
{
- /* skip the current separator */
- if (*psep > path && vim_ispathsep(**psep))
+ // skip the current separator
+ if (*psep > path && vim_ispathsep(**psep)) {
--*psep;
+ }
- /* find the previous separator */
+ // find the previous separator
while (*psep > path) {
- if (vim_ispathsep(**psep))
+ if (vim_ispathsep(**psep)) {
return OK;
+ }
MB_PTR_BACK(path, *psep);
}
@@ -828,8 +835,9 @@ static void expand_path_option(char_u *curdir, garray_T *gap)
/* Relative to current buffer:
* "/path/file" + "." -> "/path/"
* "/path/file" + "./subdir" -> "/path/subdir" */
- if (curbuf->b_ffname == NULL)
+ if (curbuf->b_ffname == NULL) {
continue;
+ }
char_u *p = path_tail(curbuf->b_ffname);
size_t len = (size_t)(p - curbuf->b_ffname);
if (len + STRLEN(buf) >= MAXPATHL) {
@@ -870,13 +878,13 @@ static void expand_path_option(char_u *curdir, garray_T *gap)
*
* path: /foo/bar/baz
* fname: /foo/bar/baz/quux.txt
- * returns: ^this
+ * returns: ^this
*/
static char_u *get_path_cutoff(char_u *fname, garray_T *gap)
{
int maxlen = 0;
- char_u **path_part = (char_u **)gap->ga_data;
- char_u *cutoff = NULL;
+ char_u **path_part = (char_u **)gap->ga_data;
+ char_u *cutoff = NULL;
for (int i = 0; i < gap->ga_len; i++) {
int j = 0;
@@ -932,14 +940,16 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern)
STRCAT(file_pattern, pattern);
char_u *pat = file_pat_to_reg_pat(file_pattern, NULL, NULL, true);
xfree(file_pattern);
- if (pat == NULL)
+ if (pat == NULL) {
return;
+ }
- regmatch.rm_ic = TRUE; /* always ignore case */
+ regmatch.rm_ic = TRUE; // always ignore case
regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
xfree(pat);
- if (regmatch.regprog == NULL)
+ if (regmatch.regprog == NULL) {
return;
+ }
char_u *curdir = xmalloc(MAXPATHL);
os_dirname(curdir, MAXPATHL);
@@ -951,16 +961,17 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern)
char_u *path = fnames[i];
int is_in_curdir;
char_u *dir_end = (char_u *)gettail_dir((const char *)path);
- char_u *pathsep_p;
- char_u *path_cutoff;
+ char_u *pathsep_p;
+ char_u *path_cutoff;
len = STRLEN(path);
is_in_curdir = fnamencmp(curdir, path, dir_end - path) == 0
&& curdir[dir_end - path] == NUL;
- if (is_in_curdir)
+ if (is_in_curdir) {
in_curdir[i] = vim_strsave(path);
+ }
- /* Shorten the filename while maintaining its uniqueness */
+ // Shorten the filename while maintaining its uniqueness
path_cutoff = get_path_cutoff(path, &path_ga);
// Don't assume all files can be reached without path when search
@@ -1010,19 +1021,21 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern)
os_breakcheck();
}
- /* Shorten filenames in /in/current/directory/{filename} */
+ // Shorten filenames in /in/current/directory/{filename}
for (int i = 0; i < gap->ga_len && !got_int; i++) {
char_u *rel_path;
char_u *path = in_curdir[i];
- if (path == NULL)
+ if (path == NULL) {
continue;
+ }
/* If the {filename} is not unique, change it to ./{filename}.
* Else reduce it to {filename} */
short_name = path_shorten_fname(path, curdir);
- if (short_name == NULL)
+ if (short_name == NULL) {
short_name = path;
+ }
if (is_unique(short_name, gap, i)) {
STRCPY(fnames[i], short_name);
continue;
@@ -1040,14 +1053,16 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern)
}
xfree(curdir);
- for (int i = 0; i < gap->ga_len; i++)
+ for (int i = 0; i < gap->ga_len; i++) {
xfree(in_curdir[i]);
+ }
xfree(in_curdir);
ga_clear_strings(&path_ga);
vim_regfree(regmatch.regprog);
- if (sort_again)
+ if (sort_again) {
ga_remove_duplicate_strings(gap);
+ }
}
/// Find end of the directory name
@@ -1072,8 +1087,9 @@ const char *gettail_dir(const char *const fname)
look_for_sep = false;
}
} else {
- if (!look_for_sep)
+ if (!look_for_sep) {
dir_end = next_dir_end;
+ }
look_for_sep = true;
}
MB_PTR_ADV(p);
@@ -1082,16 +1098,12 @@ const char *gettail_dir(const char *const fname)
}
-/*
- * Calls globpath() with 'path' values for the given pattern and stores the
- * result in "gap".
- * Returns the total number of matches.
- */
-static int expand_in_path(
- garray_T *const gap,
- char_u *const pattern,
- const int flags // EW_* flags
-)
+/// Calls globpath() with 'path' values for the given pattern and stores the
+/// result in "gap".
+/// Returns the total number of matches.
+///
+/// @param flags EW_* flags
+static int expand_in_path(garray_T *const gap, char_u *const pattern, const int flags)
{
garray_T path_ga;
@@ -1131,7 +1143,7 @@ static bool has_env_var(char_u *p)
for (; *p; MB_PTR_ADV(p)) {
if (*p == '\\' && p[1] != NUL) {
p++;
- } else if (vim_strchr((char_u *) "$" , *p) != NULL) {
+ } else if (vim_strchr((char_u *)"$", *p) != NULL) {
return true;
}
}
@@ -1186,8 +1198,7 @@ static bool has_special_wildchar(char_u *p)
/// If FAIL is returned, *num_file and *file are either
/// unchanged or *num_file is set to 0 and *file is set
/// to NULL or points to "".
-int gen_expand_wildcards(int num_pat, char_u **pat, int *num_file,
- char_u ***file, int flags)
+int gen_expand_wildcards(int num_pat, char_u **pat, int *num_file, char_u ***file, int flags)
{
garray_T ga;
char_u *p;
@@ -1203,9 +1214,9 @@ int gen_expand_wildcards(int num_pat, char_u **pat, int *num_file,
*/
if (recursive)
#ifdef SPECIAL_WILDCHAR
- return os_expand_wildcards(num_pat, pat, num_file, file, flags);
+ { return os_expand_wildcards(num_pat, pat, num_file, file, flags); }
#else
- return FAIL;
+ { return FAIL; }
#endif
#ifdef SPECIAL_WILDCHAR
@@ -1247,8 +1258,9 @@ int gen_expand_wildcards(int num_pat, char_u **pat, int *num_file,
// First expand environment variables, "~/" and "~user/".
if ((has_env_var(p) && !(flags & EW_NOTENV)) || *p == '~') {
p = expand_env_save_opt(p, true);
- if (p == NULL)
+ if (p == NULL) {
p = pat[i];
+ }
#ifdef UNIX
/*
* On Unix, if expand_env() can't expand an environment
@@ -1278,8 +1290,8 @@ int gen_expand_wildcards(int num_pat, char_u **pat, int *num_file,
&& !path_is_absolute(p)
&& !(p[0] == '.'
&& (vim_ispathsep(p[1])
- || (p[1] == '.' && vim_ispathsep(p[2]))))
- ) {
+ || (p[1] == '.' &&
+ vim_ispathsep(p[2]))))) {
/* :find completion where 'path' is used.
* Recursiveness is OK here. */
recursive = false;
@@ -1295,7 +1307,7 @@ int gen_expand_wildcards(int num_pat, char_u **pat, int *num_file,
}
if (add_pat == -1 || (add_pat == 0 && (flags & EW_NOTFOUND))) {
- char_u *t = backslash_halve_save(p);
+ char_u *t = backslash_halve_save(p);
/* When EW_NOTFOUND is used, always add files and dirs. Makes
* "vim c:/" work. */
@@ -1310,10 +1322,12 @@ int gen_expand_wildcards(int num_pat, char_u **pat, int *num_file,
}
}
- if (did_expand_in_path && !GA_EMPTY(&ga) && (flags & EW_PATH))
+ if (did_expand_in_path && !GA_EMPTY(&ga) && (flags & EW_PATH)) {
uniquefy_paths(&ga, p);
- if (p != pat[i])
+ }
+ if (p != pat[i]) {
xfree(p);
+ }
}
*num_file = ga.ga_len;
@@ -1333,14 +1347,12 @@ static int vim_backtick(char_u *p)
return *p == '`' && *(p + 1) != NUL && *(p + STRLEN(p) - 1) == '`';
}
-// Expand an item in `backticks` by executing it as a command.
-// Currently only works when pat[] starts and ends with a `.
-// Returns number of file names found, -1 if an error is encountered.
-static int expand_backtick(
- garray_T *gap,
- char_u *pat,
- int flags /* EW_* flags */
-)
+/// Expand an item in `backticks` by executing it as a command.
+/// Currently only works when pat[] starts and ends with a `.
+/// Returns number of file names found, -1 if an error is encountered.
+///
+/// @param flags EW_* flags
+static int expand_backtick(garray_T *gap, char_u *pat, int flags)
{
char_u *p;
char_u *buffer;
@@ -1361,11 +1373,12 @@ static int expand_backtick(
cmd = buffer;
while (*cmd != NUL) {
- cmd = skipwhite(cmd); /* skip over white space */
+ cmd = skipwhite(cmd); // skip over white space
p = cmd;
- while (*p != NUL && *p != '\r' && *p != '\n') /* skip over entry */
+ while (*p != NUL && *p != '\r' && *p != '\n') { // skip over entry
++p;
- /* add an entry if it is not empty */
+ }
+ // add an entry if it is not empty
if (p > cmd) {
char_u i = *p;
*p = NUL;
@@ -1374,8 +1387,9 @@ static int expand_backtick(
++cnt;
}
cmd = p;
- while (*cmd != NUL && (*cmd == '\r' || *cmd == '\n'))
+ while (*cmd != NUL && (*cmd == '\r' || *cmd == '\n')) {
++cmd;
+ }
}
xfree(buffer);
@@ -1414,18 +1428,16 @@ void slash_adjust(char_u *p)
}
#endif
-// Add a file to a file list. Accepted flags:
-// EW_DIR add directories
-// EW_FILE add files
-// EW_EXEC add executable files
-// EW_NOTFOUND add even when it doesn't exist
-// EW_ADDSLASH add slash after directory name
-// EW_ALLLINKS add symlink also when the referred file does not exist
-void addfile(
- garray_T *gap,
- char_u *f, /* filename */
- int flags
-)
+/// Add a file to a file list. Accepted flags:
+/// EW_DIR add directories
+/// EW_FILE add files
+/// EW_EXEC add executable files
+/// EW_NOTFOUND add even when it doesn't exist
+/// EW_ADDSLASH add slash after directory name
+/// EW_ALLLINKS add symlink also when the referred file does not exist
+///
+/// @param f filename
+void addfile(garray_T *gap, char_u *f, int flags)
{
bool isdir;
FileInfo file_info;
@@ -1439,14 +1451,16 @@ void addfile(
}
#ifdef FNAME_ILLEGAL
- /* if the file/dir contains illegal characters, don't add it */
- if (vim_strpbrk(f, (char_u *)FNAME_ILLEGAL) != NULL)
+ // if the file/dir contains illegal characters, don't add it
+ if (vim_strpbrk(f, (char_u *)FNAME_ILLEGAL) != NULL) {
return;
+ }
#endif
isdir = os_isdir(f);
- if ((isdir && !(flags & EW_DIR)) || (!isdir && !(flags & EW_FILE)))
+ if ((isdir && !(flags & EW_DIR)) || (!isdir && !(flags & EW_FILE))) {
return;
+ }
// If the file isn't executable, may not add it. Do accept directories.
// When invoked from expand_shellcmd() do not use $PATH.
@@ -1464,8 +1478,9 @@ void addfile(
/*
* Append a slash or backslash after directory names if none is present.
*/
- if (isdir && (flags & EW_ADDSLASH))
+ if (isdir && (flags & EW_ADDSLASH)) {
add_pathsep((char *)p);
+ }
GA_APPEND(char_u *, gap, p);
}
@@ -1478,14 +1493,15 @@ void addfile(
void simplify_filename(char_u *filename)
{
int components = 0;
- char_u *p, *tail, *start;
+ char_u *p, *tail, *start;
bool stripping_disabled = false;
bool relative = true;
p = filename;
#ifdef BACKSLASH_IN_FILENAME
- if (p[1] == ':') /* skip "x:" */
+ if (p[1] == ':') { // skip "x:"
p += 2;
+ }
#endif
if (vim_ispathsep(*p)) {
@@ -1494,17 +1510,18 @@ void simplify_filename(char_u *filename)
++p;
while (vim_ispathsep(*p));
}
- start = p; /* remember start after "c:/" or "/" or "///" */
+ start = p; // remember start after "c:/" or "/" or "///"
do {
/* At this point "p" is pointing to the char following a single "/"
* or "p" is at the "start" of the (absolute or relative) path name. */
- if (vim_ispathsep(*p))
- STRMOVE(p, p + 1); /* remove duplicate "/" */
- else if (p[0] == '.' && (vim_ispathsep(p[1]) || p[1] == NUL)) {
- if (p == start && relative)
- p += 1 + (p[1] != NUL); /* keep single "." or leading "./" */
- else {
+ if (vim_ispathsep(*p)) {
+ STRMOVE(p, p + 1); // remove duplicate "/"
+ } else if (p[0] == '.' &&
+ (vim_ispathsep(p[1]) || p[1] == NUL)) {
+ if (p == start && relative) {
+ p += 1 + (p[1] != NUL); // keep single "." or leading "./"
+ } else {
/* Strip "./" or ".///". If we are at the end of the file name
* and there is no trailing path separator, either strip "/." if
* we are after "start", or strip "." if we are at the beginning
@@ -1527,11 +1544,11 @@ void simplify_filename(char_u *filename)
MB_PTR_ADV(tail);
}
- if (components > 0) { /* strip one preceding component */
+ if (components > 0) { // strip one preceding component
bool do_strip = false;
char_u saved_char;
- /* Don't strip for an erroneous file name. */
+ // Don't strip for an erroneous file name.
if (!stripping_disabled) {
/* If the preceding component does not exist in the file
* system, we strip it. On Unix, we don't accept a symbolic
@@ -1613,21 +1630,22 @@ void simplify_filename(char_u *filename)
*p++ = '.';
*p = NUL;
} else {
- if (p > start && tail[-1] == '.')
+ if (p > start && tail[-1] == '.') {
--p;
- STRMOVE(p, tail); /* strip previous component */
+ }
+ STRMOVE(p, tail); // strip previous component
}
--components;
}
- } else if (p == start && !relative) /* leading "/.." or "/../" */
- STRMOVE(p, tail); /* strip ".." or "../" */
- else {
- if (p == start + 2 && p[-2] == '.') { /* leading "./../" */
- STRMOVE(p - 2, p); /* strip leading "./" */
+ } else if (p == start && !relative) { // leading "/.." or "/../"
+ STRMOVE(p, tail); // strip ".." or "../"
+ } else {
+ if (p == start + 2 && p[-2] == '.') { // leading "./../"
+ STRMOVE(p - 2, p); // strip leading "./"
tail -= 2;
}
- p = tail; /* skip to char after ".." or "../" */
+ p = tail; // skip to char after ".." or "../"
}
} else {
components++; // Simple path component.
@@ -1639,31 +1657,24 @@ void simplify_filename(char_u *filename)
static char *eval_includeexpr(const char *const ptr, const size_t len)
{
set_vim_var_string(VV_FNAME, ptr, (ptrdiff_t)len);
- char *res = (char *)eval_to_string_safe(
- curbuf->b_p_inex, NULL,
- was_set_insecurely(curwin, (char_u *)"includeexpr", OPT_LOCAL));
+ char *res = (char *)eval_to_string_safe(curbuf->b_p_inex, NULL,
+ was_set_insecurely(curwin, (char_u *)"includeexpr",
+ OPT_LOCAL));
set_vim_var_string(VV_FNAME, NULL, 0);
return res;
}
-/*
- * Return the name of the file ptr[len] in 'path'.
- * Otherwise like file_name_at_cursor().
- */
-char_u *
-find_file_name_in_path (
- char_u *ptr,
- size_t len,
- int options,
- long count,
- char_u *rel_fname /* file we are searching relative to */
-)
+/// Return the name of the file ptr[len] in 'path'.
+/// Otherwise like file_name_at_cursor().
+///
+/// @param rel_fname file we are searching relative to
+char_u *find_file_name_in_path(char_u *ptr, size_t len, int options, long count, char_u *rel_fname)
{
char_u *file_name;
char_u *tofree = NULL;
if ((options & FNAME_INCL) && *curbuf->b_p_inex != NUL) {
- tofree = (char_u *) eval_includeexpr((char *) ptr, len);
+ tofree = (char_u *)eval_includeexpr((char *)ptr, len);
if (tofree != NULL) {
ptr = tofree;
len = STRLEN(ptr);
@@ -1680,7 +1691,7 @@ find_file_name_in_path (
*/
if (file_name == NULL
&& !(options & FNAME_INCL) && *curbuf->b_p_inex != NUL) {
- tofree = (char_u *) eval_includeexpr((char *) ptr, len);
+ tofree = (char_u *)eval_includeexpr((char *)ptr, len);
if (tofree != NULL) {
ptr = tofree;
len = STRLEN(ptr);
@@ -1701,8 +1712,9 @@ find_file_name_in_path (
xfree(file_name);
file_name = find_file_in_path(ptr, len, options, FALSE, rel_fname);
}
- } else
+ } else {
file_name = vim_strnsave(ptr, len);
+ }
xfree(tofree);
@@ -1714,10 +1726,11 @@ find_file_name_in_path (
// URL_BACKSLASH.
int path_is_url(const char *p)
{
- if (strncmp(p, "://", 3) == 0)
+ if (strncmp(p, "://", 3) == 0) {
return URL_SLASH;
- else if (strncmp(p, ":\\\\", 3) == 0)
+ } else if (strncmp(p, ":\\\\", 3) == 0) {
return URL_BACKSLASH;
+ }
return 0;
}
@@ -1735,7 +1748,9 @@ int path_with_url(const char *fname)
bool path_with_extension(const char *path, const char *extension)
{
const char *last_dot = strrchr(path, '.');
- if (!last_dot) { return false; }
+ if (!last_dot) {
+ return false;
+ }
return strcmp(last_dot + 1, extension) == 0;
}
@@ -1809,8 +1824,9 @@ char *fix_fname(const char *fname)
# ifdef BACKSLASH_IN_FILENAME
|| strstr(fname, "\\\\") != NULL
# endif
- )
+ ) {
return FullName_save(fname, false);
+ }
fname = xstrdup(fname);
@@ -1845,7 +1861,7 @@ void path_fix_case(char_u *name)
tail = name;
} else {
*slash = NUL;
- ok = os_scandir(&dir, (char *) name);
+ ok = os_scandir(&dir, (char *)name);
*slash = '/';
tail = slash + 1;
}
@@ -1855,7 +1871,7 @@ void path_fix_case(char_u *name)
}
char_u *entry;
- while ((entry = (char_u *) os_scandir_next(&dir))) {
+ while ((entry = (char_u *)os_scandir_next(&dir))) {
// Only accept names that differ in case and are the same byte
// length. TODO: accept different length name.
if (STRICMP(tail, entry) == 0 && STRLEN(tail) == STRLEN(entry)) {
@@ -1895,12 +1911,13 @@ int after_pathsep(const char *b, const char *p)
bool same_directory(char_u *f1, char_u *f2)
{
char_u ffname[MAXPATHL];
- char_u *t1;
- char_u *t2;
+ char_u *t1;
+ char_u *t2;
- /* safety check */
- if (f1 == NULL || f2 == NULL)
+ // safety check
+ if (f1 == NULL || f2 == NULL) {
return false;
+ }
(void)vim_FullName((char *)f1, (char *)ffname, MAXPATHL, FALSE);
t1 = path_tail_with_sep(ffname);
@@ -1918,22 +1935,23 @@ int pathcmp(const char *p, const char *q, int maxlen)
{
int i, j;
int c1, c2;
- const char *s = NULL;
+ const char *s = NULL;
for (i = 0, j = 0; maxlen < 0 || (i < maxlen && j < maxlen);) {
c1 = PTR2CHAR((char_u *)p + i);
c2 = PTR2CHAR((char_u *)q + j);
- /* End of "p": check if "q" also ends or just has a slash. */
+ // End of "p": check if "q" also ends or just has a slash.
if (c1 == NUL) {
- if (c2 == NUL) /* full match */
+ if (c2 == NUL) { // full match
return 0;
+ }
s = q;
i = j;
break;
}
- /* End of "q": check if "p" just has a slash. */
+ // End of "q": check if "p" just has a slash.
if (c2 == NUL) {
s = p;
break;
@@ -1941,15 +1959,17 @@ int pathcmp(const char *p, const char *q, int maxlen)
if ((p_fic ? mb_toupper(c1) != mb_toupper(c2) : c1 != c2)
#ifdef BACKSLASH_IN_FILENAME
- /* consider '/' and '\\' to be equal */
+ // consider '/' and '\\' to be equal
&& !((c1 == '/' && c2 == '\\')
|| (c1 == '\\' && c2 == '/'))
#endif
) {
- if (vim_ispathsep(c1))
+ if (vim_ispathsep(c1)) {
return -1;
- if (vim_ispathsep(c2))
+ }
+ if (vim_ispathsep(c2)) {
return 1;
+ }
return p_fic ? mb_toupper(c1) - mb_toupper(c2)
: c1 - c2; // no match
}
@@ -2057,26 +2077,27 @@ char_u *path_shorten_fname(char_u *full_path, char_u *dir_name)
/// If FAIL is returned, *num_file and *file are either
/// unchanged or *num_file is set to 0 and *file is set
/// to NULL or points to "".
-int expand_wildcards_eval(char_u **pat, int *num_file, char_u ***file,
- int flags)
+int expand_wildcards_eval(char_u **pat, int *num_file, char_u ***file, int flags)
{
int ret = FAIL;
- char_u *eval_pat = NULL;
- char_u *exp_pat = *pat;
- char_u *ignored_msg;
+ char_u *eval_pat = NULL;
+ char_u *exp_pat = *pat;
+ char_u *ignored_msg;
size_t usedlen;
if (*exp_pat == '%' || *exp_pat == '#' || *exp_pat == '<') {
++emsg_off;
eval_pat = eval_vars(exp_pat, exp_pat, &usedlen,
- NULL, &ignored_msg, NULL);
+ NULL, &ignored_msg, NULL);
--emsg_off;
- if (eval_pat != NULL)
+ if (eval_pat != NULL) {
exp_pat = concat_str(eval_pat, exp_pat + usedlen);
+ }
}
- if (exp_pat != NULL)
+ if (exp_pat != NULL) {
ret = expand_wildcards(1, &exp_pat, num_file, file, flags);
+ }
if (eval_pat != NULL) {
xfree(exp_pat);
@@ -2100,25 +2121,25 @@ int expand_wildcards_eval(char_u **pat, int *num_file, char_u ***file,
/// If FAIL is returned, *num_file and *file are either
/// unchanged or *num_file is set to 0 and *file is set to
/// NULL or points to "".
-int expand_wildcards(int num_pat, char_u **pat, int *num_files, char_u ***files,
- int flags)
+int expand_wildcards(int num_pat, char_u **pat, int *num_files, char_u ***files, int flags)
{
int retval;
int i, j;
- char_u *p;
- int non_suf_match; /* number without matching suffix */
+ char_u *p;
+ int non_suf_match; // number without matching suffix
retval = gen_expand_wildcards(num_pat, pat, num_files, files, flags);
- /* When keeping all matches, return here */
- if ((flags & EW_KEEPALL) || retval == FAIL)
+ // When keeping all matches, return here
+ if ((flags & EW_KEEPALL) || retval == FAIL) {
return retval;
+ }
/*
* Remove names that match 'wildignore'.
*/
if (*p_wig) {
- char_u *ffname;
+ char_u *ffname;
// check all files in (*files)[]
assert(*num_files == 0 || *files != NULL);
@@ -2183,7 +2204,7 @@ int match_suffix(char_u *fname)
if (setsuflen == 0) {
char_u *tail = path_tail(fname);
- /* empty entry: match name without a '.' */
+ // empty entry: match name without a '.'
if (vim_strchr(tail, '.') == NULL) {
setsuflen = 1;
break;
@@ -2209,13 +2230,13 @@ int path_full_dir_name(char *directory, char *buffer, size_t len)
int retval = OK;
if (STRLEN(directory) == 0) {
- return os_dirname((char_u *) buffer, len);
+ return os_dirname((char_u *)buffer, len);
}
char old_dir[MAXPATHL];
// Get current directory name.
- if (os_dirname((char_u *) old_dir, MAXPATHL) == FAIL) {
+ if (os_dirname((char_u *)old_dir, MAXPATHL) == FAIL) {
return FAIL;
}
@@ -2229,7 +2250,7 @@ int path_full_dir_name(char *directory, char *buffer, size_t len)
retval = FAIL;
}
- if (retval == FAIL || os_dirname((char_u *) buffer, len) == FAIL) {
+ if (retval == FAIL || os_dirname((char_u *)buffer, len) == FAIL) {
// Do not return immediately since we are in the wrong directory.
retval = FAIL;
}
@@ -2283,14 +2304,13 @@ int append_path(char *path, const char *to_append, size_t max_len)
/// @param force also expand when "fname" is already absolute.
///
/// @return FAIL for failure, OK for success.
-static int path_to_absolute(const char_u *fname, char_u *buf, size_t len,
- int force)
+static int path_to_absolute(const char_u *fname, char_u *buf, size_t len, int force)
{
char_u *p;
*buf = NUL;
char *relative_directory = xmalloc(len);
- char *end_of_path = (char *) fname;
+ char *end_of_path = (char *)fname;
// expand it if forced or not an absolute path
if (force || !path_is_absolute(fname)) {
@@ -2311,13 +2331,13 @@ static int path_to_absolute(const char_u *fname, char_u *buf, size_t len,
memcpy(relative_directory, fname, (size_t)(p - fname));
relative_directory[p-fname] = NUL;
}
- end_of_path = (char *) (p + 1);
+ end_of_path = (char *)(p + 1);
} else {
relative_directory[0] = NUL;
- end_of_path = (char *) fname;
+ end_of_path = (char *)fname;
}
- if (FAIL == path_full_dir_name(relative_directory, (char *) buf, len)) {
+ if (FAIL == path_full_dir_name(relative_directory, (char *)buf, len)) {
xfree(relative_directory);
return FAIL;
}
diff --git a/src/nvim/plines.c b/src/nvim/plines.c
index a656686a95..28138af13c 100644
--- a/src/nvim/plines.c
+++ b/src/nvim/plines.c
@@ -5,18 +5,17 @@
#include <assert.h>
#include <inttypes.h>
+#include <limits.h>
#include <stdbool.h>
#include <string.h>
-#include <limits.h>
-#include "nvim/vim.h"
#include "nvim/ascii.h"
-#include "nvim/plines.h"
+#include "nvim/buffer.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/diff.h"
-#include "nvim/func_attr.h"
#include "nvim/fold.h"
+#include "nvim/func_attr.h"
#include "nvim/indent.h"
#include "nvim/main.h"
#include "nvim/mbyte.h"
@@ -24,10 +23,11 @@
#include "nvim/memory.h"
#include "nvim/move.h"
#include "nvim/option.h"
+#include "nvim/plines.h"
#include "nvim/screen.h"
#include "nvim/strings.h"
+#include "nvim/vim.h"
#include "nvim/window.h"
-#include "nvim/buffer.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "plines.c.generated.h"
@@ -71,7 +71,7 @@ int plines_win_nofill(win_T *wp, linenr_T lnum, bool winheight)
/// "wp". Does not care about folding, 'wrap' or 'diff'.
int plines_win_nofold(win_T *wp, linenr_T lnum)
{
- char_u *s;
+ char_u *s;
unsigned int col;
int width;
@@ -159,8 +159,8 @@ int plines_win_col(win_T *wp, linenr_T lnum, long column)
/// @param[in] cache whether to use the window's cache for folds
///
/// @return the total number of screen lines
-int plines_win_full(win_T *wp, linenr_T lnum, linenr_T *const nextp,
- bool *const foldedp, const bool cache)
+int plines_win_full(win_T *wp, linenr_T lnum, linenr_T *const nextp, bool *const foldedp,
+ const bool cache)
{
bool folded = hasFoldingWin(wp, lnum, NULL, nextp, cache, NULL);
if (foldedp) {
@@ -302,8 +302,7 @@ int lbr_chartabsize_adv(char_u *line, char_u **s, colnr_T col)
/// @param headp
///
/// @return The number of characters taken up on the screen.
-int win_lbr_chartabsize(win_T *wp, char_u *line, char_u *s,
- colnr_T col, int *headp)
+int win_lbr_chartabsize(win_T *wp, char_u *line, char_u *s, colnr_T col, int *headp)
{
colnr_T col2;
colnr_T col_adj = 0; // col + screen size of tab
@@ -326,7 +325,7 @@ int win_lbr_chartabsize(win_T *wp, char_u *line, char_u *s,
int size = win_chartabsize(wp, s, col);
int c = *s;
if (*s == TAB) {
- col_adj = size - 1;
+ col_adj = size - 1;
}
// If 'linebreak' set check at a blank before a non-blank if the line
@@ -343,8 +342,8 @@ int win_lbr_chartabsize(win_T *wp, char_u *line, char_u *s,
colmax = (colnr_T)(wp->w_width_inner - numberextra - col_adj);
if (col >= colmax) {
- colmax += col_adj;
- n = colmax + win_col_off2(wp);
+ colmax += col_adj;
+ n = colmax + win_col_off2(wp);
if (n > 0) {
colmax += (((col - colmax) / n) + 1) * n - col_adj;
diff --git a/src/nvim/popupmnu.c b/src/nvim/popupmnu.c
index 1705ea0c12..aeb2c8c44a 100644
--- a/src/nvim/popupmnu.c
+++ b/src/nvim/popupmnu.c
@@ -9,27 +9,27 @@
#include <inttypes.h>
#include <stdbool.h>
-#include "nvim/buffer.h"
-#include "nvim/vim.h"
#include "nvim/api/private/helpers.h"
#include "nvim/ascii.h"
-#include "nvim/eval/typval.h"
-#include "nvim/popupmnu.h"
+#include "nvim/buffer.h"
#include "nvim/charset.h"
+#include "nvim/edit.h"
+#include "nvim/eval/typval.h"
#include "nvim/ex_cmds.h"
#include "nvim/memline.h"
+#include "nvim/memory.h"
#include "nvim/move.h"
#include "nvim/option.h"
+#include "nvim/popupmnu.h"
#include "nvim/screen.h"
-#include "nvim/ui_compositor.h"
#include "nvim/search.h"
#include "nvim/strings.h"
-#include "nvim/memory.h"
-#include "nvim/window.h"
-#include "nvim/edit.h"
#include "nvim/ui.h"
+#include "nvim/ui_compositor.h"
+#include "nvim/vim.h"
+#include "nvim/window.h"
-static pumitem_T *pum_array = NULL; // items of displayed pum
+static pumitem_T *pum_array = NULL; // items of displayed pum
static int pum_size; // nr of items in "pum_array"
static int pum_selected; // index of selected item or -1
static int pum_first = 0; // index of top item
@@ -98,8 +98,7 @@ static void pum_compute_size(void)
/// if false, a new item is selected, but the array
/// is the same
/// @param cmd_startcol only for cmdline mode: column of completed match
-void pum_display(pumitem_T *array, int size, int selected, bool array_changed,
- int cmd_startcol)
+void pum_display(pumitem_T *array, int size, int selected, bool array_changed, int cmd_startcol)
{
int context_lines;
int above_row;
@@ -234,7 +233,7 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed,
context_lines = 3;
} else {
context_lines = curwin->w_cline_row
- + curwin->w_cline_height - curwin->w_wrow;
+ + curwin->w_cline_height - curwin->w_wrow;
}
pum_row = pum_win_row + context_lines;
@@ -488,17 +487,17 @@ void pum_redraw(void)
s = NULL;
switch (round) {
- case 1:
- p = pum_array[idx].pum_text;
- break;
+ case 1:
+ p = pum_array[idx].pum_text;
+ break;
- case 2:
- p = pum_array[idx].pum_kind;
- break;
+ case 2:
+ p = pum_array[idx].pum_kind;
+ break;
- case 3:
- p = pum_array[idx].pum_extra;
- break;
+ case 3:
+ p = pum_array[idx].pum_extra;
+ break;
}
if (p != NULL) {
diff --git a/src/nvim/profile.c b/src/nvim/profile.c
index f9b0bb0a2b..fe7bd2e912 100644
--- a/src/nvim/profile.c
+++ b/src/nvim/profile.c
@@ -1,17 +1,16 @@
// This is an open source non-commercial project. Dear PVS-Studio, please check
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
-#include <stdio.h>
-#include <math.h>
#include <assert.h>
+#include <math.h>
+#include <stdio.h>
#include "nvim/assert.h"
-#include "nvim/profile.h"
-#include "nvim/os/time.h"
#include "nvim/func_attr.h"
-#include "nvim/os/os_defs.h"
-
#include "nvim/globals.h" // for the global `time_fd` (startuptime)
+#include "nvim/os/os_defs.h"
+#include "nvim/os/time.h"
+#include "nvim/profile.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "profile.c.generated.h"
@@ -97,7 +96,7 @@ proftime_T profile_divide(proftime_T tm, int count) FUNC_ATTR_CONST
return profile_zero();
}
- return (proftime_T) round((double) tm / (double) count);
+ return (proftime_T)round((double)tm / (double)count);
}
/// Adds time `tm2` to `tm1`.
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index e1ee5dc28f..d0bd63e6ca 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -8,9 +8,8 @@
#include <stdbool.h>
#include <string.h>
-#include "nvim/vim.h"
+#include "nvim/api/private/helpers.h"
#include "nvim/ascii.h"
-#include "nvim/quickfix.h"
#include "nvim/buffer.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
@@ -26,29 +25,30 @@
#include "nvim/mark.h"
#include "nvim/mbyte.h"
#include "nvim/memline.h"
+#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/misc1.h"
-#include "nvim/memory.h"
#include "nvim/move.h"
#include "nvim/normal.h"
#include "nvim/option.h"
+#include "nvim/os/input.h"
+#include "nvim/os/os.h"
#include "nvim/os_unix.h"
#include "nvim/path.h"
+#include "nvim/quickfix.h"
#include "nvim/regexp.h"
#include "nvim/screen.h"
#include "nvim/search.h"
#include "nvim/strings.h"
#include "nvim/syntax.h"
#include "nvim/ui.h"
+#include "nvim/vim.h"
#include "nvim/window.h"
-#include "nvim/os/os.h"
-#include "nvim/os/input.h"
-#include "nvim/api/private/helpers.h"
struct dir_stack_T {
- struct dir_stack_T *next;
- char_u *dirname;
+ struct dir_stack_T *next;
+ char_u *dirname;
};
// For each error the next struct is allocated and linked in a list.
@@ -67,7 +67,7 @@ struct qfline_S {
char_u *qf_pattern; ///< search pattern for the error
char_u *qf_text; ///< description of the error
char_u qf_viscol; ///< set to TRUE if qf_col and qf_end_col is
- // screen column
+ // screen column
char_u qf_cleared; ///< set to TRUE if line has been deleted
char_u qf_type; ///< type of the error (mostly 'E'); 1 for :helpgrep
char_u qf_valid; ///< valid error message detected
@@ -83,7 +83,7 @@ typedef enum
QFLT_QUICKFIX, ///< Quickfix list - global list
QFLT_LOCATION, ///< Location list - per window list
QFLT_INTERNAL ///< Internal - Temporary list used by
- // getqflist()/getloclist()
+ // getqflist()/getloclist()
} qfltype_T;
/// Quickfix/Location list definition
@@ -94,15 +94,15 @@ typedef enum
typedef struct qf_list_S {
unsigned qf_id; ///< Unique identifier for this list
qfltype_T qfl_type;
- qfline_T *qf_start; ///< pointer to the first error
- qfline_T *qf_last; ///< pointer to the last error
- qfline_T *qf_ptr; ///< pointer to the current error
+ qfline_T *qf_start; ///< pointer to the first error
+ qfline_T *qf_last; ///< pointer to the last error
+ qfline_T *qf_ptr; ///< pointer to the current error
int qf_count; ///< number of errors (0 means empty list)
int qf_index; ///< current index in the error list
int qf_nonevalid; ///< TRUE if not a single valid entry found
- char_u *qf_title; ///< title derived from the command that created
- ///< the error list or set by setqflist
- typval_T *qf_ctx; ///< context set by setqflist/setloclist
+ char_u *qf_title; ///< title derived from the command that created
+ ///< the error list or set by setqflist
+ typval_T *qf_ctx; ///< context set by setqflist/setloclist
Callback qftf_cb; ///< 'quickfixtextfunc' callback function
struct dir_stack_T *qf_dir_stack;
@@ -137,8 +137,8 @@ static unsigned last_qf_id = 0; // Last Used quickfix list id
// Structure used to hold the info of one part of 'errorformat'
typedef struct efm_S efm_T;
struct efm_S {
- regprog_T *prog; // pre-formatted part of 'errorformat'
- efm_T *next; // pointer to next (NULL if last)
+ regprog_T *prog; // pre-formatted part of 'errorformat'
+ efm_T *next; // pointer to next (NULL if last)
char_u addr[FMT_PATTERNS]; // indices of used % patterns
char_u prefix; // prefix of this format line:
// 'D' enter directory
@@ -183,12 +183,12 @@ typedef struct {
size_t linelen;
char_u *growbuf;
size_t growbufsiz;
- FILE *fd;
- typval_T *tv;
- char_u *p_str;
- list_T *p_list;
+ FILE *fd;
+ typval_T *tv;
+ char_u *p_str;
+ list_T *p_list;
listitem_T *p_li;
- buf_T *buf;
+ buf_T *buf;
linenr_T buflnum;
linenr_T lnumlast;
vimconv_T vc;
@@ -236,7 +236,7 @@ static char_u *e_no_more_items = (char_u *)N_("E553: No more items");
// Macro to loop through all the items in a quickfix list
// Quickfix item index starts from 1, so i below starts at 1
#define FOR_ALL_QFL_ITEMS(qfl, qfp, i) \
- for (i = 1, qfp = qfl->qf_start; /* NOLINT(readability/braces) */ \
+ for (i = 1, qfp = qfl->qf_start; /* NOLINT(readability/braces) */ \
!got_int && i <= qfl->qf_count && qfp != NULL; \
i++, qfp = qfp->qf_next)
@@ -258,9 +258,7 @@ static qf_delq_T *qf_delq_head = NULL;
/// Process the next line from a file/buffer/list/string and add it
/// to the quickfix list 'qfl'.
-static int qf_init_process_nextline(qf_list_T *qfl,
- efm_T *fmt_first,
- qfstate_T *state,
+static int qf_init_process_nextline(qf_list_T *qfl, efm_T *fmt_first, qfstate_T *state,
qffields_T *fields)
{
int status;
@@ -308,11 +306,10 @@ static int qf_init_process_nextline(qf_list_T *qfl,
/// @params enc If non-NULL, encoding used to parse errors
///
/// @returns -1 for error, number of errors for success.
-int qf_init(win_T *wp, const char_u *restrict efile,
- char_u *restrict errorformat, int newlist,
+int qf_init(win_T *wp, const char_u *restrict efile, char_u *restrict errorformat, int newlist,
const char_u *restrict qf_title, char_u *restrict enc)
{
- qf_info_T *qi = &ql_info;
+ qf_info_T *qi = &ql_info;
if (wp != NULL) {
qi = ll_get_or_alloc_list(wp);
@@ -338,7 +335,7 @@ static struct fmtpattern
{ 't', "." },
{ 'm', ".\\+" },
{ 'r', ".*" },
- { 'p', "[- .]*" }, // NOLINT(whitespace/tab)
+ { 'p', "[- .]*"}, // NOLINT(whitespace/tab)
{ 'v', "\\d\\+" },
{ 's', ".\\+" },
{ 'o', ".\\+" }
@@ -348,14 +345,8 @@ static struct fmtpattern
/// See fmt_pat definition above for the list of supported patterns. The
/// pattern specifier is supplied in "efmpat". The converted pattern is stored
/// in "regpat". Returns a pointer to the location after the pattern.
-static char_u * efmpat_to_regpat(
- const char_u *efmpat,
- char_u *regpat,
- efm_T *efminfo,
- int idx,
- int round,
- char_u *errmsg,
- size_t errmsglen)
+static char_u *efmpat_to_regpat(const char_u *efmpat, char_u *regpat, efm_T *efminfo, int idx,
+ int round, char_u *errmsg, size_t errmsglen)
FUNC_ATTR_NONNULL_ALL
{
if (efminfo->addr[idx]) {
@@ -374,7 +365,7 @@ static char_u * efmpat_to_regpat(
EMSG(errmsg);
return NULL;
}
- efminfo->addr[idx] = (char_u)++round;
+ efminfo->addr[idx] = (char_u)++ round;
*regpat++ = '\\';
*regpat++ = '(';
#ifdef BACKSLASH_IN_FILENAME
@@ -415,13 +406,8 @@ static char_u * efmpat_to_regpat(
/// Convert a scanf like format in 'errorformat' to a regular expression.
/// Returns a pointer to the location after the pattern.
-static char_u * scanf_fmt_to_regpat(
- const char_u **pefmp,
- const char_u *efm,
- int len,
- char_u *regpat,
- char_u *errmsg,
- size_t errmsglen)
+static char_u *scanf_fmt_to_regpat(const char_u **pefmp, const char_u *efm, int len, char_u *regpat,
+ char_u *errmsg, size_t errmsglen)
FUNC_ATTR_NONNULL_ALL
{
const char_u *efmp = *pefmp;
@@ -459,8 +445,8 @@ static char_u * scanf_fmt_to_regpat(
}
/// Analyze/parse an errorformat prefix.
-static const char_u *efm_analyze_prefix(const char_u *efmp, efm_T *efminfo,
- char_u *errmsg, size_t errmsglen)
+static const char_u *efm_analyze_prefix(const char_u *efmp, efm_T *efminfo, char_u *errmsg,
+ size_t errmsglen)
FUNC_ATTR_NONNULL_ALL
{
if (vim_strchr((char_u *)"+-", *efmp) != NULL) {
@@ -480,8 +466,8 @@ static const char_u *efm_analyze_prefix(const char_u *efmp, efm_T *efminfo,
// Converts a 'errorformat' string to regular expression pattern
-static int efm_to_regpat(const char_u *efm, int len, efm_T *fmt_ptr,
- char_u *regpat, char_u *errmsg, size_t errmsglen)
+static int efm_to_regpat(const char_u *efm, int len, efm_T *fmt_ptr, char_u *regpat, char_u *errmsg,
+ size_t errmsglen)
FUNC_ATTR_NONNULL_ALL
{
// Build regexp pattern from current 'errorformat' option
@@ -598,7 +584,7 @@ static int efm_option_part_len(char_u *efm)
/// Parse the 'errorformat' option. Multiple parts in the 'errorformat' option
/// are parsed and converted to regular expressions. Returns information about
/// the parsed 'errorformat' option.
-static efm_T * parse_efm_option(char_u *efm)
+static efm_T *parse_efm_option(char_u *efm)
{
efm_T *fmt_ptr = NULL;
efm_T *fmt_first = NULL;
@@ -769,7 +755,7 @@ retry:
errno = 0;
if (fgets((char *)IObuff, IOSIZE, state->fd) == NULL) {
if (errno == EINTR) {
- goto retry;
+ goto retry;
}
return QF_END_OF_INPUT;
}
@@ -915,7 +901,7 @@ static bool qf_list_has_valid_entries(qf_list_T *qfl)
}
/// Return a pointer to a list in the specified quickfix stack
-static qf_list_T * qf_get_list(qf_info_T *qi, int idx)
+static qf_list_T *qf_get_list(qf_info_T *qi, int idx)
FUNC_ATTR_NONNULL_ALL
{
return &qi->qf_lists[idx];
@@ -923,8 +909,8 @@ static qf_list_T * qf_get_list(qf_info_T *qi, int idx)
/// Parse a line and get the quickfix fields.
/// Return the QF_ status.
-static int qf_parse_line(qf_list_T *qfl, char_u *linebuf,
- size_t linelen, efm_T *fmt_first, qffields_T *fields)
+static int qf_parse_line(qf_list_T *qfl, char_u *linebuf, size_t linelen, efm_T *fmt_first,
+ qffields_T *fields)
{
efm_T *fmt_ptr;
int idx = 0;
@@ -1030,14 +1016,8 @@ static void qf_free_fields(qffields_T *pfields)
// Setup the state information used for parsing lines and populating a
// quickfix list.
-static int qf_setup_state(
- qfstate_T *pstate,
- char_u *restrict enc,
- const char_u *restrict efile,
- typval_T *tv,
- buf_T *buf,
- linenr_T lnumfirst,
- linenr_T lnumlast)
+static int qf_setup_state(qfstate_T *pstate, char_u *restrict enc, const char_u *restrict efile,
+ typval_T *tv, buf_T *buf, linenr_T lnumfirst, linenr_T lnumlast)
FUNC_ATTR_NONNULL_ARG(1)
{
pstate->vc.vc_type = CONV_NONE;
@@ -1080,38 +1060,32 @@ static void qf_cleanup_state(qfstate_T *pstate)
}
}
-// Read the errorfile "efile" into memory, line by line, building the error
-// list.
-// Alternative: when "efile" is NULL read errors from buffer "buf".
-// Alternative: when "tv" is not NULL get errors from the string or list.
-// Always use 'errorformat' from "buf" if there is a local value.
-// Then "lnumfirst" and "lnumlast" specify the range of lines to use.
-// Set the title of the list to "qf_title".
-// Return -1 for error, number of errors for success.
-static int
-qf_init_ext(
- qf_info_T *qi,
- int qf_idx,
- const char_u *restrict efile,
- buf_T *buf,
- typval_T *tv,
- char_u *restrict errorformat,
- bool newlist, // true: start a new error list
- linenr_T lnumfirst, // first line number to use
- linenr_T lnumlast, // last line number to use
- const char_u *restrict qf_title,
- char_u *restrict enc
-)
+/// Read the errorfile "efile" into memory, line by line, building the error
+/// list.
+/// Alternative: when "efile" is NULL read errors from buffer "buf".
+/// Alternative: when "tv" is not NULL get errors from the string or list.
+/// Always use 'errorformat' from "buf" if there is a local value.
+/// Then "lnumfirst" and "lnumlast" specify the range of lines to use.
+/// Set the title of the list to "qf_title".
+///
+/// @param newlist true: start a new error list
+/// @param lnumfirst first line number to use
+/// @param lnumlast last line number to use
+///
+/// @return -1 for error, number of errors for success.
+static int qf_init_ext(qf_info_T *qi, int qf_idx, const char_u *restrict efile, buf_T *buf,
+ typval_T *tv, char_u *restrict errorformat, bool newlist, linenr_T lnumfirst,
+ linenr_T lnumlast, const char_u *restrict qf_title, char_u *restrict enc)
FUNC_ATTR_NONNULL_ARG(1)
{
qf_list_T *qfl;
qfstate_T state = { 0 };
qffields_T fields = { 0 };
- qfline_T *old_last = NULL;
+ qfline_T *old_last = NULL;
bool adding = false;
- static efm_T *fmt_first = NULL;
- char_u *efm;
- static char_u *last_efm = NULL;
+ static efm_T *fmt_first = NULL;
+ char_u *efm;
+ static char_u *last_efm = NULL;
int retval = -1; // default: return error flag
int status;
@@ -1237,7 +1211,7 @@ static void qf_store_title(qf_list_T *qfl, const char_u *title)
/// that created the quickfix list with the ":" prefix.
/// Create a quickfix list title string by prepending ":" to a user command.
/// Returns a pointer to a static buffer with the title.
-static char_u * qf_cmdtitle(char_u *cmd)
+static char_u *qf_cmdtitle(char_u *cmd)
{
static char_u qftitle_str[IOSIZE];
@@ -1247,7 +1221,7 @@ static char_u * qf_cmdtitle(char_u *cmd)
}
/// Return a pointer to the current list in the specified quickfix stack
-static qf_list_T * qf_get_curlist(qf_info_T *qi)
+static qf_list_T *qf_get_curlist(qf_info_T *qi)
FUNC_ATTR_NONNULL_ALL
{
return qf_get_list(qi, qi->qf_curlist);
@@ -1276,8 +1250,9 @@ static void qf_new_list(qf_info_T *qi, const char_u *qf_title)
qi->qf_lists[i - 1] = qi->qf_lists[i];
}
qi->qf_curlist = LISTCOUNT - 1;
- } else
+ } else {
qi->qf_curlist = qi->qf_listcount++;
+ }
qfl = qf_get_curlist(qi);
memset(qfl, 0, sizeof(qf_list_T));
qf_store_title(qfl, qf_title);
@@ -1287,10 +1262,7 @@ static void qf_new_list(qf_info_T *qi, const char_u *qf_title)
/// Parse the match for filename ('%f') pattern in regmatch.
/// Return the matched value in "fields->namebuf".
-static int qf_parse_fmt_f(regmatch_T *rmp,
- int midx,
- qffields_T *fields,
- int prefix)
+static int qf_parse_fmt_f(regmatch_T *rmp, int midx, qffields_T *fields, int prefix)
{
char_u c;
@@ -1360,9 +1332,7 @@ static int qf_parse_fmt_t(regmatch_T *rmp, int midx, qffields_T *fields)
/// Parse the match for '%+' format pattern. The whole matching line is included
/// in the error string. Return the matched line in "fields->errmsg".
-static void qf_parse_fmt_plus(const char_u *linebuf,
- size_t linelen,
- qffields_T *fields)
+static void qf_parse_fmt_plus(const char_u *linebuf, size_t linelen, qffields_T *fields)
FUNC_ATTR_NONNULL_ALL
{
if (linelen >= fields->errmsglen) {
@@ -1499,9 +1469,8 @@ static int (*qf_parse_fmt[FMT_PATTERNS])(regmatch_T *, int, qffields_T *) = {
/// fmt_ptr contains the 'efm' format specifiers/prefixes that have a match.
/// Returns QF_OK if all the matches are successfully parsed. On failure,
/// returns QF_FAIL or QF_NOMEM.
-static int qf_parse_match(char_u *linebuf, size_t linelen, efm_T *fmt_ptr,
- regmatch_T *regmatch, qffields_T *fields,
- int qf_multiline, int qf_multiscan, char_u **tail)
+static int qf_parse_match(char_u *linebuf, size_t linelen, efm_T *fmt_ptr, regmatch_T *regmatch,
+ qffields_T *fields, int qf_multiline, int qf_multiscan, char_u **tail)
{
char_u idx = fmt_ptr->prefix;
int i;
@@ -1549,9 +1518,8 @@ static int qf_parse_match(char_u *linebuf, size_t linelen, efm_T *fmt_ptr,
/// 'fmt_ptr->prog' and return the matching values in 'fields'.
/// Returns QF_OK if the efm format matches completely and the fields are
/// successfully copied. Otherwise returns QF_FAIL or QF_NOMEM.
-static int qf_parse_get_fields(char_u *linebuf, size_t linelen, efm_T *fmt_ptr,
- qffields_T *fields, int qf_multiline,
- int qf_multiscan, char_u **tail)
+static int qf_parse_get_fields(char_u *linebuf, size_t linelen, efm_T *fmt_ptr, qffields_T *fields,
+ int qf_multiline, int qf_multiscan, char_u **tail)
{
regmatch_T regmatch;
int status = QF_FAIL;
@@ -1611,8 +1579,7 @@ static int qf_parse_dir_pfx(int idx, qffields_T *fields, qf_list_T *qfl)
}
/// Parse global file name error format prefixes (%O, %P and %Q).
-static int qf_parse_file_pfx(int idx, qffields_T *fields, qf_list_T *qfl,
- char_u *tail)
+static int qf_parse_file_pfx(int idx, qffields_T *fields, qf_list_T *qfl, char_u *tail)
{
fields->valid = false;
if (*fields->namebuf == NUL || os_path_exists(fields->namebuf)) {
@@ -1635,8 +1602,7 @@ static int qf_parse_file_pfx(int idx, qffields_T *fields, qf_list_T *qfl,
/// Parse a non-error line (a line which doesn't match any of the error
/// format in 'efm').
-static int qf_parse_line_nomatch(char_u *linebuf, size_t linelen,
- qffields_T *fields)
+static int qf_parse_line_nomatch(char_u *linebuf, size_t linelen, qffields_T *fields)
{
fields->namebuf[0] = NUL; // no match found, remove file name
fields->lnum = 0; // don't jump to this line
@@ -1714,11 +1680,12 @@ static void locstack_queue_delreq(qf_info_T *qi)
static void ll_free_all(qf_info_T **pqi)
{
int i;
- qf_info_T *qi;
+ qf_info_T *qi;
qi = *pqi;
- if (qi == NULL)
+ if (qi == NULL) {
return;
+ }
*pqi = NULL; // Remove reference to this list
qi->qf_refcount--;
@@ -1741,7 +1708,7 @@ static void ll_free_all(qf_info_T **pqi)
void qf_free_all(win_T *wp)
{
int i;
- qf_info_T *qi = &ql_info;
+ qf_info_T *qi = &ql_info;
if (wp != NULL) {
// location list
@@ -1761,7 +1728,7 @@ void qf_free_all(win_T *wp)
/// Must always call decr_quickfix_busy() exactly once after this.
static void incr_quickfix_busy(void)
{
- quickfix_busy++;
+ quickfix_busy++;
}
/// Safe to free location list stacks. Process any delayed delete requests.
@@ -1818,11 +1785,9 @@ void check_quickfix_busy(void)
/// @param valid valid entry
///
/// @returns QF_OK or QF_FAIL.
-static int qf_add_entry(qf_list_T *qfl, char_u *dir, char_u *fname,
- char_u *module, int bufnum, char_u *mesg,
- long lnum, long end_lnum, int col, int end_col,
- char_u vis_col, char_u *pattern, int nr,
- char_u type, char_u valid)
+static int qf_add_entry(qf_list_T *qfl, char_u *dir, char_u *fname, char_u *module, int bufnum,
+ char_u *mesg, long lnum, long end_lnum, int col, int end_col,
+ char_u vis_col, char_u *pattern, int nr, char_u type, char_u valid)
{
qfline_T *qfp = xmalloc(sizeof(qfline_T));
qfline_T **lastp; // pointer to qf_last or NULL
@@ -1921,7 +1886,7 @@ static qf_info_T *ll_get_or_alloc_list(win_T *wp)
/// For a location list command, returns the stack for the current window. If
/// the location list is not found, then returns NULL and prints an error
/// message if 'print_emsg' is TRUE.
-static qf_info_T * qf_cmd_get_stack(exarg_T *eap, int print_emsg)
+static qf_info_T *qf_cmd_get_stack(exarg_T *eap, int print_emsg)
{
qf_info_T *qi = &ql_info;
@@ -2140,10 +2105,9 @@ static int qf_get_fnum(qf_list_T *qfl, char_u *directory, char_u *fname )
// Push dirbuf onto the directory stack and return pointer to actual dir or
// NULL on error.
-static char_u *qf_push_dir(char_u *dirbuf, struct dir_stack_T **stackptr,
- bool is_file_stack)
+static char_u *qf_push_dir(char_u *dirbuf, struct dir_stack_T **stackptr, bool is_file_stack)
{
- struct dir_stack_T *ds_ptr;
+ struct dir_stack_T *ds_ptr;
// allocate new stack element and hook it in
struct dir_stack_T *ds_new = xmalloc(sizeof(struct dir_stack_T));
@@ -2165,9 +2129,10 @@ static char_u *qf_push_dir(char_u *dirbuf, struct dir_stack_T **stackptr,
while (ds_new) {
xfree((*stackptr)->dirname);
(*stackptr)->dirname = (char_u *)concat_fnames((char *)ds_new->dirname,
- (char *)dirbuf, TRUE);
- if (os_isdir((*stackptr)->dirname))
+ (char *)dirbuf, TRUE);
+ if (os_isdir((*stackptr)->dirname)) {
break;
+ }
ds_new = ds_new->next;
}
@@ -2187,9 +2152,9 @@ static char_u *qf_push_dir(char_u *dirbuf, struct dir_stack_T **stackptr,
}
}
- if ((*stackptr)->dirname != NULL)
+ if ((*stackptr)->dirname != NULL) {
return (*stackptr)->dirname;
- else {
+ } else {
ds_ptr = *stackptr;
*stackptr = (*stackptr)->next;
xfree(ds_ptr);
@@ -2202,7 +2167,7 @@ static char_u *qf_push_dir(char_u *dirbuf, struct dir_stack_T **stackptr,
// stack is empty
static char_u *qf_pop_dir(struct dir_stack_T **stackptr)
{
- struct dir_stack_T *ds_ptr;
+ struct dir_stack_T *ds_ptr;
// TODO(vim): Should we check if dirbuf is the directory on top of the stack?
// What to do if it isn't?
@@ -2222,7 +2187,7 @@ static char_u *qf_pop_dir(struct dir_stack_T **stackptr)
// clean up directory stack
static void qf_clean_dir_stack(struct dir_stack_T **stackptr)
{
- struct dir_stack_T *ds_ptr;
+ struct dir_stack_T *ds_ptr;
while ((ds_ptr = *stackptr) != NULL) {
*stackptr = (*stackptr)->next;
@@ -2251,9 +2216,9 @@ static void qf_clean_dir_stack(struct dir_stack_T **stackptr)
/// qf_guess_filepath will return NULL.
static char_u *qf_guess_filepath(qf_list_T *qfl, char_u *filename)
{
- struct dir_stack_T *ds_ptr;
- struct dir_stack_T *ds_tmp;
- char_u *fullname;
+ struct dir_stack_T *ds_ptr;
+ struct dir_stack_T *ds_tmp;
+ char_u *fullname;
// no dirs on the stack - there's nothing we can do
if (qfl->qf_dir_stack == NULL) {
@@ -2332,8 +2297,7 @@ static bool is_qf_entry_present(qf_list_T *qfl, qfline_T *qf_ptr)
/// Get the next valid entry in the current quickfix/location list. The search
/// starts from the current entry. Returns NULL on failure.
-static qfline_T *get_next_valid_entry(qf_list_T *qfl, qfline_T *qf_ptr,
- int *qf_index, int dir)
+static qfline_T *get_next_valid_entry(qf_list_T *qfl, qfline_T *qf_ptr, int *qf_index, int dir)
{
int idx = *qf_index;
int old_qf_fnum = qf_ptr->qf_fnum;
@@ -2353,8 +2317,7 @@ static qfline_T *get_next_valid_entry(qf_list_T *qfl, qfline_T *qf_ptr,
/// Get the previous valid entry in the current quickfix/location list. The
/// search starts from the current entry. Returns NULL on failure.
-static qfline_T *get_prev_valid_entry(qf_list_T *qfl, qfline_T *qf_ptr,
- int *qf_index, int dir)
+static qfline_T *get_prev_valid_entry(qf_list_T *qfl, qfline_T *qf_ptr, int *qf_index, int dir)
{
int idx = *qf_index;
int old_qf_fnum = qf_ptr->qf_fnum;
@@ -2376,8 +2339,7 @@ static qfline_T *get_prev_valid_entry(qf_list_T *qfl, qfline_T *qf_ptr,
/// the quickfix list.
/// dir == FORWARD or FORWARD_FILE: next valid entry
/// dir == BACKWARD or BACKWARD_FILE: previous valid entry
-static qfline_T *get_nth_valid_entry(qf_list_T *qfl, int errornr,
- int dir, int *new_qfidx)
+static qfline_T *get_nth_valid_entry(qf_list_T *qfl, int errornr, int dir, int *new_qfidx)
{
qfline_T *qf_ptr = qfl->qf_ptr;
int qf_idx = qfl->qf_index;
@@ -2442,20 +2404,19 @@ static qfline_T *get_nth_entry(qf_list_T *qfl, int errornr, int *new_qfidx)
/// specifies the direction (FORWARD/BACKWARD/FORWARD_FILE/BACKWARD_FILE).
/// Returns a pointer to the entry and the index of the new entry is stored in
/// 'new_qfidx'.
-static qfline_T * qf_get_entry(qf_list_T *qfl, int errornr,
- int dir, int *new_qfidx)
+static qfline_T *qf_get_entry(qf_list_T *qfl, int errornr, int dir, int *new_qfidx)
{
- qfline_T *qf_ptr = qfl->qf_ptr;
- int qfidx = qfl->qf_index;
+ qfline_T *qf_ptr = qfl->qf_ptr;
+ int qfidx = qfl->qf_index;
- if (dir != 0) { // next/prev valid entry
- qf_ptr = get_nth_valid_entry(qfl, errornr, dir, &qfidx);
- } else if (errornr != 0) { // go to specified number
- qf_ptr = get_nth_entry(qfl, errornr, &qfidx);
- }
+ if (dir != 0) { // next/prev valid entry
+ qf_ptr = get_nth_valid_entry(qfl, errornr, dir, &qfidx);
+ } else if (errornr != 0) { // go to specified number
+ qf_ptr = get_nth_entry(qfl, errornr, &qfidx);
+ }
- *new_qfidx = qfidx;
- return qf_ptr;
+ *new_qfidx = qfidx;
+ return qf_ptr;
}
// Find a window displaying a Vim help file.
@@ -2596,8 +2557,7 @@ static int qf_open_new_file_win(qf_info_T *ll_ref)
// to the window just above the location list window. This is used for opening
// a file from a location window and not from a quickfix window. If some usable
// window is previously found, then it is supplied in 'use_win'.
-static void qf_goto_win_with_ll_file(win_T *use_win, int qf_fnum,
- qf_info_T *ll_ref)
+static void qf_goto_win_with_ll_file(win_T *use_win, int qf_fnum, qf_info_T *ll_ref)
{
win_T *win = use_win;
@@ -2684,8 +2644,7 @@ static void qf_goto_win_with_qfl_file(int qf_fnum)
// window, jump to it. Otherwise open a new window to display the file. If
// 'newwin' is true, then always open a new window. This is called from either
// a quickfix or a location list window.
-static int qf_jump_to_usable_window(int qf_fnum, bool newwin,
- int *opened_window)
+static int qf_jump_to_usable_window(int qf_fnum, bool newwin, int *opened_window)
{
win_T *usable_wp = NULL;
bool usable_win = false;
@@ -2735,8 +2694,8 @@ static int qf_jump_to_usable_window(int qf_fnum, bool newwin,
}
/// Edit the selected file or help file.
-static int qf_jump_edit_buffer(qf_info_T *qi, qfline_T *qf_ptr, int forceit,
- win_T *oldwin, int *opened_window)
+static int qf_jump_edit_buffer(qf_info_T *qi, qfline_T *qf_ptr, int forceit, win_T *oldwin,
+ int *opened_window)
{
qf_list_T *qfl = qf_get_curlist(qi);
long old_changetick = qfl->qf_changedtick;
@@ -2789,8 +2748,7 @@ static int qf_jump_edit_buffer(qf_info_T *qi, qfline_T *qf_ptr, int forceit,
/// Go to the error line in the current file using either line/column number or
/// a search pattern.
-static void qf_jump_goto_line(linenr_T qf_lnum, int qf_col, char_u qf_viscol,
- char_u *qf_pattern)
+static void qf_jump_goto_line(linenr_T qf_lnum, int qf_col, char_u qf_viscol, char_u *qf_pattern)
{
linenr_T i;
@@ -2826,8 +2784,8 @@ static void qf_jump_goto_line(linenr_T qf_lnum, int qf_col, char_u qf_viscol,
}
/// Display quickfix list index and size message
-static void qf_jump_print_msg(qf_info_T *qi, int qf_index, qfline_T *qf_ptr,
- buf_T *old_curbuf, linenr_T old_lnum)
+static void qf_jump_print_msg(qf_info_T *qi, int qf_index, qfline_T *qf_ptr, buf_T *old_curbuf,
+ linenr_T old_lnum)
{
// Update the screen before showing the message, unless the screen
// scrolled up.
@@ -2862,15 +2820,14 @@ static void qf_jump_print_msg(qf_info_T *qi, int qf_index, qfline_T *qf_ptr,
/// Returns OK if successfully jumped or opened a window. Returns FAIL if not
/// able to jump/open a window. Returns NOTDONE if a file is not associated
/// with the entry.
-static int qf_jump_open_window(qf_info_T *qi, qfline_T *qf_ptr, bool newwin,
- int *opened_window)
+static int qf_jump_open_window(qf_info_T *qi, qfline_T *qf_ptr, bool newwin, int *opened_window)
{
qf_list_T *qfl = qf_get_curlist(qi);
long old_changetick = qfl->qf_changedtick;
int old_qf_curlist = qi->qf_curlist;
qfltype_T qfl_type = qfl->qfl_type;
- // For ":helpgrep" find a help window or open one.
+ // For ":helpgrep" find a help window or open one.
if (qf_ptr->qf_type == 1 && (!bt_help(curwin->w_buffer) || cmdmod.tab != 0)) {
if (jump_to_help_window(qi, newwin, opened_window) == FAIL) {
return FAIL;
@@ -2921,9 +2878,8 @@ static int qf_jump_open_window(qf_info_T *qi, qfline_T *qf_ptr, bool newwin,
/// Returns OK on success and FAIL on failing to open the file/buffer. Returns
/// NOTDONE if the quickfix/location list is freed by an autocmd when opening
/// the file.
-static int qf_jump_to_buffer(qf_info_T *qi, int qf_index, qfline_T *qf_ptr,
- int forceit, win_T *oldwin, int *opened_window,
- int openfold, int print_message)
+static int qf_jump_to_buffer(qf_info_T *qi, int qf_index, qfline_T *qf_ptr, int forceit,
+ win_T *oldwin, int *opened_window, int openfold, int print_message)
{
buf_T *old_curbuf;
linenr_T old_lnum;
@@ -2975,8 +2931,7 @@ void qf_jump(qf_info_T *qi, int dir, int errornr, int forceit)
// else if "errornr" is zero, redisplay the same line
// If 'forceit' is true, then can discard changes to the current buffer.
// If 'newwin' is true, then open the file in a new window.
-static void qf_jump_newwin(qf_info_T *qi, int dir, int errornr, int forceit,
- bool newwin)
+static void qf_jump_newwin(qf_info_T *qi, int dir, int errornr, int forceit, bool newwin)
{
qf_list_T *qfl;
qfline_T *qf_ptr;
@@ -2991,8 +2946,9 @@ static void qf_jump_newwin(qf_info_T *qi, int dir, int errornr, int forceit,
const bool old_KeyTyped = KeyTyped; // getting file may reset it
int retval = OK;
- if (qi == NULL)
+ if (qi == NULL) {
qi = &ql_info;
+ }
if (qf_stack_empty(qi) || qf_list_empty(qf_get_curlist(qi))) {
EMSG(_(e_quickfix));
@@ -3042,8 +2998,8 @@ static void qf_jump_newwin(qf_info_T *qi, int dir, int errornr, int forceit,
win_close(curwin, true); // Close opened window
}
if (qf_ptr != NULL && qf_ptr->qf_fnum != 0) {
- // Couldn't open file, so put index back where it was. This could
- // happen if the file was readonly and we changed something.
+ // Couldn't open file, so put index back where it was. This could
+ // happen if the file was readonly and we changed something.
failed:
qf_ptr = old_qf_ptr;
qf_index = old_qf_index;
@@ -3158,7 +3114,7 @@ void qf_list(exarg_T *eap)
int i;
int idx1 = 1;
int idx2 = -1;
- char_u *arg = eap->arg;
+ char_u *arg = eap->arg;
int all = eap->forceit; // if not :cl!, only show
// recognised errors
qf_info_T *qi;
@@ -3203,15 +3159,15 @@ void qf_list(exarg_T *eap)
// that this depends on syntax items defined in the qf.vim syntax file
qfFileAttr = syn_name2attr((char_u *)"qfFileName");
if (qfFileAttr == 0) {
- qfFileAttr = HL_ATTR(HLF_D);
+ qfFileAttr = HL_ATTR(HLF_D);
}
qfSepAttr = syn_name2attr((char_u *)"qfSeparator");
if (qfSepAttr == 0) {
- qfSepAttr = HL_ATTR(HLF_D);
+ qfSepAttr = HL_ATTR(HLF_D);
}
qfLineAttr = syn_name2attr((char_u *)"qfLineNr");
if (qfLineAttr == 0) {
- qfLineAttr = HL_ATTR(HLF_N);
+ qfLineAttr = HL_ATTR(HLF_N);
}
if (qfl->qf_nonevalid) {
@@ -3227,8 +3183,7 @@ void qf_list(exarg_T *eap)
// Remove newlines and leading whitespace from an error message.
// Put the result in "buf[bufsize]".
-static void qf_fmt_text(const char_u *restrict text, char_u *restrict buf,
- int bufsize)
+static void qf_fmt_text(const char_u *restrict text, char_u *restrict buf, int bufsize)
FUNC_ATTR_NONNULL_ALL
{
int i;
@@ -3237,11 +3192,14 @@ static void qf_fmt_text(const char_u *restrict text, char_u *restrict buf,
for (i = 0; *p != NUL && i < bufsize - 1; ++i) {
if (*p == '\n') {
buf[i] = ' ';
- while (*++p != NUL)
- if (!ascii_iswhite(*p) && *p != '\n')
+ while (*++p != NUL) {
+ if (!ascii_iswhite(*p) && *p != '\n') {
break;
- } else
+ }
+ }
+ } else {
buf[i] = *p++;
+ }
}
buf[i] = NUL;
}
@@ -3290,8 +3248,8 @@ static void qf_msg(qf_info_T *qi, int which, char *lead)
size_t len = STRLEN(buf);
if (len < 34) {
- memset(buf + len, ' ', 34 - len);
- buf[34] = NUL;
+ memset(buf + len, ' ', 34 - len);
+ buf[34] = NUL;
}
xstrlcat((char *)buf, title, IOSIZE);
}
@@ -3374,8 +3332,8 @@ void qf_history(exarg_T *eap)
/// associated with the list like context and title are not freed.
static void qf_free_items(qf_list_T *qfl)
{
- qfline_T *qfp;
- qfline_T *qfpnext;
+ qfline_T *qfp;
+ qfline_T *qfpnext;
bool stop = false;
while (qfl->qf_count && qfl->qf_start != NULL) {
@@ -3430,13 +3388,12 @@ static void qf_free(qf_list_T *qfl)
}
// qf_mark_adjust: adjust marks
-bool qf_mark_adjust(win_T *wp, linenr_T line1, linenr_T line2, long amount,
- long amount_after)
+bool qf_mark_adjust(win_T *wp, linenr_T line1, linenr_T line2, long amount, long amount_after)
{
int i;
- qfline_T *qfp;
+ qfline_T *qfp;
int idx;
- qf_info_T *qi = &ql_info;
+ qf_info_T *qi = &ql_info;
bool found_one = false;
int buf_has_flag = wp == NULL ? BUF_HAS_QF_ENTRY : BUF_HAS_LL_ENTRY;
@@ -3457,12 +3414,14 @@ bool qf_mark_adjust(win_T *wp, linenr_T line1, linenr_T line2, long amount,
if (qfp->qf_fnum == curbuf->b_fnum) {
found_one = true;
if (qfp->qf_lnum >= line1 && qfp->qf_lnum <= line2) {
- if (amount == MAXLNUM)
+ if (amount == MAXLNUM) {
qfp->qf_cleared = TRUE;
- else
+ } else {
qfp->qf_lnum += amount;
- } else if (amount_after && qfp->qf_lnum > line2)
+ }
+ } else if (amount_after && qfp->qf_lnum > line2) {
qfp->qf_lnum += amount_after;
+ }
}
}
}
@@ -3490,7 +3449,7 @@ static char_u *qf_types(int c, int nr)
{
static char_u buf[20];
static char_u cc[3];
- char_u *p;
+ char_u *p;
if (c == 'W' || c == 'w') {
p = (char_u *)" warning";
@@ -3509,8 +3468,9 @@ static char_u *qf_types(int c, int nr)
p = cc;
}
- if (nr <= 0)
+ if (nr <= 0) {
return p;
+ }
sprintf((char *)buf, "%s %3d", (char *)p, nr);
return buf;
@@ -3520,7 +3480,7 @@ static char_u *qf_types(int c, int nr)
// When "split" is true: Open the entry/result under the cursor in a new window.
void qf_view_result(bool split)
{
- qf_info_T *qi = &ql_info;
+ qf_info_T *qi = &ql_info;
if (!bt_quickfix(curbuf)) {
return;
@@ -3549,9 +3509,9 @@ void qf_view_result(bool split)
// close it if not.
void ex_cwindow(exarg_T *eap)
{
- qf_info_T *qi;
- qf_list_T *qfl;
- win_T *win;
+ qf_info_T *qi;
+ qf_list_T *qfl;
+ win_T *win;
if ((qi = qf_cmd_get_stack(eap, true)) == NULL) {
return;
@@ -3596,8 +3556,7 @@ void ex_cclose(exarg_T *eap)
// Goto a quickfix or location list window (if present).
// Returns OK if the window is found, FAIL otherwise.
-static int qf_goto_cwindow(const qf_info_T *qi, bool resize, int sz,
- bool vertsplit)
+static int qf_goto_cwindow(const qf_info_T *qi, bool resize, int sz, bool vertsplit)
{
win_T *const win = qf_find_win(qi);
if (win == NULL) {
@@ -3725,8 +3684,8 @@ static void qf_set_title_var(qf_list_T *qfl)
/// ":lopen": open a window that shows the location list.
void ex_copen(exarg_T *eap)
{
- qf_info_T *qi;
- qf_list_T *qfl;
+ qf_info_T *qi;
+ qf_list_T *qfl;
int height;
int status = FAIL;
int lnum;
@@ -3812,7 +3771,7 @@ void ex_cbottom(exarg_T *eap)
// window).
linenr_T qf_current_entry(win_T *wp)
{
- qf_info_T *qi = &ql_info;
+ qf_info_T *qi = &ql_info;
if (IS_LL_WINDOW(wp)) {
// In the location list window, use the referenced location list
@@ -3822,14 +3781,13 @@ linenr_T qf_current_entry(win_T *wp)
return qf_get_curlist(qi)->qf_index;
}
-// Update the cursor position in the quickfix window to the current error.
-// Return TRUE if there is a quickfix window.
-static int qf_win_pos_update(
- qf_info_T *qi,
- int old_qf_index // previous qf_index or zero
-)
+/// Update the cursor position in the quickfix window to the current error.
+/// Return TRUE if there is a quickfix window.
+///
+/// @param old_qf_index previous qf_index or zero
+static int qf_win_pos_update(qf_info_T *qi, int old_qf_index)
{
- win_T *win;
+ win_T *win;
int qf_index = qf_get_curlist(qi)->qf_index;
// Put the cursor on the current error in the quickfix window, so that
@@ -3954,8 +3912,8 @@ static void qf_update_win_titlevar(qf_info_T *qi)
// Find the quickfix buffer. If it exists, update the contents.
static void qf_update_buffer(qf_info_T *qi, qfline_T *old_last)
{
- buf_T *buf;
- win_T *win;
+ buf_T *buf;
+ win_T *win;
aco_save_T aco;
// Check if a buffer for the quickfix list exists. Update it.
@@ -4002,9 +3960,8 @@ static void qf_update_buffer(qf_info_T *qi, qfline_T *old_last)
}
// Add an error line to the quickfix buffer.
-static int qf_buf_add_line(qf_list_T *qfl, buf_T *buf, linenr_T lnum,
- const qfline_T *qfp, char_u *dirname,
- char_u *qftf_str, bool first_bufline)
+static int qf_buf_add_line(qf_list_T *qfl, buf_T *buf, linenr_T lnum, const qfline_T *qfp,
+ char_u *dirname, char_u *qftf_str, bool first_bufline)
FUNC_ATTR_NONNULL_ARG(1, 2, 4, 5)
{
int len;
@@ -4076,10 +4033,7 @@ static int qf_buf_add_line(qf_list_T *qfl, buf_T *buf, linenr_T lnum,
// Call the 'quickfixtextfunc' function to get the list of lines to display in
// the quickfix window for the entries 'start_idx' to 'end_idx'.
-static list_T *call_qftf_func(qf_list_T *qfl,
- int qf_winid,
- long start_idx,
- long end_idx)
+static list_T *call_qftf_func(qf_list_T *qfl, int qf_winid, long start_idx, long end_idx)
{
Callback *cb = &qftf_cb;
list_T *qftf_list = NULL;
@@ -4126,12 +4080,11 @@ static list_T *call_qftf_func(qf_list_T *qfl,
/// If "old_last" is not NULL append the items after this one.
/// When "old_last" is NULL then "buf" must equal "curbuf"! Because ml_delete()
/// is used and autocommands will be triggered.
-static void qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last,
- int qf_winid)
+static void qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last, int qf_winid)
FUNC_ATTR_NONNULL_ARG(2)
{
linenr_T lnum;
- qfline_T *qfp;
+ qfline_T *qfp;
const bool old_KeyTyped = KeyTyped;
list_T *qftf_list = NULL;
listitem_T *qftf_li = NULL;
@@ -4150,11 +4103,11 @@ static void qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last,
// Check if there is anything to display
if (qfl != NULL) {
- char_u dirname[MAXPATHL];
- int prev_bufnr = -1;
- bool invalid_val = false;
+ char_u dirname[MAXPATHL];
+ int prev_bufnr = -1;
+ bool invalid_val = false;
- *dirname = NUL;
+ *dirname = NUL;
// Add one line for each error
if (old_last == NULL) {
@@ -4235,7 +4188,7 @@ static void qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last,
static void qf_list_changed(qf_list_T *qfl)
{
- qfl->qf_changedtick++;
+ qfl->qf_changedtick++;
}
/// Return the quickfix/location list number with the given identifier.
@@ -4291,7 +4244,7 @@ int grep_internal(cmdidx_T cmdidx)
|| cmdidx == CMD_grepadd
|| cmdidx == CMD_lgrepadd)
&& STRCMP("internal",
- *curbuf->b_p_gp == NUL ? p_gp : curbuf->b_p_gp) == 0;
+ *curbuf->b_p_gp == NUL ? p_gp : curbuf->b_p_gp) == 0;
}
// Return the make/grep autocmd name.
@@ -4299,20 +4252,20 @@ static char_u *make_get_auname(cmdidx_T cmdidx)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
switch (cmdidx) {
- case CMD_make:
- return (char_u *)"make";
- case CMD_lmake:
- return (char_u *)"lmake";
- case CMD_grep:
- return (char_u *)"grep";
- case CMD_lgrep:
- return (char_u *)"lgrep";
- case CMD_grepadd:
- return (char_u *)"grepadd";
- case CMD_lgrepadd:
- return (char_u *)"lgrepadd";
- default:
- return NULL;
+ case CMD_make:
+ return (char_u *)"make";
+ case CMD_lmake:
+ return (char_u *)"lmake";
+ case CMD_grep:
+ return (char_u *)"grep";
+ case CMD_lgrep:
+ return (char_u *)"lgrep";
+ case CMD_grepadd:
+ return (char_u *)"grepadd";
+ case CMD_lgrepadd:
+ return (char_u *)"lgrepadd";
+ default:
+ return NULL;
}
}
@@ -4349,9 +4302,9 @@ static char *make_get_fullcmd(const char_u *makecmd, const char_u *fname)
// Used for ":make", ":lmake", ":grep", ":lgrep", ":grepadd", and ":lgrepadd"
void ex_make(exarg_T *eap)
{
- char_u *fname;
- win_T *wp = NULL;
- qf_info_T *qi = &ql_info;
+ char_u *fname;
+ win_T *wp = NULL;
+ qf_info_T *qi = &ql_info;
int res;
char_u *enc = (*curbuf->b_p_menc != NUL) ? curbuf->b_p_menc : p_menc;
@@ -4375,8 +4328,9 @@ void ex_make(exarg_T *eap)
autowrite_all();
fname = get_mef_name();
- if (fname == NULL)
+ if (fname == NULL) {
return;
+ }
os_remove((char *)fname); // in case it's not unique
char *const cmd = make_get_fullcmd(eap->arg, fname);
@@ -4422,24 +4376,28 @@ cleanup:
// Returns NULL for error.
static char_u *get_mef_name(void)
{
- char_u *p;
- char_u *name;
+ char_u *p;
+ char_u *name;
static int start = -1;
static int off = 0;
if (*p_mef == NUL) {
name = vim_tempname();
- if (name == NULL)
+ if (name == NULL) {
EMSG(_(e_notmp));
+ }
return name;
}
- for (p = p_mef; *p; ++p)
- if (p[0] == '#' && p[1] == '#')
+ for (p = p_mef; *p; ++p) {
+ if (p[0] == '#' && p[1] == '#') {
break;
+ }
+ }
- if (*p == NUL)
+ if (*p == NUL) {
return vim_strsave(p_mef);
+ }
// Keep trying until the name doesn't exist yet.
for (;; ) {
@@ -4613,7 +4571,7 @@ static size_t qf_get_nth_valid_entry(qf_list_T *qfl, size_t n, int fdo)
/// ":cdo", ":ldo", ":cfdo" and ":lfdo".
void ex_cc(exarg_T *eap)
{
- qf_info_T *qi;
+ qf_info_T *qi;
if ((qi = qf_cmd_get_stack(eap, true)) == NULL) {
return;
@@ -4624,19 +4582,19 @@ void ex_cc(exarg_T *eap)
errornr = (int)eap->line2;
} else {
switch (eap->cmdidx) {
- case CMD_cc:
- case CMD_ll:
- errornr = 0;
- break;
- case CMD_crewind:
- case CMD_lrewind:
- case CMD_cfirst:
- case CMD_lfirst:
- errornr = 1;
- break;
- default:
- errornr = 32767;
- break;
+ case CMD_cc:
+ case CMD_ll:
+ errornr = 0;
+ break;
+ case CMD_crewind:
+ case CMD_lrewind:
+ case CMD_cfirst:
+ case CMD_lfirst:
+ errornr = 1;
+ break;
+ default:
+ errornr = 32767;
+ break;
}
}
@@ -4651,9 +4609,8 @@ void ex_cc(exarg_T *eap)
} else {
n = 1;
}
- size_t valid_entry = qf_get_nth_valid_entry(
- qf_get_curlist(qi), n,
- eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo);
+ size_t valid_entry = qf_get_nth_valid_entry(qf_get_curlist(qi), n,
+ eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo);
assert(valid_entry <= INT_MAX);
errornr = (int)valid_entry;
}
@@ -4666,7 +4623,7 @@ void ex_cc(exarg_T *eap)
/// ":cdo", ":ldo", ":cfdo" and ":lfdo".
void ex_cnext(exarg_T *eap)
{
- qf_info_T *qi;
+ qf_info_T *qi;
if ((qi = qf_cmd_get_stack(eap, true)) == NULL) {
return;
@@ -4684,31 +4641,31 @@ void ex_cnext(exarg_T *eap)
// Depending on the command jump to either next or previous entry/file.
Direction dir;
switch (eap->cmdidx) {
- case CMD_cprevious:
- case CMD_lprevious:
- case CMD_cNext:
- case CMD_lNext:
- dir = BACKWARD;
- break;
- case CMD_cnfile:
- case CMD_lnfile:
- case CMD_cfdo:
- case CMD_lfdo:
- dir = FORWARD_FILE;
- break;
- case CMD_cpfile:
- case CMD_lpfile:
- case CMD_cNfile:
- case CMD_lNfile:
- dir = BACKWARD_FILE;
- break;
- case CMD_cnext:
- case CMD_lnext:
- case CMD_cdo:
- case CMD_ldo:
- default:
- dir = FORWARD;
- break;
+ case CMD_cprevious:
+ case CMD_lprevious:
+ case CMD_cNext:
+ case CMD_lNext:
+ dir = BACKWARD;
+ break;
+ case CMD_cnfile:
+ case CMD_lnfile:
+ case CMD_cfdo:
+ case CMD_lfdo:
+ dir = FORWARD_FILE;
+ break;
+ case CMD_cpfile:
+ case CMD_lpfile:
+ case CMD_cNfile:
+ case CMD_lNfile:
+ dir = BACKWARD_FILE;
+ break;
+ case CMD_cnext:
+ case CMD_lnext:
+ case CMD_cdo:
+ case CMD_ldo:
+ default:
+ dir = FORWARD;
+ break;
}
qf_jump(qi, dir, errornr, eap->forceit);
@@ -4717,9 +4674,7 @@ void ex_cnext(exarg_T *eap)
/// Find the first entry in the quickfix list 'qfl' from buffer 'bnr'.
/// The index of the entry is stored in 'errornr'.
/// Returns NULL if an entry is not found.
-static qfline_T *qf_find_first_entry_in_buf(qf_list_T *qfl,
- int bnr,
- int *errornr)
+static qfline_T *qf_find_first_entry_in_buf(qf_list_T *qfl, int bnr, int *errornr)
{
qfline_T *qfp = NULL;
int idx = 0;
@@ -4738,7 +4693,7 @@ static qfline_T *qf_find_first_entry_in_buf(qf_list_T *qfl,
/// Find the first quickfix entry on the same line as 'entry'. Updates 'errornr'
/// with the error number for the first entry. Assumes the entries are sorted in
/// the quickfix list by line number.
-static qfline_T * qf_find_first_entry_on_line(qfline_T *entry, int *errornr)
+static qfline_T *qf_find_first_entry_on_line(qfline_T *entry, int *errornr)
{
while (!got_int
&& entry->qf_prev != NULL
@@ -4754,7 +4709,7 @@ static qfline_T * qf_find_first_entry_on_line(qfline_T *entry, int *errornr)
/// Find the last quickfix entry on the same line as 'entry'. Updates 'errornr'
/// with the error number for the last entry. Assumes the entries are sorted in
/// the quickfix list by line number.
-static qfline_T * qf_find_last_entry_on_line(qfline_T *entry, int *errornr)
+static qfline_T *qf_find_last_entry_on_line(qfline_T *entry, int *errornr)
{
while (!got_int
&& entry->qf_next != NULL
@@ -4770,57 +4725,53 @@ static qfline_T * qf_find_last_entry_on_line(qfline_T *entry, int *errornr)
// Returns true if the specified quickfix entry is
// after the given line (linewise is true)
// or after the line and column.
-static bool qf_entry_after_pos(const qfline_T *qfp, const pos_T *pos,
- bool linewise)
+static bool qf_entry_after_pos(const qfline_T *qfp, const pos_T *pos, bool linewise)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
if (linewise) {
return qfp->qf_lnum > pos->lnum;
}
return qfp->qf_lnum > pos->lnum
- || (qfp->qf_lnum == pos->lnum && qfp->qf_col > pos->col);
+ || (qfp->qf_lnum == pos->lnum && qfp->qf_col > pos->col);
}
// Returns true if the specified quickfix entry is
// before the given line (linewise is true)
// or before the line and column.
-static bool qf_entry_before_pos(const qfline_T *qfp, const pos_T *pos,
- bool linewise)
+static bool qf_entry_before_pos(const qfline_T *qfp, const pos_T *pos, bool linewise)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
if (linewise) {
return qfp->qf_lnum < pos->lnum;
}
return qfp->qf_lnum < pos->lnum
- || (qfp->qf_lnum == pos->lnum && qfp->qf_col < pos->col);
+ || (qfp->qf_lnum == pos->lnum && qfp->qf_col < pos->col);
}
// Returns true if the specified quickfix entry is
// on or after the given line (linewise is true)
// or on or after the line and column.
-static bool qf_entry_on_or_after_pos(const qfline_T *qfp, const pos_T *pos,
- bool linewise)
+static bool qf_entry_on_or_after_pos(const qfline_T *qfp, const pos_T *pos, bool linewise)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
if (linewise) {
return qfp->qf_lnum >= pos->lnum;
}
return qfp->qf_lnum > pos->lnum
- || (qfp->qf_lnum == pos->lnum && qfp->qf_col >= pos->col);
+ || (qfp->qf_lnum == pos->lnum && qfp->qf_col >= pos->col);
}
// Returns true if the specified quickfix entry is
// on or before the given line (linewise is true)
// or on or before the line and column.
-static bool qf_entry_on_or_before_pos(const qfline_T *qfp, const pos_T *pos,
- bool linewise)
+static bool qf_entry_on_or_before_pos(const qfline_T *qfp, const pos_T *pos, bool linewise)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
if (linewise) {
return qfp->qf_lnum <= pos->lnum;
}
return qfp->qf_lnum < pos->lnum
- || (qfp->qf_lnum == pos->lnum && qfp->qf_col <= pos->col);
+ || (qfp->qf_lnum == pos->lnum && qfp->qf_col <= pos->col);
}
/// Find the first quickfix entry after position 'pos' in buffer 'bnr'.
@@ -4830,13 +4781,8 @@ static bool qf_entry_on_or_before_pos(const qfline_T *qfp, const pos_T *pos,
/// 'qfp' points to the very first entry in the buffer and 'errornr' is the
/// index of the very first entry in the quickfix list.
/// Returns NULL if an entry is not found after 'pos'.
-static qfline_T *qf_find_entry_after_pos(
- int bnr,
- const pos_T *pos,
- bool linewise,
- qfline_T *qfp,
- int *errornr
-)
+static qfline_T *qf_find_entry_after_pos(int bnr, const pos_T *pos, bool linewise, qfline_T *qfp,
+ int *errornr)
FUNC_ATTR_NONNULL_ALL
{
if (qf_entry_after_pos(qfp, pos, linewise)) {
@@ -4871,13 +4817,8 @@ static qfline_T *qf_find_entry_after_pos(
/// 'qfp' points to the very first entry in the buffer and 'errornr' is the
/// index of the very first entry in the quickfix list.
/// Returns NULL if an entry is not found before 'pos'.
-static qfline_T *qf_find_entry_before_pos(
- int bnr,
- const pos_T *pos,
- bool linewise,
- qfline_T *qfp,
- int *errornr
-)
+static qfline_T *qf_find_entry_before_pos(int bnr, const pos_T *pos, bool linewise, qfline_T *qfp,
+ int *errornr)
FUNC_ATTR_NONNULL_ALL
{
// Find the entry just before the position 'pos'
@@ -4902,14 +4843,8 @@ static qfline_T *qf_find_entry_before_pos(
/// Find a quickfix entry in 'qfl' closest to position 'pos' in buffer 'bnr' in
/// the direction 'dir'.
-static qfline_T *qf_find_closest_entry(
- qf_list_T *qfl,
- int bnr,
- const pos_T *pos,
- Direction dir,
- bool linewise,
- int *errornr
-)
+static qfline_T *qf_find_closest_entry(qf_list_T *qfl, int bnr, const pos_T *pos, Direction dir,
+ bool linewise, int *errornr)
FUNC_ATTR_NONNULL_ALL
{
qfline_T *qfp;
@@ -4934,8 +4869,7 @@ static qfline_T *qf_find_closest_entry(
/// Get the nth quickfix entry below the specified entry. Searches forward in
/// the list. If linewise is true, then treat multiple entries on a single line
/// as one.
-static void qf_get_nth_below_entry(qfline_T *entry, linenr_T n,
- bool linewise, int *errornr)
+static void qf_get_nth_below_entry(qfline_T *entry, linenr_T n, bool linewise, int *errornr)
FUNC_ATTR_NONNULL_ALL
{
while (n-- > 0 && !got_int) {
@@ -4966,8 +4900,7 @@ static void qf_get_nth_below_entry(qfline_T *entry, linenr_T n,
/// Get the nth quickfix entry above the specified entry. Searches backwards in
/// the list. If linewise is TRUE, then treat multiple entries on a single line
/// as one.
-static void qf_get_nth_above_entry(qfline_T *entry, linenr_T n,
- bool linewise, int *errornr)
+static void qf_get_nth_above_entry(qfline_T *entry, linenr_T n, bool linewise, int *errornr)
FUNC_ATTR_NONNULL_ALL
{
while (n-- > 0 && !got_int) {
@@ -4988,14 +4921,8 @@ static void qf_get_nth_above_entry(qfline_T *entry, linenr_T n,
/// Find the n'th quickfix entry adjacent to position 'pos' in buffer 'bnr' in
/// the specified direction. Returns the error number in the quickfix list or 0
/// if an entry is not found.
-static int qf_find_nth_adj_entry(
- qf_list_T *qfl,
- int bnr,
- pos_T *pos,
- linenr_T n,
- Direction dir,
- bool linewise
-)
+static int qf_find_nth_adj_entry(qf_list_T *qfl, int bnr, pos_T *pos, linenr_T n, Direction dir,
+ bool linewise)
FUNC_ATTR_NONNULL_ALL
{
int errornr;
@@ -5072,16 +4999,15 @@ void ex_cbelow(exarg_T *eap)
// A quickfix entry column number is 1 based whereas cursor column
// number is 0 based. Adjust the column number.
pos.col++;
- const int errornr = qf_find_nth_adj_entry(
- qfl,
- curbuf->b_fnum,
- &pos,
- eap->addr_count > 0 ? eap->line2 : 0,
- dir,
- eap->cmdidx == CMD_cbelow
- || eap->cmdidx == CMD_lbelow
- || eap->cmdidx == CMD_cabove
- || eap->cmdidx == CMD_labove);
+ const int errornr = qf_find_nth_adj_entry(qfl,
+ curbuf->b_fnum,
+ &pos,
+ eap->addr_count > 0 ? eap->line2 : 0,
+ dir,
+ eap->cmdidx == CMD_cbelow
+ || eap->cmdidx == CMD_lbelow
+ || eap->cmdidx == CMD_cabove
+ || eap->cmdidx == CMD_labove);
if (errornr > 0) {
qf_jump(qi, 0, errornr, false);
@@ -5092,16 +5018,23 @@ void ex_cbelow(exarg_T *eap)
/// Return the autocmd name for the :cfile Ex commands
-static char_u * cfile_get_auname(cmdidx_T cmdidx)
+static char_u *cfile_get_auname(cmdidx_T cmdidx)
{
switch (cmdidx) {
- case CMD_cfile: return (char_u *)"cfile";
- case CMD_cgetfile: return (char_u *)"cgetfile";
- case CMD_caddfile: return (char_u *)"caddfile";
- case CMD_lfile: return (char_u *)"lfile";
- case CMD_lgetfile: return (char_u *)"lgetfile";
- case CMD_laddfile: return (char_u *)"laddfile";
- default: return NULL;
+ case CMD_cfile:
+ return (char_u *)"cfile";
+ case CMD_cgetfile:
+ return (char_u *)"cgetfile";
+ case CMD_caddfile:
+ return (char_u *)"caddfile";
+ case CMD_lfile:
+ return (char_u *)"lfile";
+ case CMD_lgetfile:
+ return (char_u *)"lgetfile";
+ case CMD_laddfile:
+ return (char_u *)"laddfile";
+ default:
+ return NULL;
}
}
@@ -5110,9 +5043,9 @@ static char_u * cfile_get_auname(cmdidx_T cmdidx)
// ":lfile"/":lgetfile"/":laddfile" commands.
void ex_cfile(exarg_T *eap)
{
- win_T *wp = NULL;
- qf_info_T *qi = &ql_info;
- char_u *au_name = NULL;
+ win_T *wp = NULL;
+ qf_info_T *qi = &ql_info;
+ char_u *au_name = NULL;
au_name = cfile_get_auname(eap->cmdidx);
if (au_name != NULL
@@ -5173,15 +5106,24 @@ void ex_cfile(exarg_T *eap)
static char_u *vgr_get_auname(cmdidx_T cmdidx)
{
switch (cmdidx) {
- case CMD_vimgrep: return (char_u *)"vimgrep";
- case CMD_lvimgrep: return (char_u *)"lvimgrep";
- case CMD_vimgrepadd: return (char_u *)"vimgrepadd";
- case CMD_lvimgrepadd: return (char_u *)"lvimgrepadd";
- case CMD_grep: return (char_u *)"grep";
- case CMD_lgrep: return (char_u *)"lgrep";
- case CMD_grepadd: return (char_u *)"grepadd";
- case CMD_lgrepadd: return (char_u *)"lgrepadd";
- default: return NULL;
+ case CMD_vimgrep:
+ return (char_u *)"vimgrep";
+ case CMD_lvimgrep:
+ return (char_u *)"lvimgrep";
+ case CMD_vimgrepadd:
+ return (char_u *)"vimgrepadd";
+ case CMD_lvimgrepadd:
+ return (char_u *)"lvimgrepadd";
+ case CMD_grep:
+ return (char_u *)"grep";
+ case CMD_lgrep:
+ return (char_u *)"lgrep";
+ case CMD_grepadd:
+ return (char_u *)"grepadd";
+ case CMD_lgrepadd:
+ return (char_u *)"lgrepadd";
+ default:
+ return NULL;
}
}
@@ -5226,8 +5168,7 @@ static void vgr_display_fname(char_u *fname)
}
/// Load a dummy buffer to search for a pattern using vimgrep.
-static buf_T *vgr_load_dummy_buf(char_u *fname, char_u *dirname_start,
- char_u *dirname_now)
+static buf_T *vgr_load_dummy_buf(char_u *fname, char_u *dirname_start, char_u *dirname_now)
{
// Don't do Filetype autocommands to avoid loading syntax and
// indent scripts, a great speed improvement.
@@ -5249,8 +5190,7 @@ static buf_T *vgr_load_dummy_buf(char_u *fname, char_u *dirname_start,
/// Check whether a quickfix/location list is valid. Autocmds may remove or
/// change a quickfix list when vimgrep is running. If the list is not found,
/// create a new list.
-static bool vgr_qflist_valid(win_T *wp, qf_info_T *qi, unsigned qfid,
- char_u *title)
+static bool vgr_qflist_valid(win_T *wp, qf_info_T *qi, unsigned qfid, char_u *title)
{
// Verify that the quickfix/location list was not freed by an autocmd
if (!qflist_valid(wp, qfid)) {
@@ -5274,9 +5214,8 @@ static bool vgr_qflist_valid(win_T *wp, qf_info_T *qi, unsigned qfid,
/// Search for a pattern in all the lines in a buffer and add the matching lines
/// to a quickfix list.
-static bool vgr_match_buflines(qf_list_T *qfl, char_u *fname, buf_T *buf,
- regmmatch_T *regmatch, long *tomatch,
- int duplicate_name, int flags)
+static bool vgr_match_buflines(qf_list_T *qfl, char_u *fname, buf_T *buf, regmmatch_T *regmatch,
+ long *tomatch, int duplicate_name, int flags)
FUNC_ATTR_NONNULL_ARG(1, 3, 4, 5)
{
bool found_match = false;
@@ -5373,27 +5312,27 @@ void ex_vimgrep(exarg_T *eap)
{
regmmatch_T regmatch;
int fcount;
- char_u **fnames;
- char_u *fname;
- char_u *s;
- char_u *p;
+ char_u **fnames;
+ char_u *fname;
+ char_u *s;
+ char_u *p;
int fi;
- qf_list_T *qfl;
+ qf_list_T *qfl;
win_T *wp = NULL;
- buf_T *buf;
+ buf_T *buf;
int duplicate_name = FALSE;
int using_dummy;
int redraw_for_dummy = FALSE;
int found_match;
- buf_T *first_match_buf = NULL;
+ buf_T *first_match_buf = NULL;
time_t seconds = 0;
aco_save_T aco;
int flags = 0;
long tomatch;
- char_u *dirname_start = NULL;
- char_u *dirname_now = NULL;
- char_u *target_dir = NULL;
- char_u *au_name = NULL;
+ char_u *dirname_start = NULL;
+ char_u *dirname_now = NULL;
+ char_u *target_dir = NULL;
+ char_u *au_name = NULL;
au_name = vgr_get_auname(eap->cmdidx);
if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
@@ -5405,10 +5344,11 @@ void ex_vimgrep(exarg_T *eap)
qf_info_T *qi = qf_cmd_get_or_alloc_stack(eap, &wp);
- if (eap->addr_count > 0)
+ if (eap->addr_count > 0) {
tomatch = eap->line2;
- else
+ } else {
tomatch = MAXLNUM;
+ }
// Get the search pattern: either white-separated or enclosed in //
regmatch.regprog = NULL;
@@ -5492,8 +5432,9 @@ void ex_vimgrep(exarg_T *eap)
save_qfid = qf_get_curlist(qi)->qf_id;
if (buf == NULL) {
- if (!got_int)
+ if (!got_int) {
smsg(_("Cannot open file \"%s\""), fname);
+ }
} else {
// Try for a match in all lines of the buffer.
// For ":1vimgrep" look for first match only.
@@ -5502,8 +5443,9 @@ void ex_vimgrep(exarg_T *eap)
duplicate_name, flags);
if (using_dummy) {
- if (found_match && first_match_buf == NULL)
+ if (found_match && first_match_buf == NULL) {
first_match_buf = buf;
+ }
if (duplicate_name) {
// Never keep a dummy buffer if there is another buffer
// with the same name.
@@ -5585,8 +5527,9 @@ void ex_vimgrep(exarg_T *eap)
vgr_jump_to_match(qi, eap->forceit, &redraw_for_dummy, first_match_buf,
target_dir);
}
- } else
+ } else {
EMSG2(_(e_nomatch2), s);
+ }
decr_quickfix_busy();
@@ -5624,24 +5567,22 @@ static void restore_start_dir(char_u *dirname_start)
xfree(dirname_now);
}
-// Load file "fname" into a dummy buffer and return the buffer pointer,
-// placing the directory resulting from the buffer load into the
-// "resulting_dir" pointer. "resulting_dir" must be allocated by the caller
-// prior to calling this function. Restores directory to "dirname_start" prior
-// to returning, if autocmds or the 'autochdir' option have changed it.
-//
-// If creating the dummy buffer does not fail, must call unload_dummy_buffer()
-// or wipe_dummy_buffer() later!
-//
-// Returns NULL if it fails.
-static buf_T *
-load_dummy_buffer (
- char_u *fname,
- char_u *dirname_start, // in: old directory
- char_u *resulting_dir // out: new directory
-)
-{
- buf_T *newbuf;
+/// Load file "fname" into a dummy buffer and return the buffer pointer,
+/// placing the directory resulting from the buffer load into the
+/// "resulting_dir" pointer. "resulting_dir" must be allocated by the caller
+/// prior to calling this function. Restores directory to "dirname_start" prior
+/// to returning, if autocmds or the 'autochdir' option have changed it.
+///
+/// If creating the dummy buffer does not fail, must call unload_dummy_buffer()
+/// or wipe_dummy_buffer() later!
+///
+/// @param dirname_start in: old directory
+/// @param resulting_dir out: new directory
+///
+/// @return NULL if it fails.
+static buf_T *load_dummy_buffer(char_u *fname, char_u *dirname_start, char_u *resulting_dir)
+{
+ buf_T *newbuf;
bufref_T newbufref;
bufref_T newbuf_to_wipe;
int failed = true;
@@ -5807,17 +5748,14 @@ static int get_qfline_items(qfline_T *qfp, list_T *list)
|| (tv_dict_add_nr(dict, S_LEN("vcol"), (varnumber_T)qfp->qf_viscol)
== FAIL)
|| (tv_dict_add_nr(dict, S_LEN("nr"), (varnumber_T)qfp->qf_nr) == FAIL)
- || (tv_dict_add_str(
- dict, S_LEN("module"),
- (qfp->qf_module == NULL ? "" : (const char *)qfp->qf_module))
+ || (tv_dict_add_str(dict, S_LEN("module"),
+ (qfp->qf_module == NULL ? "" : (const char *)qfp->qf_module))
== FAIL)
- || (tv_dict_add_str(
- dict, S_LEN("pattern"),
- (qfp->qf_pattern == NULL ? "" : (const char *)qfp->qf_pattern))
+ || (tv_dict_add_str(dict, S_LEN("pattern"),
+ (qfp->qf_pattern == NULL ? "" : (const char *)qfp->qf_pattern))
== FAIL)
- || (tv_dict_add_str(
- dict, S_LEN("text"),
- (qfp->qf_text == NULL ? "" : (const char *)qfp->qf_text))
+ || (tv_dict_add_str(dict, S_LEN("text"),
+ (qfp->qf_text == NULL ? "" : (const char *)qfp->qf_text))
== FAIL)
|| (tv_dict_add_str(dict, S_LEN("type"), (const char *)buf) == FAIL)
|| (tv_dict_add_nr(dict, S_LEN("valid"), (varnumber_T)qfp->qf_valid)
@@ -5834,12 +5772,11 @@ static int get_qfline_items(qfline_T *qfp, list_T *list)
/// If qf_idx is -1, use the current list. Otherwise, use the specified list.
/// If eidx is not 0, then return only the specified entry. Otherwise return
/// all the entries.
-int get_errorlist(qf_info_T *qi_arg, win_T *wp, int qf_idx, int eidx,
- list_T *list)
+int get_errorlist(qf_info_T *qi_arg, win_T *wp, int qf_idx, int eidx, list_T *list)
{
qf_info_T *qi = qi_arg;
qf_list_T *qfl;
- qfline_T *qfp;
+ qfline_T *qfp;
int i;
if (qi == NULL) {
@@ -5875,7 +5812,7 @@ int get_errorlist(qf_info_T *qi_arg, win_T *wp, int qf_idx, int eidx,
return get_qfline_items(qfp, list);
}
} else if (get_qfline_items(qfp, list) == FAIL) {
- return FAIL;
+ return FAIL;
}
}
@@ -6051,10 +5988,7 @@ static int qf_getprop_qfidx(qf_info_T *qi, dict_T *what)
}
/// Return default values for quickfix list properties in retdict.
-static int qf_getprop_defaults(qf_info_T *qi,
- int flags,
- int locstack,
- dict_T *retdict)
+static int qf_getprop_defaults(qf_info_T *qi, int flags, int locstack, dict_T *retdict)
{
int status = OK;
@@ -6099,15 +6033,14 @@ static int qf_getprop_defaults(qf_info_T *qi,
/// Return the quickfix list title as 'title' in retdict
static int qf_getprop_title(qf_list_T *qfl, dict_T *retdict)
{
- return tv_dict_add_str(retdict, S_LEN("title"),
- (const char *)qfl->qf_title);
+ return tv_dict_add_str(retdict, S_LEN("title"),
+ (const char *)qfl->qf_title);
}
// Returns the identifier of the window used to display files from a location
// list. If there is no associated window, then returns 0. Useful only when
// called from a location list window.
-static int qf_getprop_filewinid(const win_T *wp, const qf_info_T *qi,
- dict_T *retdict)
+static int qf_getprop_filewinid(const win_T *wp, const qf_info_T *qi, dict_T *retdict)
FUNC_ATTR_NONNULL_ARG(3)
{
handle_T winid = 0;
@@ -6124,8 +6057,7 @@ static int qf_getprop_filewinid(const win_T *wp, const qf_info_T *qi,
/// Return the quickfix list items/entries as 'items' in retdict.
/// If eidx is not 0, then return the item at the specified index.
-static int qf_getprop_items(qf_info_T *qi, int qf_idx, int eidx,
- dict_T *retdict)
+static int qf_getprop_items(qf_info_T *qi, int qf_idx, int eidx, dict_T *retdict)
{
list_T *l = tv_list_alloc(kListLenMayKnow);
get_errorlist(qi, NULL, qf_idx, eidx, l);
@@ -6284,11 +6216,8 @@ static int qf_setprop_qftf(qf_list_T *qfl, dictitem_T *di)
/// Add a new quickfix entry to list at 'qf_idx' in the stack 'qi' from the
/// items in the dict 'd'. If it is a valid error entry, then set 'valid_entry'
/// to true.
-static int qf_add_entry_from_dict(
- qf_list_T *qfl,
- const dict_T *d,
- bool first_entry,
- bool *valid_entry)
+static int qf_add_entry_from_dict(qf_list_T *qfl, const dict_T *d, bool first_entry,
+ bool *valid_entry)
FUNC_ATTR_NONNULL_ALL
{
static bool did_bufnr_emsg;
@@ -6364,8 +6293,7 @@ static int qf_add_entry_from_dict(
/// Add list of entries to quickfix/location list. Each list entry is
/// a dictionary with item information.
-static int qf_add_entries(qf_info_T *qi, int qf_idx, list_T *list,
- char_u *title, int action)
+static int qf_add_entries(qf_info_T *qi, int qf_idx, list_T *list, char_u *title, int action)
{
qf_list_T *qfl = qf_get_list(qi, qf_idx);
qfline_T *old_last = NULL;
@@ -6428,11 +6356,7 @@ static int qf_add_entries(qf_info_T *qi, int qf_idx, list_T *list,
}
/// Get the quickfix list index from 'nr' or 'id'
-static int qf_setprop_get_qfidx(
- const qf_info_T *qi,
- const dict_T *what,
- int action,
- bool *newlist)
+static int qf_setprop_get_qfidx(const qf_info_T *qi, const dict_T *what, int action, bool *newlist)
FUNC_ATTR_NONNULL_ALL
{
dictitem_T *di;
@@ -6483,8 +6407,7 @@ static int qf_setprop_get_qfidx(
}
// Set the quickfix list title.
-static int qf_setprop_title(qf_info_T *qi, int qf_idx, const dict_T *what,
- const dictitem_T *di)
+static int qf_setprop_title(qf_info_T *qi, int qf_idx, const dict_T *what, const dictitem_T *di)
FUNC_ATTR_NONNULL_ALL
{
qf_list_T *qfl = qf_get_list(qi, qf_idx);
@@ -6502,8 +6425,7 @@ static int qf_setprop_title(qf_info_T *qi, int qf_idx, const dict_T *what,
}
// Set quickfix list items/entries.
-static int qf_setprop_items(qf_info_T *qi, int qf_idx, dictitem_T *di,
- int action)
+static int qf_setprop_items(qf_info_T *qi, int qf_idx, dictitem_T *di, int action)
FUNC_ATTR_NONNULL_ALL
{
if (di->di_tv.v_type != VAR_LIST) {
@@ -6520,12 +6442,8 @@ static int qf_setprop_items(qf_info_T *qi, int qf_idx, dictitem_T *di,
}
// Set quickfix list items/entries from a list of lines.
-static int qf_setprop_items_from_lines(
- qf_info_T *qi,
- int qf_idx,
- const dict_T *what,
- dictitem_T *di,
- int action)
+static int qf_setprop_items_from_lines(qf_info_T *qi, int qf_idx, const dict_T *what,
+ dictitem_T *di, int action)
FUNC_ATTR_NONNULL_ALL
{
char_u *errorformat = p_efm;
@@ -6570,8 +6488,7 @@ static int qf_setprop_context(qf_list_T *qfl, dictitem_T *di)
}
// Set the current index in the specified quickfix list
-static int qf_setprop_curidx(qf_info_T *qi, qf_list_T *qfl,
- const dictitem_T *di)
+static int qf_setprop_curidx(qf_info_T *qi, qf_list_T *qfl, const dictitem_T *di)
FUNC_ATTR_NONNULL_ALL
{
int newidx;
@@ -6615,8 +6532,7 @@ static int qf_setprop_curidx(qf_info_T *qi, qf_list_T *qfl,
/// Set quickfix/location list properties (title, items, context).
/// Also used to add items from parsing a list of lines.
/// Used by the setqflist() and setloclist() Vim script functions.
-static int qf_set_properties(qf_info_T *qi, const dict_T *what, int action,
- char_u *title)
+static int qf_set_properties(qf_info_T *qi, const dict_T *what, int action, char_u *title)
FUNC_ATTR_NONNULL_ALL
{
qf_list_T *qfl;
@@ -6727,8 +6643,7 @@ static void qf_free_stack(win_T *wp, qf_info_T *qi)
// of dictionaries. "title" will be copied to w:quickfix_title
// "action" is 'a' for add, 'r' for replace. Otherwise create a new list.
// When "what" is not NULL then only set some properties.
-int set_errorlist(win_T *wp, list_T *list, int action, char_u *title,
- dict_T *what)
+int set_errorlist(win_T *wp, list_T *list, int action, char_u *title, dict_T *what)
{
qf_info_T *qi = &ql_info;
int retval = OK;
@@ -6813,32 +6728,37 @@ bool set_ref_in_quickfix(int copyID)
}
/// Return the autocmd name for the :cbuffer Ex commands
-static char_u * cbuffer_get_auname(cmdidx_T cmdidx)
+static char_u *cbuffer_get_auname(cmdidx_T cmdidx)
{
switch (cmdidx) {
- case CMD_cbuffer: return (char_u *)"cbuffer";
- case CMD_cgetbuffer: return (char_u *)"cgetbuffer";
- case CMD_caddbuffer: return (char_u *)"caddbuffer";
- case CMD_lbuffer: return (char_u *)"lbuffer";
- case CMD_lgetbuffer: return (char_u *)"lgetbuffer";
- case CMD_laddbuffer: return (char_u *)"laddbuffer";
- default: return NULL;
+ case CMD_cbuffer:
+ return (char_u *)"cbuffer";
+ case CMD_cgetbuffer:
+ return (char_u *)"cgetbuffer";
+ case CMD_caddbuffer:
+ return (char_u *)"caddbuffer";
+ case CMD_lbuffer:
+ return (char_u *)"lbuffer";
+ case CMD_lgetbuffer:
+ return (char_u *)"lgetbuffer";
+ case CMD_laddbuffer:
+ return (char_u *)"laddbuffer";
+ default:
+ return NULL;
}
}
/// Process and validate the arguments passed to the :cbuffer, :caddbuffer,
/// :cgetbuffer, :lbuffer, :laddbuffer, :lgetbuffer Ex commands.
-static int cbuffer_process_args(exarg_T *eap,
- buf_T **bufp,
- linenr_T *line1,
- linenr_T *line2)
+static int cbuffer_process_args(exarg_T *eap, buf_T **bufp, linenr_T *line1, linenr_T *line2)
{
buf_T *buf = NULL;
- if (*eap->arg == NUL)
+ if (*eap->arg == NUL) {
buf = curbuf;
- else if (*skipwhite(skipdigits(eap->arg)) == NUL)
+ } else if (*skipwhite(skipdigits(eap->arg)) == NUL) {
buf = buflist_findnr(atoi((char *)eap->arg));
+ }
if (buf == NULL) {
EMSG(_(e_invarg));
@@ -6944,16 +6864,23 @@ void ex_cbuffer(exarg_T *eap)
}
/// Return the autocmd name for the :cexpr Ex commands.
-static char_u * cexpr_get_auname(cmdidx_T cmdidx)
+static char_u *cexpr_get_auname(cmdidx_T cmdidx)
{
switch (cmdidx) {
- case CMD_cexpr: return (char_u *)"cexpr";
- case CMD_cgetexpr: return (char_u *)"cgetexpr";
- case CMD_caddexpr: return (char_u *)"caddexpr";
- case CMD_lexpr: return (char_u *)"lexpr";
- case CMD_lgetexpr: return (char_u *)"lgetexpr";
- case CMD_laddexpr: return (char_u *)"laddexpr";
- default: return NULL;
+ case CMD_cexpr:
+ return (char_u *)"cexpr";
+ case CMD_cgetexpr:
+ return (char_u *)"cgetexpr";
+ case CMD_caddexpr:
+ return (char_u *)"caddexpr";
+ case CMD_lexpr:
+ return (char_u *)"lexpr";
+ case CMD_lgetexpr:
+ return (char_u *)"lgetexpr";
+ case CMD_laddexpr:
+ return (char_u *)"laddexpr";
+ default:
+ return NULL;
}
}
@@ -7047,10 +6974,7 @@ static qf_info_T *hgr_get_ll(bool *new_ll)
}
// Search for a pattern in a help file.
-static void hgr_search_file(
- qf_list_T *qfl,
- char_u *fname,
- regmatch_T *p_regmatch)
+static void hgr_search_file(qf_list_T *qfl, char_u *fname, regmatch_T *p_regmatch)
FUNC_ATTR_NONNULL_ARG(1, 3)
{
FILE *const fd = os_fopen((char *)fname, "r");
@@ -7105,11 +7029,8 @@ static void hgr_search_file(
// Search for a pattern in all the help files in the doc directory under
// the given directory.
-static void hgr_search_files_in_dir(
- qf_list_T *qfl,
- char_u *dirname,
- regmatch_T *p_regmatch,
- const char_u *lang)
+static void hgr_search_files_in_dir(qf_list_T *qfl, char_u *dirname, regmatch_T *p_regmatch,
+ const char_u *lang)
FUNC_ATTR_NONNULL_ARG(1, 2, 3)
{
int fcount;
@@ -7141,8 +7062,7 @@ static void hgr_search_files_in_dir(
// and add the matches to a quickfix list.
// 'lang' is the language specifier. If supplied, then only matches in the
// specified language are found.
-static void hgr_search_in_rtp(qf_list_T *qfl, regmatch_T *p_regmatch,
- const char_u *lang)
+static void hgr_search_in_rtp(qf_list_T *qfl, regmatch_T *p_regmatch, const char_u *lang)
FUNC_ATTR_NONNULL_ARG(1, 2)
{
// Go through all directories in 'runtimepath'
@@ -7162,9 +7082,12 @@ void ex_helpgrep(exarg_T *eap)
char_u *au_name = NULL;
switch (eap->cmdidx) {
- case CMD_helpgrep: au_name = (char_u *)"helpgrep"; break;
- case CMD_lhelpgrep: au_name = (char_u *)"lhelpgrep"; break;
- default: break;
+ case CMD_helpgrep:
+ au_name = (char_u *)"helpgrep"; break;
+ case CMD_lhelpgrep:
+ au_name = (char_u *)"lhelpgrep"; break;
+ default:
+ break;
}
if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
curbuf->b_fname, true, curbuf)) {
diff --git a/src/nvim/rbuffer.c b/src/nvim/rbuffer.c
index df9394fbb2..4ac50095b3 100644
--- a/src/nvim/rbuffer.c
+++ b/src/nvim/rbuffer.c
@@ -6,8 +6,8 @@
#include <string.h>
#include "nvim/memory.h"
-#include "nvim/vim.h"
#include "nvim/rbuffer.h"
+#include "nvim/vim.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "rbuffer.c.generated.h"
@@ -144,7 +144,7 @@ void rbuffer_consumed(RBuffer *buf, size_t count)
buf->read_ptr += count;
if (buf->read_ptr >= buf->end_ptr) {
- buf->read_ptr -= rbuffer_capacity(buf);
+ buf->read_ptr -= rbuffer_capacity(buf);
}
bool was_full = buf->size == rbuffer_capacity(buf);
diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c
index d4191cff6b..cbd1e081b3 100644
--- a/src/nvim/runtime.c
+++ b/src/nvim/runtime.c
@@ -5,16 +5,16 @@
///
/// Management of runtime files (including packages)
-#include "nvim/vim.h"
#include "nvim/ascii.h"
#include "nvim/charset.h"
#include "nvim/eval.h"
-#include "nvim/option.h"
#include "nvim/ex_cmds.h"
#include "nvim/ex_cmds2.h"
#include "nvim/misc1.h"
+#include "nvim/option.h"
#include "nvim/os/os.h"
#include "nvim/runtime.h"
+#include "nvim/vim.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "runtime.c.generated.h"
@@ -60,12 +60,11 @@ static void source_callback(char_u *fname, void *cookie)
/// When "flags" has DIP_ERR: give an error message if there is no match.
///
/// return FAIL when no file could be sourced, OK otherwise.
-int do_in_path(char_u *path, char_u *name, int flags,
- DoInRuntimepathCB callback, void *cookie)
+int do_in_path(char_u *path, char_u *name, int flags, DoInRuntimepathCB callback, void *cookie)
{
- char_u *tail;
+ char_u *tail;
int num_files;
- char_u **files;
+ char_u **files;
int i;
bool did_one = false;
@@ -91,7 +90,7 @@ int do_in_path(char_u *path, char_u *name, int flags,
// Skip after or non-after directories.
if (flags & (DIP_NOAFTER | DIP_AFTER)) {
bool is_after = buflen >= 5
- && STRCMP(buf + buflen - 5, "after") == 0;
+ && STRCMP(buf + buflen - 5, "after") == 0;
if ((is_after && (flags & DIP_NOAFTER))
|| (!is_after && (flags & DIP_AFTER))) {
@@ -164,8 +163,8 @@ int do_in_path(char_u *path, char_u *name, int flags,
/// If "name" is NULL calls callback for each entry in "path". Cookie is
/// passed by reference in this case, setting it to NULL indicates that callback
/// has done its job.
-int do_in_path_and_pp(char_u *path, char_u *name, int flags,
- DoInRuntimepathCB callback, void *cookie)
+int do_in_path_and_pp(char_u *path, char_u *name, int flags, DoInRuntimepathCB callback,
+ void *cookie)
{
int done = FAIL;
if (!(flags & (DIP_NOAFTER | DIP_AFTER))) {
@@ -564,8 +563,7 @@ static char *strcpy_comma_escaped(char *dest, const char *src, const size_t len)
/// (common_suf is present after each new item, single_suf is present
/// after half of the new items) and with commas after each item, commas
/// inside the values are escaped.
-static inline size_t compute_double_env_sep_len(const char *const val,
- const size_t common_suf_len,
+static inline size_t compute_double_env_sep_len(const char *const val, const size_t common_suf_len,
const size_t single_suf_len)
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_PURE
{
@@ -608,9 +606,8 @@ static inline size_t compute_double_env_sep_len(const char *const val,
/// Otherwise in reverse.
///
/// @return (dest + appended_characters_length)
-static inline char *add_env_sep_dirs(char *dest, const char *const val,
- const char *const suf1, const size_t len1,
- const char *const suf2, const size_t len2,
+static inline char *add_env_sep_dirs(char *dest, const char *const val, const char *const suf1,
+ const size_t len1, const char *const suf2, const size_t len2,
const bool forward)
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_ARG(1)
{
@@ -669,9 +666,8 @@ static inline char *add_env_sep_dirs(char *dest, const char *const val,
/// Otherwise in reverse.
///
/// @return (dest + appended_characters_length)
-static inline char *add_dir(char *dest, const char *const dir,
- const size_t dir_len, const XDGVarType type,
- const char *const suf1, const size_t len1,
+static inline char *add_dir(char *dest, const char *const dir, const size_t dir_len,
+ const XDGVarType type, const char *const suf1, const size_t len1,
const char *const suf2, const size_t len2)
FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_ARG(1) FUNC_ATTR_WARN_UNUSED_RESULT
{
diff --git a/src/uncrustify.cfg b/src/uncrustify.cfg
index 1bc6bb02c5..08296a644a 100644
--- a/src/uncrustify.cfg
+++ b/src/uncrustify.cfg
@@ -1,4 +1,4 @@
-# Uncrustify-0.73.0-164-c9a58467
+# Uncrustify-0.73.0-168-f20a083e
#
# General options