Re: patchfs, audio update



We had some letters in private, now I understand it was not so good to low list traffic by this way ;-)

Adam Byrtek 'alpha' wrote:
On Wed, Dec 18, 2002 at 09:26:05PM +0200, Andrew V. Samoilov wrote:

You can use ideas from attached file. I eliminated all tell() call and calculate position itself by adding current line length to some variable. Patched patchfs list works more well, but file size are bit smaller than truth. Copyout is ok.


I've used your ideas, but made it a bit simpler (there is no need for
a separate $cpos, $npos, $pos). Could you review this and check if it
works well on your system? If it works, could you apply/send to Pavel
by yourself?

Exellent!  I applied your patch.

Few questions about your patch, to be sure I didn't missed anything:

-use bytes;
 use strict;
-use POSIX;

Why did you want to this? I use bytes to count size in bytes, not
characters (in multibyte encodings char can be two or more bytes
wide). I don't remember why I used POSIX :)

I didn't know what is bytes good for.  This hunk reverted.


Index: patchfs.in
===================================================================
RCS file: /cvs/gnome/mc/vfs/extfs/patchfs.in,v
retrieving revision 1.8
diff -u -r1.8 patchfs.in
--- patchfs.in	18 Dec 2002 14:31:55 -0000	1.8
+++ patchfs.in	19 Dec 2002 16:42:06 -0000
@@ -47,7 +47,7 @@
 sub list
 {
     my ($archive)=(quotemeta $_[0]);
-    my ($state,$pos,$npos,$time);
+    my ($state,$pos,$len,$time);
     my ($f,$fsrc,$fdst,$prefix);
# use uid and gid from file
@@ -56,15 +56,14 @@
     import Date::Parse if ($parsedates);
# state==1 means diff contents, state==0 means comments
-    $state=1; $f="";
+    $state=1; $len=0; $f="";
     while (<I>) {
-	if (/^-{3} /) {
+	if (/^--- /) {
 	    # parse diff header
 	    if ($state==1) {
-		$npos=tell(I)-length;
-		printf "-rw-r--r-- 1 %s %s %d %s %s%s\n", $uid, $gid, $npos-$pos, datetime($time), $prefix, $f
+		printf "-rw-r--r-- 1 %s %s %d %s %s%s\n", $uid, $gid, $len, datetime($time), $prefix, $f
 		  if $f;
-		$pos=$npos;
+		$len=0;
 	    }
 	    $state=1;
@@ -110,15 +109,13 @@ } elsif ($state==1 && !/^([+\- ]|@@)/) {
 	    # start of comments, end of diff contents
-	    $npos=tell(I)-length;
-	    printf "-rw-r--r-- 1 %s %s %d %s %s%s\n", $uid, $gid, $npos-$pos, datetime($time), $prefix, $f
+	    printf "-rw-r--r-- 1 %s %s %d %s %s%s\n", $uid, $gid, $len, datetime($time), $prefix, $f
 	      if $f;
-	    $pos=$npos;
-	    $state=0;
+	    $state=$len=0;
 	}
+	$len+=length;
     }
-    $npos=tell(I);
-    printf "-rw-r--r-- 1 %s %s %d %s %s%s\n", $uid, $gid, $npos-$pos, datetime($time), $prefix, $f
+    printf "-rw-r--r-- 1 %s %s %d %s %s%s\n", $uid, $gid, $len, datetime($time), $prefix, $f
       if $f;
 }

Thanks a lot, Adam!

--
Regards,
Andrew V. Samoilov






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