nitems() from <sys/param.h> works just fine.
See diff below; no binary change.
cheers,
natano
Index: common/msg.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/msg.c,v
retrieving revision 1.21
diff -u -r1.21 msg.c
--- common/msg.c 12 Nov 2014 16:29:04 -0000 1.21
+++ common/msg.c 14 Nov 2014 13:45:35 -0000
@@ -276,15 +276,14 @@
* I got complaints, so nvi conforms to System III/V historic practice
* except that we report a yank of 1 line if report is set to 1.
*/
-#define ARSIZE(a) sizeof(a) / sizeof (*a)
#define MAXNUM 25
rptval = O_VAL(sp, O_REPORT);
- for (cnt = 0, total = 0; cnt < ARSIZE(action); ++cnt)
+ for (cnt = 0, total = 0; cnt < nitems(action); ++cnt)
total += sp->rptlines[cnt];
if (total == 0)
return;
if (total <= rptval && sp->rptlines[L_YANKED] < rptval) {
- for (cnt = 0; cnt < ARSIZE(action); ++cnt)
+ for (cnt = 0; cnt < nitems(action); ++cnt)
sp->rptlines[cnt] = 0;
return;
}
@@ -292,7 +291,7 @@
/* Build and display the message. */
GET_SPACE_GOTO(sp, bp, blen, sizeof(action) * MAXNUM + 1);
for (p = bp, first = 1, tlen = 0,
- ap = action, cnt = 0; cnt < ARSIZE(action); ++ap, ++cnt)
+ ap = action, cnt = 0; cnt < nitems(action); ++ap, ++cnt)
if (sp->rptlines[cnt] != 0) {
if (first)
first = 0;
@@ -329,7 +328,6 @@
alloc_err:
return;
-#undef ARSIZE
#undef MAXNUM
}