Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
5e8fc30b
Commit
5e8fc30b
authored
Apr 14, 2002
by
zak@balfor.local
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Various improvements to the colspec fixup script
parent
1f14c6a0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
9 deletions
+33
-9
Docs/Support/colspec-fix.pl
Docs/Support/colspec-fix.pl
+33
-9
No files found.
Docs/Support/colspec-fix.pl
View file @
5e8fc30b
...
...
@@ -9,7 +9,7 @@
use
strict
;
my
$table_width
=
12.75
;
# cm
my
$gutter_width
=
0.
09
;
# c
m
my
$gutter_width
=
0.
55
;
# 2 m
m
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
";
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment