bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

change exclude, strtoimax, utimecmp to use verify


From: Paul Eggert
Subject: change exclude, strtoimax, utimecmp to use verify
Date: Sun, 02 Oct 2005 15:45:30 -0700
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

I installed this to remove some code duplication.  mktime.c also has a
related verify macro, but that's a glibc thing so I'll hold off for
now.

2005-10-02  Paul Eggert  <address@hidden>

        * lib/exclude.c: Include verify.h.
        (verify): Remove.  All callers changed to use verify.h's version.
        * lib/strtoimax.c: Likewise.
        * lib/utimecmp.c: Likewis.e
        * modules/exclude (Depends-on): Depend on verify.
        * modules/strtoimax (Depends-on): Likewise.
        * modules/utimecmp (Depends-on): Likewise.

Index: lib/exclude.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/exclude.c,v
retrieving revision 1.26
diff -p -u -r1.26 exclude.c
--- lib/exclude.c       23 Sep 2005 04:15:13 -0000      1.26
+++ lib/exclude.c       2 Oct 2005 22:41:00 -0000
@@ -37,6 +37,7 @@
 #include "fnmatch.h"
 #include "strcase.h"
 #include "xalloc.h"
+#include "verify.h"
 
 #if USE_UNLOCKED_IO
 # include "unlocked-io.h"
@@ -54,9 +55,6 @@ is_space (unsigned char c)
   return IN_CTYPE_DOMAIN (c) && isspace (c);
 }
 
-/* Verify a requirement at compile-time (unlike assert, which is runtime).  */
-#define verify(name, assertion) struct name { char a[(assertion) ? 1 : -1]; }
-
 /* Non-GNU systems lack these options, so we don't need to check them.  */
 #ifndef FNM_CASEFOLD
 # define FNM_CASEFOLD 0
@@ -65,11 +63,10 @@ is_space (unsigned char c)
 # define FNM_LEADING_DIR 0
 #endif
 
-verify (EXCLUDE_macros_do_not_collide_with_FNM_macros,
-       (((EXCLUDE_ANCHORED | EXCLUDE_INCLUDE | EXCLUDE_WILDCARDS)
-         & (FNM_PATHNAME | FNM_NOESCAPE | FNM_PERIOD | FNM_LEADING_DIR
-            | FNM_CASEFOLD))
-        == 0));
+verify (((EXCLUDE_ANCHORED | EXCLUDE_INCLUDE | EXCLUDE_WILDCARDS)
+        & (FNM_PATHNAME | FNM_NOESCAPE | FNM_PERIOD | FNM_LEADING_DIR
+           | FNM_CASEFOLD))
+       == 0);
 
 /* An exclude pattern-options pair.  The options are fnmatch options
    ORed with EXCLUDE_* options.  */
Index: lib/strtoimax.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/strtoimax.c,v
retrieving revision 1.12
diff -p -u -r1.12 strtoimax.c
--- lib/strtoimax.c     19 Sep 2005 17:28:15 -0000      1.12
+++ lib/strtoimax.c     2 Oct 2005 22:41:00 -0000
@@ -32,8 +32,7 @@
 
 #include <stdlib.h>
 
-/* Verify a requirement at compile-time (unlike assert, which is runtime).  */
-#define verify(name, assertion) struct name { char a[(assertion) ? 1 : -1]; }
+#include "verify.h"
 
 #ifdef UNSIGNED
 # ifndef HAVE_DECL_STRTOULL
@@ -68,15 +67,13 @@ INT
 strtoimax (char const *ptr, char **endptr, int base)
 {
 #if HAVE_LONG_LONG
-  verify (size_is_that_of_long_or_long_long,
-         (sizeof (INT) == sizeof (long int)
-          || sizeof (INT) == sizeof (long long int)));
+  verify (sizeof (INT) == sizeof (long int)
+         || sizeof (INT) == sizeof (long long int));
 
   if (sizeof (INT) != sizeof (long int))
     return strtoll (ptr, endptr, base);
 #else
-  verify (size_is_that_of_long,
-         sizeof (INT) == sizeof (long int));
+  verify (sizeof (INT) == sizeof (long int));
 #endif
 
   return strtol (ptr, endptr, base);
Index: lib/utimecmp.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/utimecmp.c,v
retrieving revision 1.5
diff -p -u -r1.5 utimecmp.c
--- lib/utimecmp.c      19 Sep 2005 17:28:15 -0000      1.5
+++ lib/utimecmp.c      2 Oct 2005 22:41:00 -0000
@@ -39,11 +39,9 @@
 #include "stat-time.h"
 #include "timespec.h"
 #include "utimens.h"
+#include "verify.h"
 #include "xalloc.h"
 
-/* Verify a requirement at compile-time (unlike assert, which is runtime).  */
-#define verify(name, assertion) struct name { char a[(assertion) ? 1 : -1]; }
-
 #ifndef MAX
 # define MAX(a, b) ((a) > (b) ? (a) : (b))
 #endif
@@ -139,8 +137,8 @@ utimecmp (char const *dst_name,
 
      time_t might be unsigned.  */
 
-  verify (time_t_is_integer, TYPE_IS_INTEGER (time_t));
-  verify (twos_complement_arithmetic, TYPE_TWOS_COMPLEMENT (int));
+  verify (TYPE_IS_INTEGER (time_t));
+  verify (TYPE_TWOS_COMPLEMENT (int));
 
   /* Destination and source time stamps.  */
   time_t dst_s = dst_stat->st_mtime;
Index: modules/exclude
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/exclude,v
retrieving revision 1.6
diff -p -u -r1.6 exclude
--- modules/exclude     21 Mar 2005 22:07:25 -0000      1.6
+++ modules/exclude     2 Oct 2005 22:41:00 -0000
@@ -11,6 +11,7 @@ xalloc
 strcase
 fnmatch-gnu
 stdbool
+verify
 
 configure.ac:
 gl_EXCLUDE
Index: modules/strtoimax
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/strtoimax,v
retrieving revision 1.4
diff -p -u -r1.4 strtoimax
--- modules/strtoimax   22 Sep 2004 15:11:04 -0000      1.4
+++ modules/strtoimax   2 Oct 2005 22:41:00 -0000
@@ -11,6 +11,7 @@ m4/strtoimax.m4
 
 Depends-on:
 strtoll
+verify
 
 configure.ac:
 gl_FUNC_STRTOIMAX
@@ -24,4 +25,3 @@ GPL
 
 Maintainer:
 Paul Eggert
-
Index: modules/utimecmp
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/utimecmp,v
retrieving revision 1.6
diff -p -u -r1.6 utimecmp
--- modules/utimecmp    16 Sep 2005 07:18:35 -0000      1.6
+++ modules/utimecmp    2 Oct 2005 22:41:00 -0000
@@ -14,6 +14,7 @@ timespec
 utimens
 xalloc
 stdbool
+verify
 
 configure.ac:
 gl_UTIMECMP




reply via email to

[Prev in Thread] Current Thread [Next in Thread]