parse_args();
sub dump_args () {
- my @oargs;
- my @ounders;
- my @opoints;
+ my @out;
+ my $lmax= 78;
+ my $xpos= -1;
+
+ lprintf("args:");
+ lprintf("");
+
+ my $writeout= sub {
+ foreach my $oi (0..2) {
+ lprintf(" %s",
+ join(($oi==1 ? '|' : ' '),
+ @{ $out[$oi] }));
+ }
+ };
+ my $push= sub {
+ $xpos += 1 + length($_[0]);
+ if ($xpos >= $lmax) {
+ foreach my $oi (0..2) {
+ push @{ $out[$oi] },
+ ($oi==1 && $_[$oi] =~ m/^\-/ ? '-' : '');
+ }
+ $writeout->();
+ lprintf('');
+ @out= ();
+ $xpos= length($_[0]);
+ }
+ foreach my $oi (0..2) {
+ push @{ $out[$oi] }, $_[$oi];
+ }
+ };
+
foreach (my $i=0; $i<@cp; $i++) {
my $cp= $cp[$i];
my @iargs= @{ $cp->{Args} };
if (@iargs && $iargs[0] =~ m/^\+$numre$/) {
my $relmove= shift @iargs;
- push @oargs, $relmove;
- my $spc= ' 'x length $relmove;;
- push @ounders, '-'x length $relmove;;
- push @opoints, $spc;
+ $push->($relmove,
+ '-'x length $relmove,
+ ' 'x length $relmove);
} elsif ($i) {
- push @oargs, ' ';
- push @ounders, '-';
- push @opoints, ' ';
+ $push->(' ',
+ '-',
+ ' ');
}
my $ipoint= "#$i";
my $lip= $lipoint;
my $l= $lipoint > length($iargs) ? $lipoint : length($iargs);
- push @oargs, sprintf "%-*s", $l, $iargs;
- push @ounders, ' 'x $l;
-
my $pad= int(($l-$lipoint)/2);
- push @opoints, (' 'x $pad). $ipoint. (' ' x ($l-$lipoint-$pad));
+
+ $push->((sprintf "%-*s", $l, $iargs),
+ ' 'x $l,
+ (' 'x $pad). $ipoint. (' ' x ($l-$lipoint-$pad)));
}
- lprintf("args: %s", join ' ', @oargs);
- lprintf(" %s", join '|', @ounders);
- lprintf(" %s", join ' ', @opoints);
+ $writeout->();
}
dump_args();