diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-01-20 11:16:02 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-01-20 11:16:02 +0200 |
commit | 63f2e969ddc162da7ae49a955bba9c6a2a0e77dc (patch) | |
tree | 92e6d983af220a789ff5521b35324d8c7159db70 | |
parent | 445293654d92a1dabb04255547730b35c5cde387 (diff) | |
download | tar-63f2e969ddc162da7ae49a955bba9c6a2a0e77dc.tar.gz |
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.
-rw-r--r-- | THANKS | 2 | ||||
-rw-r--r-- | src/transform.c | 16 | ||||
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/testsuite.at | 3 | ||||
-rw-r--r-- | tests/xform02.at | 36 |
5 files changed, 50 insertions, 8 deletions
@@ -78,6 +78,7 @@ Cesar Romani romani@ifm.uni-hamburg.de Chad Hurwitz churritz@cts.com Chance Reschke creschke@usra.edu Charles Fu ccwf@klab.caltech.edu +Charles McGarvey chazmcgarvey@brokenzipper.com Charles Lopes Charles.Lopes@infm.ulst.ac.uk Charles M. Hannum mycroft@gnu.org Chip Salzenberg tct!chip @@ -173,6 +174,7 @@ Erik D. Frederick edf@deckard.mc.duke.edu Esa Karell karell@cs.helsinki.fi Ezra Peisach epeisach@mit.edu Fabio d'Alessi cars@civ.bio.unipd.it +Flavio Poletti polettix@gmail.com Frank Heckenbach frank@g-n-u.de Frank Koenen koenfr@lidp.com Franz-Werner Gergen gergen@edvulx.mpi-stuttgart.mpg.de diff --git a/src/transform.c b/src/transform.c index cd9e27cc..e53d61aa 100644 --- a/src/transform.c +++ b/src/transform.c @@ -378,13 +378,15 @@ parse_transform_expr (const char *expr) break; default: - /* Try to be nice */ - { - char buf[2]; - buf[0] = '\\'; - buf[1] = *cur; - add_literal_segment (tf, buf, buf + 2); - } + if (*cur == delim) + add_char_segment (tf, delim); + else + { + char buf[2]; + buf[0] = '\\'; + buf[1] = *cur; + add_literal_segment (tf, buf, buf + 2); + } cur++; break; } diff --git a/tests/Makefile.am b/tests/Makefile.am index 05c59599..0772fab7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -228,6 +228,7 @@ TESTSUITE_AT = \ version.at\ xform-h.at\ xform01.at\ + xform02.at\ star/gtarfail.at\ star/gtarfail2.at\ star/multi-fail.at\ diff --git a/tests/testsuite.at b/tests/testsuite.at index 42a40276..954d48cd 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -1,7 +1,7 @@ # Process this file with autom4te to create testsuite. -*- Autotest -*- # 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. @@ -247,6 +247,7 @@ m4_include([append04.at]) AT_BANNER([Transforms]) m4_include([xform-h.at]) m4_include([xform01.at]) +m4_include([xform02.at]) AT_BANNER([Exclude]) m4_include([exclude.at]) diff --git a/tests/xform02.at b/tests/xform02.at new file mode 100644 index 00000000..98306aa6 --- /dev/null +++ b/tests/xform02.at @@ -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 |