X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fargmatch.h;h=cc403145acf13457d64bc5663cc42616b5c8e040;hb=fa3486514bd8f15f8eb4c49821d0356b52e5a335;hp=ea0f46800e689a0b6fc6089ed4905a48b904fc76;hpb=267a39bafd249d7eb9c37df06dc6defcf41cb343;p=gnulib.git diff --git a/lib/argmatch.h b/lib/argmatch.h index ea0f46800..cc403145a 100644 --- a/lib/argmatch.h +++ b/lib/argmatch.h @@ -1,12 +1,12 @@ /* argmatch.h -- definitions and prototypes for argmatch.c - Copyright (C) 1990, 1998, 1999, 2001, 2002, 2004 Free Software + Copyright (C) 1990, 1998, 1999, 2001, 2002, 2004, 2005 Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or modify + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + along with this program. If not, see . */ /* Written by David MacKenzie Modified by Akim Demaille */ @@ -25,24 +24,15 @@ # include -# define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array)) +# include "verify.h" -# define ARGMATCH_CONSTRAINT(Arglist, Vallist) \ - (ARRAY_CARDINALITY (Arglist) == ARRAY_CARDINALITY (Vallist) + 1) +# define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array)) /* 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. */ - -# define ARGMATCH_VERIFY(Arglist, Vallist) \ - struct argmatch_verify \ - { \ - char argmatch_verify[ARGMATCH_CONSTRAINT(Arglist, Vallist) ? 1 : -1]; \ - } - -# define ARGMATCH_ASSERT(Arglist, Vallist) \ - assert (ARGMATCH_CONSTRAINT (Arglist, Vallist)) + (argument list ends with a NULL guard). */ + +# define ARGMATCH_VERIFY(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