]> diplodocus.org Git - nmh/commitdiff
sbr/vector.c: Replace Nbby with <limits.h>'s CHAR_BIT.
authorRalph Corderoy <ralph@inputplus.co.uk>
Mon, 24 Apr 2017 21:08:09 +0000 (22:08 +0100)
committerRalph Corderoy <ralph@inputplus.co.uk>
Wed, 26 Apr 2017 06:43:40 +0000 (07:43 +0100)
POSIX mandates CHAR_BIT is 8;  see stdint.h(0p).

h/mh.h
sbr/vector.c

diff --git a/h/mh.h b/h/mh.h
index 79a230b..b15bd32 100644 (file)
--- a/h/mh.h
+++ b/h/mh.h
@@ -10,7 +10,6 @@
 #define        OK             0        /*  ditto on success               */
 #define        DONE           1        /* trinary logic                   */
 #define ALL           ""
-#define        Nbby           8        /* number of bits/byte */
 
 #define MAXARGS            1000        /* max arguments to exec                */
 #define NFOLDERS    1000       /* max folder arguments on command line */
index fc5cc00..f0c8bb4 100644 (file)
  * constants in the code below must also be changed to a 1 that's at
  * least as wide as the new type.
  */
-#ifndef Nbby
-# define Nbby 8
-#endif
-#define BVEC_WORD(vec, max) ((max) / (sizeof *vec->bits * Nbby))
-#define BVEC_OFFSET(vec, max) ((max) % (sizeof *vec->bits * Nbby))
+#define BVEC_WORD(vec, max) ((max) / (sizeof *vec->bits * CHAR_BIT))
+#define BVEC_OFFSET(vec, max) ((max) % (sizeof *vec->bits * CHAR_BIT))
 #define BVEC_BYTES(vec, n) \
     ((BVEC_WORD (vec, n) + (BVEC_OFFSET (vec, n) == 0 ? 0 : 1))  * \
     sizeof *vec->bits)
@@ -52,7 +49,7 @@ bvector_create (size_t init_size) {
     bytes = BVEC_BYTES (vec, init_size  ?  init_size  :  VEC_INIT_SIZE);
 
     vec->bits = mh_xcalloc (1, bytes);
-    vec->maxsize = bytes * Nbby;
+    vec->maxsize = bytes * CHAR_BIT;
 
     return vec;
 }