patch 8.2.2922: computing array length is done in various ways
Problem: Computing array length is done in various ways.
Solution: Use ARRAY_LENGTH everywhere. (Ken Takata, closes #8305)
diff --git a/src/usercmd.c b/src/usercmd.c
index 03e7b24..a4bbfd7 100644
--- a/src/usercmd.c
+++ b/src/usercmd.c
@@ -339,7 +339,7 @@
"count", "nargs", "range", "register"
};
- if (idx >= (int)(sizeof(user_cmd_flags) / sizeof(user_cmd_flags[0])))
+ if (idx >= (int)ARRAY_LENGTH(user_cmd_flags))
return NULL;
return (char_u *)user_cmd_flags[idx];
}
@@ -352,7 +352,7 @@
{
static char *user_cmd_nargs[] = {"0", "1", "*", "?", "+"};
- if (idx >= (int)(sizeof(user_cmd_nargs) / sizeof(user_cmd_nargs[0])))
+ if (idx >= (int)ARRAY_LENGTH(user_cmd_nargs))
return NULL;
return (char_u *)user_cmd_nargs[idx];
}