mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 12:56:51 +03:00
* extfs/patchfs.in: Fix patch size calculation. Use bytes to
count size in bytes, not characters (in multibyte encodings char can be two or more bytes wide).
This commit is contained in:
parent
1df0641954
commit
b6aa32d9b2
@ -1,3 +1,9 @@
|
|||||||
|
2002-12-19 Adam Byrtek <alpha@debian.org>
|
||||||
|
|
||||||
|
* extfs/patchfs.in: Fix patch size calculation. Use bytes to
|
||||||
|
count size in bytes, not characters (in multibyte encodings char
|
||||||
|
can be two or more bytes wide).
|
||||||
|
|
||||||
2002-12-19 Andrew V. Samoilov <sav@bcs.zp.ua>
|
2002-12-19 Andrew V. Samoilov <sav@bcs.zp.ua>
|
||||||
|
|
||||||
* extfs/patchfs.in: Don't rely on tell() - it doesn't always
|
* extfs/patchfs.in: Don't rely on tell() - it doesn't always
|
||||||
|
@ -4,7 +4,9 @@
|
|||||||
#
|
#
|
||||||
# extfs to handle patches in unified diff format
|
# extfs to handle patches in unified diff format
|
||||||
|
|
||||||
|
use bytes;
|
||||||
use strict;
|
use strict;
|
||||||
|
use POSIX;
|
||||||
|
|
||||||
# standard binaries
|
# standard binaries
|
||||||
my $bzip = "bzip2";
|
my $bzip = "bzip2";
|
||||||
@ -45,7 +47,7 @@ sub error
|
|||||||
sub list
|
sub list
|
||||||
{
|
{
|
||||||
my ($archive)=(quotemeta $_[0]);
|
my ($archive)=(quotemeta $_[0]);
|
||||||
my ($state,$pos,$npos,$time);
|
my ($state,$pos,$len,$time);
|
||||||
my ($f,$fsrc,$fdst,$prefix);
|
my ($f,$fsrc,$fdst,$prefix);
|
||||||
|
|
||||||
# use uid and gid from file
|
# use uid and gid from file
|
||||||
@ -54,17 +56,14 @@ sub list
|
|||||||
import Date::Parse if ($parsedates);
|
import Date::Parse if ($parsedates);
|
||||||
|
|
||||||
# state==1 means diff contents, state==0 means comments
|
# state==1 means diff contents, state==0 means comments
|
||||||
$state = 1; $f = '';
|
$state=1; $len=0; $f='';
|
||||||
my $cpos = 0;
|
|
||||||
while (<I>) {
|
while (<I>) {
|
||||||
$cpos += length;
|
|
||||||
if (/^--- /) {
|
if (/^--- /) {
|
||||||
# parse diff header
|
# parse diff header
|
||||||
if ($state==1) {
|
if ($state==1) {
|
||||||
$npos = $cpos - length;
|
printf "-rw-r--r-- 1 %s %s %d %s %s%s\n", $uid, $gid, $len, datetime($time), $prefix, $f
|
||||||
printf "-rw-r--r-- 1 %s %s %d %s %s%s\n", $uid, $gid, $npos-$pos, datetime($time), $prefix, $f
|
|
||||||
if $f;
|
if $f;
|
||||||
$pos=$npos;
|
$len=0;
|
||||||
}
|
}
|
||||||
$state=1;
|
$state=1;
|
||||||
|
|
||||||
@ -110,15 +109,13 @@ sub list
|
|||||||
|
|
||||||
} elsif ($state==1 && !/^([+\- \n]|@@)/) {
|
} elsif ($state==1 && !/^([+\- \n]|@@)/) {
|
||||||
# start of comments, end of diff contents
|
# start of comments, end of diff contents
|
||||||
$npos = $cpos - length;
|
printf "-rw-r--r-- 1 %s %s %d %s %s%s\n", $uid, $gid, $len, datetime($time), $prefix, $f
|
||||||
printf "-rw-r--r-- 1 %s %s %d %s %s%s\n", $uid, $gid, $npos-$pos, datetime($time), $prefix, $f
|
|
||||||
if $f;
|
if $f;
|
||||||
$pos=$npos;
|
$state=$len=0;
|
||||||
$state=0;
|
|
||||||
}
|
}
|
||||||
|
$len+=length;
|
||||||
}
|
}
|
||||||
$npos = $cpos;
|
printf "-rw-r--r-- 1 %s %s %d %s %s%s\n", $uid, $gid, $len, datetime($time), $prefix, $f
|
||||||
printf "-rw-r--r-- 1 %s %s %d %s %s%s\n", $uid, $gid, $npos-$pos, datetime($time), $prefix, $f
|
|
||||||
if $f;
|
if $f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user