1 /* Test suite for exclude.
2 Copyright (C) 2009-2016 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/>. */
31 # define FNM_CASEFOLD 0
33 #ifndef FNM_LEADING_DIR
34 # define FNM_LEADING_DIR 0
37 char const * const exclude_keywords[] = {
49 int exclude_flags[] = {
60 ARGMATCH_VERIFY (exclude_keywords, exclude_flags);
62 /* Some packages define ARGMATCH_DIE and ARGMATCH_DIE_DECL in <config.h>, and
63 thus must link with a definition of that function. Provide it here. */
64 #ifdef ARGMATCH_DIE_DECL
66 _Noreturn ARGMATCH_DIE_DECL;
67 ARGMATCH_DIE_DECL { exit (1); }
72 main (int argc, char **argv)
74 int exclude_options = 0;
75 struct exclude *exclude = new_exclude ();
78 error (1, 0, "usage: %s file -- words...", argv[0]);
89 if (opt[1] == '-' && opt[2] == 0)
94 if (strlen (s) > 3 && memcmp (s, "no-", 3) == 0)
99 flag = XARGMATCH (opt, s, exclude_keywords, exclude_flags);
101 exclude_options &= ~flag;
103 exclude_options |= flag;
105 /* Skip this test if invoked with -leading-dir on a system that
106 lacks support for FNM_LEADING_DIR. */
107 if (strcmp (s, "leading_dir") == 0 && FNM_LEADING_DIR == 0)
110 /* Likewise for -casefold and FNM_CASEFOLD. */
111 if (strcmp (s, "casefold") == 0 && FNM_CASEFOLD == 0)
114 else if (add_exclude_file (add_exclude, exclude, opt,
115 exclude_options, '\n') != 0)
116 error (1, errno, "error loading %s", opt);
121 char *word = *++argv;
123 printf ("%s: %d\n", word, excluded_file_name (exclude, word));