Well, I don't really like this one, to be frank. My opinion is that it would
be better to test it with the dtd which the user wants to use. So, you'll
have to make a function doing so with the doctype passed as argument, and
then call it from parse_file(), just before the set_tags_kind calls.
Bye, Mt.
On Wed, May 25, 2005 at 03:09:00AM +0200, Francois Gouget wrote:
When the nsgmls parser is missing po4a-translate just reports success
and that the documentation is translated to 100% when in fact it does
nothing. This could be pretty confusing. Reporting that nsgmls is
missing would be better.
So I propose this patch to detect that nsgmls is missing and issue an
error. The trick here is we run it on an empty Sgml document and check
that it returned success which should ensure that it works, etc. The
'document' in question uses DocBook and that may be an issue if all the
user wants to use if DebianDoc or some other Sgml document type. Also
the check is performed in initialize() and this may not be the best place.
Alternate solutions would be to:
* we could look for nsgmls in $PATH manually and issue an error if we
could not find it.
* we could check nsgmls' return code after the close(IN) in parse().
What makes this tricky is the way we invoke nsgmls but I think it would
be feasible anyway.
So let me know which approach seems best.
Changelog:
* lib/Locale/Po4a/Sgml.pm
Francois Gouget <fgouget(a)codeweavers.com>
Check for nsgmls and issue an error if it is missing.
--
Francois Gouget
fgouget(a)codeweavers.com
Index: lib/Locale/Po4a/Sgml.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/Sgml.pm,v
retrieving revision 1.55
diff -u -p -r1.55 Sgml.pm
--- lib/Locale/Po4a/Sgml.pm 21 May 2005 18:42:21 -0000 1.55
+++ lib/Locale/Po4a/Sgml.pm 25 May 2005 01:04:39 -0000
@@ -195,7 +195,15 @@ my $xmlprolog = undef; # the '<?xml ...
sub initialize {
my $self = shift;
my %options = @_;
-
+
+ # Check that nsgmls is installed
+ my $cmd="echo '<!doctype article PUBLIC \"-//OASIS//DTD DocBook
V3.1//EN\"><article><para></para></article>' | nsgmls
2>&1";
+ my $output=`$cmd`;
+ if ($? != 0)
+ {
+ die "po4a::sgml: nsgmls is missing or non-functional:\n$output";
+ }
+
$self->{options}{'translate'}='';
$self->{options}{'section'}='';
$self->{options}{'indent'}='';