[Po4a-devel]Sgml.pm: Issue an error if nsgmls is missing

Martin Quinson martin.quinson@loria.fr
Thu, 26 May 2005 09:36:56 +0200


--vOmOzSkFvhd7u8Ms
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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:
>=20
> When the nsgmls parser is missing po4a-translate just reports success=20
> and that the documentation is translated to 100% when in fact it does=20
> nothing. This could be pretty confusing. Reporting that nsgmls is=20
> missing would be better.
>=20
> So I propose this patch to detect that nsgmls is missing and issue an=20
> error. The trick here is we run it on an empty Sgml document and check=20
> that it returned success which should ensure that it works, etc. The=20
> 'document' in question uses DocBook and that may be an issue if all the=
=20
> user wants to use if DebianDoc or some other Sgml document type. Also=20
> the check is performed in initialize() and this may not be the best place.
>=20
> Alternate solutions would be to:
>  * we could look for nsgmls in $PATH manually and issue an error if we=20
> could not find it.
>  * we could check nsgmls' return code after the close(IN) in parse().=20
> What makes this tricky is the way we invoke nsgmls but I think it would=
=20
> be feasible anyway.
>=20
> So let me know which approach seems best.
>=20
> Changelog:
>=20
>  * lib/Locale/Po4a/Sgml.pm
>=20
>    Francois Gouget <fgouget@codeweavers.com>
>    Check for nsgmls and issue an error if it is missing.
>=20
> --=20
> Francois Gouget
> fgouget@codeweavers.com
>=20

> Index: lib/Locale/Po4a/Sgml.pm
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> 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 =3D undef; # the '<?xml ...=20
>  sub initialize {
>      my $self =3D shift;
>      my %options =3D @_;
> -   =20
> +
> +    # Check that nsgmls is installed
> +    my $cmd=3D"echo '<!doctype article PUBLIC \"-//OASIS//DTD DocBook V3=
=2E1//EN\"><article><para></para></article>' | nsgmls 2>&1";
> +    my $output=3D`$cmd`;
> +    if ($? !=3D 0)
> +    {
> +	die "po4a::sgml: nsgmls is missing or non-functional:\n$output";
> +    }
> +
>      $self->{options}{'translate'}=3D'';
>      $self->{options}{'section'}=3D'';
>      $self->{options}{'indent'}=3D'';


--vOmOzSkFvhd7u8Ms
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iD8DBQFClXyYIiC/MeFF8zQRAqMHAJ4rsOKm95WwghStq9I3Km6VNWuJ+gCaAuQV
SX8JFSz70hyScIj9RtpdSQ8=
=w1+q
-----END PGP SIGNATURE-----

--vOmOzSkFvhd7u8Ms--