1 diff --git a/src/common.h b/src/common.h
2 index edf787c..3cc2011 100644
5 @@ -725,7 +725,7 @@ int uname_to_uid (char const *uname, uid_t *puid);
7 void name_add_name (const char *name, int matching_flags);
8 void name_add_dir (const char *name);
9 -void name_add_file (const char *name, int term);
10 +void name_add_file (const char *name, int term, int matching_flags);
11 void name_term (void);
12 const char *name_next (int change_dirs);
13 void name_gather (void);
14 diff --git a/src/names.c b/src/names.c
15 index 594e7fd..e3e145a 100644
18 @@ -258,6 +258,21 @@ name_elt_alloc (void)
22 +static struct name_elt *
23 +name_elt_alloc_matflags (int matflags)
25 + static int prev_flags = 0; /* FIXME: Or EXCLUDE_ANCHORED? */
26 + struct name_elt *ep = name_elt_alloc ();
27 + if (prev_flags != matflags)
29 + ep->type = NELT_FMASK;
30 + ep->v.matching_flags = matflags;
31 + prev_flags = matflags;
32 + ep = name_elt_alloc ();
38 name_list_adjust (void)
40 @@ -276,20 +291,13 @@ name_list_advance (void)
44 -/* Add to name_array the file NAME with fnmatch options MATCHING_FLAGS */
46 +/* Add to name_array the file NAME with fnmatch options MATFLAGS */
48 -name_add_name (const char *name, int matching_flags)
49 +name_add_name (const char *name, int matflags)
51 - static int prev_flags = 0; /* FIXME: Or EXCLUDE_ANCHORED? */
52 - struct name_elt *ep = name_elt_alloc ();
53 + struct name_elt *ep = name_elt_alloc_matflags (matflags);
55 - if (prev_flags != matching_flags)
57 - ep->type = NELT_FMASK;
58 - ep->v.matching_flags = matching_flags;
59 - prev_flags = matching_flags;
60 - ep = name_elt_alloc ();
65 @@ -305,9 +313,10 @@ name_add_dir (const char *name)
69 -name_add_file (const char *name, int term)
70 +name_add_file (const char *name, int term, int matflags)
72 - struct name_elt *ep = name_elt_alloc ();
73 + struct name_elt *ep = name_elt_alloc_matflags (matflags);
76 ep->v.file.name = name;
77 ep->v.file.term = term;
78 @@ -389,6 +398,15 @@ add_file_id (const char *filename)
83 +/* Chop trailing slashes. */
85 +chopslash (char *str)
87 + char *p = str + strlen (str) - 1;
88 + while (p > str && ISSLASH (*p))
92 enum read_file_list_state /* Result of reading file name from the list file */
94 @@ -428,7 +446,7 @@ read_name_from_file (struct name_elt *ent)
95 if (counter == name_buffer_length)
96 name_buffer = x2realloc (name_buffer, &name_buffer_length);
97 name_buffer[counter] = 0;
99 + chopslash (name_buffer);
100 return (counter == 0 && c == EOF) ? file_list_end : file_list_success;
103 @@ -518,7 +536,6 @@ copy_name (struct name_elt *ep)
110 source_len = strlen (source);
111 @@ -536,11 +553,7 @@ copy_name (struct name_elt *ep)
112 name_buffer = xmalloc(name_buffer_length + 2);
114 strcpy (name_buffer, source);
116 - /* Zap trailing slashes. */
117 - cursor = name_buffer + strlen (name_buffer) - 1;
118 - while (cursor > name_buffer && ISSLASH (*cursor))
120 + chopslash (name_buffer);
124 @@ -553,7 +566,8 @@ static int matching_flags; /* exclude_fnmatch options */
125 the request to change to the given directory.
127 Entries of type NELT_FMASK cause updates of the matching_flags
131 static struct name_elt *
132 name_next_elt (int change_dirs)
134 diff --git a/src/tar.c b/src/tar.c
135 index cd32379..225c624 100644
138 @@ -1641,7 +1641,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
142 - name_add_file (arg, filename_terminator);
143 + name_add_file (arg, filename_terminator, MAKE_INCL_OPTIONS (args));
144 /* Indicate we've been given -T option. This is for backward
145 compatibility only, so that `tar cfT archive /dev/null will
147 diff --git a/tests/Makefile.am b/tests/Makefile.am
148 index 6684d1d..c71d294 100644
149 --- a/tests/Makefile.am
150 +++ b/tests/Makefile.am
151 @@ -43,6 +43,8 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac
160 diff --git a/tests/T-dir00.at b/tests/T-dir00.at
162 index 0000000..7f89fcf
164 +++ b/tests/T-dir00.at
166 +# Process this file with autom4te to create testsuite. -*- Autotest -*-
168 +# Test suite for GNU tar.
169 +# Copyright 2014 Free Software Foundation, Inc.
171 +# This file is part of GNU tar.
173 +# GNU tar is free software; you can redistribute it and/or modify
174 +# it under the terms of the GNU General Public License as published by
175 +# the Free Software Foundation; either version 3 of the License, or
176 +# (at your option) any later version.
178 +# GNU tar is distributed in the hope that it will be useful,
179 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
180 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
181 +# GNU General Public License for more details.
183 +# You should have received a copy of the GNU General Public License
184 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
186 +# Tar 1.27 and 1.28 did not extract files under directory memberes listed
187 +# in the file read by --file-from.
189 +# Reported-by: Jean-Louis Martineau <address@hidden>
190 +# References: <address@hidden>,
191 +# http://lists.gnu.org/archive/html/bug-tar/2014-09/msg00006.html
193 +AT_SETUP([recursive extraction from --files-from])
194 +AT_KEYWORDS([files-from extract T-dir T-dir00])
197 +genfile -f dir/file1
198 +genfile -f dir/file2
202 +tar xfTv archive list
211 diff --git a/tests/T-dir01.at b/tests/T-dir01.at
213 index 0000000..155a373
215 +++ b/tests/T-dir01.at
217 +# Process this file with autom4te to create testsuite. -*- Autotest -*-
219 +# Test suite for GNU tar.
220 +# Copyright 2014 Free Software Foundation, Inc.
222 +# This file is part of GNU tar.
224 +# GNU tar is free software; you can redistribute it and/or modify
225 +# it under the terms of the GNU General Public License as published by
226 +# the Free Software Foundation; either version 3 of the License, or
227 +# (at your option) any later version.
229 +# GNU tar is distributed in the hope that it will be useful,
230 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
231 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
232 +# GNU General Public License for more details.
234 +# You should have received a copy of the GNU General Public License
235 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
237 +# Tar 1.27 and 1.28 did not remove trailing slashes from file names
238 +# obtained with the --file-from option.
240 +# Reported-by: Jean-Louis Martineau <address@hidden>
241 +# References: <address@hidden>,
242 +# http://lists.gnu.org/archive/html/bug-tar/2014-09/msg00006.html
244 +AT_SETUP([trailing slash in --files-from])
245 +AT_KEYWORDS([files-from extract T-dir T-dir01])
248 +genfile -f dir/file1
249 +genfile -f dir/file2
253 +tar xfTv archive list
262 diff --git a/tests/testsuite.at b/tests/testsuite.at
263 index 7f8e4c4..f28e86c 100644
264 --- a/tests/testsuite.at
265 +++ b/tests/testsuite.at
266 @@ -205,6 +205,8 @@ m4_include([T-empty.at])
267 m4_include([T-null.at])
268 m4_include([T-zfile.at])
269 m4_include([T-nonl.at])
270 +m4_include([T-dir00.at])
271 +m4_include([T-dir01.at])
273 AT_BANNER([Various options])
274 m4_include([indexfile.at])