From: Adam Di Carlo Date: Mon, 17 Mar 2003 02:08:11 +0000 (+0000) Subject: Use the English module because we're using PREMATCH and POSTMATCH; X-Git-Tag: release/1.79.1~6^2~4746 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6f77abca4045fc6de074a856ecf19eecaf4880be;p=docbook-dsssl Use the English module because we're using PREMATCH and POSTMATCH; this is the bug that broke docbook-dsssl-doc 1.78. Use File::Basename so that the output dir can be independant of the input (needed for debugging). Die if we can't open a file for reading or writing with an appropriate error message. Implement -D switch for debugging messages. --- diff --git a/cvstools/dsl2man b/cvstools/dsl2man index 0f8a05ee9..cb78a1d6d 100755 --- a/cvstools/dsl2man +++ b/cvstools/dsl2man @@ -2,12 +2,13 @@ use Text::DelimMatch; use Getopt::Std; +use File::Basename; +use English; # call \share\dsssl\bin\dsl2man -i lib -d ..\docsrc\libref dblib.dsl - -$usage = "Usage: $0 -i idprefix -d dir [ file ... ]\n"; -die $usage if ! getopts('i:d:'); +$usage = "Usage: $0 -i idprefix -d dir [-D] [ file ... ]\n"; +die $usage if ! getopts('i:d:D'); $pubid = "-//OASIS//DTD DocBook V3.1//EN"; @@ -19,9 +20,15 @@ $DOCINFO = ""; %FFUNC = (); %FFILE = (); -$idprefix = $opt_i || die $usage; +$idprefix = $opt_i || die $usage; # idprefix doesn't seem to be implemented $outputdir = $opt_d || die $usage; +sub debugmsg { + if ( $opt_D ) { + warn('D: ' . shift() . "\n"); + } +} + @FILES = @ARGV; if (!@FILES) { opendir (DIR, "."); @@ -32,19 +39,25 @@ if (!@FILES) { } } -open (SGM, ">$outputdir/refentry.sgm"); +open(SGM, ">$outputdir/refentry.sgm") or + die("cannot write to $outputdir/refentry.sgm: $!\n"); $inref = 0; while (@FILES) { $file = shift @FILES; ($reference = $file) =~ s/\.dsl/\.sgm/; - open (REF, ">$outputdir/$reference"); + $reference = basename($file); + open (REF, ">$outputdir/$reference") or + die("cannot write to $outputdir/$reference: $!\n"); - open (F, $file); + open (F, "<$file") or + die("cannot read $file: $!\n"); read (F, $_, -s $file); close (F); + debugmsg("reading from $file, writing to $outputdir/$reference"); + if (/;; DOCINFO(.*?);; \/DOCINFO/s) { $_ = $PREMATCH . $POSTMATCH; $DOCINFO = $1; @@ -53,13 +66,14 @@ while (@FILES) { if ($DOCINFO) { print REF "$outputdir/docinfo.sgm"); + open (INFO, ">$outputdir/docinfo.sgm") or + die("error writing to $outputdir/docinfo.sgm: $!\n"); } else { print REF "match($_); $_ = $post; @@ -80,7 +94,7 @@ while (@FILES) { if ($match =~ /^\(define /) { my($function) = $match; my($funcmatch) = new Text::DelimMatch '\(', '\)'; - my($func) = $'; + my($func) = $'; # ' if ($func =~ /^\(/) { $func = $funcmatch->match($func); @@ -162,7 +176,8 @@ while (@FILES) { print SGM "\n\n" if $inref; close (SGM); -open (ENT, ">$outputdir/refentry.ent"); +open (ENT, ">$outputdir/refentry.ent") or + die("cannot write to $outputdir/refentry.ent: $!\n"); foreach $func (keys %FFUNC) { my($refname, $synopsis) = ("", ""); @@ -195,7 +210,8 @@ foreach $func (keys %FFUNC) { print ENT "\n"; - open (F, ">$outputdir/$html_filename.sgm"); + open (F, ">$outputdir/$html_filename.sgm") or + die("error writing to $outputdir/$html_filename.sgm: $!\n"); print F <