mirror of
https://github.com/neovim/neovim.git
synced 2025-10-17 15:21:47 +00:00
Merge pull request #1663 from philix/array_size
Define and use the ARRAY_SIZE macro
This commit is contained in:
@@ -2280,7 +2280,7 @@ int modifier_len(char_u *cmd)
|
||||
|
||||
if (VIM_ISDIGIT(*cmd))
|
||||
p = skipwhite(skipdigits(cmd));
|
||||
for (i = 0; i < (int)(sizeof(cmdmods) / sizeof(struct cmdmod)); ++i) {
|
||||
for (i = 0; i < (int)ARRAY_SIZE(cmdmods); ++i) {
|
||||
for (j = 0; p[j] != NUL; ++j)
|
||||
if (p[j] != cmdmods[i].name[j])
|
||||
break;
|
||||
@@ -2305,7 +2305,7 @@ int cmd_exists(char_u *name)
|
||||
char_u *p;
|
||||
|
||||
/* Check command modifiers. */
|
||||
for (i = 0; i < (int)(sizeof(cmdmods) / sizeof(struct cmdmod)); ++i) {
|
||||
for (i = 0; i < (int)ARRAY_SIZE(cmdmods); ++i) {
|
||||
for (j = 0; name[j] != NUL; ++j)
|
||||
if (name[j] != cmdmods[i].name[j])
|
||||
break;
|
||||
@@ -4973,7 +4973,7 @@ char_u *get_user_cmd_flags(expand_T *xp, int idx)
|
||||
{"bang", "bar", "buffer", "complete", "count",
|
||||
"nargs", "range", "register"};
|
||||
|
||||
if (idx >= (int)(sizeof(user_cmd_flags) / sizeof(user_cmd_flags[0])))
|
||||
if (idx >= (int)ARRAY_SIZE(user_cmd_flags))
|
||||
return NULL;
|
||||
return (char_u *)user_cmd_flags[idx];
|
||||
}
|
||||
@@ -4985,7 +4985,7 @@ char_u *get_user_cmd_nargs(expand_T *xp, int idx)
|
||||
{
|
||||
static char *user_cmd_nargs[] = {"0", "1", "*", "?", "+"};
|
||||
|
||||
if (idx >= (int)(sizeof(user_cmd_nargs) / sizeof(user_cmd_nargs[0])))
|
||||
if (idx >= (int)ARRAY_SIZE(user_cmd_nargs))
|
||||
return NULL;
|
||||
return (char_u *)user_cmd_nargs[idx];
|
||||
}
|
||||
@@ -7481,7 +7481,7 @@ int find_cmdline_var(const char_u *src, int *usedlen) FUNC_ATTR_NONNULL_ALL
|
||||
# define SPEC_AMATCH 9
|
||||
};
|
||||
|
||||
for (i = 0; i < (int)(sizeof(spec_str) / sizeof(char *)); ++i) {
|
||||
for (i = 0; i < (int)ARRAY_SIZE(spec_str); ++i) {
|
||||
len = (int)STRLEN(spec_str[i]);
|
||||
if (STRNCMP(src, spec_str[i], len) == 0) {
|
||||
*usedlen = len;
|
||||
|
Reference in New Issue
Block a user