patch 8.1.1241: Ex command info contains confusing information
Problem: Ex command info contains confusing information.
Solution: When using the NOTADR flag use ADDR_OTHER for the address type.
Cleanup code using NOTADR. Check for errors in
create_cmdidxs.vim. Adjust Makefile to see the errors.
diff --git a/src/usercmd.c b/src/usercmd.c
index db1a77b..37c519d 100644
--- a/src/usercmd.c
+++ b/src/usercmd.c
@@ -20,7 +20,7 @@
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
# ifdef FEAT_EVAL
sctx_T uc_script_ctx; // SCTX where the command was defined
# ifdef FEAT_CMDL_COMPL
@@ -101,9 +101,9 @@
*/
static struct
{
- int expand;
- char *name;
- char *shortname;
+ cmd_addr_T expand;
+ char *name;
+ char *shortname;
} addr_type_complete[] =
{
{ADDR_ARGUMENTS, "arguments", "arg"},
@@ -114,7 +114,7 @@
{ADDR_WINDOWS, "windows", "win"},
{ADDR_QUICKFIX, "quickfix", "qf"},
{ADDR_OTHER, "other", "?"},
- {-1, NULL, NULL}
+ {ADDR_NONE, NULL, NULL}
};
#define UC_BUFFER 1 // -buffer: local to current buffer
@@ -495,7 +495,7 @@
} 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)
{
@@ -566,12 +566,11 @@
parse_addr_type_arg(
char_u *value,
int vallen,
- long *argt,
- int *addr_type_arg)
+ cmd_addr_T *addr_type_arg)
{
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;
@@ -582,7 +581,7 @@
}
}
- if (addr_type_complete[i].expand == -1)
+ if (addr_type_complete[i].expand == ADDR_NONE)
{
char_u *err = value;
@@ -593,9 +592,6 @@
return FAIL;
}
- if (*addr_type_arg != ADDR_LINES)
- *argt |= NOTADR;
-
return OK;
}
@@ -694,7 +690,7 @@
int *flags,
int *complp,
char_u **compl_arg,
- int *addr_type_arg)
+ cmd_addr_T *addr_type_arg)
{
char_u *p;
@@ -773,7 +769,7 @@
}
*def = getdigits(&p);
- *argt |= (ZEROR | NOTADR);
+ *argt |= ZEROR;
if (p != val + vallen || vallen == 0)
{
@@ -782,10 +778,16 @@
return FAIL;
}
}
+ // default for -range is using buffer lines
+ if (*addr_type_arg == ADDR_NONE)
+ *addr_type_arg = ADDR_LINES;
}
else if (STRNICMP(attr, "count", attrlen) == 0)
{
- *argt |= (COUNT | ZEROR | RANGE | NOTADR);
+ *argt |= (COUNT | ZEROR | RANGE);
+ // default for -count is using any number
+ if (*addr_type_arg == ADDR_NONE)
+ *addr_type_arg = ADDR_OTHER;
if (val != NULL)
{
@@ -822,11 +824,10 @@
emsg(_("E179: argument required for -addr"));
return FAIL;
}
- if (parse_addr_type_arg(val, (int)vallen, argt, addr_type_arg)
- == FAIL)
+ if (parse_addr_type_arg(val, (int)vallen, addr_type_arg) == FAIL)
return FAIL;
if (addr_type_arg != ADDR_LINES)
- *argt |= (ZEROR | NOTADR) ;
+ *argt |= (ZEROR) ;
}
else
{
@@ -854,7 +855,7 @@
int flags,
int compl,
char_u *compl_arg UNUSED,
- int addr_type,
+ cmd_addr_T addr_type,
int force)
{
ucmd_T *cmd = NULL;
@@ -974,17 +975,17 @@
void
ex_command(exarg_T *eap)
{
- char_u *name;
- char_u *end;
- char_u *p;
- long argt = 0;
- long def = -1;
- int flags = 0;
- int compl = EXPAND_NOTHING;
- char_u *compl_arg = NULL;
- int addr_type_arg = ADDR_LINES;
- int has_attr = (eap->arg[0] == '-');
- int name_len;
+ char_u *name;
+ char_u *end;
+ char_u *p;
+ long argt = 0;
+ long def = -1;
+ int flags = 0;
+ int compl = EXPAND_NOTHING;
+ char_u *compl_arg = NULL;
+ cmd_addr_T addr_type_arg = ADDR_NONE;
+ int has_attr = (eap->arg[0] == '-');
+ int name_len;
p = eap->arg;