bug-coreutils
[Top][All Lists]
Advanced

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

argmatch.h simplification using verify.h


From: Paul Eggert
Subject: argmatch.h simplification using verify.h
Date: Wed, 21 Sep 2005 23:40:45 -0700
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

I installed this to simplify argmatch.h using verify.h, since
I'm going to put verify.h into gnulib:

2005-09-21  Paul Eggert  <address@hidden>

        * lib/argmatch.h (GL_CONCAT): Remove.
        Include "verify.h" instead.
        (ARGMATCH_CONSTRAINT, ARGMATCH_ASSERT): Remove.
        (ARGMATCH_VERIFY): Rewrite in terms of new verify macros.

Index: lib/argmatch.h
===================================================================
RCS file: /fetish/cu/lib/argmatch.h,v
retrieving revision 1.26
diff -p -u -r1.26 argmatch.h
--- lib/argmatch.h      4 Jul 2005 14:47:42 -0000       1.26
+++ lib/argmatch.h      22 Sep 2005 06:24:28 -0000
@@ -25,34 +25,15 @@
 
 # include <stddef.h>
 
-# ifndef verify_dcl
-#  define GL_CONCAT0(x, y) x##y
-#  define GL_CONCAT(x, y) GL_CONCAT0 (x, y)
-
-/* Verify requirement, R, at compile-time, as a declaration.
-   The implementation uses a struct declaration whose name includes the
-   expansion of __LINE__, so there is a small chance that two uses of
-   verify_dcl from different files will end up colliding (for example,
-   f.c includes f.h and verify_dcl is used on the same line in each).  */
-#  define verify_dcl(R) \
-    struct GL_CONCAT (ct_assert_, __LINE__) { char a[(R) ? 1 : -1]; }
-# endif
+# include "verify.h"
 
 # define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array))
 
-# define ARGMATCH_CONSTRAINT(Arglist, Vallist) \
-  (ARRAY_CARDINALITY (Arglist) == ARRAY_CARDINALITY (Vallist) + 1)
-
 /* Assert there are as many real arguments as there are values
-   (argument list ends with a NULL guard).  ARGMATCH_VERIFY is
-   preferred, since it is guaranteed to be checked at compile-time.
-   ARGMATCH_ASSERT is for backward compatibility only.  */
+   (argument list ends with a NULL guard).  */
 
 # define ARGMATCH_VERIFY(Arglist, Vallist) \
-    verify_dcl (ARGMATCH_CONSTRAINT (Arglist, Vallist))
-
-# define ARGMATCH_ASSERT(Arglist, Vallist) \
-  assert (ARGMATCH_CONSTRAINT (Arglist, Vallist))
+    verify (ARRAY_CARDINALITY (Arglist) == ARRAY_CARDINALITY (Vallist) + 1)
 
 /* Return the index of the element of ARGLIST (NULL terminated) that
    matches with ARG.  If VALLIST is not NULL, then use it to resolve




reply via email to

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