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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
b3a396b1
Commit
b3a396b1
authored
Feb 18, 2002
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added DocBook chapter split script.
parent
b0ae3c3b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
96 additions
and
0 deletions
+96
-0
Docs/Support/docbook-split
Docs/Support/docbook-split
+96
-0
No files found.
Docs/Support/docbook-split
0 → 100755
View file @
b3a396b1
#! /usr/local/bin/perl
# O'Reilly's Perl script to chop mysql.xml into separate ch/apps/index files.
# The indexes are actually not used, they're created straight from the xrefs.
use
strict
;
# Breaks the MySQL reference manual into chapters, appendices, and indexes.
my
$input_file
;
my
$directory
;
my
$chap_num
;
my
$app_letter
;
my
$start_text
;
my
$line
;
my
$input_file
;
my
$output_name
;
$input_file
=
"
mysql.xml
";
$directory
=
"
chaps_apps_index
";
$chap_num
=
1
;
# Start chapter numbers at one (there is no preface)
$app_letter
=
"
a
";
# Start appendix letters at "a"
$start_text
=
"";
$line
=
"";
open
(
INPUT_FILE
,
'
<
'
.
$input_file
)
or
die
"
Cannot open
$input_file
";
if
(
-
d
$directory
)
{
my
$unlinked
=
unlink
<
$directory
/*>
;
printf
(
Removed
"
%d files
\n
",
$unlinked
);
}
else
{
mkdir
$directory
or
die
"
Cannot make
$directory
subdirectory
";
}
while
(
1
)
{
# Terminating statement for loop.
exit
if
not
defined
$line
;
if
(
$line
=~
/(?:.*)(<chapter.*)/i
)
{
$start_text
=
$1
;
$output_name
=
&
make_chapter_name
(
$chap_num
);
$chap_num
++
;
&
process_file
("
chapter
");
}
elsif
(
$line
=~
/(?:.*)(<appendix.*)/i
)
{
$start_text
=
$1
;
$output_name
=
&
make_appendix_name
(
$app_letter
);
$app_letter
++
;
&
process_file
("
appendix
");
}
elsif
(
$line
=~
/(?:.*)(<index\s+id=")(.*?)(">.*)/i
)
{
$start_text
=
$1
.
$2
.
$3
;
$output_name
=
lc
(
$2
)
.
"
.xml
";
&
process_file
("
index
");
}
else
{
# Automatically skips junk in between chapters, appendices,
# and indexes.
$line
=
<
INPUT_FILE
>
;
}
}
sub
make_chapter_name
{
my
$num
=
shift
;
my
$name
=
"
ch
"
.
sprintf
("
%02d
",
$num
)
.
"
.xml
";
return
$name
;
}
sub
make_appendix_name
{
my
$letter
=
shift
;
my
$name
=
"
app
"
.
sprintf
("
%s
",
$letter
)
.
"
.xml
";
return
$name
;
}
sub
process_file
{
my
$marker
=
shift
;
open
(
OUTPUT_FILE
,
'
>
'
.
$directory
.
"
/
"
.
$output_name
)
or
die
"
Cannot open
$output_name
";
# Print whatever happened to appear at the end of the previous chapter.
print
OUTPUT_FILE
$start_text
.
"
\n
"
if
$start_text
;
while
(
1
)
{
$line
=
<
INPUT_FILE
>
;
exit
if
not
defined
$line
;
# Note: Anything after the terminating marker is lost, just like
# lines in between chapters.
if
(
$line
=~
/(.*<\/\s*$marker\s*>)/i
)
{
print
OUTPUT_FILE
$1
.
"
\n
"
if
$1
;
close
OUTPUT_FILE
;
return
;
}
print
OUTPUT_FILE
$line
;
}
}
exit
0
;
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