rewrite int foo[2*X-1] to verify(X) or to int foo[X?1:-1]
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 11 Oct 2010 03:16:39 +0000 (20:16 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 11 Oct 2010 03:17:17 +0000 (20:17 -0700)
* lib/float+.h (verify_sizeof_flt, verify_sizeof_dbl):
(verify_sizeof_ldbl): Rewrite 2*X-1 to X?1:-1.
* lib/malloca.c: Include "verify.h".
(verify1): Remove, replacing with a verify call.
* lib/relocwrapper.c (verify1): Likewise.
* lib/vasnprintf.c (mp_limb_verify, mp_twolimb_verify, TCHAR_T_verify):
Likewise.
* modules/malloca (Depends-on): Add 'verify'.
* modules/relocatable-prog-wrapper (Depends-on): Add 'verify'.
* modules/vasnprintf (Depends-on): Add 'verify'.
* modules/unistdio/u8-vasnprintf (Depends-on): Likewise.
* modules/unistdio/u8-u8-vasnprintf (Depends-on): Likewise.
* modules/unistdio/u16-vasnprintf (Depends-on): Likewise.
* modules/unistdio/u16-u16-vasnprintf (Depends-on): Likewise.
* modules/unistdio/u32-vasnprintf (Depends-on): Likewise.
* modules/unistdio/u32-u32-vasnprintf (Depends-on): Likewise.
* modules/unistdio/ulc-vasnprintf (Depends-on): Likewise.

15 files changed:
ChangeLog
lib/float+.h
lib/malloca.c
lib/relocwrapper.c
lib/vasnprintf.c
modules/malloca
modules/relocatable-prog-wrapper
modules/unistdio/u16-u16-vasnprintf
modules/unistdio/u16-vasnprintf
modules/unistdio/u32-u32-vasnprintf
modules/unistdio/u32-vasnprintf
modules/unistdio/u8-u8-vasnprintf
modules/unistdio/u8-vasnprintf
modules/unistdio/ulc-vasnprintf
modules/vasnprintf

index 6a56a313c99d893944a3411b46fb8101a9164f64..e1fbbd44dbadfcb3a401a91c1bfbfda2d5693623 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,25 @@
 2010-10-10  Paul Eggert  <eggert@cs.ucla.edu>
 
+       rewrite int foo[2*X-1] to verify(X) or to int foo[X?1:-1]
+
+       * lib/float+.h (verify_sizeof_flt, verify_sizeof_dbl):
+       (verify_sizeof_ldbl): Rewrite 2*X-1 to X?1:-1.
+       * lib/malloca.c: Include "verify.h".
+       (verify1): Remove, replacing with a verify call.
+       * lib/relocwrapper.c (verify1): Likewise.
+       * lib/vasnprintf.c (mp_limb_verify, mp_twolimb_verify, TCHAR_T_verify):
+       Likewise.
+       * modules/malloca (Depends-on): Add 'verify'.
+       * modules/relocatable-prog-wrapper (Depends-on): Add 'verify'.
+       * modules/vasnprintf (Depends-on): Add 'verify'.
+       * modules/unistdio/u8-vasnprintf (Depends-on): Likewise.
+       * modules/unistdio/u8-u8-vasnprintf (Depends-on): Likewise.
+       * modules/unistdio/u16-vasnprintf (Depends-on): Likewise.
+       * modules/unistdio/u16-u16-vasnprintf (Depends-on): Likewise.
+       * modules/unistdio/u32-vasnprintf (Depends-on): Likewise.
+       * modules/unistdio/u32-u32-vasnprintf (Depends-on): Likewise.
+       * modules/unistdio/ulc-vasnprintf (Depends-on): Likewise.
+
        prefer (X ? 1 : -1) when converting from boolean (1,0) to int (1,-1)
 
        Formerly the style was sometimes 2*X - 1, because the C standard
index d25492192990adcda9e12e85d0a9fa61f964b6f1..2bbba5102bea41bb46cf3beba24f707570a80022 100644 (file)
 #define SIZEOF_LDBL ((LDBL_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT)
 
 /* Verify that SIZEOF_FLT <= sizeof (float) etc.  */
-typedef int verify_sizeof_flt[2 * (SIZEOF_FLT <= sizeof (float)) - 1];
-typedef int verify_sizeof_dbl[2 * (SIZEOF_DBL <= sizeof (double)) - 1];
-typedef int verify_sizeof_ldbl[2 * (SIZEOF_LDBL <= sizeof (long double)) - 1];
+typedef int verify_sizeof_flt[SIZEOF_FLT <= sizeof (float) ? 1 : -1];
+typedef int verify_sizeof_dbl[SIZEOF_DBL <= sizeof (double) ? 1 : - 1];
+typedef int verify_sizeof_ldbl[SIZEOF_LDBL <= sizeof (long double) ? 1 : - 1];
 
 #endif /* _FLOATPLUS_H */
index 226887849f43799f090f8d1068b18a95694c3f86..3e4fd0bb968c1de85161781ae5b685712b10d1c0 100644 (file)
@@ -21,6 +21,8 @@
 /* Specification.  */
 #include "malloca.h"
 
+#include "verify.h"
+
 /* Use the system functions, not the gnulib overrides in this file.  */
 #undef malloc
 
@@ -53,8 +55,7 @@ struct preliminary_header { void *next; char room[MAGIC_SIZE]; };
 #define HEADER_SIZE \
   (((sizeof (struct preliminary_header) + sa_alignment_max - 1) / sa_alignment_max) * sa_alignment_max)
 struct header { void *next; char room[HEADER_SIZE - sizeof (struct preliminary_header) + MAGIC_SIZE]; };
-/* Verify that HEADER_SIZE == sizeof (struct header).  */
-typedef int verify1[2 * (HEADER_SIZE == sizeof (struct header)) - 1];
+verify (HEADER_SIZE == sizeof (struct header));
 /* We make the hash table quite big, so that during lookups the probability
    of empty hash buckets is quite high.  There is no need to make the hash
    table resizable, because when the hash table gets filled so much that the
index 04f2258c97bb14e6eba0919644638b3c82d384e1..d3980dd07d2ea590610ed85ae283b816b2982e3e 100644 (file)
@@ -54,6 +54,7 @@
 #include "progname.h"
 #include "relocatable.h"
 #include "c-ctype.h"
+#include "verify.h"
 
 /* Use the system functions, not the gnulib overrides in this file.  */
 #undef fprintf
@@ -114,7 +115,7 @@ add_dotbin (const char *filename)
 /* List of directories that contain the libraries.  */
 static const char *libdirs[] = { LIBDIRS NULL };
 /* Verify that at least one directory is given.  */
-typedef int verify1[2 * (sizeof (libdirs) / sizeof (libdirs[0]) > 1) - 1];
+verify (sizeof (libdirs) / sizeof (libdirs[0]) > 1);
 
 /* Relocate the list of directories that contain the libraries.  */
 static void
index 41c62712fbfccf3c5a5aae5fc6941056cc8a5129..388ab0dbe31eb9f1941e713a02f3e085d99ebc3d 100644 (file)
@@ -88,6 +88,8 @@
 /* Checked size_t computations.  */
 #include "xsize.h"
 
+#include "verify.h"
+
 #if (NEED_PRINTF_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL
 # include <math.h>
 # include "float+.h"
@@ -322,11 +324,11 @@ is_infinite_or_zerol (long double x)
 
 typedef unsigned int mp_limb_t;
 # define GMP_LIMB_BITS 32
-typedef int mp_limb_verify[2 * (sizeof (mp_limb_t) * CHAR_BIT == GMP_LIMB_BITS) - 1];
+verify (sizeof (mp_limb_t) * CHAR_BIT == GMP_LIMB_BITS);
 
 typedef unsigned long long mp_twolimb_t;
 # define GMP_TWOLIMB_BITS 64
-typedef int mp_twolimb_verify[2 * (sizeof (mp_twolimb_t) * CHAR_BIT == GMP_TWOLIMB_BITS) - 1];
+verify (sizeof (mp_twolimb_t) * CHAR_BIT == GMP_TWOLIMB_BITS);
 
 /* Representation of a bignum >= 0.  */
 typedef struct
@@ -2621,7 +2623,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                   size_t characters;
 #  if !DCHAR_IS_TCHAR
                   /* This code assumes that TCHAR_T is 'char'.  */
-                  typedef int TCHAR_T_verify[2 * (sizeof (TCHAR_T) == 1) - 1];
+                  verify (sizeof (TCHAR_T) == 1);
                   TCHAR_T *tmpsrc;
                   DCHAR_T *tmpdst;
                   size_t tmpdst_len;
@@ -5284,8 +5286,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                         DCHAR_T *tmpdst;
                         size_t tmpdst_len;
                         /* This code assumes that TCHAR_T is 'char'.  */
-                        typedef int TCHAR_T_verify
-                                    [2 * (sizeof (TCHAR_T) == 1) - 1];
+                        verify (sizeof (TCHAR_T) == 1);
 # if USE_SNPRINTF
                         tmpsrc = (TCHAR_T *) (result + length);
 # else
index d54bf3061f73354261d61f5a244b9210a0c44d6e..57cbe32784706412cfff2d7bbabdf1cfb16c1fe9 100644 (file)
@@ -11,6 +11,7 @@ m4/longlong.m4
 
 Depends-on:
 alloca-opt
+verify
 
 configure.ac:
 gl_MALLOCA
index de77830ad9d5ca5864f8a32b2b3659bd84ad8df1..b96892952e0b5e0057d93cd4e37deed30bf44fd7 100644 (file)
@@ -42,6 +42,7 @@ unistd
 environ
 intprops
 string
+verify
 
 configure.ac:
 gl_FUNC_READLINK_SEPARATE
index eabd37d09a12fd2b3725e1a48cd76d11bc0ca26f..c32166961d9fed770a242616ad3fd84ecb739f22 100644 (file)
@@ -44,6 +44,7 @@ xsize
 errno
 memchr
 multiarch
+verify
 
 configure.ac:
 gl_PREREQ_VASNPRINTF_WITH_EXTRAS
index f71a120b660f25cda2de98fb126e09ea85c6dc2a..a382ce47b5a0e0e789b0bdc5757d124e1696ec00 100644 (file)
@@ -44,6 +44,7 @@ xsize
 errno
 memchr
 multiarch
+verify
 
 configure.ac:
 gl_PREREQ_VASNPRINTF_WITH_EXTRAS
index 0b83fa81b3ec3c28248d9d91f0aa74c0f1372c06..800c61e6f22d012d4ffdb7d5d1ce2b284b67e60d 100644 (file)
@@ -44,6 +44,7 @@ xsize
 errno
 memchr
 multiarch
+verify
 
 configure.ac:
 gl_PREREQ_VASNPRINTF_WITH_EXTRAS
index 1a8159749385ce92933e5960828229fd30ae5ddf..fe71cb2b723500fdd7fc1bc59a93ea97195d0c2e 100644 (file)
@@ -44,6 +44,7 @@ xsize
 errno
 memchr
 multiarch
+verify
 
 configure.ac:
 gl_PREREQ_VASNPRINTF_WITH_EXTRAS
index 612901ed62ac37eac8f7a086b3446733044f141c..5e9552169d22b975829066e1363220e6576cd37a 100644 (file)
@@ -44,6 +44,7 @@ xsize
 errno
 memchr
 multiarch
+verify
 
 configure.ac:
 gl_PREREQ_VASNPRINTF_WITH_EXTRAS
index 6e651bb5d79065b5516eceb62d7b10517043aed6..3aaf935c8acedd6e58e2d5c867530bdf4219f134 100644 (file)
@@ -44,6 +44,7 @@ xsize
 errno
 memchr
 multiarch
+verify
 
 configure.ac:
 gl_PREREQ_VASNPRINTF_WITH_EXTRAS
index 8a6f2fc68f9515f300b66168fe917c53b263ccd7..8228a0678e4be7d2c3c03448d3b51dea10bb52ef 100644 (file)
@@ -42,6 +42,7 @@ xsize
 errno
 memchr
 multiarch
+verify
 
 configure.ac:
 gl_PREREQ_VASNPRINTF_WITH_EXTRAS
index 480998d3c18d29fbde713c04f57fe54725dd4eea..6d266a17ee9f9cc099fe433de84390a39ad19bb7 100644 (file)
@@ -26,6 +26,7 @@ stdint
 xsize
 errno
 memchr
+verify
 
 configure.ac:
 gl_FUNC_VASNPRINTF