summaryrefslogtreecommitdiff
path: root/Docs/Support
diff options
context:
space:
mode:
authorunknown <arjen@co3064164-a.bitbike.com>2002-02-18 11:39:36 +1000
committerunknown <arjen@co3064164-a.bitbike.com>2002-02-18 11:39:36 +1000
commitb3a396b1ebed3e983122682aad19e46210bc435b (patch)
tree55758c748f041b963f958bed35374a95a52a8f4b /Docs/Support
parentb0ae3c3b4f5e6aa208e4af3511e89e44c566c805 (diff)
downloadmariadb-git-b3a396b1ebed3e983122682aad19e46210bc435b.tar.gz
Added DocBook chapter split script.
Diffstat (limited to 'Docs/Support')
-rwxr-xr-xDocs/Support/docbook-split96
1 files changed, 96 insertions, 0 deletions
diff --git a/Docs/Support/docbook-split b/Docs/Support/docbook-split
new file mode 100755
index 00000000000..62fcc866e04
--- /dev/null
+++ b/Docs/Support/docbook-split
@@ -0,0 +1,96 @@
+#! /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;