patchfs: Fixed leading ./ bug



Hi,

with this patch patchfs accepts file names that are "equivalent" to the ones mentioned in the patch file.

[ ] ok to commit
[ ] needs review
[ ] rejected

Roland
Index: patchfs.in
===================================================================
RCS file: /cvsroot/mc/mc/vfs/extfs/patchfs.in,v
retrieving revision 1.16
diff -u -r1.16 patchfs.in
--- patchfs.in	19 Aug 2004 15:43:09 -0000	1.16
+++ patchfs.in	22 Oct 2004 12:58:03 -0000
@@ -31,6 +31,12 @@
 my $ls_extract_id=qr/^[^\s]+\s+[^\s]+\s+([^\s]+)\s+([^\s]+)/;
 my $basename=qr|^(.*/)*([^/]+)$|;
 
+sub mc_canonicalize_path ($) {
+  my ($fname) = @_;
+  $fname =~ s,/+,/,g;
+  $fname =~ s,^\./,,;
+  $fname =~ s,/\.$,,;
+}
 
 # output unix date in a mc-readable format
 sub timef
@@ -203,6 +209,7 @@
     my ($unified,$context)=(0,0);
 
     $file=~s/^(PATCH-(CREATE|REMOVE)\/)?(.*)\.diff$/$3/;
+    $file = mc_canonicalize_path ($file);
     
     # state==1 means diff contents, state==0 mens comments
     $state=0; $found=0; $buf='';
@@ -223,6 +230,8 @@
 	    $state=1;
 
 	    ($fsrc,$fdst,)=parse_header($unified,$context,\$_);
+	    $fsrc = mc_canonicalize_path ($fsrc);
+	    $fdst = mc_canonicalize_path ($fdst);
 	    $found=1 if (($fsrc eq $file) || ($fdst eq $file));
 
 	} elsif ($state==1 && (($unified && !/$unified_contents/) || ($context && !/$context_contents/))) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]