5 void name_add_name (const char *name, int matching_flags);
6 void name_add_dir (const char *name);
7 -void name_add_file (const char *name, int term);
8 +void name_add_file (const char *name, int term, int matching_flags);
10 const char *name_next (int change_dirs);
11 void name_gather (void);
18 +static struct name_elt *
19 +name_elt_alloc_matflags (int matflags)
21 + static int prev_flags = 0; /* FIXME: Or EXCLUDE_ANCHORED? */
22 + struct name_elt *ep = name_elt_alloc ();
23 + if (prev_flags != matflags)
25 + ep->type = NELT_FMASK;
26 + ep->v.matching_flags = matflags;
27 + prev_flags = matflags;
28 + ep = name_elt_alloc ();
34 name_list_adjust (void)
40 -/* Add to name_array the file NAME with fnmatch options MATCHING_FLAGS */
42 +/* Add to name_array the file NAME with fnmatch options MATFLAGS */
44 -name_add_name (const char *name, int matching_flags)
45 +name_add_name (const char *name, int matflags)
47 - static int prev_flags = 0; /* FIXME: Or EXCLUDE_ANCHORED? */
48 - struct name_elt *ep = name_elt_alloc ();
49 + struct name_elt *ep = name_elt_alloc_matflags (matflags);
51 - if (prev_flags != matching_flags)
53 - ep->type = NELT_FMASK;
54 - ep->v.matching_flags = matching_flags;
55 - prev_flags = matching_flags;
56 - ep = name_elt_alloc ();
65 -name_add_file (const char *name, int term)
66 +name_add_file (const char *name, int term, int matflags)
68 - struct name_elt *ep = name_elt_alloc ();
69 + struct name_elt *ep = name_elt_alloc_matflags (matflags);
72 ep->v.file.name = name;
73 ep->v.file.term = term;
79 +/* Chop trailing slashes. */
81 +chopslash (char *str)
83 + char *p = str + strlen (str) - 1;
84 + while (p > str && ISSLASH (*p))
88 enum read_file_list_state /* Result of reading file name from the list file */
91 if (counter == name_buffer_length)
92 name_buffer = x2realloc (name_buffer, &name_buffer_length);
93 name_buffer[counter] = 0;
95 + chopslash (name_buffer);
96 return (counter == 0 && c == EOF) ? file_list_end : file_list_success;
106 source_len = strlen (source);
108 name_buffer = xmalloc(name_buffer_length + 2);
110 strcpy (name_buffer, source);
112 - /* Zap trailing slashes. */
113 - cursor = name_buffer + strlen (name_buffer) - 1;
114 - while (cursor > name_buffer && ISSLASH (*cursor))
116 + chopslash (name_buffer);
121 the request to change to the given directory.
123 Entries of type NELT_FMASK cause updates of the matching_flags
127 static struct name_elt *
128 name_next_elt (int change_dirs)
132 @@ -1669,7 +1669,7 @@
136 - name_add_file (arg, filename_terminator);
137 + name_add_file (arg, filename_terminator, MAKE_INCL_OPTIONS (args));
138 /* Indicate we've been given -T option. This is for backward
139 compatibility only, so that `tar cfT archive /dev/null will
141 --- a/tests/Makefile.am
142 +++ b/tests/Makefile.am
153 +++ b/tests/T-dir00.at
155 +# Process this file with autom4te to create testsuite. -*- Autotest -*-
157 +# Test suite for GNU tar.
158 +# Copyright 2014 Free Software Foundation, Inc.
160 +# This file is part of GNU tar.
162 +# GNU tar is free software; you can redistribute it and/or modify
163 +# it under the terms of the GNU General Public License as published by
164 +# the Free Software Foundation; either version 3 of the License, or
165 +# (at your option) any later version.
167 +# GNU tar is distributed in the hope that it will be useful,
168 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
169 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
170 +# GNU General Public License for more details.
172 +# You should have received a copy of the GNU General Public License
173 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
175 +# Tar 1.27 and 1.28 did not extract files under directory memberes listed
176 +# in the file read by --file-from.
178 +# Reported-by: Jean-Louis Martineau <address@hidden>
179 +# References: <address@hidden>,
180 +# http://lists.gnu.org/archive/html/bug-tar/2014-09/msg00006.html
182 +AT_SETUP([recursive extraction from --files-from])
183 +AT_KEYWORDS([files-from extract T-dir T-dir00])
186 +genfile -f dir/file1
187 +genfile -f dir/file2
191 +tar xfTv archive list
201 +++ b/tests/T-dir01.at
203 +# Process this file with autom4te to create testsuite. -*- Autotest -*-
205 +# Test suite for GNU tar.
206 +# Copyright 2014 Free Software Foundation, Inc.
208 +# This file is part of GNU tar.
210 +# GNU tar is free software; you can redistribute it and/or modify
211 +# it under the terms of the GNU General Public License as published by
212 +# the Free Software Foundation; either version 3 of the License, or
213 +# (at your option) any later version.
215 +# GNU tar is distributed in the hope that it will be useful,
216 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
217 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
218 +# GNU General Public License for more details.
220 +# You should have received a copy of the GNU General Public License
221 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
223 +# Tar 1.27 and 1.28 did not remove trailing slashes from file names
224 +# obtained with the --file-from option.
226 +# Reported-by: Jean-Louis Martineau <address@hidden>
227 +# References: <address@hidden>,
228 +# http://lists.gnu.org/archive/html/bug-tar/2014-09/msg00006.html
230 +AT_SETUP([trailing slash in --files-from])
231 +AT_KEYWORDS([files-from extract T-dir T-dir01])
234 +genfile -f dir/file1
235 +genfile -f dir/file2
239 +tar xfTv archive list
248 --- a/tests/testsuite.at
249 +++ b/tests/testsuite.at
251 m4_include([T-null.at])
252 m4_include([T-zfile.at])
253 m4_include([T-nonl.at])
254 +m4_include([T-dir00.at])
255 +m4_include([T-dir01.at])
257 AT_BANNER([Various options])
258 m4_include([indexfile.at])