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/highlight.c b/src/highlight.c
index 56b1988..defbe55 100644
--- a/src/highlight.c
+++ b/src/highlight.c
@@ -998,7 +998,7 @@
off = 0;
while (arg[off] != NUL)
{
- for (i = sizeof(hl_attr_table) / sizeof(int); --i >= 0; )
+ for (i = ARRAY_LENGTH(hl_attr_table); --i >= 0; )
{
len = (int)STRLEN(hl_name_table[i]);
if (STRNICMP(arg + off, hl_name_table[i], len) == 0)
@@ -1168,7 +1168,7 @@
// reduce calls to STRICMP a bit, it can be slow
off = TOUPPER_ASC(*arg);
- for (i = (sizeof(color_names) / sizeof(char *)); --i >= 0; )
+ for (i = ARRAY_LENGTH(color_names); --i >= 0; )
if (off == color_names[i][0]
&& STRICMP(arg + 1, color_names[i] + 1) == 0)
break;