|
Packit |
e4b6da |
# vim:sw=4 sta et showmatch
|
|
Packit |
e4b6da |
|
|
Packit |
e4b6da |
# docbook2X.pl - script to invoke man page or Texinfo conversion
|
|
Packit |
e4b6da |
# (See docbook2X documentation for details)
|
|
Packit |
e4b6da |
#
|
|
Packit |
e4b6da |
# (C) 2003-2004 Steve Cheng <stevecheng@users.sourceforge.net>
|
|
Packit |
e4b6da |
#
|
|
Packit |
e4b6da |
# See the COPYING file in the docbook2X distribution
|
|
Packit |
e4b6da |
# for the copyright status of this software.
|
|
Packit |
e4b6da |
#
|
|
Packit |
e4b6da |
# Note: docbook2X.pl does not run by itself!
|
|
Packit |
e4b6da |
# It must be configured by including a config.pl file
|
|
Packit |
e4b6da |
# which is done when building docbook2X.
|
|
Packit |
e4b6da |
|
|
Packit |
e4b6da |
use strict;
|
|
Packit |
e4b6da |
|
|
Packit |
e4b6da |
my @xsltproc_opts;
|
|
Packit |
e4b6da |
my @xml_opts;
|
|
Packit |
e4b6da |
|
|
Packit |
e4b6da |
while(my $opt = shift @ARGV)
|
|
Packit |
e4b6da |
{
|
|
Packit |
e4b6da |
if($opt eq '--help') {
|
|
Packit |
e4b6da |
print_help();
|
|
Packit |
e4b6da |
exit(0);
|
|
Packit |
e4b6da |
}
|
|
Packit |
e4b6da |
elsif($opt eq '--version') {
|
|
Packit |
e4b6da |
print_version();
|
|
Packit |
e4b6da |
exit(0);
|
|
Packit |
e4b6da |
}
|
|
Packit |
e4b6da |
elsif($opt =~ /^--((sym-?|so-?|no-?)links|no-groff-extensions|compatible|list-files|to-stdout|info|plaintext)$/) {
|
|
Packit |
e4b6da |
push @xml_opts, $opt;
|
|
Packit |
e4b6da |
}
|
|
Packit |
e4b6da |
elsif($opt =~ /^--(encoding|utf8trans-(program|map)|iconv-program)/) {
|
|
Packit |
e4b6da |
push @xml_opts, $opt;
|
|
Packit |
e4b6da |
push @xml_opts, shift(@ARGV) if $opt !~ /=/;
|
|
Packit |
e4b6da |
}
|
|
Packit |
e4b6da |
elsif($opt eq '--output') {
|
|
Packit |
e4b6da |
# This option is ineffectual.
|
|
Packit |
e4b6da |
shift @ARGV if $opt !~ /=/; # Get rid of filename argument also
|
|
Packit |
e4b6da |
}
|
|
Packit |
e4b6da |
elsif($opt eq '-o') {
|
|
Packit |
e4b6da |
# Same as --output.
|
|
Packit |
e4b6da |
shift @ARGV;
|
|
Packit |
e4b6da |
}
|
|
Packit |
e4b6da |
else {
|
|
Packit |
e4b6da |
push @xsltproc_opts, $opt;
|
|
Packit |
e4b6da |
}
|
|
Packit |
e4b6da |
}
|
|
Packit |
e4b6da |
|
|
Packit |
e4b6da |
if(!grep /^-s|--stylesheet$/, @xsltproc_opts) {
|
|
Packit |
e4b6da |
unshift @xsltproc_opts, ('-s', $CONVERSION_TYPE);
|
|
Packit |
e4b6da |
}
|
|
Packit |
e4b6da |
|
|
Packit |
e4b6da |
unshift @xsltproc_opts, $db2x_config{'db2x_xsltproc-program'};
|
|
Packit |
e4b6da |
|
|
Packit |
e4b6da |
if($CONVERSION_TYPE eq 'texi') {
|
|
Packit |
e4b6da |
unshift @xml_opts, $db2x_config{'db2x_texixml-program'};
|
|
Packit |
e4b6da |
} elsif($CONVERSION_TYPE eq 'man') {
|
|
Packit |
e4b6da |
unshift @xml_opts, $db2x_config{'db2x_manxml-program'};
|
|
Packit |
e4b6da |
}
|
|
Packit |
e4b6da |
|
|
Packit |
e4b6da |
exec(
|
|
Packit |
e4b6da |
shell_quote(@xsltproc_opts) .
|
|
Packit |
e4b6da |
' | ' .
|
|
Packit |
e4b6da |
shell_quote(@xml_opts));
|
|
Packit |
e4b6da |
|
|
Packit |
e4b6da |
|
|
Packit |
e4b6da |
sub shell_quote
|
|
Packit |
e4b6da |
{
|
|
Packit |
e4b6da |
join(' ', map { my $u = $_;
|
|
Packit |
e4b6da |
$u =~ s#([\$`"\\\n])#\\$1#g;
|
|
Packit |
e4b6da |
'"' . $u . '"' } @_);
|
|
Packit |
e4b6da |
}
|
|
Packit |
e4b6da |
|
|
Packit |
e4b6da |
|
|
Packit |
e4b6da |
|
|
Packit |
e4b6da |
|
|
Packit |
e4b6da |
|
|
Packit |
e4b6da |
sub print_help {
|
|
Packit |
e4b6da |
print "Usage: $0 [OPTION]... XML-FILE\n";
|
|
Packit |
e4b6da |
|
|
Packit |
e4b6da |
if($CONVERSION_TYPE eq 'texi') {
|
|
Packit |
e4b6da |
print "Convert DocBook XML documents to Texinfo\n\n";
|
|
Packit |
e4b6da |
} elsif($CONVERSION_TYPE eq 'man') {
|
|
Packit |
e4b6da |
print "Convert DocBook XML documents to man pages\n\n";
|
|
Packit |
e4b6da |
}
|
|
Packit |
e4b6da |
print "See docbook2X(1) for more details about this program.\n";
|
|
Packit |
e4b6da |
}
|
|
Packit |
e4b6da |
|
|
Packit |
e4b6da |
sub print_version
|
|
Packit |
e4b6da |
{
|
|
Packit |
e4b6da |
print "$0 (part of docbook2X " .
|
|
Packit |
e4b6da |
$db2x_config{'docbook2X-version'} . ")\n";
|
|
Packit |
e4b6da |
print <<'end';
|
|
Packit |
e4b6da |
$Revision: 1.12 $ $Date: 2006/04/14 17:29:04 $
|
|
Packit |
e4b6da |
<URL:http://docbook2x.sourceforge.net/>
|
|
Packit |
e4b6da |
|
|
Packit |
e4b6da |
Copyright (C) 2003-2004 Steve Cheng
|
|
Packit |
e4b6da |
This is free software; see the source for copying conditions. There is NO
|
|
Packit |
e4b6da |
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
Packit |
e4b6da |
end
|
|
Packit |
e4b6da |
}
|
|
Packit |
e4b6da |
|