1 /* Test suite for exclude.
2 Copyright (C) 2009, 2010 Free Software Foundation, Inc.
3 This file is part of the GNUlib Library.
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
32 # define FNM_CASEFOLD 0
34 #ifndef FNM_LEADING_DIR
35 # define FNM_LEADING_DIR 0
38 char const * const exclude_keywords[] = {
50 int exclude_flags[] = {
61 ARGMATCH_VERIFY (exclude_keywords, exclude_flags);
63 /* Some packages define ARGMATCH_DIE and ARGMATCH_DIE_DECL in <config.h>, and
64 thus must link with a definition of that function. Provide it here. */
65 #ifdef ARGMATCH_DIE_DECL
67 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
68 # define __attribute__(x) /* empty */
72 #ifndef ATTRIBUTE_NORETURN
73 # define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
76 ARGMATCH_DIE_DECL ATTRIBUTE_NORETURN;
77 ARGMATCH_DIE_DECL { exit (1); }
81 main (int argc, char **argv)
83 int exclude_options = 0;
84 struct exclude *exclude = new_exclude ();
86 set_program_name (argv[0]);
89 error (1, 0, "usage: %s file -- words...", argv[0]);
100 if (opt[1] == '-' && opt[2] == 0)
105 if (strlen (s) > 3 && memcmp (s, "no-", 3) == 0)
110 flag = XARGMATCH (opt, s, exclude_keywords, exclude_flags);
112 exclude_options &= ~flag;
114 exclude_options |= flag;
116 else if (add_exclude_file (add_exclude, exclude, opt,
117 exclude_options, '\n') != 0)
118 error (1, errno, "error loading %s", opt);
123 char *word = *++argv;
125 printf ("%s: %d\n", word, excluded_file_name (exclude, word));