*  src/roff/troff/env.cpp (lengthof): Add macro to calculate the number
   of elements in an array.  It's named after the proposal to ISO C,
   _Lengthof(), which wasn't accepted for C23, but hopefully will be
   added in a future revision.

Signed-off-by: Alejandro Colomar <a...@kernel.org>
---

Hi Branden,

I added it there because I didn't find a "common utilities" header file.
Please suggest a better place.

Cheers,
Alex

 src/roff/troff/env.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index e0b1b2892..106ab6889 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -33,6 +33,8 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
 #include "input.h"
 #include <math.h>
 
+#define lengthof(arr)  (sizeof(arr) / sizeof((arr)[0]))
+
 symbol default_family("T");
 
 enum { ADJUST_LEFT = 0,
-- 
2.40.1


Reply via email to