From f836434708d146fae6e9d10c3d51d0640c06b414 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Tue, 15 Nov 2022 18:23:46 +0100 Subject: [PATCH] reserve minimal length for -H formatting Without a more expensive calculation, assume regular results of 3 digits and a unit, without sign and exponent for which the reserved amount would still be insufficient. --- barcat | 2 +- t/t1401-magnitude_-H.out | 2 +- t/t1403-precision_-H.out | 2 +- t/t1404-minitude_-H.out | 48 +++++++++---------- t/t1422-all_the_time_--sexagesimal_-H_-sC.out | 4 +- t/t2201-ascii_-aHl7.out | 6 +-- 6 files changed, 32 insertions(+), 32 deletions(-) diff --git a/barcat b/barcat index fb5c1ab..426053e 100755 --- a/barcat +++ b/barcat @@ -116,7 +116,7 @@ $opt{trim} *= $opt{width} / 100 if $opt{trimpct}; $opt{units} = [split //, ' kMGTPEZYyzafpn'.($opt{ascii} ? 'u' : 'μ').'m'] if $opt{'human-readable'}; $opt{anchor} //= qr/\A/; -$opt{'value-length'} = 6 if $opt{units}; +$opt{'value-length'} = 4 if $opt{units}; $opt{'value-length'} = 1 if $opt{unmodified}; $opt{'signal-stat'} //= exists $SIG{INFO} ? 'INFO' : 'QUIT'; $opt{markers} //= '=avg >31.73v <68.27v +50v |0'; diff --git a/t/t1401-magnitude_-H.out b/t/t1401-magnitude_-H.out index bbe87ab..badb446 100644 --- a/t/t1401-magnitude_-H.out +++ b/t/t1401-magnitude_-H.out @@ -17,4 +17,4 @@ 1.7M 18M 190M =-- -2.0G =-------------------------------- +2.0G =---------------------------------- diff --git a/t/t1403-precision_-H.out b/t/t1403-precision_-H.out index da5f9ae..97fd1ef 100644 --- a/t/t1403-precision_-H.out +++ b/t/t1403-precision_-H.out @@ -4,7 +4,7 @@ 2.0k 2.0k 2.1k -200k -=------------------------------- +200k --=-------------------------------- 0 160z -150z diff --git a/t/t1404-minitude_-H.out b/t/t1404-minitude_-H.out index 0c6388b..78221cc 100644 --- a/t/t1404-minitude_-H.out +++ b/t/t1404-minitude_-H.out @@ -1,26 +1,26 @@ - -10p ----------------------------=+| --200p ----------------------------=+| --3.0n ----------------------------=+| - -40n ----------------------------=+| --500n ----------------------------=+| --6.0μ ----------------------------=+| - -70μ ----------------------------=+| --800μ ----------------------------=+| --9.0m ----------------------------=+| --100m ----------------------------=+| --1.1 ----------------------------=+| - -12 ----------------------------=+| --130 ----------------------------=+| --1.4k ----------------------------=+| - -15k ----------------------------=+| --160k ----------------------------=+| --1.7M ----------------------------=+| - -18M ----------------------------=+| --190M ---------------------------- + -10p ------------------------------=+| +-200p ------------------------------=+| +-3.0n ------------------------------=+| + -40n ------------------------------=+| +-500n ------------------------------=+| +-6.0μ ------------------------------=+| + -70μ ------------------------------=+| +-800μ ------------------------------=+| +-9.0m ------------------------------=+| +-100m ------------------------------=+| +-1.1 ------------------------------=+| + -12 ------------------------------=+| +-130 ------------------------------=+| +-1.4k ------------------------------=+| + -15k ------------------------------=+| +-160k ------------------------------=+| +-1.7M ------------------------------=+| + -18M ------------------------------=+| +-190M ------------------------------ -2.0G --999k - ----------------------------=+| --1.0M + ----------------------------=+| --1.0M ----------------------------=+| --1.0M - ----------------------------=+| --1.1M + ----------------------------=+| +-999k - ------------------------------=+| +-1.0M + ------------------------------=+| +-1.0M ------------------------------=+| +-1.0M - ------------------------------=+| +-1.1M + ------------------------------=+| diff --git a/t/t1422-all_the_time_--sexagesimal_-H_-sC.out b/t/t1422-all_the_time_--sexagesimal_-H_-sC.out index 9ba7ac2..cc1d16b 100644 --- a/t/t1422-all_the_time_--sexagesimal_-H_-sC.out +++ b/t/t1422-all_the_time_--sexagesimal_-H_-sC.out @@ -1,6 +1,6 @@ 0:00:00 - -24:00:00 ---=-- -111:11:11 long ---=------------------------ +24:00:00 ---=--- +111:11:11 long ---=-------------------------- -0:00:00 - -0:00:01 - diff --git a/t/t2201-ascii_-aHl7.out b/t/t2201-ascii_-aHl7.out index 31e871d..6110693 100644 --- a/t/t2201-ascii_-aHl7.out +++ b/t/t2201-ascii_-aHl7.out @@ -1,5 +1,5 @@ -123u micro ------------<-=-+--------| -100m long> ------------<-=-+--------|- - -1 ------------<-=-+ +123u micro -------------<--=+---------| +100m long> -------------<--=+---------|- + -1 -------------<--=+- -2 --------- -3 -- 2.30.0