فهرست منبع

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.
Sergey Poznyakoff 9 سال پیش
والد
کامیت
63f2e969dd
5فایلهای تغییر یافته به همراه50 افزوده شده و 8 حذف شده
  1. 2 0
      THANKS
  2. 9 7
      src/transform.c
  3. 1 0
      tests/Makefile.am
  4. 2 1
      tests/testsuite.at
  5. 36 0
      tests/xform02.at

+ 2 - 0
THANKS

@@ -78,6 +78,7 @@ Cesar Romani		[email protected]
 Chad Hurwitz		[email protected]
 Chance Reschke		[email protected]
 Charles Fu		[email protected]
+Charles McGarvey        [email protected]
 Charles Lopes		[email protected]
 Charles M. Hannum	[email protected]
 Chip Salzenberg		tct!chip
@@ -173,6 +174,7 @@ Erik D. Frederick	[email protected]
 Esa Karell		[email protected]
 Ezra Peisach		[email protected]
 Fabio d'Alessi		[email protected]
+Flavio Poletti          [email protected]
 Frank Heckenbach	[email protected]
 Frank Koenen		[email protected]
 Franz-Werner Gergen	[email protected]

+ 9 - 7
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;
 	    }

+ 1 - 0
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\

+ 2 - 1
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])

+ 36 - 0
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