Hi,

On Wed, Dec 25, 2013 at 09:49:45AM -0800, Russ Allbery wrote:
...
> In order to support file names that contain whitespace, uscan's parsing
> of Files-Excluded needs to handle the character escaping protocol.  The
> following code should correctly handle foo\ bar, as well as the other
> more pathological cases such as foo\\ bar (which is two files).

Following up on the regexp and the bugreport created by Russ:

I created a patch and tested it with a Files-excluded statement in
d/copyright.
I found an issue that it does not split on newlines.
Russ: If you can update the regexp to cover these use case the better.
(and thanks for the current one, my Perl knowledge is lacking when it comes to
regexpes like this one :)
In the meanwhile I updated the script to replace newlines with
whitespaces to get the same result.

I include a patch.

A separate issue is that when in dehs mode uscan should return after
repacking the archive with files removed the new filename.
I include a separate patch for this one.

I have all of these in my git repo available for conveniance:
git://cstamas.hu/git/devscripts.git

Regards,
 Tamas
-- 
CSILLAG Tamas (cstamas) - http://cstamas.hu/

commit 49703d8fcc47a0e7adcf97861525729d9e6ef539
Author: CSILLAG Tamas <csta...@cstamas.hu>
Date:   Thu Dec 26 18:06:14 2013 +0100

    dehs: returned the repacked archive instead of the orig after file-excludes

diff --git a/scripts/uscan.pl b/scripts/uscan.pl
index 6cb9c19..8bf6b99 100755
--- a/scripts/uscan.pl
+++ b/scripts/uscan.pl
@@ -1618,6 +1618,7 @@ EOF
 		$msg .= " and renamed it as $renamed_base";
 	    } elsif ($symlink eq 'files-excluded') {
 		$msg .= " and removed files from it in ${pkg}_${newversion}${excludesuffix}.orig.tar.$suffix\n";
+		$dehs_tags{'target'} = "${pkg}_${newversion}${excludesuffix}.orig.tar.$suffix";
 	    } else {
 		$dehs_tags{'target'} = $newfile_base;
 	    }
commit d60eb9eb60966d03d8e46e247eaa6f314b6e3555
Author: CSILLAG Tamas <csta...@cstamas.hu>
Date:   Thu Dec 26 18:04:51 2013 +0100

    support escaped spaces

diff --git a/scripts/uscan.pl b/scripts/uscan.pl
index 433f5e2..6cb9c19 100755
--- a/scripts/uscan.pl
+++ b/scripts/uscan.pl
@@ -1543,7 +1543,13 @@ EOF
 	    my $file_list;
 	    spawn(exec => ['find', $main_source_dir], wait_child => 1, to_string => \$file_list);
 	    my $nfiles_before = split /\n/, $file_list;
-	    foreach (grep { $_ } split /\s+/, $data->{"files-excluded"}) {
+	    my $filesexcluded = $data->{"files-excluded"};
+	    $filesexcluded =~ s!\n! !g;
+	    # see the thread for details http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=635920#127
+	    my @excluded = ($filesexcluded =~ /(?:\A|\G[ ]+)((?:\\.|[^\\ ])+)/g);
+	    # un-escape
+	    @excluded = map { s/\\(.)/$1/g; $_ } @excluded;
+	    foreach (@excluded) {
 		# delete trailing '/' because otherwise find -path will fail
 		s?/+$??;
 		# use rm -rf to enable deleting non-empty directories

Reply via email to