Skip to content

Commit

Permalink
implement hole block ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
mlschroe committed Mar 24, 2014
1 parent 6a652e9 commit 093f621
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions computeblocklists
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#
# a block is either a number or a range (start-end)
#
# TODO: instead of printing zeroes for each block in a hole use
# something like 0*num

use strict;

Expand Down Expand Up @@ -72,6 +70,8 @@ while (1) {
last unless defined $file;
chomp $file;
}
} else {
last;
}
my $n = $file;
$n =~ s/([\000-\037 %])/sprintf("%%%02X", ord($1))/ges;
Expand Down Expand Up @@ -138,6 +138,18 @@ while (1) {
}
}
$block = unpack('I', $block);
if (!$firstblock && defined($firstblock)) {
# last block was hole
if (!$block) {
$lastblock++; # count holes, 0-2 means three hole blocks
} else {
# switch back from 'hole mode' into normal mode
printf "-$lastblock" if defined($firstblock) && $firstblock != $lastblock;
print " $block";
$firstblock = $lastblock = $block;
}
next;
}
if (!$firstblock || $lastblock + 1 != $block) {
# start of a new run
printf "-$lastblock" if defined($firstblock) && $firstblock != $lastblock;
Expand Down

0 comments on commit 093f621

Please sign in to comment.