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/version.c b/src/version.c
index 321047f..8127314 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2922,
+/**/
2921,
/**/
2920,
@@ -6627,7 +6629,7 @@
// Perform a binary search.
l = 0;
- h = (int)(sizeof(included_patches) / sizeof(included_patches[0])) - 1;
+ h = (int)ARRAY_LENGTH(included_patches) - 1;
while (l < h)
{
m = (l + h) / 2;
@@ -6854,7 +6856,7 @@
{
msg_puts(_("\nIncluded patches: "));
first = -1;
- i = (int)(sizeof(included_patches) / sizeof(included_patches[0])) - 1;
+ i = (int)ARRAY_LENGTH(included_patches) - 1;
while (--i >= 0)
{
if (first < 0)
@@ -7145,7 +7147,7 @@
#endif
// blanklines = screen height - # message lines
- blanklines = (int)Rows - ((sizeof(lines) / sizeof(char *)) - 1);
+ blanklines = (int)Rows - (ARRAY_LENGTH(lines) - 1);
if (!p_cp)
blanklines += 4; // add 4 for not showing "Vi compatible" message
@@ -7164,7 +7166,7 @@
row = blanklines / 2;
if ((row >= 2 && Columns >= 50) || colon)
{
- for (i = 0; i < (int)(sizeof(lines) / sizeof(char *)); ++i)
+ for (i = 0; i < (int)ARRAY_LENGTH(lines); ++i)
{
p = lines[i];
#ifdef FEAT_GUI