git.shiar.nl
/
barcat.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
minor code cleanup for human formatting
[barcat.git]
/
barcat
diff --git
a/barcat
b/barcat
index 40f332d980ed308a3b41b45a161a662e5af63bf9..00a21739671c0a4d00df95517912299cdd472757 100755
(executable)
--- a/
barcat
+++ b/
barcat
@@
-56,7
+56,7
@@
GetOptions(\%opt,
$opt{width} ||= $ENV{COLUMNS} || 80;
$opt{color} //= -t *STDOUT; # enable on tty
$opt{trim} *= $opt{width} / 100 if $opt{trimpct};
$opt{width} ||= $ENV{COLUMNS} || 80;
$opt{color} //= -t *STDOUT; # enable on tty
$opt{trim} *= $opt{width} / 100 if $opt{trimpct};
-$opt{units} =
$opt{'human-readable'} && ['', qw( k M G T P E Z Y y z a f p n μ m )]
;
+$opt{units} =
[split //, ' kMGTPEZYyzafpnμm'] if $opt{'human-readable'}
;
$opt{anchor} //= qr/\A/;
$opt{'value-length'} = 6 if $opt{units};
$opt{anchor} //= qr/\A/;
$opt{'value-length'} = 6 if $opt{units};
@@
-136,7
+136,7
@@
sub sival {
sprintf('%*.*f%*s',
$float ? 5 : 3, $float, # length and tenths
$_[0] / 1000 ** $unit, # number
sprintf('%*.*f%*s',
$float ? 5 : 3, $float, # length and tenths
$_[0] / 1000 ** $unit, # number
- $float ?
1
: 3, # unit size
+ $float ?
0
: 3, # unit size
$#{$opt{units}} >> 1 < abs $unit ? "e$unit" : $opt{units}->[$unit]
);
}
$#{$opt{units}} >> 1 < abs $unit ? "e$unit" : $opt{units}->[$unit]
);
}