--- libsgmls-perl-1.03ii.orig/sgmlspl.pl +++ libsgmls-perl-1.03ii/sgmlspl.pl @@ -238,7 +238,7 @@ package main; $ARGV = shift; -unless ($ARGV eq '' || do $ARGV) { +unless ($ARGV eq '' || do 'sgmlspl-specs/' . $ARGV || do $ARGV) { if (!-e $ARGV) { die "FATAL: $ARGV does not exist.\n"; } elsif (!-r $ARGV) { --- libsgmls-perl-1.03ii.orig/Refs.pm +++ libsgmls-perl-1.03ii/Refs.pm @@ -2,11 +2,11 @@ use Carp; -$version = '$Id: Refs.pm,v 1.5 1995/12/03 21:28:36 david Exp $'; +$version = '$Id: Refs.pm,v 1.1 1999/10/26 19:30:45 ardo Exp $'; =head1 NAME -SGMLS::Refs +SGMLS::Refs - Forward reference handling =head1 SYNOPSIS --- libsgmls-perl-1.03ii.orig/Output.pm +++ libsgmls-perl-1.03ii/Output.pm @@ -5,7 +5,7 @@ @ISA = Exporter; @EXPORT = qw(output push_output pop_output); -$version = '$Id: Output.pm,v 1.6 1995/12/05 12:21:51 david Exp $'; +$version = '$Id: Output.pm,v 1.1 1999/10/26 19:30:45 ardo Exp $'; =head1 NAME --- libsgmls-perl-1.03ii.orig/sgmlspl.1 +++ libsgmls-perl-1.03ii/sgmlspl.1 @@ -0,0 +1,47 @@ +.\" -*- nroff -*- +.\" ---------------------------------------------------------------------- +.TH SGMLSPL 1 "October 26, 1999" "SGMLSPL" "SGMLSPL" +.\" +.\" ---------------------------------------------------------------------- +.SH "NAME" +sgmlspl \- a simple post-processor for nsgmls +.\" +.\" ---------------------------------------------------------------------- +.SH "SYNOPSIS" +.B sgmlspl +.I "spec file" +.\" +.\" ---------------------------------------------------------------------- +.SH "DESCRIPTION" +sgmlspl is a sample application to convert SGML documents to other +formats by providing a specification file detailing exactly how to +handle each element, external data entity, subdocument entity, CDATA +string, record end, SDATA string, and processing instruction. + +To use sgmlspl, prepare a specification file containing regular perl5 +code. If the SGML document were named doc.sgml, the sgmlspl +specification file were named, spec.pl, and the name of the new file +were doc.latex, then use the following command in a Unix shell to +convert the SGML document: + +nsgmls doc.sgml | sgmlspl spec.pl > doc.latex + +sgmlspl will pass any additional arguments on to the specification +file, which can then process them in the regular perl5 fashion. +.\" +.\" ---------------------------------------------------------------------- +.SH "SEE ALSO" +.TP +.BR /usr/share/doc/sgmls-doc/sgmlspl/sgmlspl.html +sgmlspl documentation in HTML format +.TP +.BR /usr/share/doc/sgmls-doc/SGMLSpm/sgmls.html +SGMLS documentation in HTML format +.TP +.BR nsgmls (1) +.\" +.\" ---------------------------------------------------------------------- +.SH "AUTHOR" +Ardo van Rangelrooij +.\" +.\" ---------------------------------------------------------------------- --- libsgmls-perl-1.03ii.orig/Makefile.PL +++ libsgmls-perl-1.03ii/Makefile.PL @@ -0,0 +1,17 @@ +use ExtUtils::MakeMaker; +# See lib/ExtUtils/MakeMaker.pm for details of how to influence +# the contents of the Makefile that is written. +WriteMakefile( + 'NAME' => 'SGMLS', + 'VERSION' => '1.03ii', + 'PM' => { 'SGMLS.pm' => '$(INST_LIBDIR)/SGMLS.pm', + 'Output.pm' => '$(INST_LIBDIR)/SGMLS/Output.pm', + 'Refs.pm' => '$(INST_LIBDIR)/SGMLS/Refs.pm', + 'skel.pl' => '$(INST_LIBDIR)/sgmlspl-specs/skel.pl', + }, + 'MAN3PODS'=> { 'SGMLS.pm' => '$(INST_MAN3DIR)/SGMLS.3pm', + 'Output.pm' => '$(INST_MAN3DIR)/SGMLS::Output.3pm', + 'Refs.pm' => '$(INST_MAN3DIR)/SGMLS::Refs.3pm', + }, + 'EXE_FILES' => [ 'sgmlspl', ], +); --- libsgmls-perl-1.03ii.orig/Makefile +++ libsgmls-perl-1.03ii/Makefile @@ -94,5 +94,5 @@ mv /tmp/${DIST} SGMLSpm clean: - cd DOC; make clean + #cd DOC; make clean rm -f *~ core *.tar *.tar.gz --- libsgmls-perl-1.03ii.orig/SGMLS.pm +++ libsgmls-perl-1.03ii/SGMLS.pm @@ -1,7 +1,7 @@ package SGMLS; use Carp; -$version = '$Revision: 1.14 $'; +$version = '$Revision: 1.1 $'; =head1 NAME --- libsgmls-perl-1.03ii.orig/debian/libsgmls-perl.examples +++ libsgmls-perl-1.03ii/debian/libsgmls-perl.examples @@ -0,0 +1 @@ +DOC/sample.pl --- libsgmls-perl-1.03ii.orig/debian/sgmls-doc.doc-base.SGMLSpm +++ libsgmls-perl-1.03ii/debian/sgmls-doc.doc-base.SGMLSpm @@ -0,0 +1,9 @@ +Document: SGMLSpm +Title: SGMLSpm +Author: David Megginson +Abstract: This manual describes the SGMLS Perl modules +Section: Text + +Format: HTML +Index: /usr/share/doc/sgmls-doc/SGMLSpm/index.html +Files: /usr/share/doc/sgmls-doc/SGMLSpm/*.html --- libsgmls-perl-1.03ii.orig/debian/rules +++ libsgmls-perl-1.03ii/debian/rules @@ -0,0 +1,76 @@ +#!/usr/bin/make -f +## ---------------------------------------------------------------------- +## debian/rules : package script for libsgmls-perl +## ---------------------------------------------------------------------- + +## ---------------------------------------------------------------------- +## uncomment this to turn on verbose mode +#export DH_VERBOSE=1 + +## ---------------------------------------------------------------------- +TMP_DIR := $(CURDIR)/debian/tmp + +## ---------------------------------------------------------------------- +CFLAGS = -Wall -g +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + CFLAGS += -O0 +else + CFLAGS += -O2 +endif + +## ---------------------------------------------------------------------- +## targets + +clean: + dh_testdir + dh_testroot + [ ! -f Makefile ] || $(MAKE) clean + dh_clean build-stamp install-stamp + +build: build-stamp +build-stamp: + dh_testdir + perl Makefile.PL INSTALLDIRS=vendor + $(MAKE) OPTIMIZE="$(CFLAGS)" + $(MAKE) test + touch build-stamp + +install: install-stamp +install-stamp: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + $(MAKE) install DESTDIR=$(TMP_DIR) PREFIX=/usr + touch install-stamp + +binary-indep: build install + dh_testdir + dh_testroot + dh_install --sourcedir=$(TMP_DIR) + dh_installman + dh_installdocs + dh_installexamples + dh_installchangelogs ChangeLog + dh_link + dh_compress + dh_fixperms + dh_installdeb + dh_perl + dh_gencontrol + dh_md5sums + dh_builddeb + +binary-arch: + +binary: binary-indep binary-arch + +.PHONY: clean build install binary-indep binary-arch binary + +## ---------------------------------------------------------------------- +## Copyright 1994,1995 by Ian Jackson. +## I hereby give you perpetual unlimited permission to copy, +## modify and relicense this file, provided that you do not remove +## my name from the file itself. (I assert my moral right of +## paternity under the Copyright, Designs and Patents Act 1988.) +## ---------------------------------------------------------------------- --- libsgmls-perl-1.03ii.orig/debian/control +++ libsgmls-perl-1.03ii/debian/control @@ -0,0 +1,48 @@ +Source: libsgmls-perl +Section: perl +Priority: optional +Maintainer: Debian XML/SGML Group +Uploaders: Ardo van Rangelrooij +Vcs-Browser: http://alioth.debian.org/plugins/scmcvs/cvsweb.php/packages/libsgmls-perl/?cvsroot=debian-xml-sgml +Vcs-Cvs: :pserver:anonymous@cvs.alioth.debian.org:/cvsroot/debian-xml-sgml/packages/libsgmls-perl +Standards-Version: 3.7.3 +Build-Depends: debhelper (>= 5.0) +Build-Depends-Indep: perl + +Package: libsgmls-perl +Section: perl +Priority: optional +Architecture: all +Conflicts: sgmlspm +Depends: ${perl:Depends} +Recommends: sp +Replaces: sgmlspm +Suggests: sgmlspl, sgmls-doc +Description: Perl modules for processing SGML parser output + This is a set of Perl5 routines for processing the output from the + sgmls and nsgmls SGML parsers. To make sensible use of this package + you will need to install a suitable SGML parser as well. + +Package: sgmlspl +Section: text +Priority: optional +Architecture: all +Conflicts: sgmlspm +Depends: ${perl:Depends}, libsgmls-perl +Replaces: sgmlspm +Suggests: sgmls-doc +Description: SGMLS-based example Perl script for processing SGML parser output + This is an example of a Perl script to post-process SGML parser output + using the SGMLS Perl modules. To make sensible use of this package + you will need to install a suitable SGML parser as well. + +Package: sgmls-doc +Section: doc +Priority: optional +Architecture: all +Conflicts: sgmlspm +Replaces: sgmlspm +Suggests: libsgmls-perl, sgmlspl +Description: HTML documentation of libsgmls-perl and sgmlspl + This package contains the documentation in HTML format of the + packages libsgmls-perl and sgmlspl. --- libsgmls-perl-1.03ii.orig/debian/sgmlspl.manpages +++ libsgmls-perl-1.03ii/debian/sgmlspl.manpages @@ -0,0 +1 @@ +sgmlspl.1 --- libsgmls-perl-1.03ii.orig/debian/changelog +++ libsgmls-perl-1.03ii/debian/changelog @@ -0,0 +1,262 @@ +libsgmls-perl (1.03ii-32) unstable; urgency=low + + * Refs.pm: fixed typo + (closes: Bug#414110) + * debian/compat: bumped version to 5 + * debian/control: + * moved debhelper from 'Build-Depends-Indep' to 'Build-Depends' + (detected by lintian) + * changed build dependency on 'debhelper' to '(>= 5.0)' + * upgraded to Debian Policy 3.7.3 (no changes) + * added Vcs-Browser and Vcs-Cvs fields + * debian/watch: bumped version to 3 + * debian/copyright: updated FSF address + (detected by lintian) + + -- Ardo van Rangelrooij Fri, 04 Jan 2008 10:48:06 -0600 + +libsgmls-perl (1.03ii-31) unstable; urgency=low + + * Added 'debian/watch' + * debiam/rules: various small improvements + + -- Ardo van Rangelrooij Wed, 24 Nov 2004 12:23:21 -0600 + +libsgmls-perl (1.03ii-30) unstable; urgency=low + + * Makefile: commented out documentation clean + (closes: Bug#240645) + + -- Ardo van Rangelrooij Sun, 28 Mar 2004 10:29:33 -0600 + +libsgmls-perl (1.03ii-29) unstable; urgency=low + + * debian/control: changed maintainer's email address to the new Debian + XML/SGML Group's packages mailing list + + -- Ardo van Rangelrooij Sun, 29 Feb 2004 10:48:45 -0600 + +libsgmls-perl (1.03ii-28) unstable; urgency=low + + * debian/control: changed 'Maintainer' to 'Debian XML/SGML Group + ' and added current + maintainer as 'Uploader' + + -- Ardo van Rangelrooij Sun, 22 Feb 2004 19:38:41 -0600 + +libsgmls-perl (1.03ii-27) unstable; urgency=low + + * debian/control: upgraded to Debian Policy 3.6.1 (no changes) + + -- Ardo van Rangelrooij Sat, 7 Feb 2004 22:31:22 -0600 + +libsgmls-perl (1.03ii-26) unstable; urgency=low + + * Fixed missing documentation + (closes: Bug#226085) + + -- Ardo van Rangelrooij Sun, 4 Jan 2004 10:56:51 -0600 + +libsgmls-perl (1.03ii-25) unstable; urgency=low + + * sgmlspl.1: fixed references to HTML documentation + (closes: Bug#202985) + + -- Ardo van Rangelrooij Sat, 26 Jul 2003 23:06:50 -0500 + +libsgmls-perl (1.03ii-24) unstable; urgency=low + + * debian/rules: moved debhelper compatibility level setting to + 'debian/compat' per latest debhelper best practices + * debian/control: updated sections according to latest archive changes: + - 'libsgmls-perl' from 'text' to 'perl' + * debian/control: changed build dependency on 'debhelper' to '(>= 4.1)' + * debian/control: upgraded to Debian Policy 3.6.0 (no changes) + + -- Ardo van Rangelrooij Sat, 26 Jul 2003 22:15:48 -0500 + +libsgmls-perl (1.03ii-23) unstable; urgency=low + + * debian/sgmls-doc.links: fixed broken symlink + (closes: Bug#158923) + * debian/control: added dependency on perl for sgmlspl (warning from linda) + + -- Ardo van Rangelrooij Thu, 19 Sep 2002 19:45:17 -0500 + +libsgmls-perl (1.03ii-22) unstable; urgency=low + + * debian/rules: added erroneously removed 'dh_testroot' to 'binary-indep' + + -- Ardo van Rangelrooij Sun, 4 Aug 2002 16:33:00 -0500 + +libsgmls-perl (1.03ii-21) unstable; urgency=low + + * debian/rules: upgraded to debhelper v4 + * debian/control: changed build dependency on debhelper accordingly + * debian/rules: migrated from 'dh_movefiles' to 'dh_install' + * debian/rules: split off 'install' target from 'binary-indep' target + + -- Ardo van Rangelrooij Sun, 4 Aug 2002 09:41:59 -0500 + +libsgmls-perl (1.03ii-20) unstable; urgency=low + + * Removed explicit support of dhelp since doc-base now takes care of this + * debian/control: upgraded to Debian Policy 3.5.6 + + -- Ardo van Rangelrooij Sun, 4 Nov 2001 16:13:15 -0600 + +libsgmls-perl (1.03ii-19) unstable; urgency=low + + * debian/control: upgraded to Debian Policy 3.5.5 + * debian/control: upgraded to Debian Perl Policy 1.20 + + -- Ardo van Rangelrooij Sat, 1 Sep 2001 22:03:51 -0500 + +libsgmls-perl (1.03ii-18) unstable; urgency=low + + * Makefile.PL: removed handling of manpage sgmlspl.1 + * debian/control: added handling of manpage sgmlspl.1 + (closes: Bug#94518) + + -- Ardo van Rangelrooij Mon, 30 Apr 2001 21:26:08 -0500 + +libsgmls-perl (1.03ii-17) unstable; urgency=low + + * debian/control: updated debhelper dependency to remove dh_testversion + * debian/control: upgraded to Debian Policy 3.5.2 + * debian/control: upgraded to Debian Perl Policy 1.17 + * debian/rules: upgraded to Debian Perl Policy 1.17 + + -- Ardo van Rangelrooij Sat, 14 Apr 2001 20:49:19 -0500 + +sgmlspm (1.03ii-16) unstable; urgency=low + + * debian/control: upgraded to Debian Policy 3.2.1 + * debian/rules: upgraded to debhelper v3 + + -- Ardo van Rangelrooij Mon, 15 Jan 2001 19:35:32 -0600 + +sgmlspm (1.03ii-15) unstable; urgency=low + + * debian/control: updated short descriptions + * debian/control: added missing Build-Depends + * debian/rules: added missing `$(MAKE) test` + * debian/rules: added missing build-stamp stuff + + -- Ardo van Rangelrooij Sun, 11 Jun 2000 19:40:09 +0200 + +sgmlspm (1.03ii-14) frozen unstable; urgency=high + + * sgmlspl.pl: updated to reflect change in spec files location + (closes: #58443) (thanks Yann!!!) + + -- Ardo van Rangelrooij Sun, 20 Feb 2000 09:35:08 +0100 + +sgmlspm (1.03ii-13) unstable; urgency=high + + * sgmlspl.pl: updated to reflect change in spec files location + (closes: #58443) (thanks Yann!!!) + + -- Ardo van Rangelrooij Sat, 19 Feb 2000 19:38:22 +0100 + +sgmlspm (1.03ii-12) unstable; urgency=low + + * Moved HTML documentation to separate package sgmls-doc + (closes: #52856) (thanks Andreas!) + + -- Ardo van Rangelrooij Thu, 30 Dec 1999 11:42:02 +0100 + +sgmlspm (1.03ii-11) unstable; urgency=low + + * Removed test-SGMLS.pl from examples + * Moved skel.pl from libsgmls-perl to sgmlspl and into a new direcotry + /usr/lib/perl5/sgmlspl-specs + (closes: #52169) (thanks Yann!) + * Upgraded to Debian Policy 3.1.1 + + -- Ardo van Rangelrooij Mon, 13 Dec 1999 21:54:48 +0100 + +sgmlspm (1.03ii-10) unstable; urgency=low + + * Split binary package into libsgmls-perl and sgmlspl. The former only + contains the SGMLS Perl modules, documentation and examples. The + latter only contains the (example) Perl script `sgmlspl' and its + documentation + * Turned libsgmls-perl into a 'real' Perl package with Makefile.PL and all + (closes: #39684) + * Added doc-base support + (closes: #31181) + * Added manual page for sgmlspl + (closes: #17909) + * Upgraded to Debian Policy 3.0.1 + * Upgraded to Debian Perl Policy 1.1 + * Made lintian-free + + -- Ardo van Rangelrooij Tue, 26 Oct 1999 19:58:37 +0200 + +sgmlspm (1.03ii-9) unstable; urgency=low + + * Complies with Perl packaging standard 1.0 + + -- Ardo van Rangelrooij Tue, 13 Jul 1999 19:19:39 -0500 + +sgmlspm (1.03ii-8) unstable; urgency=low + + * debian/control: fixed typo in description + (closes: Bug#27441) + * Maintainer's email address changed + + -- Ardo van Rangelrooij Mon, 5 Oct 1998 19:14:22 +0200 + +sgmlspm (1.03ii-7) frozen unstable; urgency=low + + * debian/rules: corrected upstream ChangeLog installation (lintian bug) + * debian/copyright: updated postal address of the FSF (lintian bug) + + -- Ardo van Rangelrooij Sun, 26 Apr 1998 17:03:11 +0200 + +sgmlspm (1.03ii-6) frozen unstable; urgency=low + + * debian/rules: added sgmlspl man page as undocumented man page + * debian/rules: changed to use debhelper + * debian/rules: removed handling of index.html links + * Makefile: added handling of index.html links + * debian/control: updated to debian standard 2.4.0.0 + * debian/rules: removed installation of DocBook examples + (closes: Bug#19689) + + -- Ardo van Rangelrooij Mon, 6 Apr 1998 19:37:59 +0200 + +sgmlspm (1.03ii-5) unstable; urgency=low + + * Fixed permissions bug + (closes: Bug#17490) + + -- Ardo van Rangelrooij Wed, 18 Feb 1998 21:30:57 +0100 + +sgmlspm (1.03ii-4) unstable; urgency=low + + * New maintainer. + + -- Ardo van Rangelrooij Wed, 14 Jan 1998 21:29:45 +0100 + +sgmlspm (1.03ii-3) frozen unstable; urgency=low + + * Updated Standards-Version to 2.1.3.0. + * New maintainer. + + -- Christian Schwarz Thu, 17 Apr 1997 15:53:51 +0200 + +sgmlspm (1.03ii-2) unstable; urgency=low + + * Split binary target into binary-indep and binary-arch. + * Updated Standards-Version. + * Released into unstable. + + -- Ian Jackson Fri, 23 Aug 1996 12:11:40 +0100 + +sgmlspm (1.03ii-1) experimental; urgency=LOW + + * Initial Debian release. + + -- Ian Jackson Sat, 10 Aug 1996 01:47:30 +0100 --- libsgmls-perl-1.03ii.orig/debian/sgmls-doc.docs +++ libsgmls-perl-1.03ii/debian/sgmls-doc.docs @@ -0,0 +1,2 @@ +DOC/HTML/SGMLSpm +DOC/HTML/sgmlspl --- libsgmls-perl-1.03ii.orig/debian/libsgmls-perl.install +++ libsgmls-perl-1.03ii/debian/libsgmls-perl.install @@ -0,0 +1,2 @@ +usr/share/perl5/SGMLS* +usr/share/man/man3 --- libsgmls-perl-1.03ii.orig/debian/sgmls-doc.doc-base.sgmlspl +++ libsgmls-perl-1.03ii/debian/sgmls-doc.doc-base.sgmlspl @@ -0,0 +1,9 @@ +Document: sgmlspl +Title: sgmlspl +Author: David Megginson +Abstract: This manual describes the (example) sgmlspl Perl script +Section: Text + +Format: HTML +Index: /usr/share/doc/sgmls-doc/sgmlspl/index.html +Files: /usr/share/doc/sgmls-doc/sgmlspl/*.html --- libsgmls-perl-1.03ii.orig/debian/copyright +++ libsgmls-perl-1.03ii/debian/copyright @@ -0,0 +1,28 @@ +This is Debian GNU/Linux's prepackaged version of David Megginson's +sgmlspm-1.03ii Perl modules for processing sgmls and nsgmls output. + +This package was put together by me, Ian Jackson +, from the sources on src.doc.ic.ac.uk in +/packages/perl/CPAN/modules/by-module/SGMLS/SGMLSpm-1.03ii.tar.gz. +The changes were very minimal - merely adding support for the Debian +package maintenance scheme, by adding various debian/* files. + +Program Copyright (C)1994,1995 David Megginson. +Modifications for Debian Copyright (C)1996 Ian Jackson. +Modifications for Debian Copyright (C) 1998,1999 Ardo van Rangelrooij + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License with +your Debian GNU/Linux system, in /usr/share/common-licenses/GPL-2, or +with the Debian GNU/Linux hello source package as the file COPYING. +If not, write to the Free Software Foundation, Inc., 51 Franklin +Street, Fifth Floor, Boston, MA 02110-1301 USA. --- libsgmls-perl-1.03ii.orig/debian/compat +++ libsgmls-perl-1.03ii/debian/compat @@ -0,0 +1 @@ +5 --- libsgmls-perl-1.03ii.orig/debian/sgmls-doc.links +++ libsgmls-perl-1.03ii/debian/sgmls-doc.links @@ -0,0 +1,2 @@ +usr/share/doc/sgmls-doc/SGMLSpm/sgmlspm.html usr/share/doc/sgmls-doc/SGMLSpm/index.html +usr/share/doc/sgmls-doc/sgmlspl/sgmlspl.html usr/share/doc/sgmls-doc/sgmlspl/index.html --- libsgmls-perl-1.03ii.orig/debian/watch +++ libsgmls-perl-1.03ii/debian/watch @@ -0,0 +1,2 @@ +version=3 +http://www.cpan.org/modules/by-module/SGMLS/SGMLSpm-([\d.]+[\w]+).tar.gz --- libsgmls-perl-1.03ii.orig/debian/sgmlspl.install +++ libsgmls-perl-1.03ii/debian/sgmlspl.install @@ -0,0 +1,2 @@ +usr/bin +/usr/share/perl5/sgmlspl-specs --- libsgmls-perl-1.03ii.orig/debian/libsgmls-perl.docs +++ libsgmls-perl-1.03ii/debian/libsgmls-perl.docs @@ -0,0 +1,2 @@ +BUGS +TODO --- libsgmls-perl-1.03ii.orig/sgmlspl +++ libsgmls-perl-1.03ii/sgmlspl @@ -0,0 +1,326 @@ +#!/usr/bin/perl +######################################################################## +# sgmlspl: a simple SGML postprocesser for the SGMLS and NSGMLS +# parsers (requires SGMLS.pm library). +# +# Copyright (c) 1995 by David Megginson +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# $Log: sgmlspl,v $ +# Revision 1.2 2008-01-03 23:49:25 ardo +# applied patch for 414110 & upgraded policy +# +# Revision 1.1 2004/02/23 01:23:07 ardo +# Added debian changes for version 1.03ii-27. +# +# Revision 1.1 2001/04/15 14:42:01 ardo +# *** empty log message *** +# +# Revision 1.8 1995/12/03 21:46:31 david +# Eliminated all use of the SGMLS_Event::key method. +# +# Revision 1.7 1995/11/15 20:22:24 david +# Changed "use Output" to "use SGMLS::Output". Qualified the STDIN +# filehandle for the SGMLS object with the main:: package name. +# +# Revision 1.6 1995/08/12 16:15:14 david +# Revised version for 1.01 distribution. +# +# Revision 1.5 1995/04/27 11:52:25 david +# Changed 'print' to 'main::output' for re handler; empty string +# translates into an empty sub {} rather than a sub printing an empty +# string; instead of evaluating every argument as a perl script, take +# only the first as a perl script and the rest as its arguments; allow +# empty scripts or scripts which do not end with '1;'; pass the event +# itself as the second argument to each handler, after the event data. +# +# Revision 1.4 1995/04/23 14:44:58 david +# Use the Output package. Fixed the $version variable. +# +# Revision 1.3 1995/04/22 21:02:49 david +# Added some missing 'last SWITCH;' statements in the sgmls function. +# +# Revision 1.2 1995/04/22 20:58:48 david +# Added $SGMLS_PL::version variable and changed SDATA notation from +# [SDATA] to |SDATA|. +# +# Revision 1.1 1995/04/22 14:40:50 david +# Initial revision +# +######################################################################## + +use SGMLS::Output; + +package SGMLS_PL; +use SGMLS; + +$version = '$Id: sgmlspl,v 1.2 2008-01-03 23:49:25 ardo Exp $'; + +# +# Set up handler defaults. +# +$start_document_handler = sub {}; +$end_document_handler = sub {}; +$start_element_handlers = { '' => sub {} }; +$end_element_handlers = { '' => sub {} }; +$cdata_handler = sub { main::output($_[0]); }; +$sdata_handlers = { '' => sub { main::output($_[0]);} }; +$re_handler = sub { main::output("\n"); }; +$pi_handler = sub { '' => sub {} }; +$entity_handlers = { '' => sub {} }; +$start_subdoc_handlers = { '' => sub {} }; +$end_subdoc_handlers = { '' => sub {} }; +$conforming_handler = sub {}; + +# +# Main access point: declare handlers for different SGML events. +# +# Usage: sgml(event, handler); +# +# The event may be one of the following strings, or a special pattern. +# The generic events are as follow: +# +# 'start' The beginning of the document. +# 'end' The end of the document. +# 'start_element' The beginning of an element. +# 'end_element' The end of an element. +# 'cdata' Regular character data. +# 'sdata' Special system-specific data. +# 're' A record-end. +# 'pi' A processing instruction. +# 'entity' An external-entity reference. +# 'start_subdoc' The beginning of a subdocument entity. +# 'end_subdoc' The end of a subdocument entity. +# 'conforming' The document is conforming. +# +# In addition to these generic events, it is possible to handlers +# for certain specific, named events, as follow: +# +# '' The beginning of element GI. +# '' The end of element GI. +# '[SDATA]' The system-specific data SDATA. +# '&ENAME;' A reference to the external entity ENAME. +# '{ENAME}' The beginning of the subdocument-entity ENAME. +# '{/ENAME}' The end of the subdocument-entity ENAME. +# +# +# The handler may be a string, which will simply be printed when the +# event occurs (this is usually useful only for the specific, named +# events), or a reference to an anonymous subroutine, which will +# receive two arguments: the event data and the event itself. For +# example, +# +# sgml('', "\n\\begin{foo}\n"); +# +# and +# +# sgml('', sub { output("\n\\begin{foo}\n"); }); +# +# will have identical results. +# +sub main::sgml { + my ($spec,$handler) = (@_); + if (ref($handler) ne 'CODE') { + $handler =~ s/\\/\\\\/g; + $handler =~ s/'/\\'/g; + if ($handler eq '') { + $handler = sub {}; + } else { + $handler = eval "sub { main::output('$handler'); };"; + } + } + SWITCH: { + # start-document handler + $spec eq 'start' && do { + $start_document_handler = $handler; + last SWITCH; + }; + # end-document handler + $spec eq 'end' && do { + $end_document_handler = $handler; + last SWITCH; + }; + # start-element handler + $spec =~ /^<([^\/].*|)>$/ && do { + $start_element_handlers->{$1} = $handler; + last SWITCH; + }; + # generic start-element handler + $spec eq 'start_element' && do { + $start_element_handlers->{''} = $handler; + last SWITCH; + }; + # end-element handler + $spec =~ /^<\/(.*)>$/ && do { + $end_element_handlers->{$1} = $handler; + last SWITCH; + }; + # generic end-element handler + $spec =~ 'end_element' && do { + $end_element_handlers->{''} = $handler; + last SWITCH; + }; + # cdata handler + $spec eq 'cdata' && do { + $cdata_handler = $handler; + last SWITCH; + }; + # sdata handler + $spec =~ /^\|(.*)\|$/ && do { + $sdata_handlers->{$1} = $handler; + last SWITCH; + }; + # generic sdata handler + $spec eq 'sdata' && do { + $sdata_handlers->{''} = $handler; + last SWITCH; + }; + # record-end handler + $spec eq 're' && do { + $re_handler = $handler; + last SWITCH; + }; + # processing-instruction handler + $spec eq 'pi' && do { + $pi_handler = $handler; + last SWITCH; + }; + # entity-reference handler + $spec =~ /^\&(.*);$/ && do { + $entity_handlers->{$1} = $handler; + last SWITCH; + }; + # generic entity-reference handler + $spec eq 'entity' && do { + $entity_handlers->{''} = $handler; + last SWITCH; + }; + # start-subdoc handler + $spec =~ /^\{([^\/].*|)\}$/ && do { + $start_subdoc_handlers->{$1} = $handler; + last SWITCH; + }; + # generic start-subdoc handler + $spec eq 'start_subdoc' && do { + $start_subdoc_handlers->{''} = $handler; + last SWITCH; + }; + # end-subdoc handler + $spec =~ /^\{\/(.*)\}$/ && do { + $end_subdoc_handlers->{$1} = $handler; + last SWITCH; + }; + # generic end-subdoc handler + $spec eq 'end_subdoc' && do { + $end_subdoc_handlers->{''} = $handler; + last SWITCH; + }; + # conforming handler + $spec eq 'conforming' && do { + $conforming_handler = $handler; + last SWITCH; + }; + + die "Bad SGML handler pattern: $spec\n"; + } +} + + +# +# The first argument on the command line is a perl module which will be +# read here and evaluated in the 'main' package -- everything else will +# be an argument to it. +# +package main; + +$ARGV = shift; +unless ($ARGV eq '' || do 'sgmlspl-specs/' . $ARGV || do $ARGV) { + if (!-e $ARGV) { + die "FATAL: $ARGV does not exist.\n"; + } elsif (!-r $ARGV) { + die "FATAL: $ARGV exists but is read-protected.\n"; + } elsif ($@) { + die "FATAL: $@\n"; + } +} + + +# +# Do the actual work, using the SGMLS package. +# +package SGMLS_PL; + +$parse = new SGMLS(main::STDIN); # a new parse object + +&{$start_document_handler}(); # run the start handler. + + # run the appropriate handler for each + # event +while ($event = $parse->next_event) { + my $type = $event->type; + SWITCH: { + $type eq 'start_element' && do { + &{($start_element_handlers->{$event->data->name}|| + $start_element_handlers->{''} || sub {})}($event->data,$event); + last SWITCH; + }; + $type eq 'end_element' && do { + &{($end_element_handlers->{$event->data->name}|| + $end_element_handlers->{''} || sub {})}($event->data,$event); + last SWITCH; + }; + $type eq 'cdata' && do { + &{$cdata_handler}($event->data,$event); + last SWITCH; + }; + $type eq 'sdata' && do { + &{($sdata_handlers->{$event->data}|| + $sdata_handlers->{''} || sub {})}($event->data,$event); + last SWITCH; + }; + $type eq 're' && do { + &{$re_handler}($event->data,$event); + last SWITCH; + }; + $type eq 'pi' && do { + &{$pi_handler}($event->data,$event); + last SWITCH; + }; + $type eq 'entity' && do { + &{($entity_handlers->{$event->data->name}|| + $entity_handlers->{''} || sub {})}($event->data,$event); + last SWITCH; + }; + $type eq 'start_subdoc' && do { + &{($start_subdoc_handlers->{$event->data->name}|| + $start_subdoc_handlers->{''} || sub {})}($event->data,$event); + last SWITCH; + }; + $type eq 'end_subdoc' && do { + &{($end_subdoc_handlers->{$event->data->name}|| + $end_subdoc_handlers->{''} || sub {})}($event->data,$event); + last SWITCH; + }; + $type eq 'conforming' && do { + &{$conforming_handler}($event->data,$event); + last SWITCH; + }; + + die "Unknown SGML event type: $type\n"; + } +} + +&{$end_document_handler}(); # run the end handler