summaryrefslogtreecommitdiff
path: root/Docs/Support/colspec-fix.pl
diff options
context:
space:
mode:
authorunknown <zak@balfor.local>2002-04-14 09:28:06 +0200
committerunknown <zak@balfor.local>2002-04-14 09:28:06 +0200
commit0cdd756d1c2c6fe4273ed7518cf5d08cb0bbe764 (patch)
tree4245fe5b341ebe7763695eaef5a75aac8f8f7ccd /Docs/Support/colspec-fix.pl
parentc88744d306c224843fd28046a671a1672233503c (diff)
downloadmariadb-git-0cdd756d1c2c6fe4273ed7518cf5d08cb0bbe764.tar.gz
Various improvements to the colspec fixup script
Docs/Support/colspec-fix.pl: Various improvements, error checks and cleaning - Increased gutter size - Added check to ensure that total column % is not greater than 100% - Changed code to work with hacks to makeinfo - Ensure that total column width is less than max table width - Trim overly long end columns if needed
Diffstat (limited to 'Docs/Support/colspec-fix.pl')
-rwxr-xr-xDocs/Support/colspec-fix.pl42
1 files changed, 33 insertions, 9 deletions
diff --git a/Docs/Support/colspec-fix.pl b/Docs/Support/colspec-fix.pl
index 64269fdbe3a..bba0d27858f 100755
--- a/Docs/Support/colspec-fix.pl
+++ b/Docs/Support/colspec-fix.pl
@@ -9,7 +9,7 @@
use strict;
my $table_width = 12.75; # cm
-my $gutter_width = 0.09; # cm
+my $gutter_width = 0.55; # 2 mm
my $str = join '', <>;
@@ -28,12 +28,17 @@ sub msg {
}
sub rel2abs {
- my $str = shift;
- my $colnum = 1;
+ my $str = shift;
+ my $colnum = 1;
- my @widths = ();
- my $total = 0;
- my $output = '';
+ my @widths = ();
+ my $total = 0;
+ my $output = '';
+
+ my $gutters;
+ my $content_width;
+ my $total_width;
+ my @num_cache;
$str =~ /^(\s+)/;
my $ws = $1;
@@ -43,12 +48,31 @@ sub rel2abs {
push @widths, $1;
}
- my $unit = ($table_width - ($#widths * $gutter_width)) / ($total);
+ msg("!!! WARNING: Total Percent > 100%: $total%") if $total > 100;
+
+ if (! $total) {
+ die 'Something bad has happened - the script believes that there are no columns';
+ }
+
+ $gutters = $#widths * $gutter_width;
+ $content_width = $table_width - $gutters;
+ # Don't forget that $#... is the last offset not the count
foreach (@widths) {
- $output .= $ws . '<colspec colnum="'. $colnum .'" colwidth="'. sprintf ("%0.2f", $_ * $unit) .'cm" />' . "\n";
+ my $temp = sprintf ("%0.2f", $_/100 * $content_width);
+ $total_width += $temp;
+
+ if ($total_width > $content_width) {
+ $temp -= $total_width - $content_width;
+ msg("!!! WARNING: Column width reduced from " .
+ ($temp + ($total_width - $content_width)) . " to $temp !!!");
+ $total_width -= $total_width - $content_width;
+ }
+
+ $output .= $ws . '<colspec colnum="'. $colnum .'" colwidth="'. $temp .'cm" />' . "\n";
++$colnum;
+ push @num_cache, $temp;
}
-
+
return $output . "\n$ws";
}