]> git.gag.com Git - debian/tar/commitdiff
Allow escaped delimiters in transform expressions.
authorSergey Poznyakoff <gray@gnu.org.ua>
Wed, 20 Jan 2016 09:16:02 +0000 (11:16 +0200)
committerSergey Poznyakoff <gray@gnu.org.ua>
Wed, 20 Jan 2016 09:16:02 +0000 (11:16 +0200)
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.

THANKS
src/transform.c
tests/Makefile.am
tests/testsuite.at
tests/xform02.at [new file with mode: 0644]

diff --git a/THANKS b/THANKS
index 4add25ab29e351bcd5c7c5080699b26164cd3b2c..68336997021cf0ce2bc6c9d7ba2f2643e13e6589 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -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
index cd9e27ccf4f6fe624d9f401a58ffd4304bc9794b..e53d61aabb08c6f329165c1685dc0531e4582057 100644 (file)
@@ -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;
            }
index 05c59599d5a3c5ed108d8adbfde3fc40bea2ac50..0772fab71019db01d59d67298b1add6ddfe9b432 100644 (file)
@@ -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\
index 42a40276565aa446e27f5e8b6d7f7165ce567ee9..954d48cd7b5efa1f62f52b1466ba48ee5273a9fc 100644 (file)
@@ -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 (file)
index 0000000..98306aa
--- /dev/null
@@ -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