aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_docmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/ex_docmd.c')
-rw-r--r--src/nvim/ex_docmd.c46
1 files changed, 34 insertions, 12 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 0ffe67a4db..a5eccc12b9 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -85,7 +85,7 @@ typedef struct ucmd {
char_u *uc_rep; // The command's replacement string
long uc_def; // The default value for a range/count
int uc_compl; // completion type
- int uc_addr_type; // The command's address type
+ cmd_addr_T uc_addr_type; // The command's address type
sctx_T uc_script_ctx; // SCTX where the command was defined
char_u *uc_compl_arg; // completion argument if any
} ucmd_T;
@@ -1734,6 +1734,9 @@ static char_u * do_one_cmd(char_u **cmdlinep,
ea.line2 = 1;
}
break;
+ case ADDR_NONE:
+ IEMSG(_("INTERNAL: Cannot use DFLALL with ADDR_NONE"));
+ break;
}
}
@@ -2347,6 +2350,9 @@ int parse_cmd_address(exarg_T *eap, char_u **errormsg, bool silent)
case ADDR_QUICKFIX:
eap->line2 = qf_get_cur_valid_idx(eap);
break;
+ case ADDR_NONE:
+ // Will give an error later if a range is found.
+ break;
}
eap->cmd = skipwhite(eap->cmd);
lnum = get_address(eap, &eap->cmd, eap->addr_type, eap->skip, silent,
@@ -2412,6 +2418,9 @@ int parse_cmd_address(exarg_T *eap, char_u **errormsg, bool silent)
eap->line2 = 1;
}
break;
+ case ADDR_NONE:
+ // Will give an error later if a range is found.
+ break;
}
eap->addr_count++;
} else if (*eap->cmd == '*') {
@@ -3698,12 +3707,14 @@ char_u *skip_range(
// Return MAXLNUM when no Ex address was found.
static linenr_T get_address(exarg_T *eap,
char_u **ptr,
- int addr_type, // flag: one of ADDR_LINES, ...
+ cmd_addr_T addr_type_arg,
int skip, // only skip the address, don't use it
bool silent, // no errors or side effects
int to_other_file, // flag: may jump to other file
int address_count) // 1 for first, >1 after comma
+ FUNC_ATTR_NONNULL_ALL
{
+ const int addr_type = addr_type_arg;
int c;
int i;
long n;
@@ -3737,6 +3748,7 @@ static linenr_T get_address(exarg_T *eap,
lnum = CURRENT_TAB_NR;
break;
case ADDR_TABS_RELATIVE:
+ case ADDR_NONE:
EMSG(_(e_invrange));
cmd = NULL;
goto error;
@@ -3776,6 +3788,7 @@ static linenr_T get_address(exarg_T *eap,
lnum = LAST_TAB_NR;
break;
case ADDR_TABS_RELATIVE:
+ case ADDR_NONE:
EMSG(_(e_invrange));
cmd = NULL;
goto error;
@@ -3938,6 +3951,8 @@ static linenr_T get_address(exarg_T *eap,
case ADDR_QUICKFIX:
lnum = qf_get_cur_valid_idx(eap);
break;
+ case ADDR_NONE:
+ break;
}
}
@@ -4089,6 +4104,9 @@ static char_u *invalid_range(exarg_T *eap)
return (char_u *)_(e_invrange);
}
break;
+ case ADDR_NONE:
+ // Will give an error elsewhere.
+ break;
}
}
return NULL;
@@ -4957,7 +4975,8 @@ char_u *get_command_name(expand_T *xp, int idx)
static int uc_add_command(char_u *name, size_t name_len, char_u *rep,
uint32_t argt, long def, int flags, int compl,
- char_u *compl_arg, int addr_type, int force)
+ char_u *compl_arg, cmd_addr_T addr_type, bool force)
+ FUNC_ATTR_NONNULL_ARG(1, 3)
{
ucmd_T *cmd = NULL;
char_u *p;
@@ -5049,7 +5068,7 @@ fail:
static struct {
- int expand;
+ cmd_addr_T expand;
char *name;
char *shortname;
} addr_type_complete[] =
@@ -5062,7 +5081,7 @@ static struct {
{ ADDR_WINDOWS, "windows", "win" },
{ ADDR_QUICKFIX, "quickfix", "qf" },
{ ADDR_OTHER, "other", "?" },
- { -1, NULL, NULL }
+ { ADDR_NONE, NULL, NULL }
};
/*
@@ -5236,7 +5255,7 @@ static void uc_list(char_u *name, size_t name_len)
} while (len < 8 - over);
// Address Type
- for (j = 0; addr_type_complete[j].expand != -1; j++) {
+ for (j = 0; addr_type_complete[j].expand != ADDR_NONE; j++) {
if (addr_type_complete[j].expand != ADDR_LINES
&& addr_type_complete[j].expand == cmd->uc_addr_type) {
STRCPY(IObuff + len, addr_type_complete[j].shortname);
@@ -5284,7 +5303,8 @@ static void uc_list(char_u *name, size_t name_len)
static int uc_scan_attr(char_u *attr, size_t len, uint32_t *argt, long *def,
int *flags, int *complp, char_u **compl_arg,
- int *addr_type_arg)
+ cmd_addr_T *addr_type_arg)
+ FUNC_ATTR_NONNULL_ALL
{
char_u *p;
@@ -5421,7 +5441,7 @@ static void ex_command(exarg_T *eap)
int flags = 0;
int compl = EXPAND_NOTHING;
char_u *compl_arg = NULL;
- int addr_type_arg = ADDR_LINES;
+ cmd_addr_T addr_type_arg = ADDR_LINES;
int has_attr = (eap->arg[0] == '-');
int name_len;
@@ -6080,11 +6100,12 @@ char_u *get_user_cmd_complete(expand_T *xp, int idx)
* Parse address type argument
*/
int parse_addr_type_arg(char_u *value, int vallen, uint32_t *argt,
- int *addr_type_arg)
+ cmd_addr_T *addr_type_arg)
+ FUNC_ATTR_NONNULL_ALL
{
int i, a, b;
- for (i = 0; addr_type_complete[i].expand != -1; i++) {
+ for (i = 0; addr_type_complete[i].expand != ADDR_NONE; i++) {
a = (int)STRLEN(addr_type_complete[i].name) == vallen;
b = STRNCMP(value, addr_type_complete[i].name, vallen) == 0;
if (a && b) {
@@ -6093,7 +6114,7 @@ int parse_addr_type_arg(char_u *value, int vallen, uint32_t *argt,
}
}
- if (addr_type_complete[i].expand == -1) {
+ if (addr_type_complete[i].expand == ADDR_NONE) {
char_u *err = value;
for (i = 0; err[i] != NUL && !ascii_iswhite(err[i]); i++) {}
@@ -6117,6 +6138,7 @@ int parse_addr_type_arg(char_u *value, int vallen, uint32_t *argt,
*/
int parse_compl_arg(const char_u *value, int vallen, int *complp,
uint32_t *argt, char_u **compl_arg)
+ FUNC_ATTR_NONNULL_ALL
{
const char_u *arg = NULL;
size_t arglen = 0;
@@ -9489,7 +9511,7 @@ Dictionary commands_array(buf_T *buf)
PUT(d, "range", obj);
obj = NIL;
- for (int j = 0; addr_type_complete[j].expand != -1; j++) {
+ for (int j = 0; addr_type_complete[j].expand != ADDR_NONE; j++) {
if (addr_type_complete[j].expand != ADDR_LINES
&& addr_type_complete[j].expand == cmd->uc_addr_type) {
obj = STRING_OBJ(cstr_to_string(addr_type_complete[j].name));