Allow escaped delimiters in transform expressions.

Patch provided by Charles McGarvey and Flavio Poletti.

* src/transform.c (parse_transform_expr): Allow escaped delimiters
in transform expressions.
* tests/xform02.at: New test case.
* tests/Makefile.am: Add xform02.at
* tests/testsuite.at: Include xform02.at
* THANKS: Update.
This commit is contained in:
Sergey Poznyakoff
2016-01-20 11:16:02 +02:00
parent 445293654d
commit 63f2e969dd
5 changed files with 50 additions and 8 deletions

2
THANKS
View File

@@ -78,6 +78,7 @@ Cesar Romani romani@ifm.uni-hamburg.de
Chad Hurwitz churritz@cts.com Chad Hurwitz churritz@cts.com
Chance Reschke creschke@usra.edu Chance Reschke creschke@usra.edu
Charles Fu ccwf@klab.caltech.edu Charles Fu ccwf@klab.caltech.edu
Charles McGarvey chazmcgarvey@brokenzipper.com
Charles Lopes Charles.Lopes@infm.ulst.ac.uk Charles Lopes Charles.Lopes@infm.ulst.ac.uk
Charles M. Hannum mycroft@gnu.org Charles M. Hannum mycroft@gnu.org
Chip Salzenberg tct!chip Chip Salzenberg tct!chip
@@ -173,6 +174,7 @@ Erik D. Frederick edf@deckard.mc.duke.edu
Esa Karell karell@cs.helsinki.fi Esa Karell karell@cs.helsinki.fi
Ezra Peisach epeisach@mit.edu Ezra Peisach epeisach@mit.edu
Fabio d'Alessi cars@civ.bio.unipd.it Fabio d'Alessi cars@civ.bio.unipd.it
Flavio Poletti polettix@gmail.com
Frank Heckenbach frank@g-n-u.de Frank Heckenbach frank@g-n-u.de
Frank Koenen koenfr@lidp.com Frank Koenen koenfr@lidp.com
Franz-Werner Gergen gergen@edvulx.mpi-stuttgart.mpg.de Franz-Werner Gergen gergen@edvulx.mpi-stuttgart.mpg.de

View File

@@ -378,7 +378,9 @@ parse_transform_expr (const char *expr)
break; break;
default: default:
/* Try to be nice */ if (*cur == delim)
add_char_segment (tf, delim);
else
{ {
char buf[2]; char buf[2];
buf[0] = '\\'; buf[0] = '\\';

View File

@@ -228,6 +228,7 @@ TESTSUITE_AT = \
version.at\ version.at\
xform-h.at\ xform-h.at\
xform01.at\ xform01.at\
xform02.at\
star/gtarfail.at\ star/gtarfail.at\
star/gtarfail2.at\ star/gtarfail2.at\
star/multi-fail.at\ star/multi-fail.at\

View File

@@ -1,7 +1,7 @@
# Process this file with autom4te to create testsuite. -*- Autotest -*- # Process this file with autom4te to create testsuite. -*- Autotest -*-
# Test suite for GNU tar. # Test suite for GNU tar.
# Copyright 2004-2008, 2010-2015 Free Software Foundation, Inc. # Copyright 2004-2008, 2010-2016 Free Software Foundation, Inc.
# This file is part of GNU tar. # This file is part of GNU tar.
@@ -247,6 +247,7 @@ m4_include([append04.at])
AT_BANNER([Transforms]) AT_BANNER([Transforms])
m4_include([xform-h.at]) m4_include([xform-h.at])
m4_include([xform01.at]) m4_include([xform01.at])
m4_include([xform02.at])
AT_BANNER([Exclude]) AT_BANNER([Exclude])
m4_include([exclude.at]) m4_include([exclude.at])

36
tests/xform02.at Normal file
View File

@@ -0,0 +1,36 @@
# Process this file with autom4te to create testsuite. -*- Autotest -*-
# Test suite for GNU tar.
# Copyright 2009-2010, 2013-2016 Free Software Foundation, Inc.
# This file is part of GNU tar.
# GNU tar 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 3 of the License, or
# (at your option) any later version.
# GNU tar is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# 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, see <http://www.gnu.org/licenses/>.
AT_SETUP([transforming escaped delimiters on create])
AT_KEYWORDS([transform xform delimiter])
AT_TAR_CHECK([
genfile --file file
tar cvf /dev/null file \
--transform='s/file/other\/name/' \
--show-transformed-name
],
[0],
[other/name
])
AT_CLEANUP
# End of xform02.at