ranges in nl output possible

master
Vincent Schweiger 2024-01-28 16:50:43 +01:00
parent 12f0643a83
commit 1e9c12e424
Signed by: vincent
GPG Key ID: F83B0F0E383CC23F
1 changed files with 31 additions and 6 deletions

View File

@ -89,16 +89,41 @@ foreach my $item (keys %seen) {
@uniq = sort { GA->comp($a, $b) } @uniq;
# my @uniq = sort gw_comp keys %seen;
if (@uniq) {
if ($newlines) {
foreach my $item (@uniq) {
print $item->str, "\n";
if ($newlines) {
if ($ranges) {
while (my $item = shift @uniq) {
my $from = $item;
my $to = $item;
my @copy = @uniq;
foreach my $next (@copy) {
if ($next->{top} == $to->{top} and $next->{middle} == $to->{middle}) {
if ($next->{bottom} == ($to->{bottom} + 1)) {
$to = $next;
shift @uniq;
}
}
}
if ($from != $to) {
print "$from->{top}/$from->{middle}/[$from->{bottom}-$to->{bottom}]\n";
} else {
print $from->str, "\n";
}
}
} else {
foreach my $item (@uniq) {
print $item->str, " ";
print $item->str, "\n";
}
}
} else {
if ($ranges) {
print "ranges not implemented for non-nl output\n";
}
foreach my $item (@uniq) {
print $item->str, " ";
}
if (@uniq) {
print "\n";
}
}