logarithmic repeat markers multiply by 10
authorMischa POSLAWSKY <perl@shiar.org>
Mon, 21 Nov 2022 19:40:41 +0000 (20:40 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Tue, 22 Nov 2022 23:06:47 +0000 (00:06 +0100)
Quick solution to make it at least somewhat useful.

barcat
t/t2258-repeat_markers_--mark=:/1.out
t/t2259-log_axis.in [new symlink]
t/t2259-log_axis_-e_--markers=+/1.out [new file with mode: 0644]

diff --git a/barcat b/barcat
index 1ffdeda9097523dfcbc6fa9e224899df7e84c6b9..431ed401489a1aa40aa9a1315966b2422734a2c5 100755 (executable)
--- a/barcat
+++ b/barcat
@@ -263,10 +263,10 @@ if ($opt{markers} and $size > 0) {
                                return $func;
                        }
                        elsif ($func =~ /\A\/($float)\z/) {
-                               my @range = $1;
-                               #TODO log
-                               for (my $next = $1; $next < $maxval; $next += $range[0]) {
-                                       push @range, $next;
+                               my @range = my $multiple = my $next = $1;
+                               while ($next < $maxval) {
+                                       $multiple *= 10 if $opt{log};
+                                       push @range, $next += $multiple;
                                }
                                return @range;
                        }
index 369ae19642377658f8700761dcf34501f391c813..c23950d9bd57546cb4dc86b042ab492b99621716 100644 (file)
@@ -6,4 +6,4 @@
 6 ---:---:---:---:----:---:
 7 ---:---:---:---:----:---:---:-
 8 ---:---:---:---:----:---:---:---:-
-9 ---:---:---:---:----:---:---:---:-----
+9 ---:---:---:---:----:---:---:---:----:
diff --git a/t/t2259-log_axis.in b/t/t2259-log_axis.in
new file mode 120000 (symlink)
index 0000000..655505d
--- /dev/null
@@ -0,0 +1 @@
+t1260-powers_of_ten.in
\ No newline at end of file
diff --git a/t/t2259-log_axis_-e_--markers=+/1.out b/t/t2259-log_axis_-e_--markers=+/1.out
new file mode 100644 (file)
index 0000000..4cd6f7c
--- /dev/null
@@ -0,0 +1,7 @@
+     1 
+    10 ----+-
+   100 ----+-----+
+  1000 ----+-----+----+-
+   1e4 ----+-----+----+-----+
+100000 ----+-----+----+-----+----+-
+   1e6 ----+-----+----+-----+----+-----+