summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorjfieber <jfieber@FreeBSD.org>1997-07-19 15:19:08 +0000
committerjfieber <jfieber@FreeBSD.org>1997-07-19 15:19:08 +0000
commitdd12b6c2e5843ad06dd22cba8334290e59dcd5dd (patch)
treeae2ab920ce5faed5fe029b6d747109a092a0dc19 /usr.bin
parent84c0a5dcfe5457e17760d668151e508b658ed6e6 (diff)
downloadFreeBSD-src-dd12b6c2e5843ad06dd22cba8334290e59dcd5dd.zip
FreeBSD-src-dd12b6c2e5843ad06dd22cba8334290e59dcd5dd.tar.gz
Remove SGML tools from -current.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/Makefile4
-rw-r--r--usr.bin/sgmlfmt/Makefile9
-rw-r--r--usr.bin/sgmlfmt/sgmlfmt.1172
-rwxr-xr-xusr.bin/sgmlfmt/sgmlfmt.pl749
-rw-r--r--usr.bin/sgmls/LICENSE43
-rw-r--r--usr.bin/sgmls/Makefile9
-rw-r--r--usr.bin/sgmls/Makefile.inc16
-rw-r--r--usr.bin/sgmls/README138
-rwxr-xr-xusr.bin/sgmls/configure617
-rw-r--r--usr.bin/sgmls/instant/Makefile15
-rw-r--r--usr.bin/sgmls/instant/README150
-rw-r--r--usr.bin/sgmls/instant/browse.c462
-rw-r--r--usr.bin/sgmls/instant/general.h329
-rw-r--r--usr.bin/sgmls/instant/hyper.c100
-rw-r--r--usr.bin/sgmls/instant/info.c300
-rw-r--r--usr.bin/sgmls/instant/instant.1183
-rw-r--r--usr.bin/sgmls/instant/main.c710
-rw-r--r--usr.bin/sgmls/instant/tables.c2013
-rw-r--r--usr.bin/sgmls/instant/traninit.c577
-rw-r--r--usr.bin/sgmls/instant/translate.c881
-rw-r--r--usr.bin/sgmls/instant/translate.h153
-rw-r--r--usr.bin/sgmls/instant/transpec.5528
-rw-r--r--usr.bin/sgmls/instant/tranvar.c763
-rw-r--r--usr.bin/sgmls/instant/util.c1109
-rw-r--r--usr.bin/sgmls/libsgmls/Makefile17
-rw-r--r--usr.bin/sgmls/libsgmls/sgmls.c1032
-rw-r--r--usr.bin/sgmls/libsgmls/sgmls.h127
-rwxr-xr-xusr.bin/sgmls/sgmls.pl247
-rw-r--r--usr.bin/sgmls/sgmls/Makefile19
-rw-r--r--usr.bin/sgmls/sgmls/action.h180
-rw-r--r--usr.bin/sgmls/sgmls/adl.h118
-rw-r--r--usr.bin/sgmls/sgmls/alloc.h8
-rw-r--r--usr.bin/sgmls/sgmls/ambig.c438
-rw-r--r--usr.bin/sgmls/sgmls/appl.h31
-rw-r--r--usr.bin/sgmls/sgmls/catalog.c925
-rw-r--r--usr.bin/sgmls/sgmls/catalog.h45
-rw-r--r--usr.bin/sgmls/sgmls/config.h158
-rw-r--r--usr.bin/sgmls/sgmls/context.c451
-rw-r--r--usr.bin/sgmls/sgmls/context.h19
-rw-r--r--usr.bin/sgmls/sgmls/dosproc.c40
-rw-r--r--usr.bin/sgmls/sgmls/ebcdic.c42
-rw-r--r--usr.bin/sgmls/sgmls/ebcdic.h25
-rw-r--r--usr.bin/sgmls/sgmls/entgen.c517
-rw-r--r--usr.bin/sgmls/sgmls/entity.h192
-rw-r--r--usr.bin/sgmls/sgmls/error.h61
-rw-r--r--usr.bin/sgmls/sgmls/etype.h93
-rw-r--r--usr.bin/sgmls/sgmls/exclude.c121
-rw-r--r--usr.bin/sgmls/sgmls/genlex.c140
-rw-r--r--usr.bin/sgmls/sgmls/getopt.c166
-rw-r--r--usr.bin/sgmls/sgmls/getopt.h11
-rw-r--r--usr.bin/sgmls/sgmls/keyword.h22
-rw-r--r--usr.bin/sgmls/sgmls/latin1.h37
-rw-r--r--usr.bin/sgmls/sgmls/lexcode.h12
-rw-r--r--usr.bin/sgmls/sgmls/lexrf.c125
-rw-r--r--usr.bin/sgmls/sgmls/lextaba.c750
-rw-r--r--usr.bin/sgmls/sgmls/lextabe.c357
-rw-r--r--usr.bin/sgmls/sgmls/lextoke.h10
-rw-r--r--usr.bin/sgmls/sgmls/lineout.c656
-rw-r--r--usr.bin/sgmls/sgmls/lineout.h23
-rw-r--r--usr.bin/sgmls/sgmls/main.c650
-rw-r--r--usr.bin/sgmls/sgmls/md1.c866
-rw-r--r--usr.bin/sgmls/sgmls/md2.c792
-rw-r--r--usr.bin/sgmls/sgmls/msg.h258
-rw-r--r--usr.bin/sgmls/sgmls/msgcat.c840
-rw-r--r--usr.bin/sgmls/sgmls/msgcat.h13
-rw-r--r--usr.bin/sgmls/sgmls/pars1.c984
-rw-r--r--usr.bin/sgmls/sgmls/pars2.c1333
-rw-r--r--usr.bin/sgmls/sgmls/pcbrf.c1351
-rw-r--r--usr.bin/sgmls/sgmls/portproc.c105
-rw-r--r--usr.bin/sgmls/sgmls/serv.c299
-rw-r--r--usr.bin/sgmls/sgmls/sgml1.c485
-rw-r--r--usr.bin/sgmls/sgmls/sgml2.c522
-rw-r--r--usr.bin/sgmls/sgmls/sgmlaux.h72
-rw-r--r--usr.bin/sgmls/sgmls/sgmldecl.c1804
-rw-r--r--usr.bin/sgmls/sgmls/sgmldecl.h90
-rw-r--r--usr.bin/sgmls/sgmls/sgmlfnsm.h130
-rw-r--r--usr.bin/sgmls/sgmls/sgmlincl.h20
-rw-r--r--usr.bin/sgmls/sgmls/sgmlio.c384
-rw-r--r--usr.bin/sgmls/sgmls/sgmlmain.h101
-rw-r--r--usr.bin/sgmls/sgmls/sgmlmsg.c514
-rw-r--r--usr.bin/sgmls/sgmls/sgmls.1970
-rw-r--r--usr.bin/sgmls/sgmls/sgmlxtrn.c225
-rw-r--r--usr.bin/sgmls/sgmls/sgmlxtrn.h123
-rw-r--r--usr.bin/sgmls/sgmls/source.h114
-rw-r--r--usr.bin/sgmls/sgmls/std.h110
-rw-r--r--usr.bin/sgmls/sgmls/stklen.c2
-rw-r--r--usr.bin/sgmls/sgmls/strerror.c36
-rw-r--r--usr.bin/sgmls/sgmls/synrf.c72
-rw-r--r--usr.bin/sgmls/sgmls/synxtrn.h154
-rw-r--r--usr.bin/sgmls/sgmls/tools.h76
-rw-r--r--usr.bin/sgmls/sgmls/trace.h113
-rw-r--r--usr.bin/sgmls/sgmls/traceset.c462
-rw-r--r--usr.bin/sgmls/sgmls/unix.cfg147
-rw-r--r--usr.bin/sgmls/sgmls/unixproc.c98
-rw-r--r--usr.bin/sgmls/sgmls/version.c1
-rw-r--r--usr.bin/sgmls/sgmls/xfprintf.c564
-rw-r--r--usr.bin/sgmls/unix.cfg165
97 files changed, 2 insertions, 32288 deletions
diff --git a/usr.bin/Makefile b/usr.bin/Makefile
index 5f9e8a2..1da7a93 100644
--- a/usr.bin/Makefile
+++ b/usr.bin/Makefile
@@ -1,5 +1,5 @@
# From: @(#)Makefile 8.3 (Berkeley) 1/7/94
-# $Id: Makefile,v 1.85 1997/05/29 15:03:32 wpaul Exp $
+# $Id: Makefile,v 1.86 1997/07/05 14:22:14 peter Exp $
# XXX MISSING: deroff diction graph learn plot
# spell spline struct units xsend
@@ -19,7 +19,7 @@ SUBDIR= apply ar at banner basename biff brandelf cal calendar \
nm nohup opieinfo opiekey opiepasswd pagesize passwd paste pr printenv \
printf quota ranlib rdist renice rev rlogin rpcgen \
rpcinfo rs rsh rup ruptime rusers rwall \
- rwho script sed sgmlfmt sgmls shar showmount size soelim split \
+ rwho script sed shar showmount size soelim split \
strings strip su symorder talk tconv tcopy tee tftp time \
tip tn3270 top touch tput tr true tset tsort tty ul uname \
unexpand unifdef uniq units unvis users uudecode uuencode vacation \
diff --git a/usr.bin/sgmlfmt/Makefile b/usr.bin/sgmlfmt/Makefile
deleted file mode 100644
index 12e52d5..0000000
--- a/usr.bin/sgmlfmt/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-# $Id$
-
-MAN1= sgmlfmt.1
-
-afterinstall:
- ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
- ${.CURDIR}/sgmlfmt.pl ${DESTDIR}${BINDIR}/sgmlfmt
-
-.include <bsd.prog.mk>
diff --git a/usr.bin/sgmlfmt/sgmlfmt.1 b/usr.bin/sgmlfmt/sgmlfmt.1
deleted file mode 100644
index 9b9016e..0000000
--- a/usr.bin/sgmlfmt/sgmlfmt.1
+++ /dev/null
@@ -1,172 +0,0 @@
-.Dd May 9, 1997
-.Os FreeBSD 2.2
-.Dt SGMLFMT 1
-.Sh NAME
-.Nm sgmlfmt
-.Nd Formats linuxdoc and DocBook SGML documents.
-.Sh SYNOPSIS
-.Nm
-.Op Fl d Ar doctype
-.Fl f Ar format
-.Op Fl i Ar name ...
-.Op Fl links
-.Op Fl e Ar encoding
-.Op Fl hdr Ar file
-.Op Fl ftr Ar file
-.Ar file
-.Sh DESCRIPTION
-The
-.Nm
-command reads SGML files tagged according to the linuxdoc or
-DocBook DTD,
-validates them using the
-.Xr sgmls 1
-parser and then converts them to the specified output format.
-Linuxdoc input files must include the following document type
-declaration before any uncommented text:
-.Bd -literal -offset indent
-<!DOCTYPE linuxdoc PUBLIC "-//FreeBSD//DTD linuxdoc//EN">
-.Ed
-.Pp
-Options for
-.Nm
-include the following:
-.Bl -tag -width Ds
-.It Fl d Ar doctype
-Specifies the SGML document type of the source file. Currently
-supported document types are
-.Ar linuxdoc
-and
-.Ar docbook .
-If no
-.Fl d
-option is specified, the default is
-.Ar linuxdoc .
-.It Fl f Ar format
-Determines the output format which can be one of the following:
-.Bl -tag -width Ds
-.It Ar ascii
-Generates a single output file with the extension
-.Pa .ascii
-suitable for viewing on an ASCII terminal.
-.It Ar html
-Generates a set of linked HTML files suitable for use with an
-HTML browser. A top level file,
-.Pa file.html ,
-contains the title, author, date, abstract and brief table of
-contents for the document. A file
-.Pa file_toc.html
-contains a complete table of contents. A series of files named
-.Pa file1.html ,
-.Pa file2.html ...
-.Pa filen.html
-contain the actual text of the document.
-.It Ar koi8-r
-Generates a single output file with the extension
-.Pa .koi8-r
-suitable for viewing on an terminal supporting the KOI8-R
-character encoding.
-.It Ar latin1
-Generates a single output file with the extension
-.Pa .latin1
-suitable for viewing on an terminal supporting the ISO8859-1
-character encoding.
-.It Ar ps
-Generates a single output file with the extension
-.Pa .ps
-suitable for printing or display on a PostScript compatible device.
-.It Ar roff
-Generates a single output file with the extension
-.Pa .roff
-suitable processing with
-.Xr groff 1 .
-This is actually an intermediate conversion used by the
-.Fl f Ar ascii ,
-.Fl f Ar latin1 ,
-.Fl f Ar koi8-r ,
-and
-.Fl f Ar ps
-format options.
-.El
-.It Fl i Ar name
-Pretend that
-.Dl <!ENTITY % name "INCLUDE">
-occurs at the start of the document type declaration subset in
-the document entity. Since repeated definitions of an entity are
-ignored, this definition will take precedence over any other
-definitions of this entity in the document type declaration.
-Multiple
-.Fl i
-options are allowed. If the declaration replaces the reserved
-name INCLUDE then the new reserved name will be the replacement
-text of the entity. Typically the document type declaration will
-contain
-.Dl <!ENTITY % name "IGNORE">
-and will use
-.Li %name;
-in the status keyword specification of a
-marked section declaration. In this case the effect of the
-option will be to cause the marked section not to be ignored.
-.It Fl links
-When used with the
-.Fl f Ar html
-option, this option generates a shell script named
-.Pa file.ln .
-For each
-.Li <label id="foo">
-in the document source,
-.Pa file.ln
-generates a symbolic link
-.Pa foo.html
-pointing to the numbered
-.Pa .html
-file containing the reference. Since the number of the file
-containing a particular section can change when a document
-is modified, this provides a convenient hook by which separate
-documents can provide links into another document without the
-links becoming invalid when the target document is modified.
-When creating a symbolic link, any occurrence of a slash (/) in label
-is replaced with percent (%), while any occurrence of a space is replaced
-with an underscore (_).
-.It Fl e Ar encoding
-When used with the
-.Fl f Ar html
-option, specifies document encoding to use for the generated
-HTML files. If this option is not specified, iso-8859-1 is used.
-.It Fl hdr Ar file
-When used with the
-.Fl f Ar html
-option, the specified file will be inserted at the beginning of the
-body element of each generated HTML file.
-.It Fl ftr Ar file
-When used with the
-.Fl f Ar html
-option, the specified file will be inserted at the end of the
-body element of each generated HTML file.
-.El
-.Pp
-In all cases, the output files are created in the current working
-directory.
-.Sh FILES
-.Pa /usr/share/sgml/transpec
-- directory containing translation specification files for
-.Xr instant 1 .
-.Pp
-.Sh SEE ALSO
-.Xr groff 1 ,
-.Xr instant 1 ,
-.Xr sgmls 1 ,
-.Xr transpec 5
-.Sh HISTORY
-The
-.Nm
-command appeared in Version 2.0.5 FreeBSD UNIX.
-.Sh AUTHORS
-The
-.Nm
-command was written by John Fieber
-.Aq jfieber@FreeBSD.org .
-The linuxdoc DTD was written by Matt Welsh
-.Aq mdw@cs.cornell.edu
-and based on the Qwertz DTD written by Tom Gordon
-.Aq thomas.gordon@gmd.de .
diff --git a/usr.bin/sgmlfmt/sgmlfmt.pl b/usr.bin/sgmlfmt/sgmlfmt.pl
deleted file mode 100755
index 5f9ab85..0000000
--- a/usr.bin/sgmlfmt/sgmlfmt.pl
+++ /dev/null
@@ -1,749 +0,0 @@
-#!/usr/bin/perl
-
-# $Id: sgmlfmt.pl,v 1.25 1997/05/10 20:41:11 jfieber Exp $
-
-# Copyright (C) 1996
-# John R. Fieber. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY JOHN R. FIEBER AND CONTRIBUTORS ``AS IS'' AND
-# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL JOHN R. FIEBER OR CONTRIBUTORS BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-# SUCH DAMAGE.
-
-
-# Format an sgml document tagged according to the linuxdoc DTD.
-# by John Fieber <jfieber@freebsd.org> for the FreeBSD documentation
-# project.
-
-
-require 'newgetopt.pl';
-
-#
-# The SGML parser, and translation engine.
-#
-
-$sgmls = "sgmls";
-$instant = "instant";
-
-#
-# Things to clean up if we exit abnormally
-#
-
-@cleanfiles = ();
-
-#
-# Interrupt handler, remove scratch files.
-#
-
-sub sighandler {
- local($sig) = @_;
- unlink @cleanfiles;
- exit(1);
-}
-
-$SIG{'HUP'} = 'sighandler';
-$SIG{'INT'} = 'sighandler';
-$SIG{'QUIT'} = 'sighandler';
-
-#
-# Display a usage message.
-#
-
-sub usage {
- print "Usage:\n";
- print "sgmlfmt [-d <doctype>] -f <format> [-i <namea> ...] [-links]\n";
- print " [-e encoding] [-hdr file] [-ftr file] file\n";
- print "where <doctype> is one of: linuxdoc (default), docbook.\n";
- print "and <format> is one of: ascii, html, koi8-r, latin1, ps, roff\n";
-}
-
-#
-# Look for the file specified on the command line
-#
-
-sub getfile {
- local($filearg) = @_;
- if (-f "$filearg.sgml") {
- $file = "$filearg.sgml";
- }
- elsif (-f $filearg) {
- $file = $filearg;
- }
- else {
- return 0;
- }
- $fileroot = $file;
- $fileroot =~ s/.*\///; # drop the path
- $fileroot =~ s/\.[^\.]*$//; # drop the extension
- $filepath = $file;
- $filepath =~ s/\/*[^\/]*$//;
- if ($filepath ne "") {
- $ENV{"SGML_PATH"} .= ":$filepath/%S:%S";
- }
- return 1;
-}
-
-#
-# A function to run sgmls and instant on the input file.
-#
-# Arguments:
-# 1. A file handle for the output
-# 2. A translation file
-#
-
-sub sgmlparse {
- local($ifhandle, $replacement) = @_;
- $defines = join(" -i ", @opt_i);
- if ($defines ne "") {
- $defines = "-i $defines";
- }
- open($ifhandle, "$sgmls $defines $decl $file | " .
- "$instant -Dfilename=$fileroot $instantopts -t ${dtd}-${replacement}.ts |");
-}
-
-#
-# Generate roff output
-#
-
-sub gen_roff {
- @cleanfiles = (@cleanfiles, "${fileroot}.roff");
- open (outfile, ">$fileroot.roff");
- &sgmlparse(infile, "roff");
- while (<infile>) {
- print outfile;
- }
- close(infile);
- close(outfile);
-}
-
-#
-# Generate something from roff output
-#
-
-sub do_groff {
- local($driver, $postproc) = @_;
- @cleanfiles = (@cleanfiles, "${fileroot}.trf", "${fileroot}.tmp",
- "${fileroot}.qrf", "${fileroot}.${driver}");
- open (outfile, ">$fileroot.trf");
- &sgmlparse(infile, "roff");
- while (<infile>) {
- print outfile;
- }
- close(infile);
- close(outfile);
- system("groff -T ${driver} -t ${fileroot}.trf ${postproc} > ${fileroot}.${driver}");
-
- # If foo.tmp has been created, then there are cross references
- # in the file and we need a second pass to resolve them correctly.
-
- if (stat("${fileroot}.tmp")) {
- system("groff -T ${driver} -t ${fileroot}.trf ${postproc} > ${fileroot}.${driver}");
- unlink("${fileroot}.qrf");
- }
- unlink("${fileroot}.trf");
-}
-
-#
-# Generate HTML output.
-#
-# HTML is generated in two passes.
-#
-# The first pass takes the output from sgmlsasp and gathers information
-# about the structure of the document that is used in the sceond pass
-# for splitting the file into separate files. Targets for cross
-# references are also stored in this pass.
-#
-# Based on the information from the first pass, the second pass
-# generates a numbered series of HTML files, a "toplevel" file
-# containing the title, author, abstract and a brief table of
-# contents. A detailed table of contents is also generated. The
-# second pass generates links for cross references and URLs.
-
-#
-# Tunable parameters
-#
-$maxlevel = 3; # max section depth
-$num_depth = 4; # depth of numbering
-$m_depth = 2; # depth of menus
-
-
-$sc = 0; # section counter
-$filecount = 0; # file counter
-
-$doctype = "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">";
-$BODY = "<BODY text=\"#000000\" bgcolor=\"#ffffff\">";
-
-# Other variables:
-#
-# st_xxxx - Section Table. Arrays containing information about a
-# given section. To be accesssed via the section counter $sc.
-#
-# st_ol - The output level of the given section. I.E. how many
-# levels from the table of contents does it lie in terms
-# of HTML files which is distinct from <sect1>, <sect2> etc.
-# levels.
-#
-# st_sl - The absolute depth of a section. Contrast st_ol.
-#
-# st_num - The section number in the form X.Y.Z....
-#
-# st_file - The HTML file the section belongs to.
-#
-# st_header - The text of the section title.
-#
-# st_parent - The section number of the given sections parent.
-
-sub gen_html {
- local($i, $sl);
-
- # Remove any lingering link file
- unlink("${fileroot}.ln");
-
- $tmpfile = "/tmp/sgmlf.$$";
- @cleanfiles = (@cleanfiles, "$tmpfile", "${fileroot}.html",
- "${fileroot}_toc.html", "${fileroot}.ln");
- open(bar, ">$tmpfile");
-# print STDERR "(Pass 1...";
- &sgmlparse(foo, "html");
- while (<foo>) {
- print bar;
- # count up the number of files to be generated
- # and gather assorted info about the document structure
- if (/^<\@\@sect>/) {
- $sl++; # current section level
- $sc++; # current section number
- $st_sl[$sc] = $sl;
-
- # In case this section has subsections, set the parent
- # pointer for this level to point at this section.
- $parent_pointer[$sl] = $sc;
-
- # Figure out who is the parent if this section.
- $st_parent[$sc] = $parent_pointer[$sl - 1];
-
- # Per level counters
- $counter[$sl]++;
- $counter[$sl + 1] = 0;
-
- # calculate the section number in the form x.y.z.
- if ($sl <= $num_depth) {
- $st_num[$sc] = $st_num[$st_parent[$sc]] . "$counter[$sl].";
- }
-
- # calculate the file number and output level
- if ($sl <= $maxlevel) {
- $filecount++;
- $st_ol[$sc] = $sl;
- @cleanfiles = (@cleanfiles, "${fileroot}${filecount}.html");
- }
- else {
- $st_ol[$sc] = $maxlevel;
- }
-
- $st_file[$sc] = $filecount;
-
- # Calculate the highest level node in which this
- # node should appear as a menu item.
- $st_pl[$sc] = $sl - $m_depth;
- if ($st_pl[$sc] < 0) {
- $st_pl[$sc] = 0;
- }
- if ($st_pl[$sc] > $maxlevel) {
- $st_pl[$sc] = $maxlevel;
- }
- }
- if (/^<\@\@endsect>/) {
- $sl--;
- }
-
- # record section titles
- if (/^<\@\@head>/) {
- chop;
- s/^<\@\@head>//;
- $st_header[$sc] = $_;
- }
-
- # record the section number that a label occurs in
- if (/^<\@\@label>/) {
- chop;
- s/^<\@\@label>//;
- if ($references{$_} eq "") {
- $references{$_} = "$filecount";
- if ($opt_links) {
- &extlink($_, "${fileroot}${filecount}.html");
- }
- }
- else {
- print STDERR "Warning: the label `$_' is multiply-defined.\n";
- }
- }
- }
- close(bar);
-
- open(foofile, $tmpfile);
- &html2html(foofile, "boo");
-
- unlink($tmpfile);
-}
-
-#
-# HTML conversion, pass number 2
-#
-
-sub html2html {
- local($infile, $outfile) = @_;
- local($i);
-
- $sc = 0;
- push(@scs, $sc);
-
- open(tocfile, ">${fileroot}_toc.html");
- print tocfile "$doctype\n<HTML>\n";
-
- while (<$infile>) {
- # change `<' and `>' to `&lt;' and `&gt;' in <pre></pre>
- if (/<pre>/.../<\/pre>/) {
- s/</\&lt;/g;
- s/\&lt;([\/]*)pre>/<\1pre>/g;
- s/>/\&gt;/g;
- s/<([\/]*)pre\&gt;/<\1pre>/g;
- }
-
- # remove extraneous empty paragraphs (it is arguable that this
- # is really a bug with the DTD, but changing it would break
- # almost every document written to this DTD.)
- s/<p><\/p>//;
-
- tagsw: {
- # titles and headings
- if (s/^<\@\@title>//) {
- chop;
- $st_header[0] = $_;
- $st_parent[0] = -1;
- $t = $st_header[0];
- $t =~ s|<[a-zA-Z/][^>]*>||g;
- print tocfile "<HEAD>\n$html_encoding\n<TITLE>$t</TITLE>\n" .
- "</HEAD>\n";
- print tocfile "<H1>$st_header[0]</H1>\n";
-
- $header[$st_ol[$sc]] =
- "$doctype\n<HTML>\n<HEAD>\n$html_encoding\n<TITLE>$t</TITLE>\n" .
- "</HEAD>\n$BODY\n";
- $header[$st_ol[$sc]] .= $html_header;
- $header[$st_ol[$sc]] .= "\n<H1>$st_header[0]</H1>\n";
-
- $footer[$st_ol[$sc]] = "\n";
- $footer[$st_ol[$sc]] .= $html_footer;
- $footer[$st_ol[$sc]] .= "\n</BODY>\n</HTML>\n";
- last tagsw;
- }
-
- #
- # HEADER begin
- #
- if (s/^<\@\@head>//) {
- chop;
-
- if ($part == 1) {
- $text[0] .= "<H1>Part $partnum:<BR>$_";
- last tagsw;
- }
-
- $href = "\"${fileroot}$st_file[$sc].html#$sc\"";
-
- # set up headers and footers
- if ($st_sl[$sc] > 0 && $st_sl[$sc] <= $maxlevel) {
- $t = $_;
- $t =~ s|<[a-zA-Z/][^>]*>||g;
- $header[$st_ol[$sc]] =
- "$doctype\n<HTML>\n<HEAD>\n$html_encoding\n<TITLE>$t</TITLE>\n" .
- "</HEAD>\n$BODY\n";
- $header[$st_ol[$sc]] .= $html_header;
- $header[$st_ol[$sc]] .= "\n$navbar[$st_ol[$sc]]\n<HR NOSHADE>\n";
- $footer[$st_ol[$sc]] = "<HR NOSHADE>\n$navbar[$st_ol[$sc]]\n";
- $footer[$st_ol[$sc]] .= $html_footer;
- $footer[$st_ol[$sc]] .= "\n</BODY>\n</HTML>\n";
- }
-
- # Add this to the master table of contents
- print tocfile "<DD>$st_num[$sc] " .
- "<A HREF=$href>$_";
-
- # Calculate the <H?> level to use in the HTML file
- $hlevel = $st_sl[$sc] - $st_ol[$sc] + 2;
- $shlevel = $st_sl[$sc] - $st_ol[$sc] + 3;
-
- $i = $st_ol[$sc];
-
- # Add the section header
- $text[$i] .= "<H$hlevel><A NAME=\"$sc\"></A>$st_num[$sc] $_";
- $i--;
-
- # And also to the parent
- if ($st_sl[$sc] == $st_ol[$sc] && $i >= 0) {
- $text[$i] .= "<H$shlevel>$st_num[$sc] " .
- "<A HREF=$href>$_";
- $i--;
- }
-
- # and to the grandparents
- for (; $i >= $st_pl[$sc]; $i--) {
- $text[$i] .= "<DD>$st_num[$sc] " .
- "<A HREF=$href>$_";
- }
-
- last tagsw;
- }
-
- #
- # HEADER end
- #
- if (s/^<\@\@endhead>//) {
- if ($part == 1) {
- $text[0] .= "</H1>\n";
- $part = 0;
- last tagsw;
- }
- print tocfile "</A>\n";
-
- $i = $st_ol[$sc];
-
- # Close the section header
- $text[$i] .= "</H$hlevel>\n";
- $i--;
-
- # in the parent...
- if ($st_sl[$sc] == $st_ol[$sc] && $i >= 0) {
- $text[$i] .= "</A></H$shlevel>\n";
- $i--;
- }
-
- # in the grandparent...
- for (; $i >= $st_pl[$sc]; $i--) {
- $text[$i] .= "</A></DD>\n";
- }
- last tagsw;
- }
-
- # sectioning
- if (s/^<\@\@part>//) {
- $part = 1;
- $partnum++;
- last tagsw;
- }
-
- #
- # BEGINNING of a section
- #
- if (s/^<\@\@sect>//) {
- # Increment the section counter and save it on a stack
- # for future reference.
- $sc++;
- push(@scs, $sc);
-
- # Set up the navigation bar
- if ($st_file[$sc] > $st_file[$sc - 1]) {
- &navbar($st_file[$sc], $filecount, $sc);
- }
-
- # Prepare for menu entries in the table of contents and
- # parent file(s).
- if ($st_sl[$sc - 1] < $st_sl[$sc]) {
- print tocfile "<DL>\n";
- $i = $st_ol[$sc] - 1 - ($st_sl[$sc] == $st_ol[$sc]);
- for (; $i >= $st_pl[$sc]; $i--) {
- $text[$i] .= "<DL>\n";
- }
- }
- last tagsw;
- }
-
- #
- # END of a section
- #
- if (s/^<\@\@endsect>//) {
-
- # Remember the section number! Subsections may have
- # altered the global $sc variable.
- local ($lsc) = pop(@scs);
-
- # Close off subsection menus we may have created in
- # parent file(s).
- if ($st_sl[$lsc] > $st_sl[$sc + 1]) {
- print tocfile "</DL>\n";
- if ($st_sl[$lsc] > 1) {
- print tocfile "</DD>\n";
- }
- $i = $st_ol[$lsc] - 1 - ($st_sl[$lsc] == $st_ol[$lsc]);
- for (; $i >= $st_pl[$lsc]; $i--) {
- $text[$i] .= "</DL>\n";
- }
- }
-
- # If this section is below $maxlevel, write it now.
- if ($st_sl[$lsc] <= $maxlevel) {
- open(SECOUT, ">${fileroot}$st_file[$lsc].html");
- print SECOUT "$header[$st_ol[$lsc]] $text[$st_ol[$lsc]] " .
- "$footer[$st_ol[$lsc]]";
- $text[$st_ol[$lsc]] = "";
- close(SECOUT);
- }
- last tagsw;
- }
-
- # cross references
- if (s/^<\@\@label>//) {
- chop;
- $text[$st_ol[$sc]] .= "<A NAME=\"$_\"></A>";
- last tagsw;
- }
- if (s/^<\@\@ref>//) {
- chop;
- $refname = $_;
- if ($references{$_} eq "") {
- print "Warning: Reference to $_ has no defined target\n";
- }
- else {
- $text[$st_ol[$sc]] .=
- "<A HREF=\"${fileroot}$references{$_}.html#$_\">";
- }
- last tagsw;
- }
- if (s/^<\@\@endref>//) {
- $text[$st_ol[$sc]] .= "</A>";
- last tagsw;
- }
- if (s/^<\@\@refnam>//) {
- $text[$st_ol[$sc]] .= "$refname";
- last tagsw;
- }
-
- # If nothing else did anything with this line, just print it.
- $text[$st_ol[$sc]] .= "$_";
- }
- }
-
- print tocfile "</HTML>\n";
- open(SECOUT, ">$fileroot.html");
- print SECOUT "$header[0] $text[0] $footer[0]";
- close(SECOUT);
- close tocfile;
-}
-
-# navbar
-#
-# Generate a navigation bar to go on the top and bottom of the page.
-
-sub navbar {
- local ($fnum, $fmax, $sc) = @_;
- local ($i, $itext, $prv, $nxt, $colon);
-
- $colon = "<b>:</b>";
-
- # Generate the section hierarchy
-
- $navbar[$st_ol[$sc]] =
- "<A HREF=\"${fileroot}.html\"><EM>$st_header[0]</EM></A>\n";
- $i = $st_parent[$sc];
- while ($i > 0) {
- $itext = " $colon <A HREF=\"${fileroot}$st_file[$i].html\"><EM>$st_header[$i]</EM></A>\n$itext";
- $i = $st_parent[$i];
- }
- $navbar[$st_ol[$sc]] .= "$itext $colon <EM>$st_header[$sc]</EM><BR>\n";
-
- # Generate previous and next pointers
-
- # Previous pointer must be in a different file AND must be at the
- # same or higher section level. If the current node is the
- # beginning of a chapter, then previous will go to the beginning
- # of the previous chapter, not the end of the previous chapter.
-
- $prv = $sc;
- while ($prv >= 0 && $st_file[$prv] >= $st_file[$sc] - 1) {
- $prv--;
- }
- $prv++;
- $navbar[$st_ol[$sc]] .=
- "<b>Previous:</b> <A HREF=\"${fileroot}$st_file[$prv].html\"><EM>$st_header[$prv]</EM></A><BR>\n";
-
- # Then next pointer must be in a higher numbered file OR the home
- # page of the document.
-
- $nxt = $sc;
- if ($st_file[$nxt] == $filecount) {
- $nxt = 0;
- }
- else {
- while ($st_file[$nxt] == $st_file[$sc]) {
- $nxt++;
- }
- }
-
- $navbar[$st_ol[$sc]] .=
- "<b>Next:</b> <A HREF=\"${fileroot}$st_file[$nxt].html\"><EM>$st_header[$nxt]</EM></A>\n";
-
- $navbar[$st_ol[$sc]] .= "\n";
-
-}
-
-#
-# Generate html output from docbook input
-#
-
-sub docbook_html {
- @cleanfiles = (@cleanfiles, "${fileroot}.html");
- open (outfile, ">$fileroot.html");
- &sgmlparse(infile, "html");
- while (<infile>) {
- print outfile;
- }
- close(infile);
- close(outfile);
-}
-
-# extlink
-#
-# Build a shell script to create symbolic links from the name in
-# a reference to the numbered
-# html file. Since the file number that any given section has is
-# subject to change as the document goes through revisions, this allows
-# for a fixed target that separate documents can hook into.
-#
-# Slashes (/) in the reference are converted to percents (%) while
-# spaces ( ) are converted to underscores (_);
-
-sub extlink {
- local ($ref, $fn) = @_;
-
- $ref =~ s/\//%/g;
- $ref =~ s/ /_/g;
-
- $file = "$ref.html";
-
- if (!fileno(LINKFILE)) {
- open(LINKFILE, ">${fileroot}.ln");
- }
-
- print LINKFILE "ln -fs $fn $file\n";
-}
-
-# Now, read the command line and take appropriate action
-
-sub main {
- # Check arguments
- if (!&NGetOpt('d=s', 'f=s', 'links', 'i:s@', 'hdr=s', 'ftr=s', 'e=s')) {
- &usage;
- exit 1;
- }
- if (@ARGV == 0) {
- print "An input file must be specified.\n";
- &usage;
- exit 1;
- }
- if (&getfile($ARGV[0]) == 0) {
- print "Cannot locate specified file: $ARGV[0]\n";
- &usage;
- exit 1;
- }
-
- # Figure out which DTD we are using
- if ($opt_d eq "docbook") {
- $dtd = "docbook";
- $decl = "/usr/share/sgml/docbook/docbook.dcl";
- }
- else {
- $dtd = "linuxdoc";
- $decl = "/usr/share/sgml/FreeBSD/linuxdoc.dcl";
- }
-
- # Generate the output
- if ($opt_f eq 'html') {
- # Set the character encoding
- if (! $opt_e) {
- $opt_e = "iso-8859-1";
- }
- $html_encoding = "<META HTTP-EQUIV=\"Content-Type\" " .
- "CONTENT=\"text/html; charset=" . $opt_e . "\">";
-
- if ($dtd eq "docbook") {
- if ($opt_hdr) {$instantopts .= " -D \"inchdr=${opt_hdr}\"";}
- if ($opt_ftr) {$instantopts .= " -D \"incftr=${opt_ftr}\"";}
- &docbook_html();
- }
- else {
- if ($opt_hdr) {$html_header = &gethf($opt_hdr);}
- if ($opt_ftr) {$html_footer = &gethf($opt_ftr);}
- &gen_html();
- }
- }
- elsif ($opt_f eq 'roff') {
- &gen_roff();
- }
- elsif ($opt_f eq 'ascii') {
- &do_groff("ascii", "| col");
- }
- elsif ($opt_f eq 'latin1') {
- &do_groff("latin1", "| col");
- }
- elsif ($opt_f eq 'koi8-r') {
- &do_groff("koi8-r", "| col");
- }
- elsif ($opt_f eq 'ps') {
- &do_groff("ps", "");
- }
- else {
- if ($opt_f eq "") {
- print "An output format must be specified with the -f
- option.\n";
- }
- else {
- print "\"$opt_f\" is an unknown output format.\n";
- }
- &usage;
- exit 1;
- }
-}
-
-&main;
-
-exit 0;
-
-sub getdate {
- @months = ("January", "February", "March", "April", "May","June",
- "July", "August", "September", "October", "November", "December");
- ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
- $year += 1900;
- return "$months[$mon] $mday, $year";
-}
-
-sub gethf {
- local ($file) = @_;
-
- $date = &getdate;
- $data = "";
-
- if (open(IN, $file)) {
- while (<IN>) {
- s/\@\@UPDATE\@\@/Updated $date/;
- $data .= $_;
- }
- close(IN);
- }
- return $data;
-}
diff --git a/usr.bin/sgmls/LICENSE b/usr.bin/sgmls/LICENSE
deleted file mode 100644
index 576ca35..0000000
--- a/usr.bin/sgmls/LICENSE
+++ /dev/null
@@ -1,43 +0,0 @@
- LICENSE AND DISCLAIMER OF WARRANTIES
-
- Standard Generalized Markup Language Users' Group (SGMLUG)
- SGML Parser Materials
-
- 1. License
-
-SGMLUG hereby grants to any user: (1) an irrevocable royalty-free,
-worldwide, non-exclusive license to use, execute, reproduce, display,
-perform and distribute copies of, and to prepare derivative works
-based upon these materials; and (2) the right to authorize others to
-do any of the foregoing.
-
- 2. Disclaimer of Warranties
-
-(a) The SGML Parser Materials are provided "as is" to any USER. USER
-assumes responsibility for determining the suitability of the SGML
-Parser Materials for its use and for results obtained. SGMLUG makes
-no warranty that any errors have been eliminated from the SGML Parser
-Materials or that they can be eliminated by USER. SGMLUG shall not
-provide any support maintenance or other aid to USER or its licensees
-with respect to SGML Parser Materials. SGMLUG shall not be
-responsible for losses of any kind resulting from use of the SGML
-Parser Materials including (without limitation) any liability for
-business expense, machine downtime, or damages caused to USER or third
-parties by any deficiency, defect, error, or malfunction.
-
-(b) SGMLUG DISCLAIMS ALL WARRANTIES, EXPRESSED OR IMPLIED, ARISING OUT
-OF OR RELATING TO THE SGML PARSER MATERIALS OR ANY USE THEREOF,
-INCLUDING (WITHOUT LIMITATION) ANY WARRANTY WHATSOEVER AS TO THE
-FITNESS FOR A PARTICULAR USE OR THE MERCHANTABILITY OF THE SGML PARSER
-MATERIALS.
-
-(c) In no event shall SGMLUG be liable to USER or third parties
-licensed by USER for any indirect, special, incidental, or
-consequential damages (including lost profits).
-(d) SGMLUG has no knowledge of any conditions that would impair its right
-to license the SGML Parser Materials. Notwithstanding the foregoing,
-SGMLUG does not make any warranties or representations that the
-SGML Parser Materials are free of claims by third parties of patent,
-copyright infringement or the like, nor does SGMLUG assume any
-liability in respect of any such infringement of rights of third
-parties due to USER's operation under this license.
diff --git a/usr.bin/sgmls/Makefile b/usr.bin/sgmls/Makefile
deleted file mode 100644
index 96ce820..0000000
--- a/usr.bin/sgmls/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# Bmake file for sgmls
-# $Id$
-#
-
-SUBDIR= libsgmls sgmls instant
-
-.include <bsd.subdir.mk>
-
diff --git a/usr.bin/sgmls/Makefile.inc b/usr.bin/sgmls/Makefile.inc
deleted file mode 100644
index 7a78864..0000000
--- a/usr.bin/sgmls/Makefile.inc
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# Bmakefile for rast
-#
-# $Id$
-#
-
-.if exists(${.CURDIR}/../../Makefile.inc)
-.include "${.CURDIR}/../../Makefile.inc"
-.endif
-
-.if exists(${.OBJDIR}/../libsgmls)
-LIBSGMLS= ${.OBJDIR}/../libsgmls/libsgmls.a
-.else
-LIBSGMLS= ${.CURDIR}/../libsgmls/libsgmls.a
-.endif
-
diff --git a/usr.bin/sgmls/README b/usr.bin/sgmls/README
deleted file mode 100644
index e2a8204..0000000
--- a/usr.bin/sgmls/README
+++ /dev/null
@@ -1,138 +0,0 @@
-$Id$
-
-This the sgmls release 1.1 SGML parser written by James Clark
-jjc@jclark.com, repackaged for FreeBSD. The original source may be
-obtained from ftp://ftp.jclark.com/.
-
-Pieces removed include:
- * Test documents: Compiled on FreeBSD, sgmls passes all tests.
- * sgml-mode.el: The sole file covered by the GNU GPL. This is not
- installed anyway and anyone wishing to do serious SGML editing
- would be best to get the psgml package.
- * Makefiles and config files for other operating systems (vms, dos,
- cms).
- * Formatted versions of the man pages.
-
-
-20-Apr-1995 John Fieber <jfieber@freebsd.org>
-
-
-The original README and TODO follow.
-----------------------------------------------------------------------
-This is sgmls, an SGML parser derived from the ARCSGML parser
-materials which were written by Charles F. Goldfarb. (These are
-available for anonymous ftp from ftp.ifi.uio.no [128.240.88.1] in the
-directory SIGhyper/SGMLUG/distrib.)
-
-The version number is given in the file version.c.
-
-The file INSTALL contains installation instructions.
-
-The file NEWS describes recent user-visible changes.
-
-The file sgmls.man contains a Unix manual page; sgmls.txt is the
-formatted version of this.
-
-The file sgml-mode.el contains a very simple SGML mode for GNU Emacs.
-
-The files sgmls.c and sgmls.h contain a small library for parsing the
-output of sgmls. This is used by sgmlsasp, which translates the
-output of sgmls using an ASP replacement file, and by rast, which
-translates the output of sgmls to the format of a RAST result. The
-files sgmlsasp.man and rast.man contain Unix manual pages for sgmlsasp
-and rast; sgmlsasp.txt and rast.txt are the formatted versions of
-these.
-
-The file LICENSE contains the license which applies to arcsgml and
-accordingly to those parts of sgmls derived from arcsgml. See also
-the copyright notice at the beginning of sgmlxtrn.c. The parts that
-were written by me are in the public domain (any files that were
-written entirely by me contain a comment to that effect.) The file
-sgml-mode.el is covered by the GNU GPL.
-
-Please report any bugs to me. When reporting bugs, please include the
-version number, details of your machine, OS and compiler, and a
-complete self-contained file that will allow me to reproduce the bug.
-
-James Clark
-jjc@jclark.com
-
-----------------------------------------------------------------------
-Warn about mixed content models where #PCDATA can't occur everywhere.
-
-Perhaps there should be a configuration option saying what a control
-character is for the purpose of SHUNCHAR CONTROLS.
-
-Should the current character that is printed in error messages be
-taken from be taken from the file entity or the current entity?
-
-Refine SYS_ action. If we distinguish DELNONCH in lexmark, lexgrp,
-lexsd, we can have separate action that ignores the following
-character as well.
-
-Should RSs in CDATA/SDATA entities be ignored as specified in 322:1-2?
-Similarily, do the rules on REs in 322:3-11 apply to CDATA/SDATA
-entities? (I don't think they count as being `in content'.)
-
-What should the entity manager do when it encounters code 13 in an
-input file? (Currently it treats it as an RE.)
-
-Document when invalid exclusions are detected.
-
-Option not to perform capacity checking.
-
-Give a warning if the recommendation of 422:1-3 is contravened.
-
-Should an empty CDATA/RCDATA marked section be allowed in the document
-type declaration subset?
-
-Include example of use of SGML_PATH in documentation.
-
-Try to detect the situation in 310:8-10 (but see 282:1-2).
-
-Resize hash tables if they become too full.
-
-Say something in the man page about message catalogues.
-
-Consider whether support for SHORTREF NONE requires further changes
-(other than disallowing short reference mapping declaration).
-
-Fake /dev/fd/N and /dev/stdin for systems that don't provide it.
-
-Improve the effficiency of the entity manager by not closing and
-reopening files. If we run out of FILEs choose the stream with the
-fewest bytes remaining to be read, and read the rest of it into
-memory. Each entity level will have its own read buffer.
-
-Support multi-line error messages: automatically indent after
-newline. (We could output to a temporary file first, then copy to
-stderr replacing newlines by newline+indent).
-
-Option that says to output out of context things.
-
-Divide up formal public identifier errors. Give these errors their
-own type code.
-
-Consider whether, when OMITTAG is NO, we need to change interpretation
-of an empty start-tag (7.4.1.1).
-
-Possibly turn errors 70 and 136 into warnings.
-
-Make things work with NORMSEP > 2. Would need to keep track of number
-of CDATA and SDATA entities in CDATA attributes.
-
-Handle `SCOPE INSTANCE'.
-
-In entgen.c, truncate filenames for OSs that don't do this themselves.
-
-Provide an option that specifies that maximum number of errors; when
-this limit is exceeded sgmls would exit.
-
-Document non-portable assumptions in the code.
-
-Option to write out SGML declaration. In this case make it write out
-APPINFO parameter.
-
-Allow there to be catalogs mapping public ids to filenames.
-Environment variable SGML_CATALOG containing list of filenames of
-catalogs.
diff --git a/usr.bin/sgmls/configure b/usr.bin/sgmls/configure
deleted file mode 100755
index 7fd1968..0000000
--- a/usr.bin/sgmls/configure
+++ /dev/null
@@ -1,617 +0,0 @@
-#!/bin/sh
-# Generate config.h from unix.cfg.
-
-trap 'rm -f doit doit.c doit.o doit.log config.out; exit 1' 1 2 3 15
-
-on=
-off=
-CC=${CC-cc}
-
-# Normally we use VARARGS if __STDC__ is not defined.
-# Test whether this assumption is wrong.
-
-cat >doit.c <<\EOF
-#ifdef __STDC__
-#include <stdarg.h>
-int foo(char *s,...)
-{
- va_list ap;
-
- va_start(ap, s);
- va_end(ap);
- return 0;
-}
-#else
-int foo = 0;
-#endif
-EOF
-
-$CC $CFLAGS -c doit.c >/dev/null 2>&1
-if test $? -ne 0
-then
- on="$on VARARGS"
-fi
-
-cat >doit.c <<\EOF
-#include <stddef.h>
-int foo = 0;
-EOF
-
-if $CC $CFLAGS -c doit.c >/dev/null 2>&1
-then
- off="$off STDDEF_H_MISSING"
-else
- on="$on STDDEF_H_MISSING"
-fi
-
-cat >doit.c <<\EOF
-#include <stdlib.h>
-int foo = 0;
-EOF
-
-if $CC $CFLAGS -c doit.c >/dev/null 2>&1
-then
- off="$off STDLIB_H_MISSING"
-else
- on="$on STDLIB_H_MISSING"
-fi
-
-cat >doit.c <<\EOF
-#include <limits.h>
-int foo = 0;
-EOF
-
-if $CC $CFLAGS -c doit.c >/dev/null 2>&1
-then
- off="$off LIMITS_H_MISSING"
-else
- on="$on LIMITS_H_MISSING"
-fi
-
-cat >doit.c <<\EOF
-#include <vfork.h>
-int foo = 0;
-EOF
-
-if $CC $CFLAGS -c doit.c >/dev/null 2>&1
-then
- on="$on HAVE_VFORK_H"
-else
- off="$off HAVE_VFORK_H"
-fi
-
-cat >doit.c <<\EOF
-#include <unistd.h>
-int foo = 0;
-EOF
-
-if $CC $CFLAGS -c doit.c >/dev/null 2>&1
-then
- on="$on HAVE_UNISTD_H"
-else
- off="$off HAVE_UNISTD_H"
-fi
-
-cat >doit.c <<\EOF
-#include <sys/types.h>
-#include <sys/stat.h>
-int foo = 0;
-EOF
-
-if $CC $CFLAGS -c doit.c >/dev/null 2>&1
-then
- on="$on HAVE_SYS_STAT_H"
-else
- off="$off HAVE_SYS_STAT_H"
-fi
-
-cat >doit.c <<\EOF
-/* Exit normally unless we need to use isascii. */
-
-#include <ctype.h>
-#include <signal.h>
-
-static int whoops()
-{
- _exit(1);
-}
-
-main()
-{
- int c;
-#ifdef isascii
-#ifdef SIGSEGV
- signal(SIGSEGV, whoops);
-#endif
-#ifdef SIGBUS
- signal(SIGBUS, whoops);
-#endif
-#ifdef SIGIOT
- signal(SIGIOT, whoops);
-#endif
-
- for (c = 128; c < 256; c++) {
- if (c == '0' || c == '1' || c == '2' || c == '3' || c == '4' || c == '5'
- || c == '6' || c == '7' || c == '8' || c == '9') {
- if (!isdigit(c) || isalpha(c) || iscntrl(c) || isspace(c) || ispunct(c))
- exit(1);
- }
- else if (isdigit(c))
- exit(1);
- else if (isalpha(c)) {
- if (iscntrl(c) || isspace(c) || ispunct(c)
- || (islower(c) && toupper(c) != c && !isupper(toupper(c)))
- || (isupper(c) && tolower(c) != c && !islower(tolower(c))))
- exit(1);
- }
- else if (islower(c) || isupper(c))
- exit(1);
- else if (iscntrl(c)) {
- if (ispunct(c))
- exit(1);
- }
- }
-#endif /* isascii */
- exit(0);
-}
-EOF
-
-if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null
-then
- # This tries to find the symbol that looks like the array
- # used by <ctype.h>, and sees if its length appears to be 128
- # rather than 256.
- if test 1 = `(nm -n doit 2>/dev/null) | awk '
-BEGIN {
- weight["0"] = 0;
- weight["1"] = 1;
- weight["2"] = 2;
- weight["3"] = 3;
- weight["4"] = 4;
- weight["5"] = 5;
- weight["6"] = 6;
- weight["7"] = 7;
- weight["8"] = 8;
- weight["9"] = 9;
- weight["a"] = weight["A"] = 10;
- weight["b"] = weight["B"] = 11;
- weight["c"] = weight["C"] = 12;
- weight["d"] = weight["D"] = 13;
- weight["e"] = weight["E"] = 14;
- weight["f"] = weight["F"] = 15;
-}
-
-/^[0-9a-zA-Z]* D .*ctype/ && ctype_nr == 0 {
- ctype_nr = NR;
- addr = 0;
- len = length($1);
- for (i = 1; i <= len; i++)
- addr = addr*16 + weight[substr($1, i, 1)];
-}
-
-/^[0-9a-zA-Z]* D / && NR == ctype_nr + 1 {
- next_addr = 0;
- len = length($1);
- for (i = 1; i <= len; i++)
- next_addr = next_addr*16 + weight[substr($1, i, 1)];
-}
-
-END {
- size = next_addr - addr;
- if (size >= 128 && size < 256)
- print "1";
- else
- print "0";
-}'`
- then
- on="$on USE_ISASCII"
- else
- if ((yes | man 3 ctype) 2>/dev/null) \
- | sed -e 's/.//g' -e 's/ *$//' -e '/de-$/N' \
- -e 's/-\n//g' -e '/defined$/N' -e '/only$/N' \
- -e '/where$/N' -e '/isascii$/N' -e '/is$/N' \
- -e 's/\n/ /g' -e 's/ */ /g' \
- | grep "defined only where isascii is true" >/dev/null
- then
- on="$on USE_ISASCII"
- else
- off="$off USE_ISASCII"
- fi
- fi
-else
- on="$on USE_ISASCII"
-fi
-
-cat >doit.c <<\EOF
-main(argc, argv)
-int argc;
-char **argv;
-{
- if (argc == 0)
- remove("foo");
- exit(0);
-}
-EOF
-
-if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null
-then
- off="$off REMOVE_MISSING"
-else
- on="$on REMOVE_MISSING"
-fi
-
-cat >doit.c <<\EOF
-main(argc, argv)
-int argc;
-char **argv;
-{
- if (argc == 0)
- getopt(argc, argv, "v");
- exit(0);
-}
-EOF
-
-if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null
-then
- on="$on HAVE_GETOPT"
-else
- off="$off HAVE_GETOPT"
-fi
-
-cat >doit.c <<\EOF
-main(argc, argv)
-int argc;
-char **argv;
-{
- if (argc == 0)
- access("foo", 4);
- exit(0);
-}
-EOF
-
-if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null
-then
- on="$on HAVE_ACCESS"
-else
- off="$off HAVE_ACCESS"
-fi
-
-cat >doit.c <<\EOF
-main(argc, argv)
-int argc;
-char **argv;
-{
- if (argc == 0)
- vfork();
- exit(0);
-}
-EOF
-
-if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null
-then
- on="$on HAVE_VFORK"
-else
- off="$off HAVE_VFORK"
-fi
-
-cat >doit.c <<\EOF
-main(argc, argv)
-int argc;
-char **argv;
-{
-
- if (argc == 0) {
- int status;
- waitpid(-1, &status, 0);
- }
- exit(0);
-}
-EOF
-
-if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null
-then
- on="$on HAVE_WAITPID"
-else
- off="$off HAVE_WAITPID"
-fi
-
-cat >doit.c <<\EOF
-#include <string.h>
-main(argc, argv)
-int argc;
-char **argv;
-{
- if (argc == 0)
- strerror(0);
- exit(0);
-}
-EOF
-
-if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null
-then
- off="$off STRERROR_MISSING"
-else
- on="$on STRERROR_MISSING"
-fi
-
-cat >doit.c <<\EOF
-#include <strings.h>
-main(argc, argv)
-int argc;
-char **argv;
-{
- if (argc == 0)
- bcopy((char *)0, (char *)0, 0);
- exit(0);
-}
-EOF
-
-if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null
-then
- # Only use BSD_STRINGS if ANSI string functions don't work.
- cat >doit.c <<\EOF
-#include <string.h>
-main(argc, argv)
-int argc;
-char **argv;
-{
- if (argc == 0)
- memcpy((char *)0, (char *)0, 0);
- exit(0);
-}
-EOF
-
- if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null
- then
- off="$off BSD_STRINGS"
- else
- on="$on BSD_STRINGS"
- fi
-else
- off="$off BSD_STRINGS"
-fi
-
-cat >doit.c <<\EOF
-#include <signal.h>
-main(argc, argv)
-int argc;
-char **argv;
-{
- if (argc == 0)
- raise(SIGINT);
- exit(0);
-}
-EOF
-
-if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null
-then
- off="$off RAISE_MISSING"
-else
- on="$on RAISE_MISSING"
-fi
-
-cat >doit.c <<\EOF
-#include <stdio.h>
-main(argc, argv)
-int argc;
-char **argv;
-{
- if (argc == 0) {
- fpos_t pos;
- fsetpos(stdin, &pos);
- fgetpos(stdin, &pos);
- }
- exit(0);
-}
-EOF
-
-if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null
-then
- off="$off FPOS_MISSING"
-else
- on="$on FPOS_MISSING"
-fi
-
-cat >doit.c <<\EOF
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-
-main(argc, argv)
-int argc;
-char **argv;
-{
- if (argc == 0) {
- pid_t pid;
- int status;
- long n = sysconf(_SC_OPEN_MAX);
- pid = waitpid(-1, &status, 0);
- WIFSTOPPED(status);
- WIFSIGNALED(status);
- WIFEXITED(status);
- WEXITSTATUS(status);
- WTERMSIG(status);
- WSTOPSIG(status);
- }
- exit(0);
-}
-EOF
-
-if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null
-then
- on="$on POSIX"
-else
- off="$off POSIX"
-fi
-
-cat >doit.c <<\EOF
-#include <stdio.h>
-#include <signal.h>
-
-static int whoops()
-{
- _exit(1);
-}
-
-main()
-{
- char buf[30];
-#ifdef SIGSEGV
- signal(SIGSEGV, whoops);
-#endif
-#ifdef SIGBUS
- signal(SIGBUS, whoops);
-#endif
-#ifdef SIGIOT
- signal(SIGIOT, whoops);
-#endif
- sprintf(buf, "%2$s%2$s%1$s%1$s", "bar", "foo");
- exit(!!strcmp(buf, "foofoobarbar"));
-}
-EOF
-
-if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null
-then
- on="$on HAVE_EXTENDED_PRINTF"
-else
- off="$off HAVE_EXTENDED_PRINTF"
-fi
-
-cat >doit.c <<\EOF
-#include <nl_types.h>
-
-main(argc, argv)
-int argc;
-char **argv;
-{
- if (argc == 0) {
- nl_catd d = catopen("foo", 0);
- catgets(d, 1, 1, "default");
- catclose(d);
- }
- exit(0);
-}
-EOF
-
-if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null
-then
- on="$on HAVE_CAT"
-else
- off="$off HAVE_CAT"
-fi
-
-cat >doit.c <<\EOF
-#include <limits.h>
-
-char c = UCHAR_MAX;
-
-main(argc, argv)
-int argc;
-char **argv;
-{
-#if CHAR_MIN < 0
- exit(!(c < 0));
-#else
- exit(!(c > 0));
-#endif
-}
-EOF
-
-if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null
-then
- char_signed=
-else
- cat >doit.c <<\EOF
-main()
-{
- int i;
-
- for (i = 0; i < 512; i++) {
- char c = (char)i;
- if (c < 0)
- exit(1);
- }
- exit(0);
-}
-EOF
-
- if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null
- then
- char_signed=0
- else
- char_signed=1
- fi
-fi
-
-cat >doit.c <<\EOF
-
-typedef void VOID;
-
-extern VOID bar();
-
-VOID foo()
-{
-}
-EOF
-
-if $CC $CFLAGS -c doit.c >/dev/null 2>&1
-then
- void_ret=void
-else
- void_ret=int
-fi
-
-
-cat >doit.c <<\EOF
-
-void *foo()
-{
- static char *buf;
- return buf;
-}
-EOF
-
-if $CC $CFLAGS -c doit.c >doit.log 2>&1
-then
- if test -s doit.log
- then
- void_star="char \*"
- else
- void_star="void \*"
- fi
-
-else
- void_star="char \*"
-fi
-
-edit=
-
-rm -f doit.c doit doit.log doit.o
-
-for var in $on
-do
- edit="$edit -e 's;^/\\* *\\(#define $var [^/]*\\) *\\*/;\\1;'"
-done
-for var in $off
-do
- edit="$edit -e 's;^#define $var [^/]*;/* & */;'"
-done
-
-if test -n "$char_signed"
-then
- edit="$edit -e 's;^/\\* *\\(#define CHAR_SIGNED $char_signed\\) *\\*/;\\1;'"
-fi
-
-edit="$edit -e 's/^typedef .*VOID;/typedef $void_ret VOID;/'"
-edit="$edit -e 's/^typedef .*UNIV;/typedef ${void_star}UNIV;/'"
-
-if test "X$(PREFIX)" != "X/usr/local"
-then
- edit="$edit -e '/DEFAULT_PATH/s;/usr/local;$PREFIX;g'"
-fi
-
-eval sed $edit unix.cfg ">config.out"
-
-mv config.out config.h
-
-exit 0
diff --git a/usr.bin/sgmls/instant/Makefile b/usr.bin/sgmls/instant/Makefile
deleted file mode 100644
index c004f87..0000000
--- a/usr.bin/sgmls/instant/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-# $Id$
-
-PROG= instant
-SRCS= browse.c info.c main.c tables.c traninit.c translate.c
-SRCS+= tranvar.c util.c
-
-CFLAGS+= -I${.CURDIR}/../libsgmls -I${.CURDIR}/../sgmls
-
-LDADD= ${LIBSGMLS} -lcompat
-DPADD= ${LIBSGMLS} ${LIBCOMPAT}
-
-MAN1= instant.1
-MAN5= transpec.5
-
-.include <bsd.prog.mk>
diff --git a/usr.bin/sgmls/instant/README b/usr.bin/sgmls/instant/README
deleted file mode 100644
index d04547c..0000000
--- a/usr.bin/sgmls/instant/README
+++ /dev/null
@@ -1,150 +0,0 @@
-#
-# Copyright (c) 1994
-# Open Software Foundation, Inc.
-#
-# Permission is hereby granted to use, copy, modify and freely distribute
-# the software in this file and its documentation for any purpose without
-# fee, provided that the above copyright notice appears in all copies and
-# that both the copyright notice and this permission notice appear in
-# supporting documentation. Further, provided that the name of Open
-# Software Foundation, Inc. ("OSF") not be used in advertising or
-# publicity pertaining to distribution of the software without prior
-# written permission from OSF. OSF makes no representations about the
-# suitability of this software for any purpose. It is provided "as is"
-# without express or implied warranty.
-#
-
- instant - a formatting application for OSF SGML instances
-____________________________________________________________________________
-
-Requirements
-
- ANSI C compiler (gcc is one)
-
- sgmls 1.1 -- sgml parser from James Clark. Based on Goldfarb's ARC parser.
-
- Vanilla unix make
-
- POSIX C libraries
-
-
-Files for instant program
-
- Module Function
- ------ --------
- browse.c interactive browser
- general.h general definitions
- info.c print information about the instances
- main.c main entry, arg parsing, instance reading
- tables.c table-specific formatting routines (TeX and tbl)
- traninit.c translator initialization (read spec, etc.)
- translate.c main translator
- translate.h structure definitions for translation code
- tranvar.c routines for handling "special variables"
- util.c general utilities
-
-
-Also required
-
- 1. Translation spec (transpec) files. (../transpecs/*.ts)
- 2. SDATA mapping files for mapping sdata entities. (../transpecs/*.sdata)
- 3. Character mapping files for mapping characters. (../transpecs/*.cmap)
-
-
-Platforms tried on
-
- OSF1 1.3 (i486)
- Ultrix 4.2 (mips)
- HP-UX 9.01 (hp 9000/700)
- AIX 3.2 (rs6000)
- SunOS [missing strerror()]
-
-____________________________________________________________________________
-
- General outline of program
- ------- ------- -- -------
-
-To summarize in a sentence, instant reads the output of sgmls, builds a tree
-of the instnace in memory, then traverses the tree in in-order, processing
-the nodes according to a translation spec.
-
-Element tree storage
-------- ---- -------
-
-The first thing instant must do is read the ESIS (output of sgmls) from the
-specified file or stdin, forming a tree in memory. (Nothing makes sense
-without an instance...) Each element of the instance is a node in the tree,
-stored as a structure called Element_t. Elements contain content (what
-else?), which is a mixture of data (#PCDATA, #CDATA, #RCDATA - all the same
-in the ESIS), child elements, and PIs. Each 'chunk' of content is referred
-to by a Content_t structure. A Content_t contains an enum that can point to
-a string (data or PI), another Element_t. For example, if a <p> element
-contains some characters, an <emphasis> element, some more characters,
-a <function> element, then some more characters, it has 5 Content_t children
-as an array.
-
-Element_t's have pointers to their parents, and a next element in a linked
-list (they're stored as a linked list, for cases when you'd want to quickly
-travers all the nodes, in no particular order).
-For convenience, Element_t's have an array of pointers to it's child
-Element_t's. These are just pointers to the same thing contained in the
-Content_t array, without the intervening data or PIs. This makes it easier
-for the program to traverse the elements of the tree (it does not have to
-be concerned with skipping data, etc.). There is an analagous array of
-pointers for the data content, an array of (char *)'s. This makes it easier
-to consider the immediate character content of an element.
-
-Attributes are kept as an array of name-value mappings (using the typedef
-Mapping_t). ID attributes are also stored in a separate list of ID value -
-element pointer pairs so that it is quick to find an element by ID.
-
-Other information kept about each element (in the Element_t struct) includes
-the line number in the EISI where the element occurs, the input filename.
-(These depend on sgmls being run with the "-l" option.) Also stored is
-an element's order in its parent's collection of children and an element's
-depth in the tree.
-
-Translation specs
------------ -----
-
-A translation spec is read into a linked list in memory. As the instance
-tree is traversed, the transpecs are searched in order for a match. As a
-rule, one should position the less specific transpecs later in the file.
-Also, specs for seldom-used element are best placed later in the file, since
-it takes cpu cycles to skip over them for each of the more-used elements.
-
-During translation of a particular element, the list of Content_t structures
-are processed in order. If a content 'chunk' is data, it is printed to
-the output stream. If it is an element, the translation routine is called
-for that elemen, recursively. Hence, in-order traversal.
-
-Miscellaneous information displays
-------------- ----------- --------
-
-There are several informational display options available. They include:
- - a list of element usage (-u) -- lists each element in the instance,
- it's attributes, number of children, parent, data content 'nodes'.
- - statistics about elements (-S) -- lists elements, number of times
- each is used, percent of elements that this is, total char content
- in that element, average number of characters in they element.
- - show context of each element (-x) -- lists each element and its
- context, looking up the tree (this is the same context that
- would match the Context field of a transpec).
- - show the hierarchy of the instance (-h) -- show an ascii 'tree' of
- the instance, where elements deeper in the tree are indented more.
- Numbers after the element name in parentheses are the number of
- element content nodes and the number of data content nodes.
-
-Interactive browser
------------ -------
-
-Originally, the interactive browser was intended as a debugging aid for
-the code developer. It was a way to examine a particular node of the
-instance tree or process a subtree without being distracted by the rest
-of the instance. Many of the commands test functionality of the query
-and search code (such as testing whether a certain element has a given
-relationship to the current position in the tree).
-
-
-____________________________________________________________________________
-
diff --git a/usr.bin/sgmls/instant/browse.c b/usr.bin/sgmls/instant/browse.c
deleted file mode 100644
index c904476..0000000
--- a/usr.bin/sgmls/instant/browse.c
+++ /dev/null
@@ -1,462 +0,0 @@
-/*
- * Copyright 1993 Open Software Foundation, Inc., Cambridge, Massachusetts.
- * All rights reserved.
- */
-/*
- * Copyright (c) 1994
- * Open Software Foundation, Inc.
- *
- * Permission is hereby granted to use, copy, modify and freely distribute
- * the software in this file and its documentation for any purpose without
- * fee, provided that the above copyright notice appears in all copies and
- * that both the copyright notice and this permission notice appear in
- * supporting documentation. Further, provided that the name of Open
- * Software Foundation, Inc. ("OSF") not be used in advertising or
- * publicity pertaining to distribution of the software without prior
- * written permission from OSF. OSF makes no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- */
-/*
- * Copyright (c) 1996 X Consortium
- * Copyright (c) 1995, 1996 Dalrymple Consulting
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * X CONSORTIUM OR DALRYMPLE CONSULTING BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the names of the X Consortium and
- * Dalrymple Consulting shall not be used in advertising or otherwise to
- * promote the sale, use or other dealings in this Software without prior
- * written authorization.
- */
-
-/* ________________________________________________________________________
- *
- * Module for interactive browsing.
- *
- * Entry points for this module:
- * Browse() interactive browser
- * ________________________________________________________________________
- */
-
-#ifndef lint
-static char *RCSid =
- "$Header: /usr/src/docbook-to-man/Instant/RCS/browse.c,v 1.2 1996/06/02 21:46:10 fld Exp $";
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <string.h>
-
-#include "general.h"
-
-static void PrElemPlusID(Element_t *);
-static void ls_node(Element_t *, int, char **);
-static void do_query(Element_t *, char *, char *);
-static void do_find(Element_t *, char **);
-
-/* ______________________________________________________________________ */
-
-static char *br_help_msg[] = {
- " ls List info about current element in tree",
- " (context, children, attributes, etc.)",
- " cd N ... Change to Nth elememt child, where N is shown by 'ls'.",
- " N may also be '/' (top) or '..' (up).",
- " cd id I Change to elememt whose ID is I",
- " data N Show data of Nth data node",
- " where Show current position in the tree",
- " id I Show path to element with id I",
- " (using '?' for I will lists all IDs and their paths)",
- " find S Find elements matching spec S. Recognized syntaxes:",
- " find attr <name> <value>",
- " find cont <string>",
- " find parent <gi-name>",
- " find child <gi-name>",
- " find gi <gi-name>",
- " q rel gi Query: report if elem 'gi' has relation to current elem",
- " ('rel' is one of 'child parent ancestor descendant",
- " sibling sibling+ sibling+1 sibling- sibling-1 cousin')",
- "",
- " tran [outfile]",
- " Translate into 'outfile' (stdout)",
- " stat Print statistics (how often elements occur, etc.)",
- " sum Print elem usage summary (# of children, depth, etc.)",
- " tree Print document hierarchy as a tree",
- " cont Print context of each element",
- NULL
-};
-
-/* ______________________________________________________________________ */
-
-void
-Browse()
-{
- char buf[256], *cmd, **av, **sv;
- char *Prompt;
- Element_t *ce; /* current element */
- Element_t *e;
- int i, n, ac;
-
- if (slave) Prompt = "=>\n";
- else Prompt = "=> ";
-
- ce = DocTree;
- while (fputs(Prompt, stdout)) {
- if (!fgets(buf, 256, stdin)) break;
- stripNL(buf);
- if (buf[0] == EOS) {
- fputs(Prompt, stdout);
- continue;
- }
- ac = 20;
- av = Split(buf, &ac, S_ALVEC);
- if (ac > 0) cmd = av[0];
- if (!cmd || !(*cmd)) continue;
-
- if (!strcmp(cmd, "ls")) ls_node(ce, ac, av);
-
- else if (!strcmp(cmd, "cd")) {
- if (av[1]) {
- if (ac == 3 && !strcmp(av[1], "id")) {
- if ((e = FindElemByID(av[2]))) ce = e;
- else printf("Element with ID '%s' not found.\n", av[2]);
- continue;
- }
- for (i=1; i<ac; i++) {
- if (!strcmp(av[i], "..")) {
- if (ce->parent) ce = ce->parent;
- continue;
- }
- if (!strcmp(av[i], "/")) {
- if (ce->parent) ce = DocTree;
- continue;
- }
- if (!isdigit(*av[i])) {
- printf("Expecting digit, '..', or '/', got '%s'.\n",
- av[i]);
- break;
- }
- n = atoi(av[i]);
- if (n < ce->necont) ce = ce->econt[n];
- else {
- printf("Must be in range 0 - %d.\n", ce->necont);
- break;
- }
- }
- }
- }
-
- else if (!strcmp(cmd, "data")) {
- if (av[1] && isdigit(*av[1])) {
- n = atoi(av[1]);
- if (n < ce->ndcont) {
- printf(ce->dcont[n]);
- fputs("\n", stdout);
- }
- else if (ce->ndcont == 0)
- printf("No data at this node.\n");
- else printf("Must be in range 0 - %d.\n", ce->ndcont);
- }
- }
-
- /* show where we are in the tree */
- else if (!strcmp(cmd, "where")) PrintLocation(ce, stdout);
-
- /* show where we are in the tree */
- else if (!strcmp(cmd, "pwd")) PrElemPlusID(ce);
-
- /* perform query with yes/no answer */
- else if (!strcmp(cmd, "q") && av[1] && av[2])
- do_query(ce, av[1], av[2]);
-
- /* perform query printing paths to matching elements */
- else if (!strcmp(cmd, "find") && av[1] && av[2])
- do_find(ce, av);
-
- /* list locations where specified ID(s) occur */
- else if (!strcmp(cmd, "id")) {
- if (ac <= 1) continue;
- if (*av[1] == '?') PrintIDList();
- else {
- /* short: "id i1 i2 ...", long: "id -l i1 i2 ..." */
- if (!strcmp(av[1], "-l")) n = 2;
- else n = 1;
- for (i=n; i<ac; i++) {
- if ((e = FindElemByID(av[i]))) {
- if (n == 2) { /* long (multiline) format */
- if (n != i) putchar('\n');
- PrintLocation(e, stdout);
- }
- else PrElemPlusID(e);
- }
- else printf("Element with ID '%s' not found.\n", av[i]);
- }
- }
- }
-
- /* show and set variables */
- else if (!strcmp(cmd, "show") && av[1]) {
- printf("%s\n", FindMappingVal(Variables, av[1]));
- }
- else if (!strcmp(cmd, "set") && av[1] && av[2]) {
- SetMappingNV(Variables, av[1], av[2]);
- }
-
- /* print summary of tag usage */
- else if (!strcmp(cmd, "sum")) {
- if (ac > 1) PrintElemSummary(ce);
- else PrintElemSummary(DocTree);
- }
- /* print element tree */
- else if (!strcmp(cmd, "tree")) {
- if (ac > 1) PrintElemTree(ce);
- else PrintElemTree(DocTree);
- }
- /* print statistics */
- else if (!strcmp(cmd, "stat")) {
- if (ac > 1) PrintStats(ce);
- else PrintStats(DocTree);
- }
- /* print context of each element of tree */
- else if (!strcmp(cmd, "cont")) {
- if (ac > 1) PrintContext(ce);
- else PrintContext(DocTree);
- }
- /* print translation, given transpec */
- else if (!strcmp(cmd, "tran")) {
- FILE *fp;
- if (ac > 1){
- if (!(fp = fopen(av[1], "w"))) {
- perror("Can not open output file");
- continue;
- }
- }
- else fp = stdout;
- DoTranslate(ce, fp);
- if (ac > 1) fclose(fp);
- }
-
- else if (!strcmp(cmd, "help") || *cmd == '?') {
- sv = br_help_msg;
- while (*sv) puts(*sv++);
- }
-
- /* quit (control-D also works) */
- else if (!strcmp(cmd, "quit")) break;
-
- else
- fprintf(stderr, "Unknown command '%s' - ingored.\n", cmd);
- }
- putc(NL, stdout);
-}
-
-/* ______________________________________________________________________ */
-/* Do the "ls" command.
- * Arguments:
- * Pointer to element under consideration.
- * Arg count from command line (this command, not the shell command).
- * Arg vector.
- */
-
-static void
-ls_node(
- Element_t *e,
- int ac,
- char **av
-)
-{
- int i;
- char buf[LINESIZE];
-
- if (ac > 1 && !strcmp(av[1], "-n")) {
- for(i=0; i<e->ncont; i++) {
- if (IsContElem(e,i)) printf("%s\n", ContElem(e,i)->gi);
- else if (IsContData(e,i)) printf("#data %s\n", ContData(e,i));
- else if (IsContPI(e,i)) printf("#pi %s\n", ContData(e,i));
- }
- return;
- }
-
- printf("Element: %s\tLineNumber: %d\n", e->gi, e->lineno);
- if (e->parent)
- printf("Context: %s\n", FindContext(e, 20, buf));
-
- if (e->natts) {
- printf("%d attributes:\n", e->natts);
- for (i=0; i<e->natts; i++)
- printf("\t%2d: %s = '%s'\n", i, e->atts[i].name, e->atts[i].sval);
- }
- if (e->entity) {
- printf("Entity & notation information:\n");
- if (e->entity->ename)
- printf("Entity name: %s\n", e->entity->ename);
- if (e->entity->nname)
- printf("Notation name: %s\n", e->entity->nname);
- if (e->entity->sysid)
- printf("Sys id: %s\n", e->entity->sysid);
- if (e->entity->pubid)
- printf("Pub id: %s\n", e->entity->pubid);
- if (e->entity->fname)
- printf("Filename: %s\n", e->entity->fname);
- }
-
- if (e->my_eorder >= 0)
- printf("My order among my siblings: %d\n", e->my_eorder);
-
- if (e->necont) {
- printf("%d child element nodes:\n", e->necont);
- for(i=0; i<e->necont; i++) printf("\t%2d: %s\n", i, e->econt[i]->gi);
- }
-
- if (e->ndcont) {
- printf("%d child data nodes:\n", e->ndcont);
- for(i=0; i<e->ndcont; i++) {
- if (strlen(e->dcont[i]) < 40)
- printf("\t%2d: %s\n", i, e->dcont[i]);
- else
- printf("\t%2d: %-40.40s...\n", i, e->dcont[i]);
- }
- }
-}
-
-/* ______________________________________________________________________ */
-/* Perform query. Syntax: find relationship gi. Tells whether gi has
- * given relationship to current element. Result (message) sent to stdout.
- * Args:
- * Pointer to element under consideration.
- * Pointer to name of relationship. (see FindRelByName() for names)
- * Pointer to GI to look for.
- */
-
-static void
-do_query(
- Element_t *e,
- char *rel,
- char *gi
-)
-{
- char *cp;
- Relation_t r;
- Element_t *ep;
-
- for (cp=gi; *cp; cp++) if (islower(*cp)) *cp = toupper(*cp);
-
- if ((r = FindRelByName(rel)) == REL_Unknown) {
- return;
- }
- ep = QRelation(e, gi, r);
- printf("%s, '%s' is%s %s of '%s'.\n", (ep ? "Yes" : "No"), gi,
- (ep ? "" : " not"), rel, e->gi);
-}
-
-/* ______________________________________________________________________ */
-/* Print path to the element and its ID (if it has one) on a single line.
- * Arguments:
- * Pointer to element under consideration.
- */
-static void
-PrElemPlusID(
- Element_t *e
-)
-{
- char buf[LINESIZE];
-
- if (e->id) printf("%s -- ID=%s\n", FindElementPath(e, buf), e->id);
- else printf("%s\n", FindElementPath(e, buf));
-}
-
-/* ______________________________________________________________________ */
-/* Print path to the element and its ID (if it has one) on a single line.
- * Arguments:
- * Pointer to element under consideration.
- */
-
-static void
-match_gi(
- Element_t *e,
- char **av
-)
-{
- if (!strcmp(av[1], e->gi)) PrElemPlusID(e);
-}
-
-/* Shorthand for defining simple finctions, which are just interfaces to
- * calling QRelation(). DescendTree() only passes ptr to element. */
-#define MATCH(Fun,Rel) \
- static void Fun(Element_t *e, char **av) \
- { if (QRelation(e, av[1], Rel)) PrElemPlusID(e); }
-
-MATCH(match_parent, REL_Parent)
-MATCH(match_child, REL_Child)
-MATCH(match_anc, REL_Ancestor)
-MATCH(match_desc, REL_Descendant)
-MATCH(match_sib, REL_Sibling)
-
-static void
-match_attr(
- Element_t *e,
- char **av
-)
-{
- char *atval;
-
- if ((atval = FindAttValByName(e, av[1])) && !strcmp(av[2], atval))
- PrElemPlusID(e);
-}
-
-static void
-match_cont(
- Element_t *e,
- char **av
-)
-{
- int i;
- for (i=0; i<e->ncont; i++) {
- if (IsContData(e,i) && strstr(ContData(e,i), av[1])) {
- PrElemPlusID(e);
- return;
- }
- }
-}
-
-/* Find an element, given the criteria on its command line.
- * Arguments:
- * Pointer to element under consideration.
- */
-static void
-do_find(
- Element_t *e,
- char **av
-)
-{
- av++;
- if (!strcmp(av[0], ".")) av++;
- else e = DocTree;
- if (!strcmp(av[0], "gi")) DescendTree(e, match_gi, 0, 0, av);
- else if (!strcmp(av[0], "attr")) DescendTree(e, match_attr, 0, 0, av);
- else if (!strcmp(av[0], "parent")) DescendTree(e, match_parent, 0, 0, av);
- else if (!strcmp(av[0], "child")) DescendTree(e, match_child, 0, 0, av);
- else if (!strcmp(av[0], "cont")) DescendTree(e, match_cont, 0, 0, av);
- else if (!strcmp(av[0], "sib")) DescendTree(e, match_sib, 0, 0, av);
- else if (!strcmp(av[0], "desc")) DescendTree(e, match_desc, 0, 0, av);
- else if (!strcmp(av[0], "anc")) DescendTree(e, match_anc, 0, 0, av);
- else fprintf(stderr, "Unknown find command: %s.\n", av[0]);
-}
-
-/* ______________________________________________________________________ */
diff --git a/usr.bin/sgmls/instant/general.h b/usr.bin/sgmls/instant/general.h
deleted file mode 100644
index f6e6ea0..0000000
--- a/usr.bin/sgmls/instant/general.h
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
- * Copyright 1993 Open Software Foundation, Inc., Cambridge, Massachusetts.
- * All rights reserved.
- */
-/*
- * Copyright (c) 1994
- * Open Software Foundation, Inc.
- *
- * Permission is hereby granted to use, copy, modify and freely distribute
- * the software in this file and its documentation for any purpose without
- * fee, provided that the above copyright notice appears in all copies and
- * that both the copyright notice and this permission notice appear in
- * supporting documentation. Further, provided that the name of Open
- * Software Foundation, Inc. ("OSF") not be used in advertising or
- * publicity pertaining to distribution of the software without prior
- * written permission from OSF. OSF makes no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- */
-/*
- * Copyright (c) 1996 X Consortium
- * Copyright (c) 1995, 1996 Dalrymple Consulting
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * X CONSORTIUM OR DALRYMPLE CONSULTING BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the names of the X Consortium and
- * Dalrymple Consulting shall not be used in advertising or otherwise to
- * promote the sale, use or other dealings in this Software without prior
- * written authorization.
- */
-/* ________________________________________________________________________
- *
- * Common definitions for "instant" program.
- * ________________________________________________________________________
- */
-
-#ifdef STORAGE
-#ifndef lint
-static char *gen_h_RCSid =
- "$Header: /usr/src/docbook-to-man/Instant/RCS/general.h,v 1.5 1996/06/11 20:25:03 fld Exp $";
-#endif
-#endif
-
-/* string/numeric/character definitions */
-
-#define EOS '\0'
-#define NL '\n'
-#define TAB '\t'
-#define CR '\r'
-#define ANCHOR '^'
-
-/* bigmask/flags for the Split() function */
-#define S_STRDUP 0x01
-#define S_ALVEC 0x02
-
-/* Command codes (1st char of esis lines) from sgmls. See its manpage. */
-#define CMD_DATA '-'
-#define CMD_OPEN '('
-#define CMD_CLOSE ')'
-#define CMD_ATT 'A'
-#define CMD_D_ATT 'D'
-#define CMD_NOTATION 'N'
-#define CMD_EXT_ENT 'E'
-#define CMD_INT_ENT 'I'
-#define CMD_SYSID 's'
-#define CMD_PUBID 'p'
-#define CMD_FILENAME 'f'
-#define CMD_LINE 'L'
-#define CMD_PI '?'
-#define CMD_SUBDOC 'S'
-#define CMD_SUBDOC_S '{'
-#define CMD_SUBDOC_E '}'
-#define CMD_EXT_REF '&'
-#define CMD_APPINFO '#'
-#define CMD_CONFORM 'C'
-
-/* Some sizes */
-#define MAX_DEPTH 40
-#define LINESIZE 60000
-
-/* Name of library env variable, and default value. */
-#ifndef TPT_LIB
-#define TPT_LIB "TPT_LIB"
-#endif
-#ifndef DEF_TPT_LIB
-#define DEF_TPT_LIB "/usr/share/sgml/transpec"
-#endif
-
-/* Relationships - for querying */
-typedef enum {
- REL_None, REL_Parent, REL_Child, REL_Ancestor, REL_Descendant,
- REL_Sibling, REL_Preceding, REL_ImmPreceding, REL_Following,
- REL_ImmFollowing, REL_Cousin, REL_Unknown
-} Relation_t;
-
-/* Initial map sizes (IMS) */
-#define IMS_relations 3
-#define IMS_setvar 3
-#define IMS_incvar 3
-#define IMS_sdata 50
-#define IMS_sdatacache 30
-#define IMS_variables 20
-#define IMS_attnames 50
-#define IMS_elemnames 50
-
-/* ----- typedef and other misc definitions ----- */
-
-#ifndef TRUE
-#define TRUE (1 == 1)
-#endif
-
-#ifndef FALSE
-#define FALSE (1 == 0)
-#endif
-
-typedef short bool;
-
-
-/* ----- structure definitions ----- */
-
-/* We use this for variables, attributes, etc., so the caller only needs an
- * opaque handle to the thing below, not worrying about array management. */
-typedef struct {
- char *name; /* name of the thing */
- char *sval; /* string value */
-} Mapping_t;
-
-typedef struct {
- int n_alloc; /* number of elements allocated */
- int n_used; /* number of elements used */
- int slot_incr; /* increment for allocating slots */
- int flags; /* info about this set of mappings */
- Mapping_t *maps; /* array of mappings */
-} Map_t;
-
-/* ______________________________________________________________________ */
-
-/* Information about an entity reference. Not all fields will be used
- * at once. */
-typedef struct _ent {
- char *type; /* entity type */
- char *ename; /* entity name */
- char *nname; /* notation name */
- char *sysid; /* sys id */
- char *pubid; /* pub id */
- char *fname; /* filename */
- struct _ent *next; /* next in linked list */
-} Entity_t;
-
-/* Content (child nodes) of an element (node in the tree) -- both data
- * and other elements. */
-typedef struct {
- char type; /* element, data, or pi? */
- union {
- struct _elem *elem; /* direct children of this elem */
- char *data; /* character data of this elem */
- } ch;
-} Content_t;
-
-/* An element (node in the tree) */
-typedef struct _elem {
- char *gi; /* element GI */
- Content_t *cont; /* content - element & data children */
- int ncont; /* # of content/children */
- struct _elem **econt; /* element children */
- int necont; /* # of element children */
- char **dcont; /* character data children */
- int ndcont; /* # of data children */
- Mapping_t *atts; /* array of attributes */
- int natts; /* # of attributes */
- Entity_t *entity; /* ext entity & notation info */
- char *id; /* for linking */
- int index; /* an internal bookkeeping mechanism */
- int depth; /* how deep in tree */
- int lineno; /* line number */
- char *infile; /* input filename */
- int my_eorder; /* order of this elem of its parent */
- struct _elem *parent; /* this elem's direct parent */
- struct _elem *next; /* kept in linked list */
- void *trans; /* pointer to translation spec */
- /* I'm not crazy about this, but it works */
- int gen_trans[2]; /* refs to generated trans specs */
- int processed; /* was this node processed? */
-} Element_t;
-
-/* For mapping of element IDs to elements themselves. */
-typedef struct id_s {
- char *id; /* ID of the element */
- Element_t *elem; /* pointer to it */
- struct id_s *next;
-} ID_t;
-
-/* ----- global variable declarations ----- */
-
-#ifdef STORAGE
-# define def
-#else
-# define def extern
-#endif
-
-def Element_t *DocTree; /* root of document tree */
-def char **UsedElem; /* a unique list of used elem names */
-def int nUsedElem; /* number of used elem names */
-def char **UsedAtt; /* a unique list of used attrib names */
-def int nUsedAtt; /* number of used attrib names */
-def ID_t *IDList; /* list of IDs used in the doc */
-def Map_t *Variables; /* general, global variables */
-def Map_t *SDATAmap; /* SDATA mappings */
-def Map_t *PImap; /* Processing Instruction mappings */
-def Entity_t *Entities; /* list of entities */
-
-def FILE *outfp; /* where output is written */
-def char *tpt_lib; /* TPT library directory */
-def int verbose; /* flag - verbose output? */
-def int warnings; /* flag - show warnings? */
-def int interactive; /* flag - interactive browsing? */
-def int slave; /* are we slave to another process? */
-def int fold_case; /* flag - fold case of GIs? */
-
-/* ----- some macros for convenience and ease of code reading ----- */
-
-#define stripNL(s) { char *_cp; if ((_cp=strchr(s, NL))) *_cp = EOS; }
-
-/* Similar to calloc(), malloc(), and realloc(), but check for success.
- * Args to all:
- * (1) number of 'elements' to allocate
- * (2) variable to point at allocated space
- * (3) type of 'element'
- * Eg: Calloc(5, e, Element_t) replaces
- * if (!(e = (Element_t *)calloc(5, sizeof(Element_t))) {
- * ... handle error ... ;
- * }
- */
-#define Calloc(N,V,T) \
- { if (!((V) = (T *)calloc((size_t)N, sizeof(T)))) { \
- perror("Calloc failed -- out of memory. Bailing out."); exit(1); \
- }; memset((void *) (V), 0, (size_t) sizeof(T)); }
-#define Malloc(N,V,T) \
- { if (!((V) = (T *)malloc((size_t)N*sizeof(T)))) { \
- perror("Malloc failed -- out of memory. Bailing out."); exit(1); \
- }; memset((void *) (V), 0, (size_t) sizeof(T)); }
-#define Realloc(N,V,T) \
- { if (!((V) = (T *)realloc(V,(size_t)N*sizeof(T)))) { \
- perror("Realloc failed -- out of memory. Bailing out."); exit(1); \
- } }
-
-/* similar to strcmp(), but check first chars first, for efficiency */
-#define StrEq(s1,s2) (s1[0] == s2[0] && !strcmp(s1,s2))
-
-/* similar to isspace(), but check for blank or tab - without overhead
- * of procedure call */
-#define IsWhite(c) (c == ' ' || c == TAB || c == NL)
-
-#define ContType(e,i) (e->cont[i].type)
-#define ContData(e,i) (e->cont[i].ch.data)
-#define ContElem(e,i) (e->cont[i].ch.elem)
-#define IsContData(e,i) (e->cont[i].type == CMD_DATA)
-#define IsContElem(e,i) (e->cont[i].type == CMD_OPEN)
-#define IsContPI(e,i) (e->cont[i].type == CMD_PI)
-
-/* ----- function prototypes ----- */
-
-/* things defined in util.c */
-Element_t *QRelation(Element_t *, char *, Relation_t);
-Relation_t FindRelByName(char *);
-char *FindAttValByName(Element_t *, char *);
-char *FindContext(Element_t *, int, char *);
-char *AddElemName(char *);
-char *AddAttName(char *);
-char *ExpandString(char *);
-void OutputString(char *, FILE *, int);
-char *LookupSDATA(char *);
-FILE *OpenFile(char *);
-char *FilePath(char *);
-char *FindElementPath(Element_t *, char *);
-char *NearestOlderElem(Element_t *, char *);
-void PrintLocation(Element_t *, FILE *);
-char **Split(char *, int *, int);
-void DescendTree(Element_t *, void(*)(), void(*)(), void(*)(), void *);
-Map_t *NewMap(int);
-Mapping_t *FindMapping(Map_t *, const char *);
-char *FindMappingVal(Map_t *, const char *);
-void SetMapping(Map_t *, const char *);
-void SetMappingNV(Map_t *, const char *, const char *);
-void AddID(Element_t *, char *);
-Element_t *FindElemByID(char *);
-
-/* things defined in translate.c */
-void DoTranslate(Element_t*, FILE *);
-void ExpandVariables(char*, char*, Element_t*);
-
-/* things defined in traninit.c */
-void ReadTransSpec(char *);
-
-/* things defined in tranvar.c */
-char *Get_A_C_value(const char *);
-
-/* things defined in info.c */
-void PrintContext(Element_t *e);
-void PrintElemSummary(Element_t *);
-void PrintElemTree(Element_t *);
-void PrintStats(Element_t *);
-void PrintIDList();
-
-/* things defined in table.c */
-void CALStable(Element_t *, FILE *, char **, int);
-
-/* ----- other declarations ----- */
-
-#ifdef ultrix
-#define strdup(s) strcpy((char *)malloc(strlen(s)+1), s)
-#endif
-
diff --git a/usr.bin/sgmls/instant/hyper.c b/usr.bin/sgmls/instant/hyper.c
deleted file mode 100644
index 4f50b97..0000000
--- a/usr.bin/sgmls/instant/hyper.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 1993 Open Software Foundation, Inc., Cambridge, Massachusetts.
- * All rights reserved.
- */
-/*
- * Copyright (c) 1994
- * Open Software Foundation, Inc.
- *
- * Permission is hereby granted to use, copy, modify and freely distribute
- * the software in this file and its documentation for any purpose without
- * fee, provided that the above copyright notice appears in all copies and
- * that both the copyright notice and this permission notice appear in
- * supporting documentation. Further, provided that the name of Open
- * Software Foundation, Inc. ("OSF") not be used in advertising or
- * publicity pertaining to distribution of the software without prior
- * written permission from OSF. OSF makes no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- */
-/*
- * Copyright (c) 1996 X Consortium
- * Copyright (c) 1995, 1996 Dalrymple Consulting
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * X CONSORTIUM OR DALRYMPLE CONSULTING BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the names of the X Consortium and
- * Dalrymple Consulting shall not be used in advertising or otherwise to
- * promote the sale, use or other dealings in this Software without prior
- * written authorization.
- */
-/* ________________________________________________________________________
- *
- * Hypermedia-related facilities.
- *
- * Entry points for this module:
- * AddID(elem, idval) add elem-id pair to list of known ids
- * FindElemByID(idval) find elem by id
- * ________________________________________________________________________
- */
-
-#ifndef lint
-static char *RCSid =
- "$Header: /usr/src/docbook-to-man/Instant/RCS/hyper.c,v 1.2 1996/06/02 21:46:10 fld Exp $";
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <string.h>
-#include <memory.h>
-#include <sys/types.h>
-
-#include "general.h"
-
-
-/* ______________________________________________________________________ */
-
-void
-AddID(Element *e, char *idval)
-{
- static ID *id_last;
- if (!IDList) {
- Calloc(1, id_last, ID);
- IDList = id_last;
- }
- else {
- Calloc(1, id_last->next, ID);
- id_last = id_last->next;
- }
- id_last->elem = e;
- id_last->id = idval;
-}
-
-Element *
-FindElemByID(char *idval)
-{
- ID *id;
- for (id=IDList; id; id=id->next)
- if (!strcmp(id->id, idval)) return id->elem;
- return 0;
-}
-
-/* ______________________________________________________________________ */
-
diff --git a/usr.bin/sgmls/instant/info.c b/usr.bin/sgmls/instant/info.c
deleted file mode 100644
index 27ab1c7..0000000
--- a/usr.bin/sgmls/instant/info.c
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * Copyright 1993 Open Software Foundation, Inc., Cambridge, Massachusetts.
- * All rights reserved.
- */
-/*
- * Copyright (c) 1994
- * Open Software Foundation, Inc.
- *
- * Permission is hereby granted to use, copy, modify and freely distribute
- * the software in this file and its documentation for any purpose without
- * fee, provided that the above copyright notice appears in all copies and
- * that both the copyright notice and this permission notice appear in
- * supporting documentation. Further, provided that the name of Open
- * Software Foundation, Inc. ("OSF") not be used in advertising or
- * publicity pertaining to distribution of the software without prior
- * written permission from OSF. OSF makes no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- */
-/*
- * Copyright (c) 1996 X Consortium
- * Copyright (c) 1995, 1996 Dalrymple Consulting
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * X CONSORTIUM OR DALRYMPLE CONSULTING BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the names of the X Consortium and
- * Dalrymple Consulting shall not be used in advertising or otherwise to
- * promote the sale, use or other dealings in this Software without prior
- * written authorization.
- */
-/* ________________________________________________________________________
- *
- * Functions for printing information about an instance in the 'instant'
- * program. Most of these are fairly short and simple.
- *
- * Entry points for this module:
- * PrintElemSummary(elem) print summary info of each element
- * PrintContext(elem) print context of each element
- * PrintElemTree(elem) print tree of document
- * PrintStats(elem) print statistics about doc tree
- * PrintIDList(elem) print list of IDs and element context
- * Most Print*() functions start at subtree pointed to by 'elem'.
- * ________________________________________________________________________
- */
-
-#ifndef lint
-static char *RCSid =
- "$Header: /usr/src/docbook-to-man/Instant/RCS/info.c,v 1.2 1996/06/02 21:46:10 fld Exp $";
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <string.h>
-
-#include "general.h"
-
-/* ______________________________________________________________________ */
-/* Print a summary of each tag use in the instance. Things like depth in
- * the tree, number of children, parent, attributes.
- */
-
-/* Do the actual printing. Print the info about the node. If null,
- * print a header for the columns.
- * Arguments:
- * Pointer to element structure of the node to print.
- */
-static void
-print_summ(
- Element_t *e
-)
-{
- int i, n, dsize;
- char *hfmt="%-18.18s %4s %5s %4s %4s %s\n";
- char *fmt ="%-18.18s %4d %5d %4d %4d %s\n";
-
- if (e == NULL) {
- fprintf(outfp, hfmt, "Element", "Att", "Data", "Chd", "Dep", "Parent");
- return;
- }
- for (i=0,n=0; i<e->ncont; i++) if (IsContElem(e,i)) n++;
- for (i=0,dsize=0; i<e->ncont; i++)
- if (IsContElem(e,i)) dsize += strlen(e->cont[i].ch.data);
- fprintf(outfp, fmt, e->gi, e->natts, dsize, n, e->depth,
- e->parent ? e->parent->gi : "-");
-
- for (i=0; i<e->natts; i++) {
- fprintf(outfp, "%45d: %s = %s\n", i, e->atts[i].name,
- e->atts[i].sval ? e->atts[i].sval : "empty");
- }
-}
-
-/* Descend the tree, calling processing routine.
- * Arguments:
- * Pointer to element structure at top of tree to traverse.
- */
-void
-PrintElemSummary(
- Element_t *e
-)
-{
- print_summ(0);
- DescendTree(e, print_summ, 0, 0, 0);
-}
-
-/* ______________________________________________________________________ */
-/* Print the context of each tag in the instance (i.e. the tag with its
- * ancestors).
- */
-
-/* Do the actual printing. Print the context of the node.
- * Arguments:
- * Pointer to element structure of the node to print.
- */
-static void
-print_context(
- Element_t *e
-)
-{
- char buf[LINESIZE];
-
- fprintf(outfp, "%-22s %s\n", e->gi, FindContext(e, 10, buf));
-}
-
-/* Descend the tree, calling processing routine.
- * Arguments:
- * Pointer to element structure at top of tree to traverse.
- */
-void
-PrintContext(
- Element_t *e
-)
-{
- fprintf(outfp, "%-22s %s\n", "Element", "Context");
- fprintf(outfp, "%-22s %s\n", "---------------", "-----------");
- DescendTree(e, print_context, 0, 0, 0);
-
- putc(NL, outfp);
-}
-
-/* ______________________________________________________________________ */
-/* Print tree of the instance. GI's are printed indented by their depth
- * in the tree.
- */
-
-/* Do the actual printing. Print the element name, indented the right amount.
- * Arguments:
- * Pointer to element structure of the node to print.
- */
-static void
-print_indent(
- Element_t *e
-)
-{
- int i, ne, nd;
- for(i=0; i<e->depth; i++) fputs(". ", outfp);
- for(i=0,ne=0; i<e->ncont; i++) if (IsContElem(e,i)) ne++;
- for(i=0,nd=0; i<e->ncont; i++) if IsContData(e,i) nd++;
- fprintf(outfp, "%s (%d,%d)\n", e->gi, ne, nd);
-}
-
-/* Descend the tree, calling processing routine.
- * Arguments:
- * Pointer to element structure at top of tree to traverse.
- */
-void
-PrintElemTree(
- Element_t *e
-)
-{
- DescendTree(e, print_indent, 0, 0, 0);
- putc(NL, outfp);
-}
-
-/* ______________________________________________________________________ */
-/* Print some statistics about the instance.
- */
-
-/* Accumulate the totals for the statistics.
- * Arguments:
- * Pointer to element structure of the node to print.
- * Pointer to the total number of elements.
- * Pointer to the total amount of content data.
- * Pointer to the maximum depth of tree.
- */
-static void
-acc_tots(
- Element_t *e,
- int *tot_el,
- int *tot_data,
- int *max_depth
-)
-{
- int i;
- for(i=0; i<e->necont; i++)
- acc_tots(e->econt[i], tot_el, tot_data, max_depth);
- for (i=0; i<e->necont; i++) (*tot_el)++;
- for (i=0; i<e->ndcont; i++) (*tot_data) += strlen(e->dcont[i]);
- if (e->depth > (*max_depth)) *max_depth = e->depth;
-}
-
-/* Descend the tree (recursively), collecting the statistics.
- * Arguments:
- * Pointer to element structure of the node to print.
- * Pointer to the total number of elements.
- * Pointer to the total amount of content data.
- * Pointer to the maximum depth of tree.
- */
-static void
-elem_usage(
- Element_t *e,
- char *name,
- int *n_used,
- int *nchars
-)
-{
- int i;
- if (!strcmp(name, e->gi)) {
- (*n_used)++;
- for (i=0; i<e->ncont; i++)
- if (IsContData(e,i)) (*nchars) += strlen(ContData(e,i));
- }
- for(i=0; i<e->necont; i++)
- elem_usage(e->econt[i], name, n_used, nchars);
-}
-
-/* Descend the tree, calling processing routine.
- * Arguments:
- * Pointer to element structure at top of tree to traverse.
- */
-void
-PrintStats(
- Element_t *top
-)
-{
- int i, n;
- int dif_el=0, tot_el=0, tot_data=0, nchars, max_depth=0;
- float pct;
-
- fprintf(outfp, "%-22s %s %s\n", "Element name", "Occurrances", "Character Content");
- fprintf(outfp, "%-22s %s %s\n", "---------------", "-----------", "-----------------");
-
- acc_tots(top, &tot_el, &tot_data, &max_depth);
-
- for (i=0; i<nUsedElem; i++) {
- n = 0;
- nchars = 0;
- elem_usage(top, UsedElem[i], &n, &nchars);
- if (n > 0) {
- pct = 100.0 * (float)n / (float)tot_el;
- fprintf(outfp, "%-22s %4d %4.1f%% %6d %4d\n", UsedElem[i],
- n, pct, nchars, (nchars/n));
- dif_el++;
- }
- }
-
- fprintf(outfp, "\nTotal of %d elements used, %d different ones.\n",
- tot_el, dif_el);
- fprintf(outfp, "Total character data: %d.\n", tot_data);
- fprintf(outfp, "Maximum element depth: %d.\n", max_depth);
- putc(NL, outfp);
-}
-
-/* ______________________________________________________________________ */
-/* Print list of: ID, GI, input file, line number, separated by colons.
- * This is better for other programs to manipulate (like for keeping a
- * database of IDs in documents) than humans to read.
- */
-
-void
-PrintIDList()
-{
- ID_t *id;
- Element_t *ep;
-
- for (id=IDList; id; id=id->next) {
- ep = id->elem;
- fprintf(outfp, "%s:%s:%s:%d\n", id->id, ep->gi,
- ep->infile?ep->infile:"-", ep->lineno);
- }
-}
-
-/* ______________________________________________________________________ */
-
diff --git a/usr.bin/sgmls/instant/instant.1 b/usr.bin/sgmls/instant/instant.1
deleted file mode 100644
index 513c84d..0000000
--- a/usr.bin/sgmls/instant/instant.1
+++ /dev/null
@@ -1,183 +0,0 @@
-...\"
-...\" Copyright (c) 1994
-...\" Open Software Foundation, Inc.
-...\"
-...\" Permission is hereby granted to use, copy, modify and freely distribute
-...\" the software in this file and its documentation for any purpose without
-...\" fee, provided that the above copyright notice appears in all copies and
-...\" that both the copyright notice and this permission notice appear in
-...\" supporting documentation. Further, provided that the name of Open
-...\" Software Foundation, Inc. ("OSF") not be used in advertising or
-...\" publicity pertaining to distribution of the software without prior
-...\" written permission from OSF. OSF makes no representations about the
-...\" suitability of this software for any purpose. It is provided "as is"
-...\" without express or implied warranty.
-...\"
-...\" Copyright (c) 1996 X Consortium
-...\" Copyright (c) 1996 Dalrymple Consulting
-...\"
-...\" Permission is hereby granted, free of charge, to any person obtaining a copy
-...\" of this software and associated documentation files (the "Software"), to deal
-...\" in the Software without restriction, including without limitation the rights
-...\" to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-...\" copies of the Software, and to permit persons to whom the Software is
-...\" furnished to do so, subject to the following conditions:
-...\"
-...\" The above copyright notice and this permission notice shall be included in
-...\" all copies or substantial portions of the Software.
-...\"
-...\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-...\" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-...\" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-...\" X CONSORTIUM OR DALRYMPLE CONSULTING BE LIABLE FOR ANY CLAIM, DAMAGES OR
-...\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-...\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-...\" OTHER DEALINGS IN THE SOFTWARE.
-...\"
-...\" Except as contained in this notice, the names of the X Consortium and
-...\" Dalrymple Consulting shall not be used in advertising or otherwise to
-...\" promote the sale, use or other dealings in this Software without prior
-...\" written authorization.
-...\"
-...\" Translated with /usr/local/lib/tpt/ref-man.ts by fld on cord, Wed 07 Feb 1996, 21:59
-.Dd September 5, 1996
-.Os FreeBSD 2.2
-.Dt SGMLFMT 1
-.Sh "NAME"
-instant - manipulates ESIS from parsed SGML instance
-.Sh "Synopsis"
-.na
-.Pp
-\fBinstant\fP [ \fB-bhuvxHISW\fP ] [ \fB-t\fP \fIfile\fP] [ \fB-o\fP \fIfile\fP] [ \fB-D\fP \fIvariable\fP\fB=\fP\fIvalue\fP ...] [ \fB-i\fP \fIid\fP] [ \fB-l\fP \fIdirectory\fP] [\fIfile\fP]
-.ad
-.Sh "DESCRIPTION"
-.Pp
-The \fBinstant\fP program manipulates an SGML document instance in a variety of ways,
-including translating into a form suitable for a formatting application and printing information about this instance.
-Input to \fBinstant\fP is the output of \fBsgmls\fP, whose format is called Element Structure Information Set (ESIS).
-.Sh "FLAGS"
-.Pp
-The following are the possible command line options to \fBinstant\fP. Output is sent to the standard output, except where otherwise noted.
-.\"'br\" labeled list
-.Bl -tag -width Ds
-.It "\fB-t\fP \fIfile\fP"
-Translate the SGML instance to another form, usually suitable for a formatting application.
-The \fIfile\fP is called a translation spec, which specifies how the tags are to be translated. See \fBtranspec\fP(4).
-By convention, names for \fIfile\fP use the suffix \fB.ts\fP, for \fItranslation spec\fP.
-.It "\fB-d\fP"
-"Data hack" \(em strip newline at the beginning of data records
-.It "\fB-f \fIlength\fR"
-Set the threshold for the length, in characters,
-of an <Entry>, over which it is called a block of filled text, to \fIlength\fR.
-.It "\fB-o\fP \fIfile\fP "
-Write all output (except error and warning messages) to file \fIfile\fP. By default, output goes to stdout.
-.It "\fB-h\fP"
-Print a text representation of the hierarchy of the instance elements.
-The deeper an element is in the tree, the more it is indented. The data content is not printed.
-.It "\fB-u\fP"
-Print a summary of the usage of each element in the instance.
-Information given includes attributes, number of children, and depth in the hierarchy.
-.It "\fB-S\fP"
-Print some statistics about element usage in the instance, including how often each element is used
-and how much PCDATA is contained.
-.It "\fB-x\fP"
-Print the context of each element in the instance, from each element to the root of the document tree.
-.It "\fB-v\fP"
-Validate the SGML instance based on the set of constraints or descriptions in the transpec file.
-This flags tells \fBinstant\fP to turn off normal output, leaving only diagnostics.
-.It "\fB-l\fP \fIdirectory\fP"
-Try to read the translation specs or other files from in the directory \fIdirectory\fP
-if not found in the current directory.
-This is called the library directory.
-The environment variable \fITPT_LIB\fP may also be used to specify this.
-.It "\fB-b\fP"
-Interactive browser mode. The user is prompted for actions,
-which include moving among and examining the various nodes in the hierarchy of the instance, displaying information about them, etc.
-.It "\fB-I\fP"
-List the IDs of all elements in the instance that have an ID. The format is more suitable for other programs than humans.
-Lines show the ID, element GI, filename, and line, separated by colons.
-(This depends on the \fB-l\fP option to \fBsgmls\fP which provide filenames and line numbers.)
-.It "\fB-i\fP \fIid\fP"
-When translating the instance, begin processing at the element whose ID is \fIid\fP instead of the topmost element.
-.It "\fB-D\fP \fIvariable\fP\fB=\fP\fIvalue\fP"
-Define the variable \fIvariable\fP with value \fIvalue\fP.
-.It "\fB-W\fP"
-Do not print warning messages.
-.It "\fB-H\fP"
-Print a help message briefly describing the options.
-.It "\fIfile\fP"
-Read the instance from the file \fIfile\fP.
-This is expected to be the output of the program \fBsgmls\fP.
-If not specified, \fBinstant\fP reads the instance from its standard input.
-.El
-.\"'br\" labeled list end
-.Pp
-In some cases it makes no sense to combine options.
-This is especially true if one of the options is to perform a translation. No checking is done for this.
-.Sh "INTERACTIVE BROWSER"
-.Pp
-These are the commands to the interactive browser:
-.Bl -tag -width Ds
-.\"'br\" labeled list
-.It "\fBcd\fP \fIargs ...\fP"
-Change to a different element in the hierarchy.
-\fBcd\fP \fBid\fP \fIid\fP will change to the element whose ID is \fIid\fP.
-\fBcd\fP \fIN\fP will change to the \fIN\fPth child element of the current element.
-Several values of \fIN\fP may be specified, so the program will change to successively descending elements in the hierarchy.
-The string \fB..\fP may appear for \fIN\fP to move up a level in the hierarchy (like in a unix file system).
-A \fB/\fP may be specified for \fIN\fP to change to the top of the hierarchy.
-.It "\fBcont\fP"
-Print the context of each element.
-.It "\fBdata\fP \fIN\fP"
-Show the data content (PCDATA, RCDATA, and DATA) of child node N.
-.It "\fBfind\fP \fIspec\fP"
-Find paths to elements matching \fIspec\fP, where \fIspec\fP may be one of:
-.Bl -tag -width Ds
-.\".RS +\n(INu
-.It "\fBparent\fP \fIgi\fP"
-Find all elements whose parent element is \fIgi\fP.
-.It "\fBchild\fP \fIgi\fP"
-Find all elements which have a child element \fIgi\fP.
-.It "\fBgi\fP \fIgi\fP"
-Find all elements whose name is \fIgi\fP.
-.It "\fBattr\fP \fIname\fP \fIvalue\fP"
-Find all elements that have a attribute \fIname\fP that have a value \fIvalue\fP.
-.\".RE
-.El
-.It "\fBid\fP \fIID\fP"
-Show location of element whose ID is \fIID\fP.
-If \fIID\fP is \fB?\fP, it will list all IDs with the paths to them.
-.It "\fBls\fP"
-List information about the current element in the hierarchy.
-This includes element name, line number in instance, context, attributes and their values, child elements, data directly within this element,
-and the order of the current element among its siblings.
-.It "\fBq\fP \fIrelation\fP \fIelement\fP"
-Report whether or not the current element has the relation \fIrelation\fP to the named element \fIelement\fP.
-Values of \fIrelation\fP are the same as for \fB_followrel\fP in \fBtranspec\fP reference page.
-.It "\fBstat\fP"
-Show statistics about the hierarchy.
-.It "\fBsum\fP"
-Show a tag usage summary about the hierarchy.
-.It "\fBtran\fP \fIoutfile\fP"
-Write translated output to file \fIoutfile\fP.
-If \fIoutfile\fP is not specified, output is sent to stdout.
-.It "\fBtree\fP"
-Print a textual representation of the hierarchy of the instance, where deeper elements are indented more.
-.It "\fBwhere\fP"
-Show current position in the hierarchy.
-.It "<\fBcontrol-D\fP>"
-Exits the program.
-.El
-.Pp
-The \fBstat\fP, \fBsum\fP, \fBtree\fP, \fBcont\fP commands take an optional first argument (of any value),
-which means to only consider the entire instance instead of the hierarchy from the current element.
-.Sh "FILES"
-.Bl -tag -width Ds
-.It "\fIfile\fP\fB.ts\fP"
-Translation specification file.
-.El
-.Sh "SEE ALSO"
-.Pp
-.Xr transpec 5 ,
-.Xr sgmls 1 ,
-Standard Generalized Markup Language (SGML), ISO 8879.
diff --git a/usr.bin/sgmls/instant/main.c b/usr.bin/sgmls/instant/main.c
deleted file mode 100644
index 2f10537..0000000
--- a/usr.bin/sgmls/instant/main.c
+++ /dev/null
@@ -1,710 +0,0 @@
-/*
- * Copyright 1993 Open Software Foundation, Inc., Cambridge, Massachusetts.
- * All rights reserved.
- */
-/*
- * Copyright (c) 1994
- * Open Software Foundation, Inc.
- *
- * Permission is hereby granted to use, copy, modify and freely distribute
- * the software in this file and its documentation for any purpose without
- * fee, provided that the above copyright notice appears in all copies and
- * that both the copyright notice and this permission notice appear in
- * supporting documentation. Further, provided that the name of Open
- * Software Foundation, Inc. ("OSF") not be used in advertising or
- * publicity pertaining to distribution of the software without prior
- * written permission from OSF. OSF makes no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- */
-/*
- * Copyright (c) 1996 X Consortium
- * Copyright (c) 1995, 1996 Dalrymple Consulting
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * X CONSORTIUM OR DALRYMPLE CONSULTING BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the names of the X Consortium and
- * Dalrymple Consulting shall not be used in advertising or otherwise to
- * promote the sale, use or other dealings in this Software without prior
- * written authorization.
- */
-/* ________________________________________________________________________
- *
- * Program to read an SGML document instance, creating any of several things:
- *
- * "translated" output for formatting applications (given a trans. spec)
- * validation report (given a appropriate trans spec)
- * tree of the document's structure
- * statistics about the element usage
- * summary of the elements used
- * context of each element used
- * IDs of each element
- *
- * A C structure is created for each element, which includes:
- * name, attributes, parent, children, content
- * The tree is descended, and the desired actions performed.
- *
- * Takes input from James Clark's "sgmls" program (v. 1.1).
- * ________________________________________________________________________
- */
-
-#ifndef lint
-static char *RCSid =
- "$Header: /home/ncvs/src/usr.bin/sgmls/instant/main.c,v 1.1.1.1 1996/09/08 01:55:10 jfieber Exp $";
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <string.h>
-#include <memory.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/file.h>
-#include <time.h>
-#include <locale.h>
-
-#define STORAGE
-#include "general.h"
-
-static int do_context, do_tree, do_summ, do_stats, do_validate, do_idlist;
-static int do_DATAhack = 0;
-static char *this_prog;
-static char *in_file, *out_file;
-static char *tranfile;
-static char *start_id;
-static char *last_file;
-static int last_lineno;
-
-extern int BOFTTextThresh;
-
-/* forward references */
-static void HandleArgs(int, char *[]);
-static void Initialize1();
-static void Initialize2();
-static void ReadInstance(char *);
-static void DoHelpMessage();
-extern void Browse();
-
-/* external reference to version number */
-char _HeadVeRsIoN_[] = "1.0 (FreeBSD)";
-
-/* ______________________________________________________________________ */
-/* Program entry point. Look at args, read instance, dispatch to the
- * correct routines to do the work, and finish.
- */
-
-int
-main(
- int ac,
- char *av[]
-)
-{
- setlocale(LC_ALL, "");
- Initialize1(av[0]);
- HandleArgs(ac, av);
- Initialize2();
-
- if (tranfile) ReadTransSpec(tranfile);
- ReadInstance(in_file);
-
- if (interactive) {
- Browse(); /* this will handle interactive commands */
- }
- else {
- /* Perform tasks based on command line flags... */
- if (tranfile) {
- Element_t *e;
- /* If user wants to start at a particular ID, point to that
- * element. Else, point to the top of the tree. */
- if (start_id) {
- if (!(e=FindElemByID(start_id))) {
- fprintf(stderr, "Error: Can not find element with ID %s\n",
- start_id);
- exit(1);
- }
- }
- else e = DocTree;
- /* If we're doing validation, make output file pointer null.
- * This means that we generate no output, except error messages. */
- if (do_validate) outfp = NULL;
- if (tranfile)
- DoTranslate(e, outfp);
- else
- fprintf(stderr, "Translation spec file not specified. Skipping translation.\n");
- }
- if (do_summ) PrintElemSummary(DocTree);
- if (do_tree) PrintElemTree(DocTree);
- if (do_stats) PrintStats(DocTree);
- if (do_context) PrintContext(DocTree);
- if (do_idlist) PrintIDList();
- }
- if (out_file && outfp) fclose(outfp);
-
- return 0;
-}
-
-/* ______________________________________________________________________ */
-/* Initialization stuff done before dealing with args.
- * Arguments:
- * Name of program (string).
- */
-
-static void
-Initialize1(
- char *myname
-)
-{
- time_t tnow;
- struct tm *nowtm;
- char *cp, buf[100];
- extern int gethostname(char *, int); /* not in a system .h file... */
-
- /* where we try to find data/library files */
- if (!(tpt_lib=getenv(TPT_LIB))) tpt_lib = DEF_TPT_LIB;
-
- /* set some global variables */
- warnings = 1;
- fold_case = 1;
- this_prog = myname;
-
- /* setup global variable mapping */
- Variables = NewMap(IMS_variables);
-
- /* set some pre-defined variables */
- SetMappingNV(Variables, "user", (cp=getenv("USER")) ? cp : "UnknownUser" );
- time(&tnow);
- nowtm = localtime(&tnow);
- strftime(buf, 100, "%a %d %b %Y, %R", nowtm);
- SetMappingNV(Variables, "date", buf);
- if (gethostname(buf, 100) < 0) strcpy(buf, "unknown-host");
- SetMappingNV(Variables, "host", buf);
- SetMappingNV(Variables, "transpec", tranfile ? tranfile : "??");
-}
-
-/* Initialization stuff done after dealing with args. */
-
-static void
-Initialize2()
-{
- SetMappingNV(Variables, "transpec", tranfile ? tranfile : "??");
-
- /* If user wants to send output to a file, open the file, and set
- * the file pointer. Else we send output to standard out. */
- if (out_file) {
- if (!(outfp = fopen(out_file, "w"))) {
- fprintf(stderr, "Could not open output '%s' file for writing.\n%s",
- out_file, strerror(errno));
- exit(1);
- }
- }
- else outfp = stdout;
-}
-
-/* ______________________________________________________________________ */
-/* Set a variable. If it is one of the "known" variables, set the
- * variable in the C code (this program).
- * Arguments:
- * Variable name/value string - separated by an '=' (eg, "myname=Sally").
- */
-static void
-CmdLineSetVariable(
- char *var
-)
-{
- char *cp, buf[100], **tok;
- int n;
-
- /* Turn '=' into a space, to isolate the name. Then set variable. */
- strcpy(buf, var);
- if ((cp=strchr(buf, '='))) {
- /* we have "var=value" */
- *cp = ' ';
- n = 2;
- tok = Split(buf, &n, 0);
- /* see if variable name matches one of our internal ones */
- if (!strcmp(tok[0], "verbose")) verbose = atoi(tok[1]);
- else if (!strcmp(tok[0], "warnings")) warnings = atoi(tok[1]);
- else if (!strcmp(tok[0], "foldcase")) fold_case = atoi(tok[1]);
- else SetMappingNV(Variables, tok[0], tok[1]);
- }
- else {
- fprintf(stderr, "Expected an '=' in variable assignment: %s. Ignored\n",
- var);
- }
-}
-
-/* ______________________________________________________________________ */
-/* Bounce through arguments, setting variables and flags.
- * Arguments:
- * Argc and Argv, as passed to main().
- */
-static void
-HandleArgs(
- int ac,
- char *av[]
-)
-{
- int c, errflag=0;
- extern char *optarg;
- extern int optind;
-
- while ((c=getopt(ac, av, "df:t:v:o:huSxIl:bHVWi:D:Z")) != -1) {
- switch (c) {
- case 't': tranfile = optarg; break;
- case 'v': do_validate = 1; break;
- case 'h': do_tree = 1; break;
- case 'u': do_summ = 1; break;
- case 'S': do_stats = 1; break;
- case 'x': do_context = 1; break;
- case 'I': do_idlist = 1; break;
- case 'l': tpt_lib = optarg; break;
- case 'i': start_id = optarg; break;
- case 'o': out_file = optarg; break;
- case 'd': do_DATAhack = 1; break;
- case 'f': BOFTTextThresh = atoi(optarg); break;
- case 'b': interactive = 1; break;
- case 'W': warnings = 0; break;
- case 'V': verbose = 1; break;
- case 'Z': slave = 1; break;
- case 'H': DoHelpMessage(); exit(0); break;
- case 'D': CmdLineSetVariable(optarg); break;
- case '?': errflag = 1; break;
- }
- if (errflag) {
- fprintf(stderr, "Try '%s -H' for help.\n", this_prog);
- exit(1);
- }
- }
-
- /* input (ESIS) file name */
- if (optind < ac) in_file = av[optind];
-
- /* If doing interactive/browsing, we can't take ESIS from stdin. */
- if (interactive && !in_file) {
- fprintf(stderr,
- "You must specify ESIS file on cmd line for browser mode.\n");
- exit(1);
- }
-}
-
-/* ______________________________________________________________________ */
-/* Simply print out a help/usage message.
- */
-
-static char *help_msg[] = {
- "",
- " -t file Print translated output using translation spec in <file>",
- " -v Validate using translation spec specified with -t",
- " -i id Consider only subtree starting at element with ID <id>",
- " -b Interactive browser",
- " -S Print statistics (how often elements occur, etc.)",
- " -u Print element usage summary (# of children, depth, etc.)",
- " -x Print context of each element",
- " -h Print document hierarchy as a tree",
- " -o file Write output to <file>. Default is standard output.",
- " -l dir Set library directory to <dir>. (or env. variable TPT_LIB)",
- " -I List all IDs used in the instance",
- " -W Do not print warning messages",
- " -H Print this help message",
- " -Dvar=val Set variable 'var' to value 'val'",
- " file Take input from named file. If not specified, assume stdin.",
- " File should be output from the 'sgmls' program (ESIS).",
- NULL
-};
-
-static void
-DoHelpMessage()
-{
- char **s = help_msg;
- printf("usage: %s [option ...] [file]", this_prog);
- while (*s) puts(*s++);
- printf("\nVersion: %s\n", _HeadVeRsIoN_);
-}
-
-/* ______________________________________________________________________ */
-/* Remember an external entity for future reference.
- * Arguments:
- * Pointer to entity structure to remember.
- */
-
-static void
-AddEntity(
- Entity_t *ent
-)
-{
- static Entity_t *last_ent;
-
- if (!Entities) {
- Malloc(1, Entities, Entity_t);
- last_ent = Entities;
- }
- else {
- Malloc(1, last_ent->next, Entity_t);
- last_ent = last_ent->next;
- }
- *last_ent = *ent;
-
-}
-
-/* Find an entity, given its entity name.
- * Arguments:
- * Name of entity to retrieve.
- */
-static Entity_t *
-FindEntity(
- char *ename
-)
-{
- Entity_t *n;
- for (n=Entities; n; n=n->next)
- if (StrEq(ename, n->ename)) return n;
- return 0;
-}
-
-/* Accumulate lines up to the open tag. Attributes, line number,
- * entity info, notation info, etc., all come before the open tag.
- */
-static Element_t *
-AccumElemInfo(
- FILE *fp
-)
-{
- char buf[LINESIZE+1];
- int c;
- int i, na;
- char *cp, *atval;
- Mapping_t a[100];
- Element_t *e;
- Entity_t ent, *ent2;
- char **tok;
- static int Index=0;
- static Element_t *last_e;
-
-
- Calloc(1, e, Element_t);
- memset(&ent, 0, sizeof ent); /* clean space for entity info */
-
- /* Also, keep a linked list of elements, so we can easily scan through */
- if (last_e) last_e->next = e;
- last_e = e;
-
- e->index = Index++; /* just a unique number for identification */
-
- /* in case these are not set for this element in the ESIS */
- e->lineno = last_lineno;
- e->infile = last_file;
-
- na = 0;
- while (1) {
- if ((c = getc(fp)) == EOF) break;
- fgets(buf, LINESIZE, fp);
- stripNL(buf);
- switch (c) {
- case EOF: /* End of input */
- fprintf(stderr, "Error: Unexpectedly reached end of ESIS.\n");
- exit(1);
- break;
-
- case CMD_OPEN: /* (gi */
- e->gi = AddElemName(buf);
- if (na > 0) {
- Malloc(na, e->atts, Mapping_t);
- memcpy(e->atts, a, na*sizeof(Mapping_t));
- e->natts = na;
- na = 0;
- }
- /* Check if this elem has a notation attr. If yes, and there
- is no notation specified, recall the previous one. (feature
- of sgmls - it does not repeat notation stuff if we the same
- is used twice in a row) */
- if (((atval=FindAttValByName(e, "NAME")) ||
- (atval=FindAttValByName(e, "ENTITYREF")) ||
- (atval=FindAttValByName(e, "EXTERNAL"))) && /* HACK */
- (ent2=FindEntity(atval))) {
- e->entity = ent2;
- }
-
- return e;
- break;
-
- case CMD_ATT: /* Aname val */
- i = 3;
- tok = Split(buf, &i, 0);
- if (!strcmp(tok[1], "IMPLIED"))
- break; /* skip IMPLIED atts. */
- else if (!strcmp(tok[1], "CDATA"))
- {
- /* CDATA attributes must have ESIS escape
- sequences and SDATA entities expanded. */
- char *val = ExpandString(tok[2]);
- a[na].name = AddAttName(tok[0]);
- a[na].sval = AddAttName(val);
- free(val);
- na++;
- }
- else if (!strcmp(tok[1], "TOKEN") ||
- !strcmp(tok[1], "ENTITY") ||!strcmp(tok[1], "NOTATION"))
- {
- a[na].name = AddAttName(tok[0]);
- a[na].sval = AddAttName(tok[2]);
- na++;
- }
- else {
- fprintf(stderr, "Error: Bad attr line (%d): A%s %s...\n",
- e->lineno, tok[0], tok[1]);
- }
- break;
-
- case CMD_LINE: /* Llineno */
- /* These lines come in 2 forms: "L123" and "L123 file.sgml".
- * Filename is given only at 1st occurance. Remember it.
- */
- if ((cp = strchr(buf, ' '))) {
- cp++;
- last_file = strdup(cp);
- }
- last_lineno = e->lineno = atoi(buf);
- e->infile = last_file;
- break;
-
- case CMD_DATA: /* -data */
- fprintf(stderr, "Error: Data in AccumElemInfo, line %d:\n%c%s\n",
- e->lineno, c,buf);
- /*return e;*/
- exit(1);
- break;
-
- case CMD_D_ATT: /* Dename name val */
-
- case CMD_NOTATION: /* Nnname */
- case CMD_PI: /* ?pi */
- /* This should be reworked soon, as it
- forces all PI's before the first GI
- to be ignored. -CSS */
- break;
-
- case CMD_EXT_ENT: /* Eename typ nname */
- i = 3;
- tok = Split(buf, &i, 0);
- ent.ename = strdup(tok[0]);
- ent.type = strdup(tok[1]);
- ent.nname = strdup(tok[2]);
- AddEntity(&ent);
- break;
- case CMD_INT_ENT: /* Iename typ text */
- fprintf(stderr, "Error: Got CMD_INT_ENT in AccumElemInfo: %s\n", buf);
- break;
- case CMD_SYSID: /* ssysid */
- ent.sysid = strdup(buf);
- break;
- case CMD_PUBID: /* ppubid */
- ent.pubid = strdup(buf);
- break;
- case CMD_FILENAME: /* ffilename */
- ent.fname = strdup(buf);
- break;
-
- case CMD_CLOSE: /* )gi */
- case CMD_SUBDOC: /* Sename */
- case CMD_SUBDOC_S: /* {ename */
- case CMD_SUBDOC_E: /* }ename */
- case CMD_EXT_REF: /* &name */
- case CMD_APPINFO: /* #text */
- case CMD_CONFORM: /* C */
- default:
- fprintf(stderr, "Error: Unexpected input in AccumElemInfo, %d:\n%c%s\n",
- e->lineno, c,buf);
- exit(1);
- break;
- }
- }
- fprintf(stderr, "Error: End of AccumElemInfo - should not be here: %s\n",
- e->gi);
-/* return e;*/
- exit(1);
-}
-
-/* Read ESIS lines.
- * Limitation? Max 5000 children per node. (done for efficiency --
- * should do some malloc and bookkeeping games later).
- */
-
-static Element_t *
-ReadESIS(
- FILE *fp,
- int depth
-)
-{
- char *buf;
- int i, c, ncont;
- Element_t *e;
- Content_t cont[5000];
-
- Malloc( LINESIZE+1, buf, char );
-
- /* Read input stream - the output of "sgmls", called "ESIS". */
- e = AccumElemInfo(fp);
- e->depth = depth;
-
- ncont = 0;
- while (1) {
- if ((c = getc(fp)) == EOF) break;
- switch (c) {
- case EOF: /* End of input */
- break;
-
- case CMD_DATA: /* -data */
- fgets(buf, LINESIZE, fp);
- stripNL(buf);
- if (do_DATAhack && (buf[0] == '\\') && (buf[1] == 'n')) {
- if ( ! buf[2] )
- break;
- buf[0] = ' ';
- memcpy(&buf[1], &buf[2], strlen(buf)-1);
- }
- cont[ncont].ch.data = ExpandString(buf);
- cont[ncont].type = CMD_DATA;
- ncont++;
- break;
-
- case CMD_PI: /* ?pi */
- fgets(buf, LINESIZE, fp);
- stripNL(buf);
- cont[ncont].type = CMD_PI;
- cont[ncont].ch.data = strdup(buf);
- ncont++;
- break;
-
- case CMD_CLOSE: /* )gi */
- fgets(buf, LINESIZE, fp);
- stripNL(buf);
- if (ncont) {
- e->ncont = ncont;
- Malloc(ncont, e->cont, Content_t);
- for (i=0; i<ncont; i++) e->cont[i] = cont[i];
- }
- free(buf);
- return e;
- break;
-
- case CMD_OPEN: /* (gi */
-/*fprintf(stderr, "+++++ OPEN +++\n");*/
-/* break;*/
-
- case CMD_ATT: /* Aname val */
- case CMD_D_ATT: /* Dename name val */
- case CMD_NOTATION: /* Nnname */
- case CMD_EXT_ENT: /* Eename typ nname */
- case CMD_INT_ENT: /* Iename typ text */
- case CMD_SYSID: /* ssysid */
- case CMD_PUBID: /* ppubid */
- case CMD_FILENAME: /* ffilename */
- ungetc(c, fp);
- cont[ncont].ch.elem = ReadESIS(fp, depth+1);
- cont[ncont].type = CMD_OPEN;
- cont[ncont].ch.elem->parent = e;
- ncont++;
- break;
-
- case CMD_LINE: /* Llineno */
- fgets(buf, LINESIZE, fp);
- break; /* ignore these here */
-
- case CMD_SUBDOC: /* Sename */
- case CMD_SUBDOC_S: /* {ename */
- case CMD_SUBDOC_E: /* }ename */
- case CMD_EXT_REF: /* &name */
- case CMD_APPINFO: /* #text */
- case CMD_CONFORM: /* C */
- default:
- fgets(buf, LINESIZE, fp);
- fprintf(stderr, "Error: Unexpected input at %d: '%c%s'\n",
- e->lineno, c, buf);
- exit(1);
- break;
- }
- }
- fprintf(stderr, "Error: End of ReadESIS - should not be here: %s\n", e->gi);
- free(buf);
- return NULL;
-}
-
-/* ______________________________________________________________________ */
-/* Read input stream, creating a tree in memory of the elements and data.
- * Arguments:
- * Filename where instance's ESIS is.
- */
-static void
-ReadInstance(
- char *filename
-)
-{
- int i, n;
- FILE *fp;
- Element_t *e;
- char *idatt;
-
- if (filename) { /* if we specified input file. else stdin */
- if ((fp=fopen(filename, "r")) == NULL) {
- perror(filename);
- exit(1);
- }
- }
- else fp = stdin;
- last_file = filename;
- DocTree = ReadESIS(fp, 0);
- if (filename) fclose(fp);
-
- /* Traverse tree, filling in econt and figuring out which child
- * (ie. what birth order) each element is. */
- DocTree->my_eorder = -1;
- for (e=DocTree; e; e=e->next) {
-
- /* count element children */
- for (i=0,n=0; i<e->ncont; i++) if (IsContElem(e,i)) n++;
- if (n > 0) Calloc(n, e->econt, Element_t *);
- for (i=0; i<e->ncont; i++)
- if (IsContElem(e,i)) e->econt[e->necont++] = ContElem(e,i);
-
- /* count data children */
- for (i=0,n=0; i<e->ncont; i++) if (IsContData(e,i)) n++;
- if (n > 0) Calloc(n, e->dcont, char *);
- for (i=0; i<e->ncont; i++)
- if (IsContData(e,i)) e->dcont[e->ndcont++] = ContData(e,i);
-
- /* where in child order order */
- for (i=0; i<e->necont; i++)
- e->econt[i]->my_eorder = i;
-
- /* Does this element have an ID? */
- for (i=0; i<e->natts; i++) {
- if ((idatt=FindAttValByName(e, "ID"))) {
- AddID(e, idatt);
- /* remember ID value for quick reference */
- e->id = idatt;
- break;
- }
- }
- }
- return;
-}
-
-/* ______________________________________________________________________ */
diff --git a/usr.bin/sgmls/instant/tables.c b/usr.bin/sgmls/instant/tables.c
deleted file mode 100644
index 54fd211..0000000
--- a/usr.bin/sgmls/instant/tables.c
+++ /dev/null
@@ -1,2013 +0,0 @@
-/*
- * Copyright 1993 Open Software Foundation, Inc., Cambridge, Massachusetts.
- * All rights reserved.
- */
-/*
- * Copyright (c) 1994
- * Open Software Foundation, Inc.
- *
- * Permission is hereby granted to use, copy, modify and freely distribute
- * the software in this file and its documentation for any purpose without
- * fee, provided that the above copyright notice appears in all copies and
- * that both the copyright notice and this permission notice appear in
- * supporting documentation. Further, provided that the name of Open
- * Software Foundation, Inc. ("OSF") not be used in advertising or
- * publicity pertaining to distribution of the software without prior
- * written permission from OSF. OSF makes no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- */
-/*
- * Copyright (c) 1996 X Consortium
- * Copyright (c) 1995, 1996 Dalrymple Consulting
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * X CONSORTIUM OR DALRYMPLE CONSULTING BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the names of the X Consortium and
- * Dalrymple Consulting shall not be used in advertising or otherwise to
- * promote the sale, use or other dealings in this Software without prior
- * written authorization.
- */
-/* ________________________________________________________________________
- *
- * Program to manipulate SGML instances.
- *
- * Originally coded for OSF DTD tables, now recoded (fld 3/27/95)
- * for CALS-type tables (fragment taken from the DocBook DTD). Then,
- * *really* upgraded to CALS tables by FLD on 5/28/96.
- *
- * This module is for handling table markup, printing TeX or tbl
- * (tbl) markup to the output stream. Also, table markup checking is
- * done here. Yes, this depends on the DTD, but it makes translation
- * specs much cleaner (and makes some things possible).
- *
- * Incomplete / not implemented / limitations / notes:
- * vertical alignment (valign attr)
- * vertical spanning
- * row separators are for the whole line, not per cell (the prog looks
- * at rowsep for the 1st cell and applies it to the whole row)
- * trusts that units in colwidths are acceptable to LaTeX and tbl
- * "s" is an acceptable shorthand for "span" in model attributes
- *
- * A note on use of OutputString(): Strings with backslashes (\) need lots
- * of backslashes. You have to escape them for the C compiler, and escape
- * them again for OutputString() itself.
- * ________________________________________________________________________
- */
-
-#ifndef lint
-static char *RCSid =
- "$Header: /usr/src/docbook-to-man/Instant/RCS/tables.c,v 1.11 1996/06/15 03:45:02 fld Exp $";
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <string.h>
-#include <memory.h>
-#include <sys/types.h>
-#include <errno.h>
-
-#include <regexp.h>
-#include "general.h"
-#include "translate.h"
-
-/* text width of page, in inches */
-#define TEXTWIDTH 5.5
-#define MAXCOLS 100
-#define SPAN_NOT 0
-#define SPAN_START 1
-#define SPAN_CONT 2
-
-/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
-/*table parameters */
-
-#define TBLMAXCOL 30 /* max number of columns in tbl table */
-#define NAMELEN 40 /* max length of a name */
-#define BOFTTHRESHOLD 35 /* text length over which to consider
- * generating a block of filled text */
-
-
-/* handy declarations */
-
-typedef enum { Left, Right, Center, Justify, Char, Span } tblalign;
-
-typedef enum { TGroup, THead, TFoot, TBody } tblsource; /* source of a spec */
-
-
-/* table line format information structures */
-
-struct tblcolspec {
-
- char name[NAMELEN]; /* colspec's name */
- short num; /* column number */
- tblsource source; /* where defined */
-
- tblalign align; /* column's alignment */
- char alignchar; /* character for alignment */
- short aligncharoff; /* offset for alignment */
- char colwidth[10]; /* width for column */
- char colpwidth[10]; /* proportional widths for column */
- bool colsep; /* separator to right of column? */
- bool rowsep; /* separator to bottom of column? */
- short moreRows; /* value for Morerows */
-
- struct tblcolspec * next; /* next colspec */
-};
-
-struct tblspanspec {
-
- char name[NAMELEN]; /* spanspec's name */
- tblsource source; /* where defined */
-
- struct tblcolspec * start; /* start column */
- struct tblcolspec * end; /* end column */
- tblalign align; /* span's alignment */
- char alignchar; /* character for alignment */
- short aligncharoff; /* offset for alignment */
- bool colsep; /* separator to right of column? */
- bool rowsep; /* separator to bottom of column? */
-
- struct tblspanspec * next; /* next spanspec */
-};
-
-struct tblformat {
- short count; /* count of rows matching this spec */
-
- short cols; /* # of columns */
- short rowNum; /* row number */
- char colformat[TBLMAXCOL]; /* per-column formats */
- char colwidth[TBLMAXCOL][10]; /* per-column widths */
- char colpwidth[TBLMAXCOL][10]; /* per-column proportional widths */
- char font[TBLMAXCOL][3]; /* column fonts (headers) */
- bool colsep[TBLMAXCOL]; /* column separators */
- bool rowsep[TBLMAXCOL]; /* row separators */
- short moreRows[TBLMAXCOL]; /* moreRows indicator */
-
- struct tblformat * next; /* for the next row */
-};
-
-
-/* table state info */
-
-static short tblcols = 0; /* number of columns in the table */
-static short tblrow = 0; /* the current row in the table */
-
-static bool tblTGroupSeen = FALSE; /* seen a TGroup in this table yet? */
-
-static char * tblFrame; /* table frame info */
-static bool tblgcolsep; /* global colsep (in table) */
-static bool tblgrowsep; /* global rowsep (in table) */
-
-static int tblBOFTCount = 0; /* count of bofts that we've created
- * (per table) */
-int BOFTTextThresh = BOFTTHRESHOLD;
- /* length of text before we
- * call it a BOFT */
-static bool tblboft = FALSE; /* within a block of filled text? */
-static bool tblinBOFT = FALSE; /* within a boft now? */
-
-static struct tblformat * formP = 0; /* THead/TBody format lines */
-
-static struct tblcolspec * tblColSpec = 0; /* colspec structure for table */
-static struct tblspanspec * tblSpanSpec = 0; /* spanspec structure for table */
-
-/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
-
-/* these cover the attributes on the Table, TGroup, Colspec elements */
-typedef struct {
- char *cols;
- char *align, **align_v;
- char *colwidth, **colwidth_v;
- char *colsep, **colsep_v;
- char *rowsep, **rowsep_v;
- char *frame;
- char *orient;
- int pgwide;
- int n_align, n_model, n_colwidth, n_colsep;
- int nc;
-} TableInfo;
-
-
-/* some flags, set when the table tag is processed, used later */
-static int rowsep, siderules;
-static int frametop, framebot, frameall;
-static char basemodel[128]; /* model for table (in formatting language) */
-static int spaninfo[MAXCOLS]; /* 100 columns, max */
-static TableInfo TheTab;
-
-/* forward references */
-void SetTabAtts(Element_t *, TableInfo *, int);
-void FreeTabAtts(TableInfo *);
-void ClearTable(TableInfo *);
-void CheckTable(Element_t *);
-void TblTStart(Element_t *, FILE *);
-void TblTEnd(Element_t *, FILE *);
-void TblTGroup(Element_t *, FILE *);
-void TblTGroupEnd(Element_t *, FILE *);
-void TblTFoot(Element_t *, FILE *);
-void TblBuildFormat(Element_t *, struct tblformat **, tblsource);
-struct tblformat * TblBuild1Format(Element_t *, bool, tblsource);
-char TblGetAlign(short, Element_t *, tblsource);
-char * TblGetWidth(short, Element_t *, bool, tblsource);
-char * TblGetFont(short, Element_t *, tblsource);
-bool TblGetColSep(short, Element_t *, tblsource);
-bool TblGetRowSep(short, Element_t *, tblsource);
-short TblGetMoreRows(short, Element_t *, tblsource);
-bool TblColAdv(short, Element_t *, struct tblformat *, tblsource);
-struct tblcolspec * TblEntryColSpec(short, Element_t *, tblsource);
-struct tblspanspec * TblEntrySpanSpec(short, Element_t *, tblsource);
-bool TblFormatMatch(struct tblformat *, struct tblformat *);
-void TblPrintFormat(FILE *, struct tblformat *);
-void TblTRowStart(Element_t *, FILE *);
-void TblTRowEnd(Element_t *, FILE *);
-void TblTCellStart(Element_t *, FILE *);
-int TblCountContent(Element_t *);
-void TblTCellEnd(Element_t *, FILE *);
-struct tblcolspec * TblDoColSpec(short, Element_t *, struct tblcolspec *, tblsource);
-struct tblspanspec * TblDoSpanSpec(Element_t *, struct tblspanspec *, tblsource);
-struct tblcolspec * TblFindColSpec(char *, tblsource);
-struct tblcolspec * TblFindColNum(short, tblsource);
-struct tblspanspec * TblFindSpanSpec(char *, tblsource);
-void TexTable(Element_t *, FILE *);
-void TexTableCellStart(Element_t *, FILE *);
-void TexTableCellEnd(Element_t *, FILE *);
-void TexTableRowStart(Element_t *, FILE *);
-void TexTableRowEnd(Element_t *, FILE *);
-void TexTableTop(Element_t *, FILE *);
-void TexTableBottom(Element_t *, FILE *);
-
-/* ______________________________________________________________________ */
-/* Hard-coded stuff for CALS-style DTD tables.
- * Here are the TABLE attributes (for handy reference):
- *
- * Table/InformalTable:
- * Colsep NUMBER separate all columns in table?
- * Frame (Top|Bottom|Topbot|All|Sides|None) frame style
- * Orient (Port | Land) orientation
- * Pgwide NUMBER wide table?
- * Rowsep NUMBER separate all rows in the table?
- * Tabstyle NMTOKEN FOSI table style
- *
- * TGroup:
- * Align (Left|Right|Center|Justify|Char) alignment of cols
- * Char CDATA Alignment specifier
- * Charoff NUTOKEN "" ""
- * Cols NUMBER number of columns
- * Colsep NUMBER separate all columns in tgroup?
- * Rowsep NUMBER separate all rows in tgroup?
- * TGroupstyle NMTOKEN FOSI table group style
- *
- * Colspec:
- * Align (Left|Right|Center|Justify|Char) entry align
- * Char CDATA Alignment specifier
- * Charoff NUTOKEN "" ""
- * Colname NMTOKEN Column identifier
- * Colnum NUMBER number of column
- * Colsep NUMBER separate this col from next?
- * Colwidth CDATA width spec
- * Rowsep NUMBER serarate entry from following row?
- *
- * SpanSpec:
- * Align (Left|Right|Center|Justify|Char) entry align
- * Char CDATA Alignment specifier
- * Charoff NUTOKEN "" ""
- * Colsep NUMBER separate this col from next?
- * Nameend NMTOKEN name of rightmost col of a span
- * Namest NMTOKEN name of leftmost col of a span
- * Rowsep NUMBER serarate entry from following row?
- * Spanname NMTOKEN name of a horiz. span
- *
- * THead/TFoot/TBody:
- * VAlign (Top | Middle | Bottom) group placement
- *
- * Row:
- * Rowsep NUMBER separate this row from next?
- * VAlign (Top | Middle | Bottom) row placement
- *
- * Entry:
- * Align (Left|Right|Center|Justify|Char) entry align
- * Char CDATA Alignment specifier
- * Charoff NUTOKEN "" ""
- * Colname NMTOKEN Column identifier
- * Colsep NUMBER separate this col from next?
- * Morerows NUMBER number of addn'l rows in vert straddle
- * Nameend NMTOKEN name of rightmost col of a span
- * Namest NMTOKEN name of leftmost col of a span
- * Rotate NUMBER 90 degree rotation counterclockwise to table?
- * Rowsep NUMBER serarate entry from following row?
- * Spanname NMTOKEN name of a horiz. span
- * VAlign (Top | Middle | Bottom) text vert alignment
- *
- *
- ** OBSOLETE OSF DTD FORM (still used for TeX form):
- ** Usage in transpec: _calstable [tex|check|clear] ['aspect']
- ** where 'aspect' is:
- ** rowstart stuff to do at start of a row (tests for spanning)
- ** rowend stuff to do at end of a row (eg, rules, etc.)
- ** cellstart stuff to do at start of a cell (eg, handle actual
- ** spanning instructions, etc.)
- ** cellend stuff to do at end of a cell (eg, cell separator)
- ** top stuff to do at top of the table
- ** (like whether or not it needs a starting horiz rule)
- ** bottom stuff to do at bottom of the table
- ** (like whether or not it needs an ending horiz rule)
- ** (nothing) the 'cols' param to LaTeX's \begin{tabular}[pos]{cols}
- ** or 'options' and 'formats' part in tbl
- *
- *
- * New tbl form:
- * Usage in transpec: _calstable [tbl] ['aspect']
- * where 'aspect' is:
- * tablestart start a table and do style info
- * tableend end the table and clean up
- * tablegroup table TGroup (.T& if not 1st, line format info)
- * tablegroupend end a TGroup
- * tablefoot TFoot within a TGroup
- * rowstart start of a row
- * rowend end of a row
- * entrystart start of an entry (block of filled text, if
- * appropriate)
- * entryend end of a cell (eg, cell separator)
- */
-
-/* Procedure to
- * Arguments:
- * Pointer to element under consideration.
- * FILE pointer to where to write output.
- * Vector of args to _osftable
- * Count of args to _osftable
- */
-void
-CALStable(
- Element_t *e,
- FILE *fp,
- char **av,
- int ac
-)
-{
- /* Check params and dispatch to appropriate routine */
-
- if (!strcmp(av[1], "tbl")) {
-
- if (ac > 2) {
- if (!strcmp(av[2], "tablestart")) TblTStart(e, fp);
- else if (!strcmp(av[2], "tableend")) TblTEnd(e, fp);
- else if (!strcmp(av[2], "tablegroup")) TblTGroup(e, fp);
- else if (!strcmp(av[2], "tablegroupend")) TblTGroupEnd(e, fp);
- else if (!strcmp(av[2], "tablefoot")) TblTFoot(e, fp);
- else if (!strcmp(av[2], "rowstart")) TblTRowStart(e, fp);
- else if (!strcmp(av[2], "rowend")) TblTRowEnd(e, fp);
- else if (!strcmp(av[2], "entrystart")) TblTCellStart(e, fp);
- else if (!strcmp(av[2], "entryend")) TblTCellEnd(e, fp);
- else fprintf(stderr, "Unknown %s table instruction: %s\n",
- av[1], av[2]);
- }
- else {
- fprintf(stderr, "Incomplete %s table instruction\n");
- }
- }
-
- else if (!strcmp(av[1], "tex")) {
-
- if (ac > 1 && !strcmp(av[1], "check")) CheckTable(e);
-
- else
- if (ac > 1 && !strcmp(av[1], "clear")) ClearTable(&TheTab);
-
- if (ac > 2) {
- if (!strcmp(av[2], "cellstart")) TexTableCellStart(e, fp);
- else if (!strcmp(av[2], "cellend")) TexTableCellEnd(e, fp);
- else if (!strcmp(av[2], "rowstart")) TexTableRowStart(e, fp);
- else if (!strcmp(av[2], "rowend")) TexTableRowEnd(e, fp);
- else if (!strcmp(av[2], "top")) TexTableTop(e, fp);
- else if (!strcmp(av[2], "bottom")) TexTableBottom(e, fp);
- else fprintf(stderr, "Unknown %s table instruction: %s\n",
- av[1], av[2]);
- }
- else TexTable(e, fp);
- }
-
- else fprintf(stderr, "Unknown table type: %s\n", av[1]);
-
-}
-
-/* ClearTable -- start a new table process
- *
- */
-
-
-void
-ClearTable( TableInfo * t )
-{
- memset(t, 0, sizeof(TableInfo));
-}
-
-
-/* ______________________________________________________________________ */
-/* Set values of the our internal table structure based on the table's
- * attributes. (This is called for tables, tgroups, colspecs, and rows,
- * since tables and rows share many of the same attributes.)
- * Arguments:
- * Pointer to element under consideration.
- * Pointer table info structure which will be filled in.
- * Flag saying whether or not to set global variables based on attrs.
- */
-void
-SetTabAtts(
- Element_t *e,
- TableInfo *t,
- int set_globals
-)
-{
- char *at;
- Element_t * ep;
-
- /* remember values of attributes */
- if ((at = FindAttValByName(e, "ALIGN"))) t->align = at;
- if ((at = FindAttValByName(e, "COLWIDTH"))) t->colwidth = at;
- if ((at = FindAttValByName(e, "COLSEP"))) t->colsep = at;
- if ((at = FindAttValByName(e, "FRAME"))) t->frame = at;
- if ((at = FindAttValByName(e, "COLS"))) t->cols = at;
-
- /* Set some things for later when processing this table */
- if (set_globals) {
-
- rowsep = 1;
- frametop = framebot = 1; /* default style */
-
- /* For now we look at the first number of rowsep - it controls the
- * horiz rule for then entire row. (not easy to specify lines that
- * span only some columns in tex or tbl. */
- if ((at = FindAttValByName(e, "ROWSEP"))) rowsep = atoi(at);
- }
-
- if (t->frame) {
- /* Top|Bottom|Topbot|All|Sides|None */
- if (!strcmp(t->frame, "NONE") || !strcmp(t->frame, "SIDES"))
- frametop = framebot = 0;
- else if (!strcmp(t->frame, "TOP")) framebot = 0;
- else if (!strcmp(t->frame, "BOTTOM")) frametop = 0;
- }
-
- /* tbl and tex like lower case for units. convert. */
- if (t->colwidth) {
- char *cp;
- for (cp=t->colwidth; *cp; cp++)
- if (isupper(*cp)) *cp = tolower(*cp);
- }
-
- /* Now, split (space-separated) strings into vectors. Hopefully, the
- * number of elements in each vector matches the number of columns.
- */
- t->align_v = Split(t->align, &t->n_align, S_STRDUP|S_ALVEC);
- t->colwidth_v = Split(t->colwidth, &t->n_colwidth, S_STRDUP|S_ALVEC);
- t->colsep_v = Split(t->colsep, &t->n_colsep, S_STRDUP|S_ALVEC);
-
- /* Determin the _numeric_ number of columns, "nc". MUST be specified
- * in Cols attribute of TGroup element.
- */
- if (t->cols) t->nc = atoi(t->cols);
-}
-
-/* ______________________________________________________________________ */
-
-/* Free the storage of info use by the table info structure. (not the
- * structure itself, but the strings its elements point to)
- * Arguments:
- * Pointer table info structure to be freed.
- */
-void
-FreeTabAtts(
- TableInfo *t
-)
-{
- if (!t) return;
- if (t->align_v) free(*t->align_v);
- if (t->colwidth_v) free(*t->colwidth_v);
- if (t->colsep_v) free(*t->colsep_v);
-}
-
-/* ______________________________________________________________________ */
-/* Check the attributes and children of the table pointed to by e.
- * Report problems and inconsistencies to stderr.
- * Arguments:
- * Pointer to element (table) under consideration.
- */
-
-void
-CheckTable(
- Element_t *e
-)
-{
- int pr_loc=0; /* flag to say if we printed location */
- int i, r, c;
- Element_t *ep, *ep2;
- float wt;
- char *tpref = "Table Check"; /* prefix for err messages */
- char *ncolchk =
- "Table Check: %s ('%s') has wrong number of tokens. Expecting %d.\n";
-
- if (strcmp(e->gi, "TABLE") &&
- strcmp(e->gi, "INFORMALTABLE") &&
- strcmp(e->gi, "TGROUP") &&
- strcmp(e->gi, "COLSPEC") &&
- strcmp(e->gi, "ROW") ) {
- fprintf(stderr, "%s: Not pointing to a table element(%s)!\n",
- tpref, e->gi);
- return;
- }
-
- FreeTabAtts(&TheTab); /* free storage, if allocated earlier */
- SetTabAtts(e, &TheTab, 1); /* look at attributes */
-
-#if FALSE
- /* NCOLS attribute set? */
- if (!TheTab.ncols) {
- pr_loc++;
- fprintf(stderr, "%s: NCOLS attribute missing. Inferred as %d.\n",
- tpref, TheTab.nc);
- }
-
- /* ALIGN attribute set? */
- if (!TheTab.align) {
- pr_loc++;
- fprintf(stderr, "%s: ALIGN attribute missing.\n", tpref);
- }
-
- /* See if the number of cells in each row matches */
- for (r=0; r<e->necont && (ep=e->econt[r]); r++) { /* each TGroup */
- for (i=0; i<ep->necont && (ep2=ep->econt[i]); i++) {
- if ( strcmp(ep2->gi, "TBODY") ) /* only TBodys */
- continue;
-
- for (c=0; c<ep2->necont; c++) {
- if (ep2->econt[c]->necont != TheTab.nc) {
- pr_loc++;
- fprintf(stderr, "%s: COLS (%d) differs from actual number of cells (%d) in row %d.\n",
- tpref, TheTab.nc, ep2->econt[c]->necont, c);
- }
- }
- }
- }
-#endif
-
- /* Check ALIGN */
- if (TheTab.align) {
- if (TheTab.nc != TheTab.n_align) { /* number of tokens OK? */
- pr_loc++;
- fprintf(stderr, ncolchk, "ALIGN", TheTab.align, TheTab.nc);
- }
- else { /* values OK? */
- for (i=0; i<TheTab.nc; i++) {
- if (*TheTab.align_v[i] != 'C' && *TheTab.align_v[i] != 'L' &&
- *TheTab.align_v[i] != 'R') {
- pr_loc++;
- fprintf(stderr, "%s: ALIGN (%d) value wrong: %s\n",
- tpref, i, TheTab.align_v[i]);
- }
- }
- }
- }
-
- /* check COLWIDTH */
- if (TheTab.colwidth) {
- if (TheTab.nc != TheTab.n_colwidth) { /* number of tokens OK? */
- pr_loc++;
- fprintf(stderr, ncolchk, "COLWIDTH", TheTab.colwidth, TheTab.nc);
- }
- else { /* values OK? */
- for (i=0; i<TheTab.nc; i++) {
-
- /* check that the units after the numbers are OK
- we want "in", "cm".
- */
- }
- }
- }
-
- /* check COLSEP */
- if (TheTab.colsep) {
- if (TheTab.nc != TheTab.n_colsep) { /* number of tokens OK? */
- pr_loc++;
- fprintf(stderr, ncolchk, "COLSEP", TheTab.colsep, TheTab.nc);
- }
- else { /* values OK? */
- for (i=0; i<TheTab.nc; i++) {
- }
- }
- }
-
- if (pr_loc) {
- fprintf(stderr, "%s: Above problem in table located at:\n", tpref);
- PrintLocation(e, stderr);
- }
-}
-
-/* ______________________________________________________________________ */
-
-/* Look at colspec attribute for spanning. If set, remember info for when
- * doing the cells. Called by TblTableRowStart() and TexTableRowStart().
- * Arguments:
- * Pointer to element (row) under consideration.
- */
-int
-check_for_spans(
- Element_t *e
-)
-{
- char *at;
- char **spans;
- int n, i, inspan;
-
-#if FALSE /* NOT IMPLEMENTED RIGHT NOW */
-
- /* See if COLSPEC element present */
- for (i=0; i < e->necont; i++) {
-
- }
-
-
- if ((at = FindAttValByName(e, "MODEL"))) {
-
- /* Split into tokens, then look at each for the word "span" */
- n = TheTab.nc;
- spans = Split(at, &n, S_STRDUP|S_ALVEC);
-
- /* Mark columns as start-of-span, in-span, or not spanned. Remember
- * in at list, "spaningo". (Span does not make sense in 1st column.)
- */
- for (i=1,inspan=0; i<n; i++) {
- if (StrEq(spans[i], "span") || StrEq(spans[i], "s")) {
- if (inspan == 0) spaninfo[i-1] = SPAN_START;
- spaninfo[i] = SPAN_CONT;
- inspan = 1;
- }
- else {
- spaninfo[i] = SPAN_NOT;
- inspan = 0;
- }
- }
- free(*spans); /* free string */
- free(spans); /* free vector */
- spaninfo[TheTab.nc] = SPAN_NOT; /* after last cell */
- return 1;
- }
- /* if model not set, mark all as not spanning */
- else
-
-#endif /* NOT CURRENTLY IMPLEMENTED */
-
- for (i=0; i<MAXCOLS; i++) spaninfo[i] = SPAN_NOT;
- return 0;
-}
-
-/* ______________________________________________________________________ */
-/* Do the "right thing" for the table spec for TeX tables. This will
- * generate the arg to \begin{tabular}[xxx].
- * Arguments:
- * Pointer to element (table) under consideration.
- * FILE pointer to where to write output.
- */
-void
-TexTable(
- Element_t *e,
- FILE *fp
-)
-{
- int i, n;
- float tot;
- char *cp, wbuf[1500], **widths=0, **widths_v=0;
-
- FreeTabAtts(&TheTab); /* free storage, if allocated earlier */
- SetTabAtts(e, &TheTab, 1); /* look at attributes */
- SetTabAtts(e->econt[0], &TheTab, 1); /* attrs of TGroup */
-
- /* Figure out the widths, based either on "colwidth".
- */
- if (TheTab.colwidth && TheTab.nc == TheTab.n_colwidth) {
- widths = TheTab.colwidth_v;
- }
-
- siderules = 1;
- if (TheTab.frame)
- if (strcmp(TheTab.frame, "ALL") && strcmp(TheTab.frame, "SIDES"))
- siderules = 0;
-
- if (siderules) OutputString("|", fp, 1);
- for (i=0; i<TheTab.nc; i++) {
- /* If width specified, use it; else if align set, use it; else left. */
- if (widths && widths[i][0] != '0' && widths[i][1] != EOS) {
- fprintf(fp, "%sp{%s}", (i?" ":""), widths[i]);
- }
- else if (TheTab.align && TheTab.nc == TheTab.n_align) {
- fprintf(fp, "%s%s", (i?" ":""), TheTab.align_v[i]);
- }
- else
- fprintf(fp, "%sl", (i?" ":""));
- /* See if we want column separators. */
- if (TheTab.colsep) {
-
- if ( (i+1) < TheTab.nc ) {
- if ( *TheTab.colsep_v[i] == '1' ) {
- fprintf(fp, " |");
- }
- if ( *TheTab.colsep_v[i] == '2' ) {
- fprintf(fp, " ||");
- }
- }
-
- }
- }
- if (siderules) OutputString("|", fp, 1);
-
- if (widths_v) free(widths_v);
-}
-
-/*
- * Arguments:
- * Pointer to element (cell) under consideration.
- * FILE pointer to where to write output.
- */
-void
-TexTableCellStart(
- Element_t *e,
- FILE *fp
-)
-{
- int n, i;
- char buf[50], *at;
-
- if (spaninfo[e->my_eorder] == SPAN_START) {
- for (i=e->my_eorder+1,n=1; ; i++) {
- if (spaninfo[i] == SPAN_CONT) n++;
- else break;
- }
- sprintf(buf, "\\\\multicolumn{%d}{%sc%s}", n,
- (siderules?"|":""), (siderules?"|":""));
- OutputString(buf, fp, 1);
- }
-#ifdef New
- if ((at = FindAttValByName(e->parent, "ALIGN"))) {
- /* no span, but user wants to change the alignment */
- h_v = Split(wbuf, 0, S_ALVEC|S_STRDUP);
- OutputString("\\\\multicolumn{1}{%sc%s}", n,
- fp, 1);
- }
-#endif
-
- if (spaninfo[e->my_eorder] != SPAN_CONT) OutputString("{", fp, 1);
-}
-
-/*
- * Arguments:
- * Pointer to element (cell) under consideration.
- * FILE pointer to where to write output.
- */
-void
-TexTableCellEnd(
- Element_t *e,
- FILE *fp
-)
-{
- if (spaninfo[e->my_eorder] != SPAN_CONT) OutputString("} ", fp, 1);
-
- /* do cell/col separators */
- if (e->my_eorder < (TheTab.nc-1)) {
- if (spaninfo[e->my_eorder] == SPAN_NOT ||
- spaninfo[e->my_eorder+1] != SPAN_CONT)
- OutputString("& ", fp, 1);
- }
-}
-
-/* Look at model for spanning. If set, remember it for when doing the cells.
- * Arguments:
- * Pointer to element (row) under consideration.
- * FILE pointer to where to write output.
- */
-void
-TexTableRowStart(
- Element_t *e,
- FILE *fp
-)
-{
- check_for_spans(e);
-}
-
-/*
- * Arguments:
- * Pointer to element (row) under consideration.
- * FILE pointer to where to write output.
- */
-void
-TexTableRowEnd(
- Element_t *e,
- FILE *fp
-)
-{
- char *at;
-
- /* check this row's attributes */
- if ((at = FindAttValByName(e, "ROWSEP"))) {
- if (at[0] == '1') OutputString("\\\\\\\\[2mm] \\\\hline ", fp, 1);
- }
- else if (rowsep) OutputString("\\\\\\\\ ", fp, 1);
- else
- OutputString("\\\\\\\\ ", fp, 1);
-
-}
-
-/*
- * Arguments:
- * Pointer to element (table) under consideration.
- * FILE pointer to where to write output.
- */
-void
-TexTableTop(Element_t *e, FILE *fp)
-{
- if (frametop) OutputString("\\\\hline", fp, 1);
-}
-
-void
-TexTableBottom(Element_t *e, FILE *fp)
-{
- if (framebot) OutputString("\\\\hline", fp, 1);
-}
-
-/* ______________________________________________________________________ */
-/* ______________________________________________________________________ */
-/* ______________________________________________________________________ */
-/* ______________________________________________________________________ */
-/* ______________________________________________________________________ */
-/* ___________________________| |____________________________ */
-/* ___________________________| TBL STUFF |____________________________ */
-/* ___________________________| |____________________________ */
-/* ___________________________|_____________|____________________________ */
-/* ______________________________________________________________________ */
-/* ______________________________________________________________________ */
-/* ______________________________________________________________________ */
-/* ______________________________________________________________________ */
-
-
-
-/* TblTStart() -- start a table and do style information
- *
- * TO DO:
- *
- * do .TS
- * find global rowsep and colsep
- */
-
-
-void
-TblTStart(Element_t * ep,
- FILE * fP)
-{
- register char * cp;
- register struct Element_t * ep2;
-
-
-
- OutputString("^.TS^", fP, 1);
-
- tblTGroupSeen = FALSE;
- tblinBOFT = FALSE; /* within a boft? */
- tblBOFTCount = 0; /* count of Blocks of Filled Text that
- * we've created */
-
- tblgcolsep = (cp = FindAttValByName(ep, "COLSEP")) && !strcmp(cp, "1");
- tblgrowsep = (cp = FindAttValByName(ep, "ROWSEP")) && !strcmp(cp, "1");
-}
-
-/* TblTEnd() -- end a table and do any cleanup
- *
- * TO DO:
- *
- * do .TE
- *
- * deallocate format line info
- */
-
-
-
-void
-TblTEnd(Element_t * ep,
- FILE * fP)
-{
- register struct tblformat * ffp, * ffp2;
-
-
- if ( tblBOFTCount > 31 ) {
- fprintf(stderr, "# warning, line %d: created %d blocks of filled text in one table\n",
- ep->lineno, tblBOFTCount);
- fprintf(stderr, "#\t\t(31 is the limit in some systems)\n");
- }
-
- OutputString("^.TE^", fP, 1);
-
- for ( ffp=formP; ffp; ffp=ffp2 ) {
- ffp2 = ffp->next;
- free(ffp); /* clear entire list */
- }
- formP = 0;
-}
-
-/* TblTTGroup() -- do body work (row format info)
- *
- * TO DO:
- *
- * set number of columns
- *
- * if this is the first TGroup of this table, do style info:
- * a. alignment
- * b. defaults: tab
- * c. box vx allbox
- *
- * do format info:
- * a. generate tableformat structure
- * b. output it
- *
- * prepare structures for colspecs and spanspecs
- *
- */
-
-
-
-void
-TblTGroup(Element_t * ep,
- FILE * fP)
-{
- register int i, j, k;
- register char * cp, * cp2;
- register Element_t * ep2, ep3;
- register struct tblcolspec * tcsp, * tcsp2;
- register struct tblspanspec * tssp, * tssp2;
-
-
- tblColSpec = 0; /* make sure they're clear */
- tblSpanSpec = 0;
-
- /* set the number of columns */
-
- tblcols = atoi(FindAttValByName(ep, "COLS"));
-
- /* do colspecs */
-
- tblColSpec = tcsp = TblDoColSpec(0, ep, 0, TGroup);
- /* do TGroup first -- it becomes the default */
-
- for ( i=0, k=1; i < ep->necont; i++ ) {
-
- if ( !strcmp(ep->econt[i]->gi, "COLSPEC") ) {
- tcsp2 = TblDoColSpec(k, ep->econt[i], tblColSpec, TGroup);
- tcsp->next = tcsp2; /* put into list */
- tcsp = tcsp2;
- k = tcsp2->num + 1; /* next column number */
- }
-
- if ( !strcmp(ep->econt[i]->gi, "THEAD") ) {
- ep2 = ep->econt[i];
- for ( j=0, k=1; j < ep2->necont; j++ ) {
- if ( !strcmp(ep2->econt[j]->gi, "COLSPEC") ) {
- tcsp2 = TblDoColSpec(k, ep2->econt[j], tblColSpec, THead);
- tcsp->next = tcsp2; /* put into list */
- tcsp = tcsp2;
- k = tcsp2->num + 1; /* next column number */
- }
- }
- }
-
- if ( !strcmp(ep->econt[i]->gi, "TFOOT") ) {
- ep2 = ep->econt[i];
- for ( j=0, k=1; j < ep2->necont; j++ ) {
- if ( !strcmp(ep2->econt[j]->gi, "COLSPEC") ) {
- tcsp2 = TblDoColSpec(k, ep2->econt[j], tblColSpec, TFoot);
- tcsp->next = tcsp2; /* put into list */
- tcsp = tcsp2;
- k = tcsp2->num + 1; /* next column number */
- }
- }
- }
-
- if ( !strcmp(ep->econt[i]->gi, "TBODY") ) {
- ep2 = ep->econt[i];
- for ( j=0, k=1; j < ep2->necont; j++ ) {
- if ( !strcmp(ep2->econt[j]->gi, "COLSPEC") ) {
- tcsp2 = TblDoColSpec(k, ep2->econt[j], tblColSpec, TBody);
- tcsp->next = tcsp2; /* put into list */
- tcsp = tcsp2;
- k = tcsp2->num + 1; /* next column number */
- }
- }
- }
- }
-
- /* do spanspecs */
-
- tblSpanSpec = tssp = TblDoSpanSpec(ep, 0, TGroup);
- /* do TGroup first -- it becomes the default */
-
- for ( i=0; i < ep->necont; i++ ) {
- if ( !strcmp(ep->econt[i]->gi, "SPANSPEC") ) {
- tssp2 = TblDoSpanSpec(ep->econt[i], tblSpanSpec, TGroup);
- tssp->next = tssp2; /* put into list */
- tssp = tssp2;
- }
- }
-
-
- /* if this is the first TGroup in this table, do style stuff */
-
- if ( ! tblTGroupSeen ) {
-
- OutputString("tab(\007)", fP, 1);
-
- ep2 = ep->parent;
- if ( ! (tblFrame = FindAttValByName(ep2, "FRAME")) )
- tblFrame = "";
-
- if ( !strcmp(tblFrame, "ALL") ) {
- if ( tcsp->colsep && tcsp->rowsep )
- OutputString(" allbox", fP, 1);
- else
- OutputString(" box", fP, 1);
- }
-
- if ( (cp = FindAttValByName(ep, "ALIGN")) &&
- !strcmp(cp, "CENTER") ) {
- OutputString(" center", fP, 1);
- }
-
- OutputString(";\n", fP, 1);
-
- tblTGroupSeen = TRUE;
- }
-
-
- /* do format stuff -- step through all THead rows then all TBody
- * rows. Build a list of tblformats that describe all of them.
- * then output the resulting list.
- */
-
- for ( i=0; i < ep->necont; i++ ) {
- if ( !strcmp(ep->econt[i]->gi, "THEAD") ) {
- TblBuildFormat(ep->econt[i], &formP, THead);
- /* add in those rows */
- break;
- }
- }
-
- for ( i=0; i < ep->necont; i++ ) {
- if ( !strcmp(ep->econt[i]->gi, "TBODY") ) {
- TblBuildFormat(ep->econt[i], &formP, TBody);
- /* add in those rows */
- break;
- }
- }
-
- TblPrintFormat(fP, formP);
-
- tblrow = 0; /* the current row within this format */
-}
-
-/* TblTGroupEnd() -- end a TGroup
- *
- * TO DO:
- *
- * deallocate colspecs and spanspecs
- */
-
-
-void
-TblTGroupEnd(Element_t * ep,
- FILE * fP)
-{
- register struct tblcolspec * tcsp, * tcsp2;
- register struct tblspanspec * tssp, * tssp2;
-
-
- for ( tcsp=tblColSpec; tcsp; tcsp=tcsp2 ) {
- tcsp2 = tcsp->next;
- free(tcsp);
- }
- for ( tssp=tblSpanSpec; tssp; tssp=tssp2 ) {
- tssp2 = tssp->next;
- free(tssp);
- }
-}
-
-/* TblTTFoot() -- do body foot work (row format info)
- *
- * TO DO:
- *
- * do format info:
- * a. generate tableformat structure
- * i. if it is only 1 line long and matches the
- * prevailing format, just output rows.
- * ii. else, output a .T& and the new format specs
- */
-
-
-
-void
-TblTFoot(Element_t * ep,
- FILE * fP)
-{
- register struct tblformat * ffp, * ffp2;
- static struct tblformat * tfp, * tfp2;
-
-
- TblBuildFormat(ep, &tfp, TFoot); /* gen format for the foot */
-
- for ( tfp2=formP; tfp2 && tfp2->next; tfp2=tfp2->next )
- ;
-
- if ( tfp->next || !TblFormatMatch(tfp, tfp2) ) {
-
- for ( ffp=formP; ffp; ffp=ffp2 ) {
- ffp2 = ffp->next;
- free(ffp); /* clear entire list */
- }
-
- formP = tfp; /* this becomes the prevailing format */
-
- OutputString("^.T&^", fP, 1);
- TblPrintFormat(fP, formP);
- }
-
- tblrow = 0; /* the current row within this format */
-}
-
-/* TblBuildFormat() -- build a format structure out of a set of
- * rows and columns
- *
- */
-
-
-void
-TblBuildFormat(Element_t * ep, /* parent of rows.. */
- struct tblformat ** fp, /* pointer to head of struct we're
- * building */
- tblsource source) /* type of record */
-{
- register int i;
- register struct tblformat * lfp; /* "current" format */
- register struct tblformat * nfp; /* the next format */
-
-
- for ( lfp= *fp; lfp && lfp->next; lfp=lfp->next )
- ; /* find end of format list */
-
- for ( i=0; i < ep->necont; i++ )
- if ( !strcmp(ep->econt[i]->gi, "ROW") )
- break; /* find where rows start */
-
- for ( ; i < ep->necont; i++ ) {
-
- nfp = TblBuild1Format(ep->econt[i], FALSE, source);
- /* do one row */
-
- if ( !lfp )
- lfp = *fp = nfp; /* first one */
- else
- if ( TblFormatMatch(lfp, nfp) )
- lfp->count++; /* matches */
- else {
- lfp->count = 1; /* only 1 so far */
- lfp->next = nfp; /* new one */
- lfp = nfp;
- }
- }
-}
-
-/* TblBuild1Format() -- build one row's worth of format information
- *
- */
-
-
-
-struct tblformat *
-TblBuild1Format(Element_t * rp, /* the row to deal with */
- bool addinRowsep, /* insert rowsep into model? */
- tblsource source) /* type type of row */
-{
- register int i;
- register bool allProp;
- float totalProp;
- register struct tblformat * tfp;
- register Element_t * ep; /* entry pointer */
-
-
- Calloc(1, tfp, struct tblformat);
- tfp->cols = tblcols;
- ep = (rp->necont) ? rp->econt[0] : 0; /* first entry */
- allProp = TRUE;
- totalProp = 0;
-
- for ( i=1; i <= tblcols; i++ ) {
- tfp->colformat[i] = TblGetAlign(i, ep, source);
- strcpy(tfp->colwidth[i], TblGetWidth(i, ep, TRUE, source));
- strcpy(tfp->colpwidth[i], TblGetWidth(i, ep, FALSE, source));
- if ( allProp ) {
- allProp = tfp->colpwidth[i][0];
- totalProp += atof(tfp->colpwidth[i]);
- }
- strcpy(tfp->font[i], TblGetFont(i, ep, source));
- tfp->colsep[i] = tblgcolsep || TblGetColSep(i, ep, source);
- if ( addinRowsep )
- tfp->rowsep[i] = tblgrowsep || TblGetRowSep(i, ep, source);
- tfp->moreRows[i] = TblGetMoreRows(i, ep, source);
-
- if ( (i < rp->necont) && TblColAdv(i, ep, tfp, source) ) {
- ep = rp->econt[i];
- }
- }
-
- /* turn proportional widths into real widths */
-
- if ( allProp ) {
- for ( i=1; i <= tblcols; i++ ) {
- sprintf(tfp->colwidth[i], "%fi",
- (atof(tfp->colpwidth[i]) / totalProp) * TEXTWIDTH);
- }
- }
-
- return tfp;
-}
-
-/* TblGetAlign() -- get alignment spec for a entry
- *
- */
-
-
-char
-TblGetAlign(short col, /* column number */
- Element_t * entry, /* the entry */
- tblsource source) /* context */
-{
- register struct tblcolspec * tcsp;
- register struct tblspanspec * tssp;
- register tblalign talign;
-
-
- if ( entry && (tssp = TblEntrySpanSpec(col, entry, source)) ) {
- talign = tssp->align;
- free(tssp);
- } else
- if ( entry && (tcsp = TblEntryColSpec(col, entry, source)) ) {
- talign = tcsp->align;
- free(tcsp);
- } else {
- return 'l';
- }
-
- switch ( talign ) {
- case Left: return 'l';
- case Right: return 'r';
- case Center: return 'c';
- case Justify: return 'l';
- case Char: return 'd';
- case Span: return 's';
- }
-}
-
-/* TblGetWidth() -- get width spec, if any, for a entry
- *
- */
-
-
-char *
-TblGetWidth(short col, /* column number */
- Element_t * entry, /* the entry */
- bool literal, /* literal (or proportional) */
- tblsource source) /* context */
-{
- register struct tblcolspec * tcsp;
- register struct tblspanspec * tssp;
- static char colWidth[10];
-
-
- colWidth[0] = 0;
-
- if ( entry &&
- (tcsp = TblEntryColSpec(col, entry, source)) &&
- tcsp->colwidth[0] ) {
-
- if ( !strstr(tcsp->colwidth, "*") ) {
- if ( literal )
- strcpy(colWidth, tcsp->colwidth);
- } else {
- if ( ! literal )
- strcpy(colWidth, tcsp->colwidth);
- }
- free(tcsp);
- }
-
- return colWidth;
-}
-
-/* TblGetFont() -- get font spec, if any, for a entry
- *
- */
-
-
-char *
-TblGetFont(short col, /* column number */
- Element_t * entry, /* the entry */
- tblsource source) /* context */
-{
- register struct tblcolspec * tcsp;
- register struct tblspanspec * tssp;
-
-
- return "";
-}
-
-/* TblGetColSep() -- get column separater spec, if any, for a entry
- *
- */
-
-
-bool
-TblGetColSep(short col, /* column number */
- Element_t * entry, /* the entry */
- tblsource source) /* context */
-{
- register struct tblcolspec * tcsp;
- register struct tblspanspec * tssp;
- register bool colsep;
-
-
- if ( entry && (tssp = TblEntrySpanSpec(col, entry, source)) ) {
- colsep = tssp->colsep;
- free(tssp);
- } else
- if ( entry && (tcsp = TblEntryColSpec(col, entry, source)) ) {
- colsep = tcsp->colsep;
- free(tcsp);
- } else
- colsep = FALSE;
-
- return colsep;
-}
-
-/* TblGetRowSep() -- get row separater spec, if any, for a entry
- *
- */
-
-
-bool
-TblGetRowSep(short col, /* column number */
- Element_t * entry, /* the entry */
- tblsource source) /* context */
-{
- register struct tblcolspec * tcsp;
- register struct tblspanspec * tssp;
- register bool rowsep;
-
- if ( entry && (tssp = TblEntrySpanSpec(col, entry, source)) ) {
- rowsep = tssp->rowsep;
- free(tssp);
- } else
- if ( entry && (tcsp = TblEntryColSpec(col, entry, source)) ) {
- rowsep = tcsp->rowsep;
- free(tcsp);
- } else {
- rowsep = FALSE;
- }
-
- return rowsep;
-}
-
-/* TblGetmoreRows() -- get moreRows value
- *
- */
-
-
-bool
-TblGetMoreRows(short col, /* column number */
- Element_t * entry, /* the entry */
- tblsource source) /* context */
-{
- register char * cp;
-
-
- if ( cp = FindAttValByName(entry, "MOREROWS") )
- return atoi(cp);
- else
- return 0;
-}
-
-/* TblColAdv() -- advance pointer to next entry, if appropriate
- *
- */
-
-
-bool
-TblColAdv(short col, /* the current column */
- Element_t *ep, /* pointer to entry */
- struct tblformat * tfp, /* pointer to prevailing format */
- tblsource source) /* context */
-{
- register bool bump;
- register struct tblspanspec * tssp;
-
-
- bump = TRUE;
-
- if ( tssp = TblEntrySpanSpec(col, ep, source) ) {
- bump = tssp->align != Span;
- free(tssp);
- }
-
- return bump;
-}
-
-/* TblEntryColSpec() -- get a completely localized colspec for an entry
- *
- */
-
-
-struct tblcolspec *
-TblEntryColSpec(short num, /* column number */
- Element_t * ep, /* entry */
- tblsource source) /* context */
-{
- register int i;
- register bool throwAway;
- register char * cp;
- register struct tblcolspec * tcsp, * tcsp2;
-
-
- tcsp = tcsp2 = 0;
- throwAway = FALSE;
-
- if ( (cp = FindAttValByName(ep, "COLNAME")) ) {
- if ( ! (tcsp = TblFindColSpec(cp, source)) ) {
- fprintf(stderr, "? can't find column name '%s'\n", cp);
- }
- }
-
- if ( tcsp2 = TblFindColNum(num, source) ) {
- tcsp = TblDoColSpec(num, ep, tcsp2, source);
- throwAway = TRUE;
- }
-
- tcsp2 = TblDoColSpec(num, ep, tcsp, source);
-
- if ( throwAway )
- free(tcsp);
-
- return tcsp2;
-}
-
-/* TblEntrySpanSpec() -- get a completely localized spanspec for an entry
- *
- */
-
-
-struct tblspanspec *
-TblEntrySpanSpec(short num, /* column number */
- Element_t * ep, /* entry */
- tblsource source) /* context */
-{
- register char * cp, * cp2;
- register struct tblspanspec * tssp, * tssp2;
-
-
- tssp2 = 0;
-
- if ( !(cp = FindAttValByName(ep, "SPANNAME")) ||
- !(tssp2 = TblFindSpanSpec(cp, source)) ) {
-
- if ( !FindAttValByName(ep, "NAMEST") )
- return 0;
- }
-
- tssp = TblDoSpanSpec(ep, tssp2, source);
-
- if ( tssp->start && tssp->end &&
- (tssp->start->num < num) && (tssp->end->num >= num) ) {
- tssp->align = Span;
- }
-
- return tssp;
-}
-
-/* TblFormatMatch() -- compare two format rows for consistency
- *
- */
-
-
-bool
-TblFormatMatch(struct tblformat * tf1, /* one row */
- struct tblformat * tf2) /* the other */
-{
- register int i;
-
- if ( tf1->cols != tf2->cols ) {
- return FALSE;
- }
-
- for ( i=0; i < tf1->cols; i++ ) {
-
- if ( tf1->colformat[i] != tf2->colformat[i] ) {
- return FALSE;
- }
- if ( strcmp(tf1->colwidth[i], tf2->colwidth[i]) ) {
- return FALSE;
- }
- if ( strcmp(tf1->font[i], tf2->font[i]) ) {
- return FALSE;
- }
- if ( tf1->colsep[i] != tf2->colsep[i] ) {
- return FALSE;
- }
- if ( tf1->rowsep[i] != tf2->rowsep[i] ) {
- return FALSE;
- }
- if ( tf1->moreRows[i] || tf2->moreRows[i] ) {
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-/* TblPrintFormat() -- print a tbl format structure
- *
- */
-
-
-void
-TblPrintFormat(FILE * fP, /* where to print */
- struct tblformat * tfp) /* the structure */
-{
- register int i;
- register struct tblformat * tfp2, * tfp3;
- static char buf[3] = "\000\000";
-
-
- for ( tfp2=tfp, tfp3=0; tfp2; tfp2=tfp2->next ) {
- for ( i=1; i <= tfp->cols; i++ ) {
- if ( i > 1 )
- OutputString(" ", fP, 1);
- if ( tfp3 && tfp3->moreRows[i] )
- OutputString("\\^", fP, 1);
- else {
- buf[0] = tfp2->colformat[i];
- OutputString(buf, fP, 1);
- }
- if ( tfp2->colwidth[i][0] ) {
- OutputString("w(", fP, 1);
- OutputString(tfp2->colwidth[i], fP, 1);
- OutputString(")", fP, 1);
- }
- if ( tfp2->font[i][0] )
- OutputString(tfp2->font[i], fP, 1);
- if ( tfp2->colsep[i] )
- OutputString("|", fP, 1);
- }
- if ( ! tfp2->next )
- OutputString(".", fP, 1);
- OutputString("^", fP, 1);
- tfp3 = tfp2;
- }
-}
-
-/* TblTRowStart() -- start a row (not much to do)
- *
- * TO DO:
- *
- * nothing..
- *
- */
-
-
-
-void
-TblTRowStart(Element_t * ep,
- FILE * fP)
-{
-
- /* nothing to do */
-
- tblrow++; /* except note that we're within a new row */
-
-}
-
-/* TblTRowEnd() -- end a row
- *
- * TO DO:
- *
- * output a row end character (newline)
- * if the current row had a rowsep, then output a "fake" row
- * with underlines in the proper place(s).
- */
-
-
-
-void
-TblTRowEnd(Element_t * ep,
- FILE * fP)
-{
- register int i, k;
- register tblsource source;
- register bool startedRow, didSep;
- register struct tblformat * rfp;
-
-
- OutputString("^", fP, 1);
-
- /* get the format for this row */
-
- if ( !strcmp(ep->parent->gi, "TFoot") )
- source = TFoot;
- else
- if ( !strcmp(ep->parent->gi, "THead") )
- source = THead;
- else
- source = TBody;
-
- rfp = TblBuild1Format(ep, TRUE, source);
- startedRow = FALSE;
- didSep = FALSE;
-
- for ( i=1; i <= formP->cols; i++ ) {
- if ( rfp->rowsep[i] ||
- (didSep && (rfp->colformat[i] == 's')) ) {
- if ( ! startedRow ) {
- OutputString("^", fP, 1);
- for ( k=1; k < i; k++ )
- OutputString("\007", fP, 1);
- startedRow = TRUE;
- }
- OutputString("_\007", fP, 1);
- didSep = TRUE;
- } else {
- if ( startedRow )
- OutputString("\007", fP, 1);
- }
- didSep = FALSE;
- }
- free(rfp); /* clear that row.. */
-
- if ( startedRow )
- OutputString("^", fP, 1);
-}
-
-/* TblTEntryStart() -- start an entry (block of filled text if
- * appropriate)
- *
- * TO DO:
- *
- * if text length > BOFTTextThresh or there is PI,
- * then output "T{\n", else do nothing
- *
- */
-
-
-
-void
-TblTCellStart(Element_t * ep,
- FILE * fP)
-{
- register int i;
- register Element_t * ep2;
- register bool sawPI;
-
-
- for ( i=0, sawPI=FALSE; (i < ep->ncont) && !sawPI; i++ )
- if ( ep->cont[i].type == '?' )
- sawPI = TRUE;
-
- if ( sawPI || (TblCountContent(ep) > BOFTTextThresh) ) {
- tblBOFTCount++;
- OutputString("T{^", fP, 1);
- tblinBOFT = TRUE; /* within a boft now */
- }
-}
-
-/* TblCountContent() -- count all content below the given element
- *
- *
- */
-
-
-
-int
-TblCountContent(Element_t * ep) /* the element to look under */
-{
- register int i, count;
-
-
- count = 0;
-
- for ( i=0; i < ep->ncont; i++ ) {
- if ( ep->cont[i].type == '-' ) {
- count += strlen(ep->cont[i].ch.data);
- } else
- if ( ep->cont[i].type == '(' ) {
- count += TblCountContent(ep->cont[i].ch.elem);
- }
- }
-
- return count;
-}
-
-/* TblTEntryEnd() -- end an entry
- *
- * TO DO:
- *
- * if within BOFT, output "T}"
- * if not last entry, output tab character
- *
- */
-
-
-
-void
-TblTCellEnd(Element_t * ep,
- FILE * fP)
-{
- register Element_t * ep2;
-
-
- if ( tblinBOFT ) {
- OutputString("^T}", fP, 1);
- tblinBOFT = FALSE; /* back out again */
- }
-
- for ( ep2=ep->next; ep2; ep2=ep2->next ) {
- if ( !strcmp(ep2->gi, "ENTRY") || !strcmp(ep2->gi, "ENTRYTBL") ) {
- OutputString("\007", fP, 1);
- break;
- }
- if ( !strcmp(ep2->gi, "ROW") )
- break;
- }
-}
-
-/* TblDoColSpec() -- process one element to create a new colspec
- *
- *
- */
-
-
-
-struct tblcolspec *
-TblDoColSpec(short number, /* this column number */
- Element_t * ep, /* element containing colspec stuff */
- struct tblcolspec * pcsp, /* prevailing colspec (with defaults) */
- tblsource source) /* precedence level of the resulting spec */
-{
- register char * cp;
- register struct tblcolspec * tcsp;
-
-
- Calloc(1, tcsp, struct tblcolspec);
-
- if ( cp = FindAttValByName(ep, "COLNAME") )
- strcpy(tcsp->name, cp);
-
- tcsp->num = number;
- tcsp->source = source;
-
- if ( cp = FindAttValByName(ep, "ALIGN") ) {
- if ( !strcmp(cp, "LEFT") ) tcsp->align = Left;
- else if ( !strcmp(cp, "RIGHT") ) tcsp->align = Right;
- else if ( !strcmp(cp, "CENTER") ) tcsp->align = Center;
- else if ( !strcmp(cp, "JUSTIFY") ) tcsp->align = Justify;
- else if ( !strcmp(cp, "CHAR") ) tcsp->align = Char;
- } else
- tcsp->align = ( pcsp ) ? pcsp->align : Left;
-
- if ( cp = FindAttValByName(ep, "CHAR") )
- tcsp->alignchar = cp[0];
- else
- tcsp->alignchar = ( pcsp ) ? pcsp->alignchar : 0;
-
- if ( cp = FindAttValByName(ep, "CHAROFF") )
- tcsp->aligncharoff = atoi(cp);
- else
- tcsp->aligncharoff = ( pcsp ) ? pcsp->aligncharoff : 0;
-
- if ( cp = FindAttValByName(ep, "COLWIDTH") )
- strcpy(tcsp->colwidth, cp);
- else
- strcpy(tcsp->colwidth, ( pcsp ) ? pcsp->colwidth : "");
-
- if ( cp = FindAttValByName(ep, "COLSEP") )
- tcsp->colsep = !strcmp(cp, "1");
- else
- tcsp->colsep = ( pcsp ) ? pcsp->colsep : FALSE;
-
- if ( cp = FindAttValByName(ep, "ROWSEP") )
- tcsp->rowsep = !strcmp(cp, "1");
- else
- tcsp->rowsep = ( pcsp ) ? pcsp->rowsep : FALSE;
-
- return tcsp;
-}
-
-/* TblDoSpanSpec() -- process one element to create a new spanspec
- *
- * Note that there's a hack inside here... NameSt and NameEnd are
- * supposed to point at colnames, but if no colname is found, this
- * code will look for a colnum by the same value.
- */
-
-
-
-struct tblspanspec *
-TblDoSpanSpec(Element_t * ep, /* element containing spanspec stuff */
- struct tblspanspec * pssp, /* prevailing spanspec (with defaults) */
- tblsource source) /* precedence level of the resulting spec */
-{
- register char * cp;
- register struct tblspanspec * tssp;
- register struct tblcolspec * tcsp;
-
-
- Calloc(1, tssp, struct tblspanspec);
-
- if ( cp = FindAttValByName(ep, "SPANNAME") ) strcpy(tssp->name, cp);
- tssp->source = source;
-
- if ( cp = FindAttValByName(ep, "NAMEST") ) {
- if ( (tcsp = TblFindColSpec(cp, source)) ||
- (tcsp = TblFindColNum(atoi(cp), source)) ) {
- tssp->start = tcsp;
- } else {
- fprintf(stderr, "? spanspec namest points to unknown column '%s'\n", cp);
- tssp->start = 0;
- }
- } else {
- if ( pssp && pssp->start ) {
- tssp->start = pssp->start;
- }
- }
-
- if ( cp = FindAttValByName(ep, "NAMEEND") ) {
- if ( (tcsp = TblFindColSpec(cp, source)) ||
- (tcsp = TblFindColNum(atoi(cp), source)) ) {
- tssp->end = tcsp;
- } else {
- fprintf(stderr, "? spanspec nameend points to unknown column '%s'\n", cp);
- tssp->end = 0;
- }
- } else {
- if ( pssp && pssp->end ) {
- tssp->end = pssp->end;
- }
- }
-
- if ( cp = FindAttValByName(ep, "ALIGN") ) {
- if ( !strcmp(cp, "LEFT") ) tssp->align = Left;
- else if ( !strcmp(cp, "RIGHT") ) tssp->align = Right;
- else if ( !strcmp(cp, "CENTER") ) tssp->align = Center;
- else if ( !strcmp(cp, "JUSTIFY") ) tssp->align = Justify;
- else if ( !strcmp(cp, "CHAR") ) tssp->align = Char;
- } else {
- if ( pssp )
- tssp->align = pssp->align;
- }
-
- if ( cp = FindAttValByName(ep, "CHAR") )
- tssp->alignchar = cp[0];
- else {
- if ( pssp )
- tssp->alignchar = pssp->alignchar;
- }
- if ( cp = FindAttValByName(ep, "CHAROFF") )
- tssp->aligncharoff = atoi(cp);
- else {
- if ( pssp )
- tssp->alignchar = pssp->alignchar;
- }
-
- if ( cp = FindAttValByName(ep, "COLSEP") )
- tssp->colsep = !strcmp(cp, "1");
- else {
- if ( pssp )
- tssp->colsep = pssp->colsep;
- }
- if ( cp = FindAttValByName(ep, "ROWSEP") )
- tssp->rowsep = !strcmp(cp, "1");
- else {
- if ( pssp )
- tssp->rowsep = pssp->rowsep;
- }
-
- return tssp;
-}
-
-/* TblFindColSpec() -- find a table colspec by name (colname)
- *
- */
-
-
-
-struct tblcolspec *
-TblFindColSpec(char * name, /* the name we're looking for */
- tblsource source) /* the context in which to find it */
-{
- register struct tblcolspec * tcsp;
-
-
- /* first, try to find the one in the right "source" */
-
- for ( tcsp=tblColSpec; tcsp; tcsp=tcsp->next ) {
- if ( (tcsp->source == source) && !strcmp(tcsp->name, name) )
- return tcsp;
- }
-
- /* else, try to find one from a TGroup.. */
-
- for ( tcsp=tblColSpec; tcsp; tcsp=tcsp->next ) {
- if ( (tcsp->source == TGroup) && !strcmp(tcsp->name, name) )
- return tcsp;
- }
-
- /* else not found.. */
-
- return 0;
-}
-
-/* TblFindColNum() -- find a table colspec by number
- *
- */
-
-
-
-struct tblcolspec *
-TblFindColNum(short number, /* the number we're looking for */
- tblsource source) /* the context in which to find it */
-{
- register struct tblcolspec * tcsp;
-
-
-
- /* first, try to find the one in the right "source" */
-
- for ( tcsp=tblColSpec; tcsp; tcsp=tcsp->next ) {
- if ( (tcsp->num == number) &&
- ((tcsp->source == source) ||
- ((source == THead) && (tcsp->source == TGroup))) )
- return tcsp;
- }
-
- /* else, try to find one from a TGroup.. */
-
- for ( tcsp=tblColSpec; tcsp; tcsp=tcsp->next ) {
- if ( (tcsp->source == TGroup) && (tcsp->num == number) )
- return tcsp;
- }
-
- /* else not found.. */
-
- return 0;
-}
-
-/* TblFindSpanSpec() -- find a table spanspec by name (spanname)
- *
- */
-
-
-
-struct tblspanspec *
-TblFindSpanSpec(char * name, /* the name we're looking for */
- tblsource source) /* the context in which to find it */
-{
- register struct tblspanspec * tssp;
-
-
- /* first, try to find the one in the right "source" */
-
- for ( tssp=tblSpanSpec; tssp; tssp=tssp->next ) {
- if ( !strcmp(tssp->name, name) &&
- ((tssp->source == source) ||
- ((source == THead) && (tssp->source == TGroup))) )
- return tssp;
- }
-
- /* else not found.. */
-
- return 0;
-}
diff --git a/usr.bin/sgmls/instant/traninit.c b/usr.bin/sgmls/instant/traninit.c
deleted file mode 100644
index d3df959..0000000
--- a/usr.bin/sgmls/instant/traninit.c
+++ /dev/null
@@ -1,577 +0,0 @@
-/*
- * Copyright 1993 Open Software Foundation, Inc., Cambridge, Massachusetts.
- * All rights reserved.
- */
-/*
- * Copyright (c) 1994
- * Open Software Foundation, Inc.
- *
- * Permission is hereby granted to use, copy, modify and freely distribute
- * the software in this file and its documentation for any purpose without
- * fee, provided that the above copyright notice appears in all copies and
- * that both the copyright notice and this permission notice appear in
- * supporting documentation. Further, provided that the name of Open
- * Software Foundation, Inc. ("OSF") not be used in advertising or
- * publicity pertaining to distribution of the software without prior
- * written permission from OSF. OSF makes no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- */
-/*
- * Copyright (c) 1996 X Consortium
- * Copyright (c) 1995, 1996 Dalrymple Consulting
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * X CONSORTIUM OR DALRYMPLE CONSULTING BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the names of the X Consortium and
- * Dalrymple Consulting shall not be used in advertising or otherwise to
- * promote the sale, use or other dealings in this Software without prior
- * written authorization.
- */
-/* ________________________________________________________________________
- *
- * Program to manipulate SGML instances.
- *
- * This module contains the initialization routines for translation module.
- * They mostly deal with reading data files (translation specs, SDATA
- * mappings, character mappings).
- *
- * Entry points:
- * ReadTransSpec(transfile) read/store translation spec from file
- * ________________________________________________________________________
- */
-
-#ifndef lint
-static char *RCSid =
- "$Header: /usr/local/home/jfieber/src/cvsroot/nsgmlfmt/traninit.c,v 1.1.1.1 1996/01/16 05:14:10 jfieber Exp $";
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <string.h>
-#include <memory.h>
-#include <sys/types.h>
-#include <errno.h>
-#include <regexp.h>
-
-#include "general.h"
-#include "translate.h"
-
-#include "sgmls.h"
-#include "config.h"
-#include "std.h"
-
-#ifndef TRUE
-#define TRUE (1 == 1)
-#endif
-
-#define MAX(a, b) ((a) > (b) ? (a) : (b))
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
-
-/* forward references */
-void RememberTransSpec(Trans_t *, int);
-static void do_data(char *gi, struct sgmls_data *v, int n);
-static void build_ts(char *gi, char* cp);
-void AddCharMap(const char *from, const char* to);
-void AddSDATA(const char *from, const char *to);
-
-/* ______________________________________________________________________ */
-/* Read the translation specs from the input file, storing in memory.
- * Arguments:
- * Name of translation spec file.
- */
-
-static Trans_t T;
-
-
-static
-void input_error(num, str, lineno)
- int num;
- char *str;
- unsigned long lineno;
-{
- fprintf(stderr, "Error at input line %lu: %s\n", lineno, str);
-}
-
-void
-ReadTransSpec(
- char *transfile
-)
-{
- FILE *fp;
- struct sgmls *sp;
- struct sgmls_event e;
- char gi[LINESIZE];
- char buf[LINESIZE];
- char buf2[LINESIZE];
- char *command;
- char *sgmls = "sgmls ";
- char maptype = '\0';
-
- (void)sgmls_set_errhandler(input_error);
- transfile = FilePath(transfile);
- if (!transfile)
- {
- fprintf(stderr, "Error: Could not locate specified transfile\n");
- exit(1);
- }
-
- /* XXX this is a quick, gross hack. Should write a parse() function. */
- Malloc(strlen(sgmls) + strlen(transfile) + 2, command, char);
- sprintf(command, "%s %s", sgmls, transfile);
- fp = popen(command, "r");
-
- sp = sgmls_create(fp);
- while (sgmls_next(sp, &e))
- switch (e.type) {
- case SGMLS_EVENT_DATA:
- do_data(gi, e.u.data.v, e.u.data.n);
- break;
- case SGMLS_EVENT_ENTITY:
- fprintf(stderr, "Hm... got an entity\n");
- break;
- case SGMLS_EVENT_PI:
- break;
- case SGMLS_EVENT_START:
- if (strncmp("RULE", e.u.start.gi, 4) == 0) {
- /* A new transpec, so clear the data structure
- * and look for an ID attribute.
- */
- struct sgmls_attribute *attr = e.u.start.attributes;
- memset(&T, 0, sizeof T);
- while (attr) {
- if (attr->type == SGMLS_ATTR_CDATA
- && strncmp("ID", attr->name, 2) == 0) {
- strncpy(buf, attr->value.data.v->s,
- MIN(attr->value.data.v->len, LINESIZE));
- buf[MIN(attr->value.data.v->len, LINESIZE - 1)] = '\0';
- T.my_id = atoi(buf);
- }
- attr = attr->next;
- }
- }
- else if (strncmp("CMAP", e.u.start.gi, 4) == 0)
- maptype = 'c';
- else if (strncmp("SMAP", e.u.start.gi, 4) == 0)
- maptype = 's';
- else if (strncmp("MAP", e.u.start.gi, 3) == 0) {
- struct sgmls_attribute *attr = e.u.start.attributes;
- char *from = 0;
- char *to = 0;
-
- while (attr) {
- if (attr->value.data.v && strncmp("FROM", attr->name, 4) == 0) {
- strncpy(buf, attr->value.data.v->s,
- MIN(attr->value.data.v->len, LINESIZE - 1));
- buf[MIN(attr->value.data.v->len, LINESIZE - 1)] = '\0';
- }
- if (attr->value.data.v && strncmp("TO", attr->name, 2) == 0) {
- strncpy(buf2, attr->value.data.v->s,
- MIN(attr->value.data.v->len, LINESIZE - 1));
- buf2[MIN(attr->value.data.v->len, LINESIZE - 1)] = '\0';
- }
- attr = attr->next;
- }
- if (maptype == 'c')
- AddCharMap(buf, buf2);
- else if (maptype == 's')
- AddSDATA(buf, buf2);
- else
- fprintf(stderr, "Unknown map type!\n");
- }
- else {
- strncpy(gi, e.u.start.gi, 512);
- sgmls_free_attributes(e.u.start.attributes);
- }
- break;
- case SGMLS_EVENT_END:
- if (strncmp("RULE", e.u.start.gi, 4) == 0)
- RememberTransSpec(&T, e.lineno);
- break;
- case SGMLS_EVENT_SUBSTART:
- break;
- case SGMLS_EVENT_SUBEND:
- break;
- case SGMLS_EVENT_APPINFO:
- break;
- case SGMLS_EVENT_CONFORMING:
- break;
- default:
- abort();
- }
- sgmls_free(sp);
- pclose(fp);
- free(command);
-}
-
-
-static void do_data(char *gi, struct sgmls_data *v, int n)
-{
- int i;
- char *cp;
- static char *buf = 0;
- static int buf_size = 0;
- int buf_pos = 0;
-
-
- /* figure out how much space this element will really
- take, inculding expanded sdata entities. */
-
- if (!buf)
- {
- buf_size = 1024;
- Malloc(buf_size, buf, char);
- }
-
- for (i = 0; i < n; i++)
- {
- char *s;
- int len;
-
- /* Mark the current position. If this is SDATA
- we will have to return here. */
- int tmp_buf_pos = buf_pos;
-
- /* Make sure the buffer is big enough. */
- if (buf_size - buf_pos <= v[i].len)
- {
- buf_size += v[i].len * (n - i);
- Realloc(buf_size, buf, char);
- }
-
- s = v[i].s;
- len = v[i].len;
- for (; len > 0; len--, s++)
- {
- if (*s != RSCHAR) {
- if (*s == RECHAR)
- buf[buf_pos] = '\n';
- else
- buf[buf_pos] = *s;
- buf_pos++;
- }
- }
- if (v[i].is_sdata)
- {
- char *p;
- buf[buf_pos] = '\0';
- p = LookupSDATA(buf + tmp_buf_pos);
- if (p)
- {
- if (buf_size - tmp_buf_pos <= strlen(p))
- {
- buf_size += strlen(p) * (n - i);
- Realloc(buf_size, buf, char);
- }
- strcpy(buf + tmp_buf_pos, p);
- buf_pos = tmp_buf_pos + strlen(p);
- }
- }
- }
-
- /* Clean up the trailing end of the data. */
- buf[buf_pos] = '\0';
- buf_pos--;
- while (buf_pos > 0 && isspace(buf[buf_pos]) && buf[buf_pos] != '\n')
- buf_pos--;
- if (buf[buf_pos] == '\n')
- buf[buf_pos] = '\0';
-
- /* Skip over whitespace at the beginning of the data. */
- cp = buf;
- while (*cp && isspace(*cp))
- cp++;
- build_ts(gi, cp);
-}
-
-/* ______________________________________________________________________ */
-/* Set a transpec parameter
- * Arguments:
- * gi - the parameter to set
- * cp - the value of the parameter
- */
-static void build_ts(char *gi, char* cp)
-{
- if (strcmp("GI", gi) == 0)
- {
- char *cp2;
- /* if we are folding the case of GIs, make all upper (unless
- it's an internal pseudo-GI name, which starts with '_') */
- if (fold_case && cp[0] != '_' && cp[0] != '#')
- {
- for (cp2=cp; *cp2; cp2++)
- if (islower(*cp2)) *cp2 = toupper(*cp2);
- }
- T.gi = AddElemName(cp);
- }
- else if (strcmp("START", gi) == 0)
- T.starttext = strdup(cp);
- else if (strcmp("END", gi) == 0)
- T.endtext = strdup(cp);
- else if (strcmp("RELATION", gi) == 0)
- {
- if (!T.relations)
- T.relations = NewMap(IMS_relations);
- SetMapping(T.relations, cp);
- }
- else if (strcmp("REPLACE", gi) == 0)
- T.replace = strdup(cp);
- else if (strcmp("ATTVAL", gi) == 0)
- {
- if (!T.nattpairs)
- {
- Malloc(1, T.attpair, AttPair_t);
- }
- else
- Realloc((T.nattpairs+1), T.attpair, AttPair_t);
- /* we'll split name/value pairs later */
- T.attpair[T.nattpairs].name = strdup(cp);
- T.nattpairs++;
- }
- else if (strcmp("CONTEXT", gi) == 0)
- T.context = strdup(cp);
- else if (strcmp("MESSAGE", gi) == 0)
- T.message = strdup(cp);
- else if (strcmp("DO", gi) == 0)
- T.use_id = atoi(cp);
- else if (strcmp("CONTENT", gi) == 0)
- T.content = strdup(cp);
- else if (strcmp("PATTSET", gi) == 0)
- T.pattrset = strdup(cp);
- else if (strcmp("VERBATIM", gi) == 0)
- T.verbatim = TRUE;
- else if (strcmp("IGNORE", gi) == 0)
- {
- if (!strcmp(cp, "all"))
- T.ignore = IGN_ALL;
- else if (!strcmp(cp, "data"))
- T.ignore = IGN_DATA;
- else if (!strcmp(cp, "children"))
- T.ignore = IGN_CHILDREN;
- else
- fprintf(stderr, "Bad 'Ignore:' arg in transpec %s: %s\n",
- gi, cp);
- }
- else if (strcmp("VARVAL", gi) == 0)
- {
- char **tok;
- int i = 2;
- tok = Split(cp, &i, S_STRDUP);
- T.var_name = tok[0];
- T.var_value = tok[1];
- }
- else if (strcmp("VARREVAL", gi) == 0)
- {
- char buf[1000];
- char **tok;
- int i = 2;
- tok = Split(cp, &i, S_STRDUP);
- T.var_RE_name = tok[0];
- ExpandVariables(tok[1], buf, 0);
- if (!(T.var_RE_value=regcomp(buf))) {
- fprintf(stderr, "Regex error in VarREValue Content: %s\n",
- tok[1]);
- }
- }
- else if (strcmp("SET", gi) == 0)
- {
- if (!T.set_var)
- T.set_var = NewMap(IMS_setvar);
- SetMapping(T.set_var, cp);
- }
- else if (strcmp("INCR", gi) == 0)
- {
- if (!T.incr_var)
- T.incr_var = NewMap(IMS_incvar);
- SetMapping(T.incr_var, cp);
- }
- else if (strcmp("NTHCHILD", gi) == 0)
- T.nth_child = atoi(cp);
- else if (strcmp("VAR", gi) == 0)
- SetMapping(Variables, cp);
- else if (strcmp("QUIT", gi) == 0)
- T.quit = strdup(cp);
- else
- fprintf(stderr, "Unknown translation spec (skipping it): %s\n", gi);
-
-}
-
-
-/* ______________________________________________________________________ */
-/* Store translation spec 't' in memory.
- * Arguments:
- * Pointer to translation spec to remember.
- * Line number where translation spec ends.
- */
-void
-RememberTransSpec(
- Trans_t *t,
- int lineno
-)
-{
- char *cp;
- int i, do_regex;
- static Trans_t *last_t;
- char buf[1000];
-
- /* If context testing, check some details and set things up for later. */
- if (t->context) {
- /* See if the context specified is a regular expression.
- * If so, compile the reg expr. It is assumed to be a regex if
- * it contains a character other than what's allowed for GIs in the
- * OSF sgml declaration (alphas, nums, '-', and '.').
- */
- for (do_regex=0,cp=t->context; *cp; cp++) {
- if (!isalnum(*cp) && *cp != '-' && *cp != '.' && *cp != ' ') {
- do_regex = 1;
- break;
- }
- }
-
- if (do_regex) {
- t->depth = MAX_DEPTH;
- if (!(t->context_re=regcomp(t->context))) {
- fprintf(stderr, "Regex error in Context: %s\n", t->context);
- }
- }
- else {
- /* If there's only one item in context, it's the parent. Treat
- * it specially, since it's faster to just check parent gi.
- */
- cp = t->context;
- if (!strchr(cp, ' ')) {
- t->parent = t->context;
- t->context = NULL;
- }
- else {
- /* Figure out depth of context string */
- t->depth = 0;
- while (*cp) {
- if (*cp) t->depth++;
- while (*cp && !IsWhite(*cp)) cp++; /* find end of gi */
- while (*cp && IsWhite(*cp)) cp++; /* skip space */
- }
- }
- }
- }
-
- /* Compile regular expressions for each attribute */
- for (i=0; i<t->nattpairs; i++) {
- /* Initially, name points to "name value". Split them... */
- cp = t->attpair[i].name;
- while (*cp && !IsWhite(*cp)) cp++; /* point past end of name */
- if (*cp) { /* value found */
- *cp++ = EOS; /* terminate name */
- while (*cp && IsWhite(*cp)) cp++; /* point to value */
- ExpandVariables(cp, buf, 0); /* expand any variables */
- t->attpair[i].val = strdup(buf);
- }
- else { /* value not found */
- t->attpair[i].val = ".";
- }
- if (!(t->attpair[i].rex=regcomp(t->attpair[i].val))) {
- fprintf(stderr, "Regex error in AttValue: %s %s\n",
- t->attpair[i].name, t->attpair[i].val);
- }
- }
-
- /* Compile regular expression for content */
- t->content_re = 0;
- if (t->content) {
- ExpandVariables(t->content, buf, 0);
- if (!(t->content_re=regcomp(buf)))
- fprintf(stderr, "Regex error in Content: %s\n",
- t->content);
- }
-
- /* If multiple GIs, break up into a vector, then remember it. We either
- * sture the individual, or the list - not both. */
- if (t->gi && strchr(t->gi, ' ')) {
- t->gilist = Split(t->gi, 0, S_ALVEC);
- t->gi = NULL;
- }
-
- /* Now, store structure in linked list. */
- if (!TrSpecs) {
- Malloc(1, TrSpecs, Trans_t);
- last_t = TrSpecs;
- }
- else {
- Malloc(1, last_t->next, Trans_t);
- last_t = last_t->next;
- }
- *last_t = *t;
-}
-
-
-/* ______________________________________________________________________ */
-/* Add an entry to the character mapping table, allocating or
- * expanding the table if necessary.
- * Arguments:
- * Character to map
- * String to map the character to
- * A 'c' or an 's' for character or sdata map
- */
-
-void
-AddCharMap(
- const char *from,
- const char* to
-)
-{
- static int n_alloc = 0;
-
- if (from && to) {
- if (nCharMap >= n_alloc) {
- n_alloc += 32;
- if (!CharMap) {
- Malloc(n_alloc, CharMap, Mapping_t);
- }
- else {
- Realloc(n_alloc, CharMap, Mapping_t);
- }
- }
- CharMap[nCharMap].name = strdup(from);
- CharMap[nCharMap].sval = strdup(to);
- nCharMap++;
- }
-}
-
-/* ______________________________________________________________________ */
-/* Add an entry to the SDATA mapping table.
- * Arguments:
- * String to map
- * String to map to
- */
-
-void
-AddSDATA(
- const char *from,
- const char *to
-)
-{
- if (from && to) {
- if (!SDATAmap)
- SDATAmap = NewMap(IMS_sdata);
- SetMappingNV(SDATAmap, from, to);
- }
-}
-
-/* ______________________________________________________________________ */
diff --git a/usr.bin/sgmls/instant/translate.c b/usr.bin/sgmls/instant/translate.c
deleted file mode 100644
index cc96b25..0000000
--- a/usr.bin/sgmls/instant/translate.c
+++ /dev/null
@@ -1,881 +0,0 @@
-/*
- * Copyright 1993 Open Software Foundation, Inc., Cambridge, Massachusetts.
- * All rights reserved.
- */
-/*
- * Copyright (c) 1994
- * Open Software Foundation, Inc.
- *
- * Permission is hereby granted to use, copy, modify and freely distribute
- * the software in this file and its documentation for any purpose without
- * fee, provided that the above copyright notice appears in all copies and
- * that both the copyright notice and this permission notice appear in
- * supporting documentation. Further, provided that the name of Open
- * Software Foundation, Inc. ("OSF") not be used in advertising or
- * publicity pertaining to distribution of the software without prior
- * written permission from OSF. OSF makes no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- */
-/*
- * Copyright (c) 1996 X Consortium
- * Copyright (c) 1995, 1996 Dalrymple Consulting
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * X CONSORTIUM OR DALRYMPLE CONSULTING BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the names of the X Consortium and
- * Dalrymple Consulting shall not be used in advertising or otherwise to
- * promote the sale, use or other dealings in this Software without prior
- * written authorization.
- */
-/* ________________________________________________________________________
- *
- * Program to manipulate SGML instances.
- *
- * This module is for "translating" an instance to another form, usually
- * suitable for a formatting application.
- *
- * Entry points for this module:
- * DoTranslate(elem, fp)
- * ExpandVariables(in, out, e)
- * ________________________________________________________________________
- */
-
-#ifndef lint
-static char *RCSid =
- "$Header: /usr/src/docbook-to-man/Instant/RCS/translate.c,v 1.11 1996/06/15 22:49:00 fld Exp $";
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <string.h>
-#include <memory.h>
-#include <sys/types.h>
-#include <errno.h>
-#include <regexp.h>
-
-#include "general.h"
-#define STORAGE
-#include "translate.h"
-
-static Trans_t NullTrans; /* an empty one */
-
-/* forward references */
-void ProcesOutputSpec(char *, Element_t *, FILE *, int);
-static void WasProcessed(Element_t *);
-
-/* ______________________________________________________________________ */
-/* Translate the subtree starting at 'e'. Output goes to 'fp'.
- * This is the entry point for translating an instance.
- * Arguments:
- * Pointer to element under consideration.
- * FILE pointer to where to write output.
- */
-
-void
-DoTranslate(
- Element_t *e,
- FILE *fp
-)
-{
- Trans_t *t, *tn;
-
- /* Find transpec for each node. */
- DescendTree(e, PrepTranspecs, 0, 0, 0);
-
- /* Stuff to do at start of processing */
- if ((t = FindTransByName("_Start"))) {
- if (t->starttext) ProcesOutputSpec(t->starttext, 0, fp, 1);
- if (t->replace) ProcesOutputSpec(t->replace, 0, fp, 1);
- if (t->message) ProcesOutputSpec(t->message, 0, stderr, 0);
- if (t->endtext) ProcesOutputSpec(t->endtext, 0, fp, 1);
- }
-
- /* Translate topmost/first element. This is recursive. */
- TransElement(e, fp, NULL);
-
- /* Stuff to do at end of processing */
- if ((t = FindTransByName("_End"))) {
- if (t->starttext) ProcesOutputSpec(t->starttext, 0, fp, 1);
- if (t->replace) ProcesOutputSpec(t->replace, 0, fp, 1);
- if (t->message) ProcesOutputSpec(t->message, 0, stderr, 0);
- if (t->endtext) ProcesOutputSpec(t->endtext, 0, fp, 1);
- }
-
- /* Warn about unprocessed elements in this doc tree, if verbose mode. */
- if (verbose)
- DescendTree(e, WasProcessed, 0, 0, 0);
-
- /* Clean up. This is not yet complete, which is no big deal (since the
- * program is normally done at this point anyway. */
- for (t=TrSpecs; t; ) {
- tn = t->next;
- /* free the contents of t here ... */
- (void)free((void* )t);
- t = tn;
- }
- TrSpecs = 0;
-}
-
-/* ______________________________________________________________________ */
-/* Print warning about unprocessed elements in this doc tree (if they
- * were not explicitely ignored).
- * Arguments:
- * Pointer to element under consideration.
- */
-static void
-WasProcessed(
- Element_t *e
-)
-{
- Trans_t *t;
- t = e->trans;
- if (!e->processed && (t && !t->ignore)) {
- fprintf(stderr, "Warning: element '%s' was not processed:\n", e->gi);
- PrintLocation(e, stderr);
- }
-}
-
-/* ______________________________________________________________________ */
-/* For each element find transpec.
- * Arguments:
- * Pointer to element under consideration.
- */
-void
-PrepTranspecs(
- Element_t *e
-)
-{
- Trans_t *t;
- t = FindTrans(e, 0);
- e->trans = t;
-}
-
-/* ______________________________________________________________________ */
-/* Copy a buffer/string into another, expanding regular variables and immediate
- * variables. (Special variables are done later.)
- * Arguments:
- * Pointer to string to expand.
- * Pointer to expanded string. (return)
- * Pointer to element under consideration.
- */
-void
-ExpandVariables(
- char *in,
- char *out,
- Element_t *e
-)
-{
- register int i, j;
- char *ip, *vp, *op;
- char *def_val, *s, *atval, *modifier;
- char vbuf[500];
- int lev;
-
- ip = in;
- op = out;
- while (*ip) {
- /* start of regular variable? */
- if (*ip == '$' && *(ip+1) == L_CURLY && *(ip+2) != '_') {
- ip++;
- ip++; /* point at variable name */
- vp = vbuf;
- /* Look for matching (closing) curly. (watch for nesting)
- * We store the variable content in a tmp buffer, so we don't
- * clobber the input buffer.
- */
- lev = 0;
- while (*ip) {
- if (*ip == L_CURLY) lev++;
- if (*ip == R_CURLY) {
- if (lev == 0) {
- ip++;
- break;
- }
- else lev--;
- }
- *vp++ = *ip++; /* copy to variable buffer */
- }
- *vp = EOS;
- /* vbuf now contains the variable name (stuff between curlys). */
- if (lev != 0) {
- fprintf(stderr, "Botched variable use: %s\n", in);
- /* copy rest of string if we can't recover ?? */
- return;
- }
- /* Now, expand variable. */
- vp = vbuf;
-
- /* Check for immediate variables -- like _special variables but
- * interpreted right now. These start with a "+" */
-
- if ( *vp == '+' ) {
-
- if ( ! strcmp(vp, "+content") ) {
- for ( i=0; i<e->ncont; i++ ) {
- if ( IsContData(e, i) ) {
- j = strlen(ContData(e,i));
- memcpy(op, ContData(e,i), j);
- op += j;
- } else {
- fprintf(stderr, "warning: ${+current} skipped element content\n");
- }
- }
-
- } else {
- fprintf(stderr, "unknown immediate variable: %s\n", vp);
- }
-
- } else {
-
- /* See if this variable has a default [ format: ${varname def} ] */
-
- def_val = vp;
- while (*def_val && *def_val != ' ') def_val++;
- if (*def_val) *def_val++ = EOS;
- else def_val = 0;
- /* def_val now points to default, if it exists, null if not. */
-
- modifier = vp;
- while (*modifier && *modifier != ':') modifier++;
- if (*modifier) *modifier++ = EOS;
- else modifier = 0;
- /* modifier now points to modifier if it exists, null if not. */
-
- s = 0;
- /* if attribute of current elem with this name found, use value */
- if (e && (atval = FindAttValByName(e, vp)))
- s = atval;
- else /* else try for (global) variable with this name */
- s = FindMappingVal(Variables, vp);
-
- /* If we found a value, copy it to the output buffer. */
-
- if (s) {
- if ( modifier && *modifier == 'l' ) {
- while (*s) {
- *op = tolower(*s);
- op++, *s++;
- }
- } else
- while (*s) *op++ = *s++;
- } else
- if (def_val) {
- while (*def_val) *op++ = *def_val++;
- }
- }
- continue;
- }
- *op++ = *ip++;
- }
- *op = EOS; /* terminate string */
-}
-
-/* ______________________________________________________________________ */
-/* Process an "output" translation spec - one of StartText, EndText,
- * Replace, Message. (These are the ones that produce output.)
- * Steps done:
- * Expand attributes and regular varaibles in input string.
- * Pass thru string, accumulating chars to be sent to output stream.
- * If we find the start of a special variable, output what we've
- * accumulated, then find the special variable's "bounds" (ie, the
- * stuff between the curly brackets), and expand that by passing to
- * ExpandSpecialVar(). Continue until done the input string.
- * Arguments:
- * Input buffer (string) to be expanded and output.
- * Pointer to element under consideration.
- * FILE pointer to where to write output.
- * Flag saying whether to track the character position we're on
- * (passed to OutputString).
- */
-void
-ProcesOutputSpec(
- char *ib,
- Element_t *e,
- FILE *fp,
- int track_pos
-)
-{
- char obuf[LINESIZE];
- char vbuf[LINESIZE];
- char *dest, vname[LINESIZE], *cp;
- int esc;
-
- obuf[0] = EOS; /* start with empty output buffer */
-
- ExpandVariables(ib, vbuf, e); /* expand regular variables */
- ib = vbuf;
- dest = obuf;
-
- esc = 0;
- while (*ib) {
- /* If not a $, it's a regular char. Just copy it and go to next. */
- if (*ib != '$') { /* look for att/variable marker */
- *dest++ = *ib++; /* it's not. just copy character */
- continue;
- }
-
- /* We have a $. What we have must be a "special variable" since
- * regular variables have already been expanded, or just a lone $. */
-
- if (ib[1] != L_CURLY) { /* just a stray dollar sign (no variable) */
- *dest++ = *ib++;
- continue;
- }
-
- ib++; /* point past $ */
-
- /* Output what we have in buffer so far. */
- *dest = EOS; /* terminate string */
- if (obuf[0]) OutputString(obuf, fp, track_pos);
- dest = obuf; /* ready for new stuff in buffer */
-
- if (!strchr(ib, R_CURLY)) {
- fprintf(stderr, "Mismatched braces in TranSpec: %s\n", ib);
- /* how do we recover from this? */
- }
- ib++;
- cp = vname;
- while (*ib && *ib != R_CURLY) *cp++ = *ib++;
- *cp = EOS; /* terminate att/var name */
- ib++; /* point past closing curly */
- /* we now have special variable name (stuff in curly {}'s) in vname */
- ExpandSpecialVar(&vname[1], e, fp, track_pos);
- }
- *dest = EOS; /* terminate string in output buffer */
-
- if (obuf[0]) OutputString(obuf, fp, track_pos);
-}
-
-/* ______________________________________________________________________ */
-/* Find the translation spec for the given tag.
- * Returns pointer to first spec that matches (name, depth, etc., of tag).
- * Arguments:
- * e -- Pointer to element under consideration.
- * specID -- name of specid that we're looking for
- * Return:
- * Pointer to translation spec that matches given element's context.
- */
-
-Trans_t *
-FindTrans(
- Element_t *e,
- int specID
-)
-{
- char context[LINESIZE], buf[LINESIZE], *cp, **vec, *atval;
- int i, a, match;
- Trans_t *t, *tt;
-
- /* loop through all transpecs */
- for (t=TrSpecs; t; t=t->next)
- {
- /* Only one of gi or gilist will be set. */
- /* Check if elem name matches */
- if (t->gi && !StrEq(t->gi, e->gi) && !specID) continue;
-
- /* test if we're looking for a specific specID and then if
- * this is it.. */
- if (specID)
- if (!t->my_id || (specID != t->my_id))
- continue;
-
- /* Match one in the list of GIs? */
- if (t->gilist) {
- for (match=0,vec=t->gilist; *vec; vec++) {
- if (StrEq(*vec, e->gi)) {
- match = 1;
- break;
- }
- }
- if (!match) continue;
- }
-
- /* Check context */
-
- /* Special case of context */
- if (t->parent)
- if (!QRelation(e, t->parent, REL_Parent)) continue;
-
- if (t->context) { /* no context specified -> a match */
- FindContext(e, t->depth, context);
-
- /* If reg expr set, do regex compare; else just string compare. */
- if (t->context_re) {
- if (! regexec(t->context_re, context)) continue;
- }
- else {
- /* Is depth of spec deeper than element's depth? */
- if (t->depth > e->depth) continue;
-
- /* See if context of element matches "context" of transpec */
- match = ( (t->context[0] == context[0]) &&
- !strcmp(t->context, context) );
- if (!match) continue;
- }
- }
-
- /* Check attributes. Loop through list, comparing each. */
- if (t->nattpairs) { /* no att specified -> a match */
- for (match=1,a=0; a<t->nattpairs; a++) {
- if (!(atval = FindAttValByName(e, t->attpair[a].name))) {
- match = 0;
- break;
- }
- if (!regexec(t->attpair[a].rex, atval)) match = 0;
- }
- if (!match) continue;
- }
-
- /* Check relationships: child, parent, ancestor, sib, ... */
- if (t->relations) {
- Mapping_t *r;
- match = 1;
- for (r=t->relations->maps,i=0; i<t->relations->n_used; i++) {
- if (!CheckRelation(e, r[i].name, r[i].sval, 0, 0, RA_Current)) {
- match = 0;
- break;
- }
- }
- if (!match) continue;
- }
-
- /* check this element's parent's attribute */
- if (t->pattrset && e->parent) {
- char *p, **tok;
-
- i = 2;
- match = 1;
- tok = Split(t->pattrset, &i, S_STRDUP);
- if ( i == 2 ) {
- p = FindAttValByName(e->parent, tok[0]);
- ExpandVariables(tok[1], buf, 0);
- if ( !p || strcmp(p, buf) )
- match = 0;
- } else {
- if (!FindAttValByName(e->parent, t->pattrset))
- match = 0;
- }
- free(tok[0]);
- if (!match) continue;
- }
-
- /* check this element's "birth order" */
- if (t->nth_child) {
- /* First one is called "1" by the user. Internally called "0". */
- i = t->nth_child;
- if (i > 0) { /* positive # -- count from beginning */
- if (e->my_eorder != (i-1)) continue;
- }
- else { /* negative # -- count from end */
- i = e->parent->necont - i;
- if (e->my_eorder != i) continue;
- }
- }
-
- /* check that variables match */
- if (t->var_name) {
- cp = FindMappingVal(Variables, t->var_name);
- if (!cp || strcmp(cp, t->var_value)) continue;
- }
-
- /* check for variable regular expression match */
- if ( t->var_RE_name ) {
- cp = FindMappingVal(Variables, t->var_RE_name);
- if (!cp || !regexec(t->var_RE_value, cp)) continue;
- }
-
- /* check content */
- if (t->content) { /* no att specified -> a match */
- for (match=0,i=0; i<e->ndcont; i++) {
- if (regexec(t->content_re, e->dcont[i])) {
- match = 1;
- break;
- }
- }
- if (!match) continue;
- }
-
- /* -------- at this point we've passed all criteria -------- */
-
- /* See if we should be using another transpec's actions. */
- if (t->use_id) {
- if (t->use_id < 0) return &NullTrans; /* missing? */
- /* see if we have a pointer to that transpec */
- if (t->use_trans) return t->use_trans;
- for (tt=TrSpecs; tt; tt=tt->next) {
- if (t->use_id == tt->my_id) {
- /* remember pointer for next time */
- t->use_trans = tt;
- return t->use_trans;
- }
- }
- t->use_id = -1; /* flag it as missing */
- fprintf(stderr, "Warning: transpec ID (%d) not found for %s.\n",
- t->use_id, e->gi);
- return &NullTrans;
- }
-
- return t;
- }
-
- /* At this point, we have not found a matching spec. See if there
- * is a wildcard, and if so, use it. (Wildcard GI is named "*".) */
- if ((t = FindTransByName("*"))) return t;
-
- if (warnings && !specID)
- fprintf(stderr, "Warning: transpec not found for %s\n", e->gi);
-
- /* default spec - pass character data and descend node */
- return &NullTrans;
-}
-
-/* ______________________________________________________________________ */
-/* Find translation spec by (GI) name. Returns the first one that matches.
- * Arguments:
- * Pointer to name of transpec (the "gi" field of the Trans structure).
- * Return:
- * Pointer to translation spec that matches name.
- */
-
-Trans_t *
-FindTransByName(
- char *s
-)
-{
- Trans_t *t;
-
- for (t=TrSpecs; t; t=t->next) {
- /* check if tag name matches (first check 1st char, for efficiency) */
- if (t->gi) {
- if (*(t->gi) != *s) continue; /* check 1st character */
- if (!strcmp(t->gi, s)) return t;
- }
- }
- return NULL;
-}
-
-/* Find translation spec by its ID (SpecID).
- * Arguments:
- * Spec ID (an int).
- * Return:
- * Pointer to translation spec that matches name.
- */
-Trans_t *
-FindTranByID(int n)
-{
- Trans_t *t;
-
- for (t=TrSpecs; t; t=t->next)
- if (n == t->my_id) return t;
- return NULL;
-}
-
-/* ______________________________________________________________________ */
-/* Process a "chunk" of content data of an element.
- * Arguments:
- * Pointer to data content to process
- * FILE pointer to where to write output.
- */
-
-void
-DoData(
- char *data,
- FILE *fp,
- int verbatim
-)
-{
- if (!fp) return;
- OutputString(data, fp, 1);
-}
-
-/* ______________________________________________________________________ */
-/* Handle a processing instruction. This is done similarly to elements,
- * where we find a transpec, then do what it says. Differences: PI names
- * start with '_' in the spec file (if a GI does not start with '_', it
- * may be forced to upper case, sgmls keeps PIs as mixed case); the args
- * to the PI are treated as the data of an element. Note that a PI wildcard
- * is "_*"
- * Arguments:
- * Pointer to the PI.
- * FILE pointer to where to write output.
- */
-
-void
-DoPI(
- char *pi,
- FILE *fp
-)
-{
- char buf[250], **tok;
- int n;
- Trans_t *t;
-
- buf[0] = '_';
- strcpy(&buf[1], pi);
- n = 2;
- tok = Split(buf, &n, 0);
- if ((t = FindTransByName(tok[0])) ||
- (t = FindTransByName("_*"))) {
- if (t->replace) ProcesOutputSpec(t->replace, 0, fp, 1);
- else {
- if (t->starttext) ProcesOutputSpec(t->starttext, 0, fp, 1);
- if (t->ignore != IGN_DATA) /* skip data nodes? */
- if (n > 1) OutputString(tok[1], fp, 1);
- if (t->endtext) ProcesOutputSpec(t->endtext, 0, fp, 1);
- }
- if (t->message) ProcesOutputSpec(t->message, 0, stderr, 0);
- }
- else {
- /* If not found, just print the PI in square brackets, along
- * with a warning message. */
- fprintf(fp, "[%s]", pi);
- if (warnings) fprintf(stderr, "Warning: Unrecognized PI: [%s]\n", pi);
- }
-}
-
-/* ______________________________________________________________________ */
-/* Set and increment variables, as appropriate, if the transpec says to.
- * Arguments:
- * Pointer to translation spec for current element.
- */
-
-static void
-set_and_increment(
- Trans_t *t,
- Element_t *e
-)
-{
- Mapping_t *m;
- int i, inc, n;
- char *cp, buf[50];
- char ebuf[500];
-
- /* set/reset variables */
- if (t->set_var) {
- for (m=t->set_var->maps,i=0; i<t->set_var->n_used; i++) {
- ExpandVariables(m[i].sval, ebuf, e); /* do some expansion */
- SetMappingNV(Variables, m[i].name, ebuf);
- }
- }
-
- /* increment counters */
- if (t->incr_var) {
- for (m=t->incr_var->maps,i=0; i<t->incr_var->n_used; i++) {
- cp = FindMappingVal(Variables, m[i].name);
- /* if not set at all, set to 1 */
- if (!cp) SetMappingNV(Variables, m[i].name, "1");
- else {
- if (isdigit(*cp) || (*cp == '-' && isdigit(cp[1]))) {
- n = atoi(cp);
- if (m[i].sval && isdigit(*m[i].sval)) inc = atoi(m[i].sval);
- else inc = 1;
- sprintf(buf, "%d", (n + inc));
- SetMappingNV(Variables, m[i].name, buf);
- } else
- if (!*(cp+1) && isalpha(*cp)) {
- buf[0] = *cp + 1;
- buf[1] = 0;
- SetMappingNV(Variables, m[i].name, buf);
- }
- }
- }
- }
-}
-
-/* ______________________________________________________________________ */
-/* Translate one element.
- * Arguments:
- * Pointer to element under consideration.
- * FILE pointer to where to write output.
- * Pointer to translation spec for current element, or null.
- */
-void
-TransElement(
- Element_t *e,
- FILE *fp,
- Trans_t *t
-)
-{
- int i;
-
- if (!t) t = ((e && e->trans) ? e->trans : &NullTrans);
-
- /* see if we should quit. */
- if (t->quit) {
- fprintf(stderr, "Quitting at location:\n");
- PrintLocation(e, fp);
- fprintf(stderr, "%s\n", t->quit);
- exit(1);
- }
-
- /* See if we want to replace subtree (do text, don't descend subtree) */
- if (t->replace) {
- ProcesOutputSpec(t->replace, e, fp, 1);
- if (t->message) ProcesOutputSpec(t->message, e, stderr, 0);
- set_and_increment(t, e); /* adjust variables, if appropriate */
- return;
- }
-
- if (t->starttext) ProcesOutputSpec(t->starttext, e, fp, 1);
- if (t->message) ProcesOutputSpec(t->message, e, stderr, 0);
-
- /* Process data for this node and descend child elements/nodes. */
- if (t->ignore != IGN_ALL) {
- /* Is there a "generated" node at the front of this one? */
- if (e->gen_trans[0]) {
- Trans_t *tp;
- if ((tp = FindTranByID(e->gen_trans[0]))) {
- if (tp->starttext) ProcesOutputSpec(tp->starttext, e, fp, 1);
- if (tp->message) ProcesOutputSpec(tp->message, e, stderr, 0);
- if (tp->endtext) ProcesOutputSpec(tp->endtext, e, fp, 1);
- }
- }
- /* Loop thruthe "nodes", whether data, child element, or PI. */
- for (i=0; i<e->ncont; i++) {
- if (IsContElem(e,i)) {
- if (t->ignore != IGN_CHILDREN) /* skip child nodes? */
- TransElement(ContElem(e,i), fp, NULL);
- }
- else if (IsContData(e,i)) {
- if (t->ignore != IGN_DATA) /* skip data nodes? */
- DoData(ContData(e,i), fp, t->verbatim);
- }
- else if (IsContPI(e,i))
- DoPI(e->cont[i].ch.data, fp);
- }
- /* Is there a "generated" node at the end of this one? */
- if (e->gen_trans[1]) {
- Trans_t *tp;
- if ((tp = FindTranByID(e->gen_trans[1]))) {
- if (tp->starttext) ProcesOutputSpec(tp->starttext, e, fp, 1);
- if (tp->message) ProcesOutputSpec(tp->message, e, stderr, 0);
- if (tp->endtext) ProcesOutputSpec(tp->endtext, e, fp, 1);
- }
- }
- }
-
- set_and_increment(t, e); /* adjust variables, if appropriate */
-
- if (t->endtext) ProcesOutputSpec(t->endtext, e, fp, 1);
-
- e->processed = 1;
-}
-
-/* ______________________________________________________________________ */
-/* Check if element matches specified relationship, and, if it does, perform
- * action on either current element or matching element (depends on flag).
- * Arguments:
- * Pointer to element under consideration.
- * Pointer to relationship name.
- * Pointer to related element name (GI).
- * Pointer to action to take (string - turned into an int).
- * FILE pointer to where to write output.
- * Flag saying whether to do action on related element (RA_Related)
- * or on current element (RA_Current).
- * Return:
- * Bool, saying whether (1) or not (0) relationship matches.
- */
-
-int
-CheckRelation(
- Element_t *e,
- char *relname, /* relationship name */
- char *related, /* related element */
- char *actname, /* action to take */
- FILE *fp,
- RelAction_t flag
-)
-{
- Element_t *ep;
- Relation_t r;
-
- if ((r = FindRelByName(relname)) == REL_Unknown) return 0;
- if (!(ep=QRelation(e, related, r))) return 0;
-
- if (!actname) return 1; /* no action - return what we found */
-
- switch (flag) {
- case RA_Related: TranTByAction(ep, actname, fp); break;
- case RA_Current: TranTByAction(e, actname, fp); break;
- }
- return 1;
-}
-
-/* ______________________________________________________________________ */
-/* Perform action given by a SpecID on the given element.
- * Arguments:
- * Pointer to element under consideration.
- * SpecID of action to perform.
- * FILE pointer to where to write output.
- *
- */
-void
-TranByAction(
- Element_t *e,
- int n,
- FILE *fp
-)
-{
- Trans_t *t;
-
- t = FindTranByID(n);
- if (!t) {
- fprintf(stderr, "Could not find named action for %d.\n", n);
- return;
- }
- TransElement(e, fp, t);
-}
-
-/* ______________________________________________________________________ */
-/* Perhaps perform action given by a SpecID on the given element.
- * Arguments:
- * Pointer to element under consideration.
- * SpecID of action to perform. Unlike TranByAction, this is the argument
- * as it occurred in the transpec (ASCII) and may end with the letter
- * "t" which means that the transpec mustpass criteria selection.
- * FILE pointer to where to write output.
- */
-void
-TranTByAction(
- Element_t *e,
- char *strn,
- FILE *fp
-)
-{
- int n;
- Trans_t *t;
-
- n = atoi(strn);
- if ( strn[strlen(strn)-1] != 't' ) {
- t = FindTranByID(n);
- if (!t) {
- fprintf(stderr, "Could not find named action for %d.\n", n);
- return;
- }
- } else {
- t = FindTrans(e, n);
- if ( !t || !t->my_id )
- return;
- }
- TransElement(e, fp, t);
-}
-
-/* ______________________________________________________________________ */
diff --git a/usr.bin/sgmls/instant/translate.h b/usr.bin/sgmls/instant/translate.h
deleted file mode 100644
index 777d591..0000000
--- a/usr.bin/sgmls/instant/translate.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Copyright 1993 Open Software Foundation, Inc., Cambridge, Massachusetts.
- * All rights reserved.
- */
-/*
- * Copyright (c) 1994
- * Open Software Foundation, Inc.
- *
- * Permission is hereby granted to use, copy, modify and freely distribute
- * the software in this file and its documentation for any purpose without
- * fee, provided that the above copyright notice appears in all copies and
- * that both the copyright notice and this permission notice appear in
- * supporting documentation. Further, provided that the name of Open
- * Software Foundation, Inc. ("OSF") not be used in advertising or
- * publicity pertaining to distribution of the software without prior
- * written permission from OSF. OSF makes no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- */
-/*
- * Copyright (c) 1996 X Consortium
- * Copyright (c) 1995, 1996 Dalrymple Consulting
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * X CONSORTIUM OR DALRYMPLE CONSULTING BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the names of the X Consortium and
- * Dalrymple Consulting shall not be used in advertising or otherwise to
- * promote the sale, use or other dealings in this Software without prior
- * written authorization.
- */
-/* ________________________________________________________________________
- *
- * Program to manipulate SGML instances.
- *
- * These are data definitions for the "translating" portion of the program.
- *
- * ________________________________________________________________________
- */
-
-#ifdef STORAGE
-#ifndef lint
-static char *tr_h_RCSid =
- "$Header: /usr/src/docbook-to-man/Instant/RCS/translate.h,v 1.3 1996/06/02 21:47:32 fld Exp $";
-#endif
-#endif
-
-#define L_CURLY '{'
-#define R_CURLY '}'
-
-/* things to ignore when processing an element */
-#define IGN_NONE 0
-#define IGN_ALL 1
-#define IGN_DATA 2
-#define IGN_CHILDREN 3
-
-/* for CheckRelation() */
-typedef enum { RA_Current, RA_Related } RelAction_t;
-
-typedef struct {
- char *name; /* attribute name string */
- char *val; /* attribute value string */
- regexp *rex; /* attribute value reg expr (compiled) */
-} AttPair_t;
-
-typedef struct _Trans {
- /* criteria */
- char *gi; /* element name of tag under consideration */
- char **gilist; /* list of element names (multiple gi's) */
- char *context; /* context in tree - looking depth levels up */
- regexp *context_re; /* tree heirarchy looking depth levels up */
- int depth; /* number of levels to look up the tree */
- AttPair_t *attpair; /* attr name-value pairs */
- int nattpairs; /* number of name-value pairs */
- char *parent; /* GI has this element as parent */
- int nth_child; /* GI is Nth child of this of parent element */
- char *content; /* element has this string in content */
- regexp *content_re; /* content reg expr (compiled) */
- char *pattrset; /* is this attr set (any value) in parent? */
- char *var_name; /* variable name */
- char *var_value; /* variable value */
- char *var_RE_name; /* variable name (for VarREValue) */
- regexp *var_RE_value; /* variable value (compiled, for VarREValue) */
- Map_t *relations; /* various relations to check */
-
- /* actions */
- char *starttext; /* string to output at the start tag */
- char *endtext; /* string to output at the end tag */
- char *replace; /* string to replace this subtree with */
- char *message; /* message for stderr, if element encountered */
- int ignore; /* flag - ignore content or data of element? */
- int verbatim; /* flag - pass content verbatim or do cmap? */
- char *var_reset;
- char *increment; /* increment these variables */
- Map_t *set_var; /* set these variables */
- Map_t *incr_var; /* increment these variables */
- char *quit; /* print message and exit */
-
- /* pointers and bookkeeping */
- int my_id; /* unique (hopefully) ID of this transpec */
- int use_id; /* use transpec whose ID is this */
- struct _Trans *use_trans; /* pointer to other transpec */
- struct _Trans *next; /* linked list */
- int lineno; /* line number of end of transpec */
-} Trans_t;
-
-#ifdef def
-#undef def
-#endif
-#ifdef STORAGE
-# define def
-#else
-# define def extern
-#endif
-
-def Trans_t *TrSpecs;
-def Mapping_t *CharMap;
-def int nCharMap;
-
-/* prototypes for things defined in translate.c */
-int CheckRelation(Element_t *, char *, char *, char *, FILE*, RelAction_t);
-Trans_t *FindTrans(Element_t *, int);
-Trans_t *FindTransByName(char *);
-Trans_t *FindTransByID(int);
-void PrepTranspecs(Element_t *);
-void ProcessOneSpec(char *, Element_t *, FILE *, int);
-void TransElement(Element_t *, FILE *, Trans_t *);
-void TranByAction(Element_t *, int, FILE *);
-void TranTByAction(Element_t *, char *, FILE *);
-
-/* prototypes for things defined in tranvar.c */
-void ExpandSpecialVar(char *, Element_t *, FILE *, int);
-
-/* prototypes for things defined in tables.c */
-void OSFtable(Element_t *, FILE *, char **, int);
-
-/* ______________________________________________________________________ */
-
diff --git a/usr.bin/sgmls/instant/transpec.5 b/usr.bin/sgmls/instant/transpec.5
deleted file mode 100644
index 297b9d0..0000000
--- a/usr.bin/sgmls/instant/transpec.5
+++ /dev/null
@@ -1,528 +0,0 @@
-...\"
-...\"
-...\" Copyright (c) 1994
-...\" Open Software Foundation, Inc.
-...\"
-...\" Permission is hereby granted to use, copy, modify and freely distribute
-...\" the software in this file and its documentation for any purpose without
-...\" fee, provided that the above copyright notice appears in all copies and
-...\" that both the copyright notice and this permission notice appear in
-...\" supporting documentation. Further, provided that the name of Open
-...\" Software Foundation, Inc. ("OSF") not be used in advertising or
-...\" publicity pertaining to distribution of the software without prior
-...\" written permission from OSF. OSF makes no representations about the
-...\" suitability of this software for any purpose. It is provided "as is"
-...\" without express or implied warranty.
-...\"
-...\" Copyright (c) 1996 X Consortium
-...\" Copyright (c) 1996 Dalrymple Consulting
-...\"
-...\" Permission is hereby granted, free of charge, to any person obtaining a copy
-...\" of this software and associated documentation files (the "Software"), to deal
-...\" in the Software without restriction, including without limitation the rights
-...\" to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-...\" copies of the Software, and to permit persons to whom the Software is
-...\" furnished to do so, subject to the following conditions:
-...\"
-...\" The above copyright notice and this permission notice shall be included in
-...\" all copies or substantial portions of the Software.
-...\"
-...\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-...\" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-...\" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-...\" X CONSORTIUM OR DALRYMPLE CONSULTING BE LIABLE FOR ANY CLAIM, DAMAGES OR
-...\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-...\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-...\" OTHER DEALINGS IN THE SOFTWARE.
-...\"
-...\" Except as contained in this notice, the names of the X Consortium and
-...\" Dalrymple Consulting shall not be used in advertising or otherwise to
-...\" promote the sale, use or other dealings in this Software without prior
-...\" written authorization.
-...\"
-...\" Translated with /usr/local/lib/tpt/ref-man.ts by fld on cord, Wed 07 Feb 1996, 22:00
-.TH "\fBtranspec\fP" "file format"
-.SH "Name"
-\fBtranspec\fP - translation specification for \fBinstant\fP
-.SH "Synopsis"
-.na
-.PP
-\fBfile.ts\fP
-.ad
-.SH "Description"
-.PP
-The \fBtranspec\fP file is used by the \fBinstant\fP program to translate an SGML document instance to a format suitable for a formatting application.
-The convention is to name the file with the suffix \fB.ts\fP.
-.PP
-A \fBtranspec\fP file is composed of a number of individual translation specs.
-Each translation spec (transpec) is made up of a number of fields, one per line.
-Translation specs are separated by a line with a leading dash. Text after the dash is ignored.
-Fields are composed of two parts, a name and a value, separated by a colon.
-The colon must immediately follow the name, and any amount of whitespace (blanks and tabs) may be present between the colon and value.
-Values should not be quoted, and you should be careful of trailing spaces.
-(Trailing space will be considered part of the value.)
-Quotes, if they appear, will be considered part of the value of the fields.
-Lines that begin with whitespace (blanks and tabs) are a continuation of the previous line; the leading space is ignored.
-These characteristics are very similar to those of e-mail headers.
-Lines beginning with a \fB#\fP (number sign) are comments and blank lines are ignored.
-.SH "Field Descriptions"
-.PP
-Some fields are for identifying criteria that determines if a particular spec matches an element in the instance.
-Others specify what action is to take place when a match happens, such as sending text to the output stream.
-.SS "Criteria fields"
-.PP
-Criteria fields restrict the conditions under which a single translation spec will apply.
-If each field specified in a particular transpec matches an element under consideration in the document instance,
-then that translation spec is said to match. The appropriate actions, as specified in that spec, are then taken.
-The program, \fBinstant\fP, searches the list of transpecs in the order given in the file.
-Therefore, the more restrictive specs (those with more criteria) should appear before less restrictive ones.
-.PP
-For quick reference, this is a brief summary of the possible criteria fields for translation. A complete discussion of each follows.
-.P
-.TS
-tab(@);
-l l l.
-\fBField Label\fR@\fBField Value\fR@\fBDescription\fR
-GI@gi ...@name of this GI
-AttValue@attname reg-expr@current element has attribute with value
-Content@reg-expr@is reg-expr in char content>
-Context@context@element context, up the tree
-NthChild@number@current element is Nth child of its parent
-PAttSet@attname (val)@parent has this attribute set (optional to value val)
-Relation@relationship gi@gi has relationship to current element
-VarREValue@var REvalue@variable is set to regular expression value
-VarValue@var value@variable is set to value
-.TE
-'br\" labeled list
-.IP "\fBGI:\fP \fIgi\fP [...]"
-\fIgi\fP is the name of the generic identifier, or element name, to consider.
-More than one GI may appear in this field.
-.IP "\fBAttValue:\fP \fIattname\fP \fIregular-expression\fP"
-This is an attribute name-value pair, where \fIattname\fP is an attribute if the GI.
-The \fIregular-expression\fP is of the form accepted by the unix program \fBegrep\fP.
-This pair is compared to the corresponding attribute name-value pairs of the GI under consideration.
-To simply test if an attribute us set, use \fB.\fP (a dot) for \fIregular-expression\fP.
-There may be more than one of these lines for each transpec.
-.IP "\fBContent:\fP \fIregular-expression\fP"
-This specifies that the character content of GI contains a string matching the \fIregular-expression\fP.
-.IP "\fBContext:\fP \fIcontext\fP"
-This specifies the \fIcontext\fP in which to apply this translation spec.
-It is either a list of generic identifiers or a regular expression describing a list of generic identifiers, looking up the hierarchy.
-The first is the parent of the GI.
-.IP "\fBNthChild:\fP \fInumber\fP"
-This specifies that the GI is the \fInumber\fPth child element of its parent.
-Children are numbered starting with \fB1\fP.
-Negative numbers may be used to indicate order counting backwards.
-For example, -1 denotes the last child.
-.IP "\fBPAttSet:\fP \fIattname\fP"
-This specifies that the parent has this attribute, \fIattname\fP, set to any value (not IMPLIED). A value to match may optionally
-be specified after attname.
-.IP "\fBRelation:\fP \fIrelationship\fP \fIgi\fP"
-This specifies that the current element has the \fIrelationship\fP to the named \fIgi\fP.
-The acceptable relationships are: \fBancestor\fP (anywhere up the tree), \fBchild\fP (immediate child),
-\fBdescendant\fP (anywhere down the tree), \fBparent\fP (immediate ancestor), \fBsibling\fP (share same parent element),
-\fBsibling+\fP (any later sibling), \fBsibling+1\fP (the immediately following sibling), \fBsibling-\fP (any earlier sibling),
-\fBsibling-1\fP (the immediately following sibling).
-.IP "\fBVarREValue:\fP \fIvarname\fP \fIREvalue\fP"
-This specifies that the global variable \fIvarname\fP has the value \fIREvalue\fP,
-where \fIREvalue\fP is a regular expression
-(see the \fBVarValue\fP statement).
-.IP "\fBVarValue:\fP \fIvarname\fP \fIvalue\fP"
-This specifies that the global variable \fIvarname\fP has the (literal)
-value \fIvalue\fP (see the \fBVarREValue\fP statement).
-'br\" labeled list end
-.PP
-There are two special GIs.
-If specified, \fB_Start\fP and \fB_End\fP are processed as if they were GIs in the instance at the start and end of the translation, respectively.
-Their criteria are never checked. Only their actions are performed.
-.SS "Action fields"
-.PP
-For quick reference, this is a brief summary of the action fields for translation. They are only performed if all the criteria are satisfied.
-A complete discussion of each follows.
-.P
-.TS
-tab(@);
-l l l.
-\fBField Label\fR@\fBField Value\fR@\fBDescription\fR
-Action@spec-id@use transpec whose spec ID is `spec-id'
-EndText@text@text for end of element
-Increment@name@increment variable `name'
-Ignore@key@flag for ignoring element's children and/or data
-Message@text@text to send to stderr
-Quit@text@print text and quit program
-Replace@text@replace this subtree with text
-Set@name value@set variable \fIname\fP to \fIvalue\fP
-SpecID@spec-id@unique Spec ID (int) of this spec
-StartText@text@text for start of element
-.TE
-'br\" labeled list
-.IP "\fBAction:\fP \fIspec-id\fP"
-Use the actions of the spec identified by the \fBSpecID\fP with matching identifier \fIspec-id\fP.
-.IP "\fBEndText:\fP \fItext\fP"
-This specifies text to be output when the end tag is processed.
-.IP "\fBIgnore:\fP \fIkey\fP"
-This specifies that the data or children for this element are to be ignored.
-Set \fIkey\fP to \fBall\fP to ignore the element (data and child elements),
-to \fBdata\fP to ignore the immediate character data content (child elements are still descended into),
-and to \fBchildren\fP to process the immediate character data content but not descended into child elements.
-Other actions specified in this transpec are still performed, however.
-.IP "\fBIncrement:\fP \fIname\fP"
-This is used to increment a variable whose value is a number.
-If the variable is not a number, no action will be taken.
-The variable must have been previously defined. This action is done immediately before \fBEndText\fP.
-There may be more than one of these lines for each transpec.
-.IP "\fBMessage:\fP \fItext\fP"
-This specifies a string to be printed to the standard error when the matching element is processed.
-It is intended for informing the user of the progress of the translation.
-It is also used for validation of instances (see the \fB-v\fP flag of \fBinstant\fP(1));
-a spec would be written to recognize a construct that is not allowed.
-This action is done immediately after \fBStartText\fP.
-Messages are also useful for debugging spec files; one is able to easily tell when a matching spec is processed,
-without looking at the actual output of the translation.
-Note that the spec writer is responsible for putting newlines (\fB\en\fP) in the message text.
-.IP "\fBReplace:\fP \fItext\fP"
-This specifies text to replace the current subtree with.
-This is equivalent to \fBStartText\fP and \fBIgnore\fP.
-.IP "\fBQuit:\fP \fItext\fP"
-This specifies text to be printed to the standard error. The program then terminates with exit status 1.
-This is intended for bailing out when an undesirable instance is encountered
-(such as when it is known that the formatting application can never handle a class of components, like tables).
-.IP "\fBSet:\fP \fIname\fP \fIvalue\fP"
-This is used to set a variable whose name is \fIname\fP and value is \fIvalue\fP.
-Names that would be valid for GIs in the document instance are valid for variable names.
-\fIvalue\fP is the rest of the line and may be any string. This action is done immediately before \fBEndText\fP.
-There may be more than one of these lines for each transpec.
-See the discussion on variables below.
-.IP "\fBSpecID:\fP \fIspec-id\fP"
-This names the spec with the number \fIspec-id\fP. Other specs may refer to this one by this number by an \fBAction\fP field or an \fB_action\fP special variable.
-This is used for cases where several specs to perform the exact same action.
-.IP "\fBStartText:\fP \fItext\fP"
-This specifies text to be output when the start tag is processed.
-'br\" labeled list end
-.SS "Other Fields"
-.PP
-These fields may appear anywhere. The action occurs when the translation spec file is read, before any elements are translated.
-Theses are independent of any element processing.
-'br\" labeled list
-.IP "\fBVar:\fP \fIname\fP \fIvalue\fP"
-This is used to define a variable whose name is \fIname\fP and value is \fIvalue\fP.
-It is similar to \fBSet\fP, but it may occur anywhere in the file and takes effect when the spec file is read.
-'br\" labeled list end
-.SS "Text Strings"
-.PP
-The \fItext\fP referred to in the \fBStartText\fP, \fBEndText\fP, \fBReplace\fP,
-and \fBMessage\fP actions is more than simple character strings.
-Special sequences allow more complex output.
-.PP
-One type of special sequence is for C-style string processing.
-Most special characters are escaped with a \e (backslash). Like in C or shell programs, to print a \e (backslash), you must escape it with another backslash. These special character strings are:
-'br\" labeled list
-.IP "\fB\en (backslash-n)\fP"
-This specifies that a newline character is to be printed to the output stream.
-.IP "\fB\er (backslash-r)\fP"
-This specifies that a carriage return character is to be printed to the output stream.
-.IP "\fB\et (backslash-t)\fP"
-This specifies that a tab character is to be printed to the output stream.
-.IP "\fB\es (backslash-s)\fP"
-This specifies that a space is to be printed to the output stream.
-This is useful for the end of a transpec line, where it can be difficult to tell if a blank is present at the end.
-.IP "\fB\e007 (backslash-007)\fP"
-This specifies that the character whose octal value is 007 is to be printed to the output stream.
-This works for any octal character value.
-.IP "\fB^ (caret)\fP"
-This specifies the that position in the string will be at the start of a line in the output stream.
-'br\" labeled list end
-.PP
-If the first token of the text string is \fB#include\fP, then the second token is taken to be a file name and that file is included.
-If the file is not found, the library directory, as mentioned above, is searched.
-If the text string starts with a \fB!\fP (exclamation point), the rest of the line is taken to be a command and the output of that command is inserted.
-.PP
-An element's attributes may also be used in the text of output fields.
-To use an attribute value, precede its name with a \fB${\fP (dollar sign-left curly bracket) and follow it with a \fB}\fP (right curly bracket).
-(This style is followed by the Bourne shell.) For example, \fB${TYPE}\fP.
-If the attribute is not set (not IMPLIED), nothing will be printed to the output stream.
-To specify a value to use if the attribute is not set, place the value after the attribute name, separated by a space.
-To return the attribute value in lower-case, add a colon followed by
-lower-case l (\fB${TYPE:l}\fP.
-.SH "Variables"
-.PP
-Variables in \fBinstant\fP are similar to those in many other string-oriented programming languages, such as \fBsh\fP and \fBawk\fP.
-They are set by: \fBVar:\fP \fIname\fP \fIvalue\fP and \fBSet:\fP \fIname\fP \fIvalue\fP.
-Values may be set and reset to any string.
-In a \fBVar\fP line, if the value begins with a \fB!\fP,
-then the rest of the line is executed as a command, and its output is taken as the \fIvalue\fP.
-.PP
-A reference to the value of a variable follows the same syntax as
-a reference to the value of an attribute: \fB${\fIname\fB}\fR.
-If that variable has not been defined, a null value will be returned.
-A default value can be returned instead of null for an undefined variable
-by using the form: \fB${\fIname default\fB}\fR.
-.PP
-Variables may be used as attributes are, that is in any of the text strings mentioned above.
-In fact, if an attribute name is referred to and it is not set for a given element,
-\fBinstant\fP looks for a variable with the same name. This way global defaults can be set.
-If you want to be sure that you are accessing a local variable value, not an attribute value, you can use lower or mixed case names.
-Attribute names, as passed by \fBsgmls\fP, are in upper case.
-.PP
-Any number of \fBVar\fP actions may appear in the spec file. These set the values of the variables before any translation takes place.
-The \fBSet\fP actions within transpecs are performed when that spec is processed when an element matches the given criteria.
-.SS "Preset Variables"
-.PP
-Several variables are preset by \fBinstant\fP upon start of the program.
-Their values may be overridden in transpec files or on the command line.
-'br\" labeled list
-.IP "\fBdate\fP"
-This is the date and time that the program started. The format is: \f(CWTue 10 Aug 1993, 16:52\fP.
-.IP "\fBhost\fP"
-This is the name of the host where the program is run. It is what is returned by the \fBgethostname\fP library call.
-.IP "\fBtranspec\fP"
-This is the translation spec filename.
-.IP "\fBuser\fP"
-This is the login name of the user running the program.
-'br\" labeled list end
-.SS "Special Variables"
-.PP
-There is a collection of special variables called \fIspecial variables\fP.
-These are identified by starting the names with a \fB_\fP (underscore).
-This is a summary of the special variables. A complete discussion of each special variable follows.
-\fBspec-id\fP refers to a number specified in a \fBSpecID\fP field.
-When used in a special variable, it means to perform the action in that translation spec.
-.PP
-Note that when a \fIspec-id\fR is given in a special variable,
-the default is to perform the translation spec named by the \fIspec-id\fR ignoring
-of any criteria statements found there.
-For most special variables that use a \fIspec-id\fP, postpending a "\fBt\fR" to
-the \fIspec-id\fR (with no spaces between them, eg,
-"\fB${_followrel child TITLE 15t}\fR"), will cause the criteria statements
-in the named translation spec to evaluate successfully before that translation
-spec will be processed.
-.P
-.TS
-tab(@);
-l l.
-\fBVariable Usage\fR@\fBDescription\fR
-\fB_action\fP \fIspec-id\fP@do spec with id spec-id
-\fB_allatts\fP@print all attribute/value pairs
-\fB_attval\fP \fIatt\fP [\fIvalue\fP] \fIspec-id\fP@use spec-id if attribute matches
-\fB_chasetogi\fP \fIgi\fP \fIspec-id\fP@follow IDREFs until gi found
-\fB_eachatt\fP \fIatt\fP \fIspec-id\fP [\fIspec-id\fP]@do spec-id for each word of attribute value
-\fB_eachcon\fP \fIspec-id\fP [\fIspec-id\fP]@do spec-id for each word of content
-\fB_env\fP \fIenv-variable\fP@return value of env variable
-\fB_filename\fP@filename of notation
-\fB_find\fP \fIrel\fP \fIgi\fP \fIspec-id\fP@find gi based on relationship
-\fB_followlink\fP [\fIattname\fP] \fIspec-id\fP@follow IDREFs [attname] and use spec-id
-\fB_followrel\fP \fIrel\fP \fIgi\fP \fIspec-id\fP [\fIspec-id\fP]@do spec-id on rel if it matches
-\fB_gi\fP [\fBM|L|U\fP]@return GI name; M, L, U case
-\fB_id\fP \fIid [\fP\fIspec-id\fP]@find element with ID and use spec-id
-\fB_include\fP \fIfilename\fP@insert file here
-\fB_infile\fP [\fBline\fP]@instance filename [and line number]
-\fB_insertnode\fP S|E \fIspec-id\fP@do spec-id when element is traversed
-\fB_isset\fP \fIvar\fP [\fIvalue\fP] \fIspec-id\fP@do spec-id if variable matches
-\fB_location\fP@print location of current element
-\fB_namelist\fP \fIspec-id\fP [\fIspec-id\fP]@content is namelist, do spec-id for each
-\fB_nchild\fP [\fIgi\fP]@number of child elements [named \fIattname\fP]
-\fB_osftable\fP \fIformat\fP [\fIflag\fP]@print table format specification
-\fB_path\fP@print path to current element
-\fB_pattr\fP \fIattname\fP@value of parent's attribute
-\fB_pfind\fP \fIargs ...\fP@same as \fB_find\fP, but start at parent
-\fB_relation\fP \fIrel\fP \fIgi\fP \fIspec-id\fP [\fIspec-id\fP]@do spec-id if relation matches
-\fB_set\fP \fIvar\fP \fIvalue\fP@set variable to value
-\fB_!\fP\fIcommand\fP@command to run
-.TE
-'br\" labeled list
-.IP "\fB_action\fP \fIspec-id\fP"
-Use the actions of the spec identified by the \fBSpecID\fP with matching identifier \fIspec-id\fP.
-This behaves similarly to the \fBAction\fP action, but is in addition to the present translation spec.
-.IP "\fB_allatts\fP"
-Print all attribute name-value pairs of the current element to the output stream.
-The name and value are separated by a \fB=\fP (equals sign), and the value is surrounded by quotes.
-This can be useful for creating a normalized version of the instance.
-.IP "\fB_attval\fP \fIattname\fP [\fIvalue\fP] \fIspec-id\fP"
-If the current element has an attribute named \fIattname\fP, optionally whose value matches \fIvalue\fP,
-use the actions of the transpec identified by \fIspec-id\fP.
-.IP "\fB_chasetogi\fP \fIgi\fP \fIspec-id\fP"
-Follow IDREF attributes until if finds an element whose GI is \fIgi\fP or which has a child element with that GI.
-It will apply the transpec \fIspec-id\fP to that element.
-By default, \fBinstant\fP assumes the attributes named \fBLINKEND\fP, \fBLINKENDS\fP, and \fBIDREF\fP are of type IDREF or IDREFS.
-(This corresponds with the OSF DTDs.)
-You can change this by setting the variable \fBlink_atts\fP to a space-separated list of attribute names.
-.IP "\fB_eachatt\fP \fIatt\fP \fIspec-id\fP [\fIspec-id2\fP]"
-The transpec named by \fIspec-id\fR is invoked once per each word
-found in the value of the attribute \fIatt\fR.
-Inside the target transpec, the current word being processed
-is available in the variable named \fBeach_A\fR (\fB${each_A}\fR).
-If \fIspec-id2\fP is specified, it will use \fIspec-id\fP for the first word
-in the attribute and \fIspec-id2\fP for the others.
-.IP "\fB_eachcon\fP \fIspec-id\fP [\fIspec-id2\fP]"
-The transpec named by \fIspec-id\fR is invoked once per each word
-found in the content of the current element.
-Inside the target transpec, the current word being processed
-is available in the variable named \fBeach_C\fR (\fB${each_C}\fR).
-If \fIspec-id2\fP is specified, it will use \fIspec-id\fP for the first word
-in the content and \fIspec-id2\fP for the others.
-.IP "\fB_env\fP \fIenv-variable\fP"
-Print the value of the environment variable \fIenv-variable\fP to the output stream.
-.IP "\fB_filename\fP"
-Print the filename of the notation associated with this element, if any.
-This is used to get the filename of an external notation entity reference.
-For example, to print the filename in the latex macro from the epsf macro package, use \f(CW\e\eepsfboxi{${_filename}}\fP.
-.IP "\fB_find\fP [\fBtop\fP] \fIrelationship\fP \fIargs ...\fP \fIspec-id\fP"
-Descend the document hierarchy finding elements that match one of several criteria.
-When one is found, the action specified by \fIspec-id\fP is performed.
-If \fBtop\fP is specified, the search starts at the top of the document hierarchy, rather than at the current element.
-The possible values for \fIrelationship\fP are \fBgi\fP, \fBgi-parent\fP, \fBparent\fP, and \fBattr\fP,
-and take different arguments.
-Explanations may be best done by example:
-\fB_find gi CHAPTER 123\fP means to find elements whose GI is CHAPTER, and perform action 123;
-\fB_find gi-parent TITLE CHAPTER 124\fP means to find elements whose GI is TITLE and whose parent is CHAPTER, and perform action 124;
-\fB_find parent BODY 125\fP means to find elements whose parent's GI is BODY, and perform action 125;
-\fB_find attr TYPE UGLY 125\fP means to find elements whose attribute named TYPE is set to UGLY, and perform action 126.
-.IP "\fB_followlink\fP [\fIattname\fP] \fIspec-id\fP"
-When processing an element, \fBinstant\fP will follow the IDREF attributes until an element with no IDREF attributes is found.
-It will then apply the transpec specified by \fIspec-id\fP to that element.
-If specified, it will follow the link pointed to by \fIattname\fP.
-By default, \fBinstant\fP assumes the attributes named \fBLINKEND\fP and \fBLINKENDS\fP are if type IDREF or IDREFS.
-You can change this by setting the variable \fBlink_atts\fP to a space-separated list of attribute names.
-.IP "\fB_followrel\fP \fIrelationship\fP \fIgi\fP \fIspec-id\fP [\fIspec-id2\fP]"
-If the \fIgi\fP has the specified \fIrelationship\fP to the current element,
-perform the action specified by \fIspec-id\fP on the related element.
-If the \fIrelationship\fP to \fIgi\fP does not exist,
-and \fIspec-id2\fP is present, perform \fIspec-id2\fP on the current element.
-See the discussion of the criteria field \fBRelation\fP for acceptable relationship names.
-.IP "\fB_gi\fP [\fBM|L|U\fP]"
-Print the name of the current GI to the output stream.
-If specified, \fBM\fP, \fBL\fP, or \fBU\fP will ensure the GI name is printed in mixed, lower, or upper case, respectively.
-.IP "\fB_id\fP \fIid\fP [\fIspec-id\fP]"
-Find the element with \fIid\fP and use \fIspec-id\fP, if set. If not set, use the spec for that element's context.
-.IP "\fB_include\fP \fIfilename\fP"
-Insert the file \fIfilename\fP into the output stream.
-.IP "\fB_infile\fP [\fBline\fP]"
-Print the name of the sgml instance file to the output stream. If \fBline\fP is specified, also print the line number.
-This depends on \fBsgmls\fP being called with the \fB-l\fP option.
-.IP "\fB_insertnode\fP \fBS\fP|\fBE\fP \fIspec-id\fP"
-Do \fIspec-id\fP when the current element is traversed at a later pass.
-This can be considered inserting a node, without content, into the hierarchy.
-This is only useful if done to elements \fIbefore\fP they are processed.
-Typically \fB_chasetogi\fP or \fB_followlink\fP is specified early in an instance's processing,
-so that when the elements found by one of these actions are processed in their turn, the added actions are performed.
-\fB_insertnode\fP would be specified as the action of a \fIspec-id\fP pointed to in a \fB_chasetogi\fP or \fB_followlink\fP usage.
-.IP "\fB_location\fP"
-The location of the current element is printed to the output stream in several ways: the path to the element (see \fB_path\fP),
-a position hint, which is the nearest title, the line number, if the ESIS (output from \fBsgmls\fP) contains line numbers,
-and the ID of the element, if it has one.
-This is especially useful when using the \fBMessage\fP action to validate an instance.
-.IP "\fB_namelist\fP \fIspec-id\fP [\fIspec-id2\fP]"
-This assumes that the content of the current element is a namelist (a list of element IDs),
-and applies the action based on \fIspec-id\fP for each element pointed to.
-If \fIspec-id2\fP is specified, it will use \fIspec-id\fP for the first ID in the namelist and \fIspec-id2\fP for the others.
-.IP "\fB_nchild\fP [\fIgi\fP]"
-Print the number of child elements of the element to the output stream.
-If \fIgi\fP is specified, print the number of child element with that name.
-.IP "\fB_osftable\fP \fBtex\fP|\fBtbl\fP|\fBcheck\fP [\fIflag\fP]"
-Print table markup into the output stream. The format depends on whether \fBtex\fP or \fBtbl\fP is specified.
-The \fIflag\fP may be one of \fBcellstart\fP, \fBcellend\fP, \fBrowstart\fP, \fBrowend\fP, \fBtop\fP, or \fBbottom\fP.
-The value determines what markup or text will be generated.
-If \fBcellstart\fP is specified, the correct markup for the beginning of a cell is output.
-If \fBtop\fP, \fBbottom\fP, or \fBrowend\fP are specified,
-the correct markup for the end of the appropriate position is printed to the output stream.
-If \fBcheck\fP is specified, the attributes and child elements are checked for errors and consistency.
-.IP "\fB_path\fP"
-Print the path to current GI to the output stream. A path is each element, going down the tree from the topmost element.
-A number in parentheses after each element name shows which child element the next one is in the order of children for that element.
-Ordering starts at 0.
-For example: \f(CWOSF-BOOK(3) BODY(0) CHAPTER(4) SECTION\fP.
-This says the path is \fB<OSF-BOOK>\fP's third child, \fB<BODY>\fP's zeroth,
-and \fB<CHAPTER>\fP's fourth, which is named \fB<SECTION>\fP.
-.IP "\fB_pattr\fP \fIname\fP"
-Print the value of parent's attribute whose name is \fIname\fP to the output stream.
-.IP "\fB_pfind\fP \fIrel\fP \fIgi\fP \fIspec-id\fP"
-This is exactly the same as \fB_find\fP except that the search starts at the current element's parent.
-.IP "\fB_relation\fP \fIrelationship\fP \fIgi\fP \fIspec-id\fP [\fIspec-id2\fP]"
-If the \fIgi\fP has the specified \fIrelationship\fP to the current element,
-perform the action specified by \fIspec-id\fP on the current element.
-If the relationship test fails and \fIspec-id2\fP is specified, perform that action.
-See the discussion of the criteria field \fBRelation\fP for acceptable relationship names.
-.IP "\fB_set\fP \fIvarname\fP \fIvalue\fP"
-Set the value of the variable \fIvarname\fP to \fIvalue\fP.
-.IP "\fB_isset\fP \fIvarname\fP [\fIvalue\fP] \fIspec-id\fP"
-If the value of the variable \fIvarname\fP is set to \fIvalue\fP, then perform action referred to by \fIspec-id\fP.
-If \fIvalue\fP is not specified, action will be performed if \fIvarname\fP is set to any value.
-.IP "\fB_!\fP \fIcommand\fP"
-Run the command \fIcommand\fP, directing its standard output into the output stream.
-'br\" labeled list end
-.SS "Immediate Variables"
-.PP
-\fIImmediate variables\fR are like special variables, except that they
-are expanded when the transpec is originally processed (special
-variables are processed later, near when the final output is being generated).
-The general syntax of immediate variables is \fB${+\fIimmediate_variable\ ...\fB}\fR.
-.PP
-There is currently only one immediate variable defined:
-.IP "\fB+content\fP"
-This special variable is replaced by the data content of the current element.
-.SH "Examples"
-.PP
-The following will output the given string for elements whose generic identifier is \fBP\fP (for paragraph).
-At the start of processing this element, the program ensures that the output starts on a new line,
-the \fBtroff\fP macro \fB<.P>\fP is output, then a newline.
-At the end of this element processing, the program ensures that the output starts on a new line.
-.DS
-.nf
-.ft CW
-GI: P
-StartText: ^.P^
-EndText: ^
--
-.ft R
-.fi
-.DE
-.PP
-The following will output the given string for elements whose generic identifier is \fBCMD-ARGUMENT\fP and which have an
-attribute \fBPRESENCE\fP set to the value \fBOPTIONAL\fP.
-.DS
-.nf
-.ft CW
-GI: CMD-ARGUMENT
-AttValue: PRESENCE OPTIONAL
-StartText: $\e\e[
-EndText: $\e\e]
--
-.ft R
-.fi
-.DE
-.PP
-The following prints the section number, title, and page number of the target of a cross reference.
-Assume the cross reference points to a section element, which contains a title element.
-The criteria for this spec to match is that the attribute \fBOSFROLE\fP is set to the value \fBgetfull\fP.
-The action is to replace the content of the \fB<XREF>\fP element with the given string.
-When processing the string, \fBinstant\fP will follow the IDREF attributes of \fB<XREF>\fP
-until an element with no IDREF attributes is found. It will then apply the transpec numbered \fB87\fP to that element,
-which will print the name of the GI in mixed case into the output stream.
-It will then print the LaTeX reference instruction with the value of the \fBLINKEND\fP attribute as an argument.
-(This will become the section number after processing by LaTeX.)
-It will then follow IDREFs until if finds an element whose GI is \fBTITLE\fP or which has a child element with that GI.
-It will apply the transpec numbered \fB1\fP to that element, which copies the title into the output stream where the cross reference occurs.
-Finally, it will print the word \fBpage\fP followed by the LaTeX instruction to obtain the page number of a reference.
-.DS
-.nf
-.ft CW
-GI: XREF
-AttValue: OSFROLE getfull
-Replace: ${_followlink 87} \e\eref{${LINKEND}},\es
- {\e\ebf ${_chasetogi TITLE 1}}, page \e\epageref{${LINKEND}}
--
-# Print GI name, in mixed case
-GI: _pr_gi_name
-SpecID: 87
-Ignore: 1
-EndText: ${_gi M}
--
-GI: _pass-text
-SpecID: 1
--
-.ft R
-.fi
-.DE
-.SH "Related Information"
-.PP
-\fBinstant\fP(1), \fBsgmls\fP(1), \fBegrep\fP(1).
diff --git a/usr.bin/sgmls/instant/tranvar.c b/usr.bin/sgmls/instant/tranvar.c
deleted file mode 100644
index ab04425..0000000
--- a/usr.bin/sgmls/instant/tranvar.c
+++ /dev/null
@@ -1,763 +0,0 @@
-/*
- * Copyright 1993 Open Software Foundation, Inc., Cambridge, Massachusetts.
- * All rights reserved.
- */
-/*
- * Copyright (c) 1994
- * Open Software Foundation, Inc.
- *
- * Permission is hereby granted to use, copy, modify and freely distribute
- * the software in this file and its documentation for any purpose without
- * fee, provided that the above copyright notice appears in all copies and
- * that both the copyright notice and this permission notice appear in
- * supporting documentation. Further, provided that the name of Open
- * Software Foundation, Inc. ("OSF") not be used in advertising or
- * publicity pertaining to distribution of the software without prior
- * written permission from OSF. OSF makes no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- */
-/*
- * Copyright (c) 1996 X Consortium
- * Copyright (c) 1995, 1996 Dalrymple Consulting
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * X CONSORTIUM OR DALRYMPLE CONSULTING BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the names of the X Consortium and
- * Dalrymple Consulting shall not be used in advertising or otherwise to
- * promote the sale, use or other dealings in this Software without prior
- * written authorization.
- */
-/* ________________________________________________________________________
- *
- * instant - a program to manipulate SGML instances.
- *
- * This module is for handling "special variables". These act a lot like
- * procedure calls
- * ________________________________________________________________________
- */
-
-#ifndef lint
-static char *RCSid =
- "$Header: /usr/src/docbook-to-man/Instant/RCS/tranvar.c,v 1.5 1996/06/11 22:43:15 fld Exp $";
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <string.h>
-#include <memory.h>
-#include <sys/types.h>
-#include <errno.h>
-
-#include <regexp.h>
-#include "general.h"
-#include "translate.h"
-
-static char **idrefs; /* list of IDREF att names to follow */
-static char *def_idrefs[] = { "LINKEND", "LINKENDS", "IDREF", 0 };
-static char *each_A = 0; /* last seen _eachatt */
-static char *each_C = 0; /* last seen _eachcon */
-
-/* forward references */
-void ChaseIDRefs(Element_t *, char *, char *, FILE *);
-void Find(Element_t *, int, char **, FILE *);
-void GetIDREFnames();
-
-/* ______________________________________________________________________ */
-/* Handle "special" variable - read file, run command, do action, etc.
- * Arguments:
- * Name of special variable to expand.
- * Pointer to element under consideration.
- * FILE pointer to where to write output.
- * Flag saying whether to track the character position we're on
- * (passed to OutputString).
- */
-
-void
-ExpandSpecialVar(
- char *name,
- Element_t *e,
- FILE *fp,
- int track_pos
-)
-{
- FILE *infile;
- char buf[LINESIZE], *cp, *atval;
- char **tok;
- int ntok, n, i, actioni;
- char *action, *action1;
- Element_t *ep;
- Trans_t *t, *tt;
-
- /* Run a command.
- * Format: _! command args ... */
- if (*name == '!') {
- name++;
- if ((infile = popen(name, "r"))) {
- while (fgets(buf, LINESIZE, infile)) fputs(buf, fp);
- pclose(infile);
- fflush(fp);
- }
- else {
- fprintf(stderr, "Could not start program '%s': %s",
- name, strerror(errno));
- }
- return;
- }
-
- /* See if caller wants one of the tokens from _eachatt or _eachcon.
- * If so, output it and return. (Yes, I admit that this is a hack.)
- */
- if (*name == 'A' && name[1] == EOS && each_A) {
- OutputString(each_A, fp, track_pos);
- return;
- }
- if (*name == 'C' && name[1] == EOS && each_C) {
- OutputString(each_C, fp, track_pos);
- return;
- }
-
- ntok = 0;
- tok = Split(name, &ntok, 0);
-
- /* Include another file.
- * Format: _include filename */
- if (StrEq(tok[0], "include")) {
- name = tok[1];
- if (ntok > 1 ) {
- if ((infile=OpenFile(name)) == NULL) {
- sprintf(buf, "Can not open included file '%s'", name);
- perror(buf);
- return;
- }
- while (fgets(buf, LINESIZE, infile)) fputs(buf, fp);
- fclose(infile);
- }
- else fprintf(stderr, "No file name specified for include\n");
- return;
- }
-
- /* Print location (nearest title, line no, path).
- * Format: _location */
- else if (StrEq(tok[0], "location")) {
- PrintLocation(e, fp);
- }
-
- /* Print path to this element.
- * Format: _path */
- else if (StrEq(tok[0], "path")) {
- (void)FindElementPath(e, buf);
- OutputString(buf, fp, track_pos);
- }
-
- /* Print name of this element (gi).
- * Format: _gi [M|L|U] */
- else if (StrEq(tok[0], "gi")) {
- strcpy(buf, e->gi);
- if (ntok >= 2) {
- if (*tok[1] == 'L' || *tok[1] == 'l' ||
- *tok[1] == 'M' || *tok[1] == 'm') {
- for (cp=buf; *cp; cp++)
- if (isupper(*cp)) *cp = tolower(*cp);
- }
- if (*tok[1] == 'M' || *tok[1] == 'm')
- if (islower(buf[0])) buf[0] = toupper(buf[0]);
- }
- OutputString(buf, fp, track_pos);
- }
-
- /* Print filename of this element's associated external entity.
- * Format: _filename */
- else if (StrEq(tok[0], "filename")) {
- if (!e->entity) {
- fprintf(stderr, "Expected ext entity (internal error? bug?):\n");
- PrintLocation(e, stderr);
- return;
- }
- if (!e->entity->fname) {
- fprintf(stderr, "Expected filename (internal error? bug?):\n");
- PrintLocation(e, stderr);
- return;
- }
- OutputString(e->entity->fname, fp, track_pos);
- }
-
- /* Value of parent's attribute, by attr name.
- * Format: _pattr attname */
- else if (StrEq(tok[0], "pattr")) {
- ep = e->parent;
- if (!ep) {
- fprintf(stderr, "Element does not have a parent:\n");
- PrintLocation(ep, stderr);
- return;
- }
- if ((atval = FindAttValByName(ep, tok[1]))) {
- OutputString(atval, fp, track_pos);
- }
- }
-
- /* Use an action, given transpec's SID.
- * Format: _action action */
- else if (StrEq(tok[0], "action")) {
- TranTByAction(e, tok[1], fp);
- }
-
- /* Number of child elements of this element.
- * Format: _nchild */
- else if (StrEq(tok[0], "nchild")) {
- if (ntok > 1) {
- for (n=0,i=0; i<e->necont; i++)
- if (StrEq(e->econt[i]->gi, tok[1])) n++;
- }
- else n = e->necont;
- sprintf(buf, "%d", n);
- OutputString(buf, fp, track_pos);
- }
-
- /* number of 1st child's child elements (grandchildren from first child).
- * Format: _n1gchild */
- else if (StrEq(tok[0], "n1gchild")) {
- if (e->necont) {
- sprintf(buf, "%d", e->econt[0]->necont);
- OutputString(buf, fp, track_pos);
- }
- }
-
- /* Chase this element's pointers until we hit the named GI.
- * Do the action if it matches.
- * Format: _chasetogi gi action */
- else if (StrEq(tok[0], "chasetogi")) {
- if (ntok < 3) {
- fprintf(stderr, "Error: Not enough args for _chasetogi.\n");
- return;
- }
- actioni = atoi(tok[2]);
- if (actioni) ChaseIDRefs(e, tok[1], tok[2], fp);
- }
-
- /* Follow link to element pointed to, then do action.
- * Format: _followlink [attname] action. */
- else if (StrEq(tok[0], "followlink")) {
- char **s;
- if (ntok > 2) {
- if ((atval = FindAttValByName(e, tok[1]))) {
- if ((ep = FindElemByID(atval))) {
- TranTByAction(ep, tok[2], fp);
- return;
- }
- }
- else fprintf(stderr, "Error: Did not find attr: %s.\n", tok[1]);
- return;
- }
- GetIDREFnames();
- for (s=idrefs; *s; s++) {
- /* is this IDREF attr set? */
- if ((atval = FindAttValByName(e, *s))) {
- ntok = 0;
- tok = Split(atval, &ntok, S_STRDUP);
- /* we'll follow the first one... */
- if ((ep = FindElemByID(tok[0]))) {
- TranTByAction(ep, tok[1], fp);
- return;
- }
- else fprintf(stderr, "Error: Can not find elem for ID: %s.\n",
- tok[0]);
- }
- }
- fprintf(stderr, "Error: Element does not have IDREF attribute set:\n");
- PrintLocation(e, stderr);
- return;
- }
-
- /* Starting at this element, decend tree (in-order), finding GI.
- * Do the action if it matches.
- * Format: _find args ... */
- else if (StrEq(tok[0], "find")) {
- Find(e, ntok, tok, fp);
- }
-
- /* Starting at this element's parent, decend tree (in-order), finding GI.
- * Do the action if it matches.
- * Format: _pfind args ... */
- else if (StrEq(tok[0], "pfind")) {
- Find(e->parent ? e->parent : e, ntok, tok, fp);
- }
-
- /* Content is supposed to be a list of IDREFs. Follow each, doing action.
- * If 2 actions are specified, use 1st for the 1st ID, 2nd for the rest.
- * Format: _namelist action [action2] */
- else if (StrEq(tok[0], "namelist")) {
- int id;
- action1 = tok[1];
- if (ntok > 2) action = tok[2];
- else action = action1;
- for (i=0; i<e->ndcont; i++) {
- n = 0;
- tok = Split(e->dcont[i], &n, S_STRDUP);
- for (id=0; id<n; id++) {
- if (fold_case)
- for (cp=tok[id]; *cp; cp++)
- if (islower(*cp)) *cp = toupper(*cp);
- if ((e = FindElemByID(tok[id]))) {
- if (id) TranTByAction(e, action, fp);
- else TranTByAction(e, action1, fp); /* first one */
- }
- else fprintf(stderr, "Error: Can not find ID: %s.\n", tok[id]);
- }
- }
- }
-
- /* For each word in the element's content, do action.
- * Format: _eachcon action [action] */
- else if (StrEq(tok[0], "eachcon")) {
- int id;
- action1 = tok[1];
- if (ntok > 3) action = tok[2];
- else action = action1;
- for (i=0; i<e->ndcont; i++) {
- n = 0;
- tok = Split(e->dcont[i], &n, S_STRDUP|S_ALVEC);
- for (id=0; id<n; id++) {
- each_C = tok[id];
- TranTByAction(e, action, fp);
- }
- free(*tok);
- }
- }
- /* For each word in the given attribute's value, do action.
- * Format: _eachatt attname action [action] */
- else if (StrEq(tok[0], "eachatt")) {
- int id;
- action1 = tok[2];
- if (ntok > 3) action = tok[3];
- else action = action1;
- if ((atval = FindAttValByName(e, tok[1]))) {
- n = 0;
- tok = Split(atval, &n, S_STRDUP|S_ALVEC);
- for (id=0; id<n; id++) {
- each_A = tok[id];
- if (id) TranTByAction(e, action, fp);
- else TranTByAction(e, action1, fp); /* first one */
- }
- free(*tok);
- }
- }
-
- /* Do action on this element if element has [relationship] with gi.
- * Format: _relation relationship gi action [action] */
- else if (StrEq(tok[0], "relation")) {
- if (ntok >= 4) {
- if (!CheckRelation(e, tok[1], tok[2], tok[3], fp, RA_Current)) {
- /* action not done, see if alt action specified */
- if (ntok >= 5)
- TranTByAction(e, tok[4], fp);
- }
- }
- }
-
- /* Do action on followed element if element has [relationship] with gi.
- * If [relationship] is not met, do alternate action on this element.
- * Format: _followrel relationship gi action [action] */
- else if (StrEq(tok[0], "followrel")) {
- if (ntok >= 4) {
- if (!CheckRelation(e, tok[1], tok[2], tok[3], fp, RA_Related)) {
- /* action not done, see if an alt action specified */
- if (ntok >= 5)
- TranTByAction(e, tok[4], fp);
- }
- }
- }
-
- /* Find element with matching ID and do action. If action not specified,
- * choose the right one appropriate for its context.
- * Format: _id id [action] */
- else if (StrEq(tok[0], "id")) {
- if ((ep = FindElemByID(tok[1]))) {
- if (ntok > 2) TranTByAction(ep, tok[2], fp);
- else {
- t = FindTrans(ep, 0);
- TransElement(ep, fp, t);
- }
- }
- }
-
- /* Set variable to value.
- * Format: _set name value */
- else if (StrEq(tok[0], "set")) {
- SetMappingNV(Variables, tok[1], tok[2]);
- }
-
- /* Do action if variable is set, optionally to value.
- * If not set, do nothing.
- * Format: _isset varname [value] action */
- else if (StrEq(tok[0], "isset")) {
- if ((cp = FindMappingVal(Variables, tok[1]))) {
- if (ntok == 3) TranTByAction(e, tok[2], fp);
- else if (ntok > 3 && !strcmp(cp, tok[2]))
- TranTByAction(e, tok[3], fp);
- }
- }
-
- /* Insert a node into the tree at start/end, pointing to action to perform.
- * Format: _insertnode S|E action */
- else if (StrEq(tok[0], "insertnode")) {
- actioni = atoi(tok[2]);
- if (*tok[1] == 'S') e->gen_trans[0] = actioni;
- else if (*tok[1] == 'E') e->gen_trans[1] = actioni;
- }
-
- /* Do an CALS DTD table spec for TeX or troff. Looks through attributes
- * and determines what to output. "check" means to check consistency,
- * and print error messages.
- * This is (hopefully) the only hard-coded part of instant.
- *
- * This was originally written for the OSF DTDs and recoded by FLD for
- * CALS tables (since no one will ever use the OSF tables). Although
- * TeX was addressed first, it seems that a fresh approach was required,
- * and so, tbl is the first to be really *fixed*. Once tbl is stable,
- * and there is a need for TeX again, that part will be recoded.
- *
- * *Obsolete* form (viz, for TeX):
- * Format: _calstable [clear|check|tex]
- * [cellstart|cellend|rowstart|rowend|top|bottom]
- *
- * New, good form:
- *
- * Format: _calstable [tbl]
- * [tablestart|tableend|tablegroup|tablefoot|rowstart|
- * rowend|entrystart|entryend]
- */
-
- else if (StrEq(tok[0], "calstable")) {
- CALStable(e, fp, tok, ntok);
- }
-
- /* Do action if element's attr is set, optionally to value.
- * If not set, do nothing.
- * Format: _attval att [value] action */
- else if (StrEq(tok[0], "attval")) {
- if ((atval = FindAttValByName(e, tok[1]))) {
- if (ntok == 3) TranTByAction(e, tok[2], fp);
- else if (ntok > 3 && !strcmp(atval, tok[2]))
- TranTByAction(e, tok[3], fp);
- }
- }
- /* Same thing, but look at parent */
- else if (StrEq(tok[0], "pattval")) {
- if ((atval = FindAttValByName(e->parent, tok[1]))) {
- if (ntok == 3) {
- TranTByAction(e, tok[2], fp);
- }
- if (ntok > 3 && !strcmp(atval, tok[2]))
- TranTByAction(e, tok[3], fp);
- }
- }
-
- /* Print each attribute and value for the current element, hopefully
- * in a legal sgml form: <elem-name att1="value1" att2="value2:> .
- * Format: _allatts */
- else if (StrEq(tok[0], "allatts")) {
- for (i=0; i<e->natts; i++) {
- if (i != 0) putc(' ', fp);
- fputs(e->atts[i].name, fp);
- fputs("=\"", fp);
- fputs(e->atts[i].sval, fp);
- putc('"', fp);
- }
- }
-
- /* Print the element's input filename, and optionally, the line number.
- * Format: _infile [line] */
- else if (StrEq(tok[0], "infile")) {
- if (e->infile) {
- if (ntok > 1 && !strcmp(tok[1], "root")) {
- strcpy(buf, e->infile);
- if ((cp = strrchr(buf, '.'))) *cp = EOS;
- fputs(buf, fp);
- }
- else {
- fputs(e->infile, fp);
- if (ntok > 1 && !strcmp(tok[1], "line"))
- fprintf(fp, " %d", e->lineno);
- }
- return;
- }
- else fputs("input-file??", fp);
- }
-
- /* Get value of an environement variable */
- else if (StrEq(tok[0], "env")) {
- if (ntok > 1 && (cp = getenv(tok[1]))) {
- OutputString(cp, fp, track_pos);
- }
- }
-
- /* If the element is not empty do specid.
- * Format: _notempty spec-id */
- else if (StrEq(tok[0], "notempty")) {
- if (ntok > 1 && e->ncont) {
- TranTByAction(e, tok[1], fp);
- }
- }
-
- /* Something unknown */
- else {
- fprintf(stderr, "Unknown special variable: %s\n", tok[0]);
- tt = e->trans;
- if (tt && tt->lineno)
- fprintf(stderr, "Used in transpec, line %d\n", tt->lineno);
- }
- return;
-}
-
-/* ______________________________________________________________________ */
-/* return the value for the special variables _A (last processed _eachatt)
- * and _C (last processed _eachcon)
- */
-
-char *
-Get_A_C_value(const char * name)
-{
- if ( !strcmp(name, "each_A") ) {
- if ( each_A ) {
- return each_A;
- } else {
- fprintf(stderr, "Requested value for unset _A variable\n");
- }
- } else
- if ( !strcmp(name, "each_C") ) {
- if ( each_C ) {
- return each_C;
- } else {
- fprintf(stderr, "Requested value for unset _C variable\n");
- }
- } else {
- fprintf(stderr, "Requested value for unknown special variable '%s'\n",
- name);
- }
- return "";
-}
-
-/* ______________________________________________________________________ */
-/* Chase IDs until we find an element whose GI matches. We also check
- * child element names, not just the names of elements directly pointed
- * at (by IDREF attributes).
- */
-
-void
-GetIDREFnames()
-{
- char *cp;
-
- if (!idrefs) {
- /* did user or transpec set the variable */
- if ((cp = FindMappingVal(Variables, "link_atts")))
- idrefs = Split(cp, 0, S_STRDUP|S_ALVEC);
- else
- idrefs = def_idrefs;
- }
-}
-
-/* ______________________________________________________________________ */
-/* Chase ID references - follow IDREF(s) attributes until we find
- * a GI named 'gi', then perform given action on that GI.
- * Arguments:
- * Pointer to element under consideration.
- * Name of GI we're looking for.
- * Spec ID of action to take.
- * FILE pointer to where to write output.
- */
-void
-ChaseIDRefs(
- Element_t *e,
- char *gi,
- char * action,
- FILE *fp
-)
-{
- int ntok, i, ei;
- char **tok, **s, *atval;
-
- /* First, see if we got what we came for with this element */
- if (StrEq(e->gi, gi)) {
- TranTByAction(e, action, fp);
- return;
- }
- GetIDREFnames();
-
- /* loop for each attribute of type IDREF(s) */
- for (s=idrefs; *s; s++) {
- /* is this IDREF attr set? */
- if ((atval = FindAttValByName(e, *s))) {
- ntok = 0;
- tok = Split(atval, &ntok, 0);
- for (i=0; i<ntok; i++) {
- /* get element pointed to */
- if ((e = FindElemByID(tok[i]))) {
- /* OK, we found a matching GI name */
- if (StrEq(e->gi, gi)) {
- /* process using named action */
- TranTByAction(e, action, fp);
- return;
- }
- else {
- /* this elem itself did not match, try its children */
- for (ei=0; ei<e->necont; ei++) {
- if (StrEq(e->econt[ei]->gi, gi)) {
- TranTByAction(e->econt[ei], action, fp);
- return;
- }
- }
- /* try this elem's IDREF attributes */
- ChaseIDRefs(e, gi, action, fp);
- return;
- }
- }
- else {
- /* should not happen, since parser checks ID/IDREFs */
- fprintf(stderr, "Error: Could not find ID %s\n", atval);
- return;
- }
- }
- }
- }
- /* if the pointers didn't lead to the GI, give error */
- if (!s)
- fprintf(stderr, "Error: Could not find '%s'\n", gi);
-}
-
-/* ______________________________________________________________________ */
-
-/* state to pass to recursive routines - so we don't have to use
- * global variables. */
-typedef struct {
- char *gi;
- char *gi2;
- char action[10];
- Element_t *elem;
- FILE *fp;
-} Descent_t;
-
-static void
-tr_find_gi(
- Element_t *e,
- Descent_t *ds
-)
-{
- if (StrEq(ds->gi, e->gi))
- if (ds->action[0]) TranTByAction(e, ds->action, ds->fp);
-}
-
-static void
-tr_find_gipar(
- Element_t *e,
- Descent_t *ds
-)
-{
- if (StrEq(ds->gi, e->gi) && e->parent &&
- StrEq(ds->gi2, e->parent->gi))
- if (ds->action[0]) TranTByAction(e, ds->action, ds->fp);
-}
-
-static void
-tr_find_attr(
- Element_t *e,
- Descent_t *ds
-)
-{
- char *atval;
- if ((atval = FindAttValByName(e, ds->gi)) && StrEq(ds->gi2, atval))
- TranTByAction(e, ds->action, ds->fp);
-}
-
-static void
-tr_find_parent(
- Element_t *e,
- Descent_t *ds
-)
-{
- if (QRelation(e, ds->gi, REL_Parent)) {
- if (ds->action[0]) TranTByAction(e, ds->action, ds->fp);
- }
-}
-
-/* ______________________________________________________________________ */
-/* Descend tree, finding elements that match criteria, then perform
- * given action.
- * Arguments:
- * Pointer to element under consideration.
- * Number of tokens in special variable.
- * Vector of tokens in special variable (eg, "find" "gi" "TITLE")
- * FILE pointer to where to write output.
- */
-void
-Find(
- Element_t *e,
- int ac,
- char **av,
- FILE *fp
-)
-{
- Descent_t DS; /* state passed to recursive routine */
-
- memset(&DS, 0, sizeof(Descent_t));
- DS.elem = e;
- DS.fp = fp;
-
- /* see if we should start at the top of instance tree */
- if (StrEq(av[1], "top")) {
- av++;
- ac--;
- e = DocTree;
- }
- if (ac < 4) {
- fprintf(stderr, "Bad '_find' specification - missing args.\n");
- return;
- }
- /* Find elem whose GI is av[2] */
- if (StrEq(av[1], "gi")) {
- DS.gi = av[2];
- strcpy(DS.action, av[3]);
- DescendTree(e, tr_find_gi, 0, 0, &DS);
- }
- /* Find elem whose GI is av[2] and whose parent GI is av[3] */
- else if (StrEq(av[1], "gi-parent")) {
- DS.gi = av[2];
- DS.gi2 = av[3];
- strcpy(DS.action, av[4]);
- DescendTree(e, tr_find_gipar, 0, 0, &DS);
- }
- /* Find elem whose parent GI is av[2] */
- else if (StrEq(av[0], "parent")) {
- DS.gi = av[2];
- strcpy(DS.action, av[3]);
- DescendTree(e, tr_find_parent, 0, 0, &DS);
- }
- /* Find elem whose attribute av[2] has value av[3] */
- else if (StrEq(av[0], "attr")) {
- DS.gi = av[2];
- DS.gi2 = av[3];
- strcpy(DS.action, av[4]);
- DescendTree(e, tr_find_attr, 0, 0, &DS);
- }
-}
-
-/* ______________________________________________________________________ */
-
diff --git a/usr.bin/sgmls/instant/util.c b/usr.bin/sgmls/instant/util.c
deleted file mode 100644
index eb6015d..0000000
--- a/usr.bin/sgmls/instant/util.c
+++ /dev/null
@@ -1,1109 +0,0 @@
-/*
- * Copyright 1993 Open Software Foundation, Inc., Cambridge, Massachusetts.
- * All rights reserved.
- */
-/*
- * Copyright (c) 1994
- * Open Software Foundation, Inc.
- *
- * Permission is hereby granted to use, copy, modify and freely distribute
- * the software in this file and its documentation for any purpose without
- * fee, provided that the above copyright notice appears in all copies and
- * that both the copyright notice and this permission notice appear in
- * supporting documentation. Further, provided that the name of Open
- * Software Foundation, Inc. ("OSF") not be used in advertising or
- * publicity pertaining to distribution of the software without prior
- * written permission from OSF. OSF makes no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- */
-/*
- * Copyright (c) 1996 X Consortium
- * Copyright (c) 1995, 1996 Dalrymple Consulting
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * X CONSORTIUM OR DALRYMPLE CONSULTING BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the names of the X Consortium and
- * Dalrymple Consulting shall not be used in advertising or otherwise to
- * promote the sale, use or other dealings in this Software without prior
- * written authorization.
- */
-/* ________________________________________________________________________
- *
- * General utility functions for 'instant' program. These are used
- * throughout the rest of the program.
- *
- * Entry points for this module:
- * Split(s, &n, flags) split string into n tokens
- * NewMap(slot_incr) create a new mapping structure
- * FindMapping(map, name) find mapping by name; return mapping
- * FindMappingVal(map, name) find mapping by name; return value
- * SetMapping(map, s) set mapping based on string
- * OpenFile(filename) open file, looking in inst path
- * FilePath(filename) find path to a file
- * FindElementPath(elem, s) find path to element
- * PrintLocation(ele, fp) print location of element in tree
- * NearestOlderElem(elem, name) find prev elem up tree with name
- * OutputString(s, fp, track_pos) output string
- * AddElemName(name) add elem to list of known elements
- * AddAttName(name) add att name to list of known atts
- * FindAttByName(elem, name) find an elem's att by name
- * FindContext(elem, lev, context) find context of elem
- * QRelation(elem, name, rel_flag) find relation elem has to named elem
- * DescendTree(elem, enter_f, leave_f, data_f, dp) descend doc tree,
- * calling functions for each elem/node
- * ________________________________________________________________________
- */
-
-#ifndef lint
-static char *RCSid =
- "$Header: /usr/src/docbook-to-man/Instant/RCS/util.c,v 1.4 1996/06/02 21:47:32 fld Exp $";
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <string.h>
-#include <memory.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/file.h>
-#include <errno.h>
-#include <regexp.h>
-/* CSS don't have it and I don't see where it's used
-#include <values.h>
-*/
-
-#include "general.h"
-#include "translate.h"
-
-/* ______________________________________________________________________ */
-/* "Split" a string into tokens. Given a string that has space-separated
- * (space/tab) tokens, return a pointer to an array of pointers to the
- * tokens. Like what the shell does with *argv[]. The array can be is
- * static or allocated. Space can be allocated for string, or allocated.
- * Arguments:
- * Pointer to string to pick apart.
- * Pointer to max number of tokens to find; actual number found is
- * returned. If 0 or null pointer, use a 'sane' maximum number (hard-
- * code). If more tokens than the number specified, make last token be
- * a single string composed of the rest of the tokens (includes spaces).
- * Flag. Bit 0 says whether to make a copy of input string (since we'll
- * clobber parts of it). To free the string, use the pointer to
- * the first token returned by the function (or *ret_value).
- * Bit 1 says whether to allocate the vector itself. If not, use
- * (and return) a static vector.
- * Return:
- * Pointer to the provided string (for convenience of caller).
- */
-
-char **
-Split(
- char *s, /* input string */
- int *ntok, /* # of tokens desired (input)/found (return) */
- int flag /* dup string? allocate a vector? */
-)
-{
- int maxnt, i=0;
- int n_alloc;
- char **tokens;
- static char *local_tokens[100];
-
- /* Figure max number of tokens (maxnt) to find. 0 means find them all. */
- if (ntok == NULL)
- maxnt = 100;
- else {
- if (*ntok <= 0 || *ntok > 100) maxnt = 100; /* arbitrary size */
- else maxnt = *ntok;
- *ntok = 0;
- }
-
- if (!s) return 0; /* no string */
-
- /* Point to 1st token (there may be initial space) */
- while (*s && IsWhite(*s)) s++; /* skip initial space, if any */
- if (*s == EOS) return 0; /* none found? */
-
- /* See if caller wants us to copy the input string. */
- if (flag & S_STRDUP) s = strdup(s);
-
- /* See if caller wants us to allocate the returned vector. */
- if (flag & S_ALVEC) {
- n_alloc = 20;
- Malloc(n_alloc, tokens, char *);
- /* if caller did not specify max tokens to find, set to more than
- * there will possibly ever be */
- if (!ntok || !(*ntok)) maxnt = 10000;
- }
- else tokens = local_tokens;
-
- i = 0; /* index into vector */
- tokens[0] = s; /* s already points to 1st token */
- while (i<maxnt) {
- tokens[i] = s; /* point vector member at start of token */
- i++;
- /* If we allocated vector, see if we need more space. */
- if ((flag & S_ALVEC) && i >= n_alloc) {
- n_alloc += 20;
- Realloc(n_alloc, tokens, char *);
- }
- if (i >= maxnt) break; /* is this the last one? */
- while (*s && !IsWhite(*s)) s++; /* skip past end of token */
- if (*s == EOS) break; /* at end of input string? */
- if (*s) *s++ = EOS; /* terminate token string */
- while (*s && IsWhite(*s)) s++; /* skip space - to next token */
- }
- if (ntok) *ntok = i; /* return number of tokens found */
- tokens[i] = 0; /* null-terminate vector */
- return tokens;
-}
-
-/* ______________________________________________________________________ */
-/* Mapping routines. These are used for name-value pairs, like attributes,
- * variables, and counters. A "Map" is an opaque data structure used
- * internally by these routines. The caller gets one when creating a new
- * map, then hands it to other routines that need it. A "Mapping" is a
- * name/value pair. The user has access to this.
- * Here's some sample usage:
- *
- * Map *V;
- * V = NewMap(20);
- * SetMappingNV(V, "home", "/users/bowe");
- * printf("Home: %s\n", FindMappingVal(V, "home");
- */
-
-/* Allocate new map structure. Only done once for each map/variable list.
- * Arg:
- * Number of initial slots to allocate space for. This is also the
- * "chunk size" - how much to allocate when we use up the given space.
- * Return:
- * Pointer to the (opaque) map structure. (User passes this to other
- * mapping routines.)
- */
-Map_t *
-NewMap(
- int slot_increment
-)
-{
- Map_t *M;
- Calloc(1, M, Map_t);
- /* should really do the memset's in Calloc/Malloc/Realloc
- macros, but that will have to wait until time permits -CSS */
- memset((char *)M, 0, sizeof(Map_t));
- if (!slot_increment) slot_increment = 1;
- M->slot_incr = slot_increment;
- return M;
-}
-
-/* Given pointer to a Map and a name, find the mapping.
- * Arguments:
- * Pointer to map structure (as returned by NewMap().
- * Variable name.
- * Return:
- * Pointer to the matching mapping structure, or null if not found.
- */
-Mapping_t *
-FindMapping(
- Map_t *M,
- const char *name
-)
-{
- int i;
- Mapping_t *m;
-
- if (!M || M->n_used == 0) return NULL;
- for (m=M->maps,i=0; i<M->n_used; i++)
- if (m[i].name[0] == name[0] && !strcmp(m[i].name, name)) return &m[i];
- return NULL;
-
-}
-
-/* Given pointer to a Map and a name, return string value of the mapping.
- * Arguments:
- * Pointer to map structure (as returned by NewMap().
- * Variable name.
- * Return:
- * Pointer to the value (string), or null if not found.
- */
-char *
-FindMappingVal(
- Map_t *M,
- const char *name
-)
-{
- Mapping_t *m;
-
- if ( !strcmp(name, "each_A") || !strcmp(name, "each_C") ) {
- return Get_A_C_value(name);
- }
-
- /*
- if (!M || M->n_used == 0) return NULL;
- if ((m = FindMapping(M, name))) return m->sval;
- return NULL;
- */
- if (!M || M->n_used == 0) {
- return NULL;
- }
- if ((m = FindMapping(M, name))) {
- return m->sval;
- }
- return NULL;
-
-}
-
-/* Set a mapping/variable in Map M. Input string is a name-value pair where
- * there is some amount of space after the name. The correct mapping is done.
- * Arguments:
- * Pointer to map structure (as returned by NewMap().
- * Pointer to variable name (string).
- * Pointer to variable value (string).
- */
-void
-SetMappingNV(
- Map_t *M,
- const char *name,
- const char *value
-)
-{
- FILE *pp;
- char buf[LINESIZE], *cp;
- int i;
- Mapping_t *m;
-
- /* First, look to see if it's a "well-known" variable. */
- if (!strcmp(name, "verbose")) { verbose = atoi(value); return; }
- if (!strcmp(name, "warnings")) { warnings = atoi(value); return; }
- if (!strcmp(name, "foldcase")) { fold_case = atoi(value); return; }
-
- m = FindMapping(M, name); /* find existing mapping (if set) */
-
- /* OK, we have a string mapping */
- if (m) { /* exists - just replace value */
- free(m->sval);
- if (value) m->sval = strdup(value);
- else m->sval = NULL;
- }
- else {
- if (name) { /* just in case */
- /* Need more slots for mapping structures? Allocate in clumps. */
- if (M->n_used == 0) {
- M->n_alloc = M->slot_incr;
- Malloc(M->n_alloc, M->maps, Mapping_t);
- }
- else if (M->n_used >= M->n_alloc) {
- M->n_alloc += M->slot_incr;
- Realloc(M->n_alloc, M->maps, Mapping_t);
- }
-
- m = &M->maps[M->n_used];
- M->n_used++;
- m->name = strdup(name);
- if (value) m->sval = strdup(value);
- else m->sval = NULL;
- }
- }
-
- if (value)
- {
- /* See if the value is a command to run. If so, run the command
- * and replace the value with the output.
- */
- if (*value == '!') {
- if ((pp = popen(value+1, "r"))) { /* run cmd, read its output */
- i = 0;
- cp = buf;
- while (fgets(cp, LINESIZE-i, pp)) {
- i += strlen(cp);
- cp = &buf[i];
- if (i >= LINESIZE) {
- fprintf(stderr,
- "Prog execution of variable '%s' too long.\n",
- m->name);
- break;
- }
- }
- free(m->sval);
- stripNL(buf);
- m->sval = strdup(buf);
- pclose(pp);
- }
- else {
- sprintf(buf, "Could not start program '%s'", value+1);
- perror(buf);
- }
- }
- }
-}
-
-/* Separate name and value from input string, then pass to SetMappingNV.
- * Arguments:
- * Pointer to map structure (as returned by NewMap().
- * Pointer to variable name and value (string), in form "name value".
- */
-void
-SetMapping(
- Map_t *M,
- const char *s
-)
-{
- char buf[LINESIZE];
- char *name, *val;
-
- if (!M) {
- fprintf(stderr, "SetMapping: Map not initialized.\n");
- return;
- }
- strcpy(buf, s);
- name = val = buf;
- while (*val && !IsWhite(*val)) val++; /* point past end of name */
- if (*val) {
- *val++ = EOS; /* terminate name */
- while (*val && IsWhite(*val)) val++; /* point to value */
- }
- if (name) SetMappingNV(M, name, val);
-}
-
-/* ______________________________________________________________________ */
-/* Opens a file for reading. If not found in current directory, try
- * lib directories (from TPT_LIB env variable, or -l option).
- * Arguments:
- * Filename (string).
- * Return:
- * FILE pointer to open file, or null if it not found or can't open.
- */
-
-FILE *
-OpenFile(
- char *filename
-)
-{
- FILE *fp;
-
- filename = FilePath(filename);
- if ((fp=fopen(filename, "r"))) return fp;
- return NULL;
-}
-
-/* ______________________________________________________________________ */
-/* Opens a file for reading. If not found in current directory, try
- * lib directories (from TPT_LIB env variable, or -l option).
- * Arguments:
- * Filename (string).
- * Return:
- * FILE pointer to open file, or null if it not found or can't open.
- */
-
-char *
-FilePath(
- char *filename
-)
-{
- FILE *fp;
- static char buf[LINESIZE];
- int i;
- static char **libdirs;
- static int nlibdirs = -1;
-
- if ((fp=fopen(filename, "r")))
- {
- fclose(fp);
- strncpy(buf, filename, LINESIZE);
- return buf;
- }
-
- if (*filename == '/') return NULL; /* full path specified? */
-
- if (nlibdirs < 0) {
- char *cp, *s;
- if (tpt_lib) {
- s = strdup(tpt_lib);
- for (cp=s; *cp; cp++) if (*cp == ':') *cp = ' ';
- nlibdirs = 0;
- libdirs = Split(s, &nlibdirs, S_ALVEC);
- }
- else nlibdirs = 0;
- }
- for (i=0; i<nlibdirs; i++) {
- sprintf(buf, "%s/%s", libdirs[i], filename);
- if ((fp=fopen(buf, "r")))
- {
- fclose(fp);
- return buf;
- }
- }
- return NULL;
-}
-
-/* ______________________________________________________________________ */
-/* This will find the path to an tag. The format is the:
- * tag1(n1):tag2(n2):tag3
- * where the tags are going down the tree and the numbers indicate which
- * child (the first is numbered 1) the next tag is.
- * Returns pointer to the string just written to (so you can use this
- * function as a printf arg).
- * Arguments:
- * Pointer to element under consideration.
- * String to write path into (provided by caller).
- * Return:
- * Pointer to the provided string (for convenience of caller).
- */
-char *
-FindElementPath(
- Element_t *e,
- char *s
-)
-{
- Element_t *ep;
- int i, e_path[MAX_DEPTH];
- char *cp;
-
- /* Move up the tree, noting "birth order" of each element encountered */
- for (ep=e; ep; ep=ep->parent)
- e_path[ep->depth-1] = ep->my_eorder;
- /* Move down the tree, printing the element names to the string. */
- for (cp=s,i=0,ep=DocTree; i<e->depth; ep=ep->econt[e_path[i]],i++) {
- sprintf(cp, "%s(%d) ", ep->gi, e_path[i]);
- cp += strlen(cp);
- }
- sprintf(cp, "%s", e->gi);
- return s;
-}
-
-/* ______________________________________________________________________ */
-/* Print some location info about a tag. Helps user locate error.
- * Messages are indented 2 spaces (convention for multi-line messages).
- * Arguments:
- * Pointer to element under consideration.
- * FILE pointer of where to print.
- */
-
-void
-PrintLocation(
- Element_t *e,
- FILE *fp
-)
-{
- char *s, buf[LINESIZE];
-
- if (!e || !fp) return;
- fprintf(fp, " Path: %s\n", FindElementPath(e, buf));
- if ((s=NearestOlderElem(e, "TITLE")))
- fprintf(fp, " Position hint: TITLE='%s'\n", s);
- if (e->lineno) {
- if (e->infile)
- fprintf(fp, " At or near instance file: %s, line: %d\n",
- e->infile, e->lineno);
- else
- fprintf(fp, " At or near instance line: %d\n", e->lineno);
- }
- if (e->id)
- fprintf(fp, " ID: %s\n", e->id);
-}
-
-/* ______________________________________________________________________ */
-/* Finds the data part of the nearest "older" tag (up the tree, and
- * preceding) whose tag name matches the argument, or "TITLE", if null.
- * Returns a pointer to the first chunk of character data.
- * Arguments:
- * Pointer to element under consideration.
- * Name (GI) of element we'll return data from.
- * Return:
- * Pointer to that element's data content.
- */
-char *
-NearestOlderElem(
- Element_t *e,
- char *name
-)
-{
- int i;
- Element_t *ep;
-
- if (!e) return 0;
- if (!name) name = "TITLE"; /* useful default */
-
- for (; e->parent; e=e->parent) /* move up tree */
- for (i=0; i<=e->my_eorder; i++) { /* check preceding sibs */
- ep = e->parent;
- if (!strcmp(name, ep->econt[i]->gi))
- return ep->econt[i]->ndcont ?
- ep->econt[i]->dcont[0] : "-empty-";
- }
-
- return NULL;
-}
-
-/* ______________________________________________________________________ */
-/* Expands escaped strings in the input buffer (things like tabs, newlines,
- * octal characters - using C style escapes).
- */
-
-char *ExpandString(
- char *s
-)
-{
- char c, *sdata, *cp, *ns;
- int len, pos, addn;
-
- if (!s) return s;
-
- len = strlen(s);
- pos = 0;
- Malloc(len + 1, ns, char);
- ns[pos] = EOS;
-
- for ( ; *s; s++) {
- c = *s;
- cp = NULL;
-
- /* Check for escaped characters from sgmls. */
- if (*s == '\\') {
- s++;
- switch (*s) {
- case 'n':
- c = NL;
- break;
-
- case '\\':
- c = '\\';
- break;
-
- case '0': case '1': case '2': case '3':
- case '4': case '5': case '6': case '7':
- /* for octal numbers (C style) of the form \012 */
- c = *s++ - '0';
- if (*s >= '0' && *s <= '7') {
- c = c * 8 + (*s++ - '0');
- if (*s >= '0' && *s <= '7')
- c = c * 8 + (*s - '0');
- }
- break;
-
- case '|': /* SDATA */
- s++; /* point past \| */
- sdata = s;
- /* find matching/closing \| */
- cp = s;
- while (*cp && *cp != '\\' && cp[1] != '|')
- cp++;
- if (!*cp)
- break;
-
- *cp = EOS; /* terminate sdata string */
- cp++;
- s = cp; /* s now points to | */
-
- cp = LookupSDATA(sdata);
- if (!cp)
- cp = sdata;
- c = 0;
- break;
-
- /* This shouldn't happen. */
- default:
- s--;
- break;
- }
- }
-
- /* Check for character re-mappings. */
- if (nCharMap && c) {
- int i;
-
- for (i = 0; i < nCharMap; i++) {
- if (c != CharMap[i].name[0])
- continue;
- cp = CharMap[i].sval;
- c = 0;
- break;
- }
- }
-
- /* See if there is enough space for the data. */
- /* XXX this should be MUCH smarter about predicting
- how much extra memory it should allocate */
- if (c)
- addn = 1;
- else
- addn = strlen(cp);
-
- /* If not, make some. */
- if (addn > len - pos) {
- len += addn - (len - pos);
- Realloc(len + 1, ns, char);
- }
-
- /* Then copy the data. */
- if (c)
- ns[pos] = c;
- else
- strcpy(&ns[pos], cp);
-
- pos += addn;
- ns[pos] = EOS;
- }
- return(ns);
-}
-
-/* ______________________________________________________________________ */
-/* Expands escaped strings in the input buffer (things like tabs, newlines,
- * octal characters - using C style escapes) and outputs buffer to specified
- * fp. The hat/anchor character forces that position to appear at the
- * beginning of a line. The cursor position is kept track of (optionally)
- * so that this can be done.
- * Arguments:
- * Pointer to element under consideration.
- * FILE pointer of where to print.
- * Flag saying whether or not to keep track of our position in the output
- * stream. (We want to when writing to a file, but not for stderr.)
- */
-
-void
-OutputString(
- char *s,
- FILE *fp,
- int track_pos
-)
-{
- char c;
- static int char_pos = 0; /* remembers our character position */
- char *p;
-
- if (!fp) return;
- if (!s) s = "^"; /* no string - go to start of line */
-
- for (p = s; *p; p++) {
- c = *p;
- /* If caller wants us to track position, see if it's an anchor
- * (ie, align at a newline). */
- if (track_pos) {
- if (c == ANCHOR && (p == s || *(p + 1) == EOS)) {
- /* If we're already at the start of a line, don't do
- * another newline. */
- if (char_pos != 0) c = NL;
- else c = 0;
- }
- else char_pos++;
- if (c == NL) char_pos = 0;
- }
- else if (c == ANCHOR && (p == s || *(p + 1) == EOS)) c = NL;
- if (c) putc(c, fp);
- }
-}
-
-/* ______________________________________________________________________ */
-/* Figure out value of SDATA entity.
- * We rememeber lookup hits in a "cache" (a shorter list), and look in
- * cache before general list. Typically there will be LOTS of entries
- * in the general list and only a handful in the hit list. Often, if an
- * entity is used once, it'll be used again.
- * Arguments:
- * Pointer to SDATA entity token in ESIS.
- * Return:
- * Mapped value of the SDATA entity.
- */
-
-char *
-LookupSDATA(
- char *s
-)
-{
- char *v;
- static Map_t *Hits; /* remember lookup hits */
-
- /* If we have a hit list, check it. */
- if (Hits) {
- if ((v = FindMappingVal(Hits, s))) return v;
- }
-
- v = FindMappingVal(SDATAmap, s);
-
- /* If mapping found, remember it, then return it. */
- if ((v = FindMappingVal(SDATAmap, s))) {
- if (!Hits) Hits = NewMap(IMS_sdatacache);
- SetMappingNV(Hits, s, v);
- return v;
- }
-
- fprintf(stderr, "Error: Could not find SDATA substitution '%s'.\n", s);
- return NULL;
-}
-
-/* ______________________________________________________________________ */
-/* Add tag 'name' of length 'len' to list of tag names (if not there).
- * This is a list of null-terminated strings so that we don't have to
- * keep using the name length.
- * Arguments:
- * Pointer to element name (GI) to remember.
- * Return:
- * Pointer to the SAVED element name (GI).
- */
-
-char *
-AddElemName(
- char *name
-)
-{
- int i;
- static int n_alloc=0; /* number of slots allocated so far */
-
- /* See if it's already in the list. */
- for (i=0; i<nUsedElem; i++)
- if (UsedElem[i][0] == name[0] && !strcmp(UsedElem[i], name))
- return UsedElem[i];
-
- /* Allocate slots in blocks of N, so we don't have to call malloc
- * so many times. */
- if (n_alloc == 0) {
- n_alloc = IMS_elemnames;
- Calloc(n_alloc, UsedElem, char *);
- }
- else if (nUsedElem >= n_alloc) {
- n_alloc += IMS_elemnames;
- Realloc(n_alloc, UsedElem, char *);
- }
- UsedElem[nUsedElem] = strdup(name);
- return UsedElem[nUsedElem++];
-}
-/* ______________________________________________________________________ */
-/* Add attrib name to list of attrib names (if not there).
- * This is a list of null-terminated strings so that we don't have to
- * keep using the name length.
- * Arguments:
- * Pointer to attr name to remember.
- * Return:
- * Pointer to the SAVED attr name.
- */
-
-char *
-AddAttName(
- char *name
-)
-{
- int i;
- static int n_alloc=0; /* number of slots allocated so far */
-
- /* See if it's already in the list. */
- for (i=0; i<nUsedAtt; i++)
- if (UsedAtt[i][0] == name[0] && !strcmp(UsedAtt[i], name))
- return UsedAtt[i];
-
- /* Allocate slots in blocks of N, so we don't have to call malloc
- * so many times. */
- if (n_alloc == 0) {
- n_alloc = IMS_attnames;
- Calloc(n_alloc, UsedAtt, char *);
- }
- else if (nUsedAtt >= n_alloc) {
- n_alloc += IMS_attnames;
- Realloc(n_alloc, UsedAtt, char *);
- }
- UsedAtt[nUsedAtt] = strdup(name);
- return UsedAtt[nUsedAtt++];
-}
-
-/* ______________________________________________________________________ */
-/* Find an element's attribute value given element pointer and attr name.
- * Typical use:
- * a=FindAttByName("TYPE", t);
- * do something with a->val;
- * Arguments:
- * Pointer to element under consideration.
- * Pointer to attribute name.
- * Return:
- * Pointer to the value of the attribute.
- */
-
-/*
-Mapping_t *
-FindAttByName(
- Element_t *e,
- char *name
-)
-{
- int i;
- if (!e) return NULL;
- for (i=0; i<e->natts; i++)
- if (e->atts[i].name[0] == name[0] && !strcmp(e->atts[i].name, name))
- return &(e->atts[i]);
- return NULL;
-}
-*/
-
-char *
-FindAttValByName(
- Element_t *e,
- char *name
-)
-{
- int i;
- if (!e) return NULL;
- for (i=0; i<e->natts; i++)
- if (e->atts[i].name[0] == name[0] && !strcmp(e->atts[i].name, name))
- return e->atts[i].sval;
- return NULL;
-}
-
-/* ______________________________________________________________________ */
-/* Find context of a tag, 'levels' levels up the tree.
- * Space for string is passed by caller.
- * Arguments:
- * Pointer to element under consideration.
- * Number of levels to look up tree.
- * String to write path into (provided by caller).
- * Return:
- * Pointer to the provided string (for convenience of caller).
- */
-
-char *
-FindContext(
- Element_t *e,
- int levels,
- char *con
-)
-{
- char *s;
- Element_t *ep;
- int i;
-
- if (!e) return NULL;
- s = con;
- *s = EOS;
- for (i=0,ep=e->parent; ep && levels; ep=ep->parent,i++,levels--) {
- if (i != 0) *s++ = ' ';
- strcpy(s, ep->gi);
- s += strlen(s);
- }
- return con;
-}
-
-
-/* ______________________________________________________________________ */
-/* Tests relationship (specified by argument/flag) between given element
- * (structure pointer) and named element.
- * Returns pointer to matching tag if found, null otherwise.
- * Arguments:
- * Pointer to element under consideration.
- * Pointer to name of elem whose relationsip we are trying to determine.
- * Relationship we are testing.
- * Return:
- * Pointer to the provided string (for convenience of caller).
- */
-
-Element_t *
-QRelation(
- Element_t *e,
- char *s,
- Relation_t rel
-)
-{
- int i;
- Element_t *ep;
-
- if (!e) return 0;
-
- /* we'll call e the "given element" */
- switch (rel)
- {
- case REL_Parent:
- if (!e->parent || !e->parent->gi) return 0;
- if (!strcmp(e->parent->gi, s)) return e->parent;
- break;
- case REL_Child:
- for (i=0; i<e->necont; i++)
- if (!strcmp(s, e->econt[i]->gi)) return e->econt[i];
- break;
- case REL_Ancestor:
- if (!e->parent || !e->parent->gi) return 0;
- for (ep=e->parent; ep; ep=ep->parent)
- if (!strcmp(ep->gi, s)) return ep;
- break;
- case REL_Descendant:
- if (e->necont == 0) return 0;
- /* check immediate children first */
- for (i=0; i<e->necont; i++)
- if (!strcmp(s, e->econt[i]->gi)) return e->econt[i];
- /* then children's children (recursively) */
- for (i=0; i<e->necont; i++)
- if ((ep=QRelation(e->econt[i], s, REL_Descendant)))
- return ep;
- break;
- case REL_Sibling:
- if (!e->parent) return 0;
- ep = e->parent;
- for (i=0; i<ep->necont; i++)
- if (!strcmp(s, ep->econt[i]->gi) && i != e->my_eorder)
- return ep->econt[i];
- break;
- case REL_Preceding:
- if (!e->parent || e->my_eorder == 0) return 0;
- ep = e->parent;
- for (i=0; i<e->my_eorder; i++)
- if (!strcmp(s, ep->econt[i]->gi)) return ep->econt[i];
- break;
- case REL_ImmPreceding:
- if (!e->parent || e->my_eorder == 0) return 0;
- ep = e->parent->econt[e->my_eorder-1];
- if (!strcmp(s, ep->gi)) return ep;
- break;
- case REL_Following:
- if (!e->parent || e->my_eorder == (e->parent->necont-1))
- return 0; /* last? */
- ep = e->parent;
- for (i=(e->my_eorder+1); i<ep->necont; i++)
- if (!strcmp(s, ep->econt[i]->gi)) return ep->econt[i];
- break;
- case REL_ImmFollowing:
- if (!e->parent || e->my_eorder == (e->parent->necont-1))
- return 0; /* last? */
- ep = e->parent->econt[e->my_eorder+1];
- if (!strcmp(s, ep->gi)) return ep;
- break;
- case REL_Cousin:
- if (!e->parent) return 0;
- /* Now, see if element's parent has that thing as a child. */
- return QRelation(e->parent, s, REL_Child);
- break;
- case REL_None:
- case REL_Unknown:
- fprintf(stderr, "You can not query 'REL_None' or 'REL_Unknown'.\n");
- break;
- }
- return NULL;
-}
-
-/* Given a relationship name (string), determine enum symbol for it.
- * Arguments:
- * Pointer to relationship name.
- * Return:
- * Relation_t enum.
- */
-Relation_t
-FindRelByName(
- char *relname
-)
-{
- if (!strcmp(relname, "?")) {
- fprintf(stderr, "Supported query/relationships %s\n%s.\n",
- "child, parent, ancestor, descendant,",
- "sibling, sibling+, sibling+1, sibling-, sibling-1");
- return REL_None;
- }
- else if (StrEq(relname, "child")) return REL_Child;
- else if (StrEq(relname, "parent")) return REL_Parent;
- else if (StrEq(relname, "ancestor")) return REL_Ancestor;
- else if (StrEq(relname, "descendant")) return REL_Descendant;
- else if (StrEq(relname, "sibling")) return REL_Sibling;
- else if (StrEq(relname, "sibling-")) return REL_Preceding;
- else if (StrEq(relname, "sibling-1")) return REL_ImmPreceding;
- else if (StrEq(relname, "sibling+")) return REL_Following;
- else if (StrEq(relname, "sibling+1")) return REL_ImmFollowing;
- else if (StrEq(relname, "cousin")) return REL_Cousin;
- else fprintf(stderr, "Unknown relationship: %s\n", relname);
- return REL_Unknown;
-}
-
-/* ______________________________________________________________________ */
-/* This will descend the element tree in-order. (enter_f)() is called
- * upon entering the node. Then all children (data and child elements)
- * are operated on, calling either DescendTree() with a pointer to
- * the child element or (data_f)() for each non-element child node.
- * Before leaving the node (ascending), (leave_f)() is called. enter_f
- * and leave_f are passed a pointer to this node and data_f is passed
- * a pointer to the data/content (which includes the data itself and
- * type information). dp is an opaque pointer to any data the caller
- * wants to pass.
- * Arguments:
- * Pointer to element under consideration.
- * Pointer to procedure to call when entering element.
- * Pointer to procedure to call when leaving element.
- * Pointer to procedure to call for each "chunk" of content data.
- * Void data pointer, passed to the avobe 3 procedures.
- */
-
-void
-DescendTree(
- Element_t *e,
- void (*enter_f)(),
- void (*leave_f)(),
- void (*data_f)(),
- void *dp
-)
-{
- int i;
- if (enter_f) (enter_f)(e, dp);
- for (i=0; i<e->ncont; i++) {
- if (e->cont[i].type == CMD_OPEN)
- DescendTree(e->cont[i].ch.elem, enter_f, leave_f, data_f, dp);
- else
- if (data_f) (data_f)(&e->cont[i], dp);
- }
- if (leave_f) (leave_f)(e, dp);
-}
-
-/* ______________________________________________________________________ */
-/* Add element, 'e', whose ID is 'idval', to a list of IDs.
- * This makes it easier to find an element by ID later.
- * Arguments:
- * Pointer to element under consideration.
- * Element's ID attribute value (a string).
- */
-
-void
-AddID(
- Element_t *e,
- char *idval
-)
-{
- static ID_t *id_last;
-
- if (!IDList) {
- Malloc(1, id_last, ID_t);
- IDList = id_last;
- }
- else {
- Malloc(1, id_last->next, ID_t);
- id_last = id_last->next;
- }
- id_last->elem = e;
- id_last->id = idval;
-}
-
-/* ______________________________________________________________________ */
-/* Return pointer to element who's ID is given.
- * Arguments:
- * Element's ID attribute value (a string).
- * Return:
- * Pointer to element whose ID matches.
- */
-
-Element_t *
-FindElemByID(
- char *idval
-)
-{
- ID_t *id;
- for (id=IDList; id; id=id->next)
- if (id->id[0] == idval[0] && !strcmp(id->id, idval)) return id->elem;
- return 0;
-}
-
-/* ______________________________________________________________________ */
-
diff --git a/usr.bin/sgmls/libsgmls/Makefile b/usr.bin/sgmls/libsgmls/Makefile
deleted file mode 100644
index 0d058f3..0000000
--- a/usr.bin/sgmls/libsgmls/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-#
-# Bmakefile for libsgmls
-#
-# $Id$
-#
-
-LIB= sgmls
-SRCS= sgmls.c
-
-CFLAGS+= -I${.CURDIR}/../sgmls
-
-NOMAN= noman
-NOPROFILE= noprofile
-
-install:
-
-.include <bsd.lib.mk>
diff --git a/usr.bin/sgmls/libsgmls/sgmls.c b/usr.bin/sgmls/libsgmls/sgmls.c
deleted file mode 100644
index 4e25957..0000000
--- a/usr.bin/sgmls/libsgmls/sgmls.c
+++ /dev/null
@@ -1,1032 +0,0 @@
-/* sgmls.c:
- Library for reading output of sgmls.
-
- Written by James Clark (jjc@jclark.com). */
-
-#include "config.h"
-#include "std.h"
-#include "sgmls.h"
-#include "lineout.h"
-
-#ifdef USE_PROTOTYPES
-#define P(parms) parms
-#else
-#define P(parms) ()
-#endif
-
-typedef struct sgmls_data data_s;
-typedef struct sgmls_notation notation_s;
-typedef struct sgmls_internal_entity internal_entity_s;
-typedef struct sgmls_external_entity external_entity_s;
-typedef struct sgmls_entity entity_s;
-typedef struct sgmls_attribute attribute_s;
-typedef struct sgmls_event event_s;
-
-/* lists are sorted in reverse order of level */
-struct list {
- int subdoc_level; /* -1 if associated with finished subdoc */
- struct list *next;
- char *name;
-};
-
-struct entity_list {
- int subdoc_level;
- struct entity_list *next;
- entity_s entity;
-};
-
-struct notation_list {
- int subdoc_level;
- struct notation_list *next;
- notation_s notation;
-};
-
-struct sgmls {
- FILE *fp;
- char *buf;
- unsigned buf_size;
- struct entity_list *entities;
- struct notation_list *notations;
- attribute_s *attributes;
- unsigned long lineno;
- char *filename;
- unsigned filename_size;
- unsigned long input_lineno;
- int subdoc_level;
- char **files; /* from `f' commands */
- int nfiles;
- char *sysid; /* from `s' command */
- char *pubid; /* from `p' command */
-};
-
-enum error_code {
- E_ZERO, /* Not an error */
- E_NOMEM, /* Out of memory */
- E_BADESCAPE, /* Bad escape */
- E_NULESCAPE, /* \000 other than in data */
- E_NUL, /* A null input character */
- E_BADENTITY, /* Reference to undefined entity */
- E_INTERNALENTITY, /* Internal entity when external was needed */
- E_SYSTEM, /* System input error */
- E_COMMAND, /* Bad command letter */
- E_MISSING, /* Missing arguments */
- E_NUMBER, /* Not a number */
- E_ATTR, /* Bad attribute type */
- E_BADNOTATION, /* Reference to undefined notation */
- E_BADINTERNAL, /* Bad internal entity type */
- E_BADEXTERNAL, /* Bad external entity type */
- E_EOF, /* EOF in middle of line */
- E_SDATA, /* \| other than in data */
- E_LINELENGTH /* line longer than UNSIGNED_MAX */
-};
-
-static char *errlist[] = {
- 0,
- "Out of memory",
- "Bad escape",
- "\\0 escape not in data",
- "Nul character in input",
- "Reference to undefined entity",
- "Internal entity when external was needed",
- "System input error",
- "Bad command letter",
- "Missing arguments",
- "Not a number",
- "Bad attribute type",
- "Reference to undefined notation",
- "Bad internal entity type",
- "Bad external entity type",
- "EOF in middle of line",
- "\\| other than in data",
- "Too many V commands",
- "Input line too long"
-};
-
-static void error P((enum error_code));
-static int parse_data P((char *, unsigned long *));
-static void parse_location P((char *, struct sgmls *));
-static void parse_notation P((char *, notation_s *));
-static void parse_internal_entity P((char *, internal_entity_s *));
-static void parse_external_entity
- P((char *, struct sgmls *, external_entity_s *));
-static void parse_subdoc_entity P((char *, external_entity_s *));
-static attribute_s *parse_attribute P((struct sgmls *, char *));
-static void grow_datav P((void));
-static char *unescape P((char *));
-static char *unescape_file P((char *));
-static int unescape1 P((char *));
-static char *scan_token P((char **));
-static int count_args P((char *));
-static struct list *list_find P((struct list *, char *, int));
-static UNIV xmalloc P((unsigned));
-static UNIV xrealloc P((UNIV , unsigned));
-static char *strsave P((char *));
-static int read_line P((struct sgmls *));
-static notation_s *lookup_notation P((struct sgmls *, char *));
-static entity_s *lookup_entity P((struct sgmls *, char *));
-static external_entity_s *lookup_external_entity P((struct sgmls *, char *));
-static void define_external_entity P((struct sgmls *, external_entity_s *));
-static void define_internal_entity P((struct sgmls *, internal_entity_s *));
-static void define_notation P((struct sgmls *, notation_s *));
-static data_s *copy_data P((data_s *, int));
-static void list_finish_level P((struct list **, int));
-static void add_attribute P((attribute_s **, attribute_s *));
-static void default_errhandler P((int, char *, unsigned long));
-
-#define xfree(s) do { if (s) free(s); } while (0)
-
-static sgmls_errhandler *errhandler = default_errhandler;
-static unsigned long input_lineno = 0;
-
-static data_s *datav = 0;
-static int datav_size = 0;
-
-struct sgmls *sgmls_create(fp)
- FILE *fp;
-{
- struct sgmls *sp;
-
- sp = (struct sgmls *)malloc(sizeof(struct sgmls));
- if (!sp)
- return 0;
- sp->fp = fp;
- sp->entities = 0;
- sp->notations = 0;
- sp->attributes = 0;
- sp->lineno = 0;
- sp->filename = 0;
- sp->filename_size = 0;
- sp->input_lineno = 0;
- sp->buf_size = 0;
- sp->buf = 0;
- sp->subdoc_level = 0;
- sp->files = 0;
- sp->nfiles = 0;
- sp->sysid = 0;
- sp->pubid = 0;
- return sp;
-}
-
-void sgmls_free(sp)
- struct sgmls *sp;
-{
- struct entity_list *ep;
- struct notation_list *np;
-
- if (!sp)
- return;
- xfree(sp->filename);
- sgmls_free_attributes(sp->attributes);
-
- for (ep = sp->entities; ep;) {
- struct entity_list *tem = ep->next;
- if (ep->entity.is_internal) {
- xfree(ep->entity.u.internal.data.s);
- free(ep->entity.u.internal.name);
- }
- else {
- int i;
- for (i = 0; i < ep->entity.u.external.nfilenames; i++)
- xfree(ep->entity.u.external.filenames[i]);
- xfree(ep->entity.u.external.filenames);
- xfree(ep->entity.u.external.sysid);
- xfree(ep->entity.u.external.pubid);
- sgmls_free_attributes(ep->entity.u.external.attributes);
- free(ep->entity.u.internal.name);
- }
- free(ep);
- ep = tem;
- }
-
- for (np = sp->notations; np;) {
- struct notation_list *tem = np->next;
- xfree(np->notation.sysid);
- xfree(np->notation.pubid);
- free(np->notation.name);
- free(np);
- np = tem;
- }
-
- xfree(sp->buf);
- xfree(sp->pubid);
- xfree(sp->sysid);
- if (sp->files) {
- int i;
- for (i = 0; i < sp->nfiles; i++)
- free(sp->files[i]);
- free(sp->files);
- }
- free(sp);
-
- xfree(datav);
- datav = 0;
- datav_size = 0;
-}
-
-sgmls_errhandler *sgmls_set_errhandler(handler)
- sgmls_errhandler *handler;
-{
- sgmls_errhandler *old = errhandler;
- if (handler)
- errhandler = handler;
- return old;
-}
-
-int sgmls_next(sp, e)
- struct sgmls *sp;
- event_s *e;
-{
- while (read_line(sp)) {
- char *buf = sp->buf;
-
- e->filename = sp->filename;
- e->lineno = sp->lineno;
-
- switch (buf[0]) {
- case DATA_CODE:
- e->u.data.n = parse_data(buf + 1, &sp->lineno);
- e->u.data.v = datav;
- e->type = SGMLS_EVENT_DATA;
- return 1;
- case START_CODE:
- {
- char *p;
- e->u.start.attributes = sp->attributes;
- sp->attributes = 0;
- e->type = SGMLS_EVENT_START;
- p = buf + 1;
- e->u.start.gi = scan_token(&p);
- return 1;
- }
- case END_CODE:
- {
- char *p = buf + 1;
- e->type = SGMLS_EVENT_END;
- e->u.end.gi = scan_token(&p);
- return 1;
- }
- case START_SUBDOC_CODE:
- case END_SUBDOC_CODE:
- {
- char *p = buf + 1;
- char *name = scan_token(&p);
- if (buf[0] == START_SUBDOC_CODE) {
- e->u.entity = lookup_external_entity(sp, name);
- sp->subdoc_level++;
- e->type = SGMLS_EVENT_SUBSTART;
- }
- else {
- e->type = SGMLS_EVENT_SUBEND;
- list_finish_level((struct list **)&sp->entities, sp->subdoc_level);
- list_finish_level((struct list **)&sp->notations, sp->subdoc_level);
- sp->subdoc_level--;
- e->u.entity = lookup_external_entity(sp, name);
- }
- return 1;
- }
- case ATTRIBUTE_CODE:
- add_attribute(&sp->attributes, parse_attribute(sp, buf + 1));
- break;
- case DATA_ATTRIBUTE_CODE:
- {
- char *p = buf + 1;
- char *name;
- attribute_s *a;
- external_entity_s *ext;
-
- name = scan_token(&p);
- a = parse_attribute(sp, p);
- ext = lookup_external_entity(sp, name);
- add_attribute(&ext->attributes, a);
- }
- break;
- case REFERENCE_ENTITY_CODE:
- {
- char *p = buf + 1;
- char *name;
- name = scan_token(&p);
- e->u.entity = lookup_external_entity(sp, name);
- e->type = SGMLS_EVENT_ENTITY;
- return 1;
- }
- case DEFINE_NOTATION_CODE:
- {
- notation_s notation;
-
- parse_notation(buf + 1, &notation);
- define_notation(sp, &notation);
- }
- break;
- case DEFINE_EXTERNAL_ENTITY_CODE:
- {
- external_entity_s external;
-
- parse_external_entity(buf + 1, sp, &external);
- define_external_entity(sp, &external);
- }
- break;
- case DEFINE_SUBDOC_ENTITY_CODE:
- {
- external_entity_s external;
-
- parse_subdoc_entity(buf + 1, &external);
- define_external_entity(sp, &external);
- }
- break;
- case DEFINE_INTERNAL_ENTITY_CODE:
- {
- internal_entity_s internal;
-
- parse_internal_entity(buf + 1, &internal);
- define_internal_entity(sp, &internal);
- }
- break;
- case PI_CODE:
- e->u.pi.len = unescape1(buf + 1);
- e->u.pi.s = buf + 1;
- e->type = SGMLS_EVENT_PI;
- return 1;
- case LOCATION_CODE:
- parse_location(buf + 1, sp);
- break;
- case APPINFO_CODE:
- e->u.appinfo = unescape(buf + 1);
- e->type = SGMLS_EVENT_APPINFO;
- return 1;
- case SYSID_CODE:
- sp->sysid = strsave(unescape(buf + 1));
- break;
- case PUBID_CODE:
- sp->pubid = strsave(unescape(buf + 1));
- break;
- case FILE_CODE:
- sp->files = xrealloc(sp->files, (sp->nfiles + 1)*sizeof(char *));
- sp->files[sp->nfiles] = strsave(unescape_file(buf + 1));
- sp->nfiles += 1;
- break;
- case CONFORMING_CODE:
- e->type = SGMLS_EVENT_CONFORMING;
- return 1;
- default:
- error(E_COMMAND);
- }
- }
-
- return 0;
-}
-
-static
-int parse_data(p, linenop)
- char *p;
- unsigned long *linenop;
-{
- int n = 0;
- char *start = p;
- char *q;
- int is_sdata = 0;
-
- /* No need to copy before first escape. */
-
- for (; *p != '\\' && *p != '\0'; p++)
- ;
- q = p;
- while (*p) {
- if (*p == '\\') {
- switch (*++p) {
- case '\\':
- *q++ = *p++;
- break;
- case 'n':
- *q++ = RECHAR;
- *linenop += 1;
- p++;
- break;
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- {
- int val = *p++ - '0';
- if (*p >= '0' && *p <= '7') {
- val = val*8 + (*p++ - '0');
- if (*p >= '0' && *p <= '7')
- val = val*8 + (*p++ - '0');
- }
- *q++ = (char)val;
- }
- break;
- case '|':
- if (q > start || is_sdata) {
- if (n >= datav_size)
- grow_datav();
- datav[n].s = start;
- datav[n].len = q - start;
- datav[n].is_sdata = is_sdata;
- n++;
- }
- is_sdata = !is_sdata;
- start = q;
- p++;
- break;
- default:
- error(E_BADESCAPE);
- }
- }
- else
- *q++ = *p++;
- }
-
- if (q > start || is_sdata) {
- if (n >= datav_size)
- grow_datav();
- datav[n].s = start;
- datav[n].len = q - start;
- datav[n].is_sdata = is_sdata;
- n++;
- }
- return n;
-}
-
-static
-void grow_datav()
-{
- unsigned size = datav_size ? 2*datav_size : 2;
- datav = (data_s *)xrealloc((UNIV)datav, size*sizeof(data_s));
- datav_size = size;
-}
-
-static
-void parse_location(s, sp)
- char *s;
- struct sgmls *sp;
-{
- unsigned size;
-
- if (*s < '0' || *s > '9' || sscanf(s, "%lu", &sp->lineno) != 1)
- error(E_NUMBER);
- do {
- ++s;
- } while (*s >= '0' && *s <= '9');
-
- if (*s != ' ')
- return;
- s++;
- s = unescape_file(s);
- size = strlen(s) + 1;
- if (size <= sp->filename_size)
- strcpy(sp->filename, s);
- else {
- sp->filename = xrealloc(sp->filename, size);
- strcpy(sp->filename, s);
- sp->filename_size = size;
- }
-}
-
-static
-void parse_notation(s, n)
- char *s;
- notation_s *n;
-{
- n->name = strsave(scan_token(&s));
-}
-
-static
-void parse_internal_entity(s, e)
- char *s;
- internal_entity_s *e;
-{
- char *type;
-
- e->name = strsave(scan_token(&s));
- type = scan_token(&s);
- if (strcmp(type, "CDATA") == 0)
- e->data.is_sdata = 0;
- else if (strcmp(type, "SDATA") == 0)
- e->data.is_sdata = 1;
- else
- error(E_BADINTERNAL);
- e->data.len = unescape1(s);
- if (e->data.len == 0)
- e->data.s = 0;
- else {
- e->data.s = xmalloc(e->data.len);
- memcpy(e->data.s, s, e->data.len);
- }
-}
-
-static
-void parse_external_entity(s, sp, e)
- char *s;
- struct sgmls *sp;
- external_entity_s *e;
-{
- char *type;
- char *notation;
-
- e->name = strsave(scan_token(&s));
- type = scan_token(&s);
- if (strcmp(type, "CDATA") == 0)
- e->type = SGMLS_ENTITY_CDATA;
- else if (strcmp(type, "SDATA") == 0)
- e->type = SGMLS_ENTITY_SDATA;
- else if (strcmp(type, "NDATA") == 0)
- e->type = SGMLS_ENTITY_NDATA;
- else
- error(E_BADEXTERNAL);
- notation = scan_token(&s);
- e->notation = lookup_notation(sp, notation);
-}
-
-static
-void parse_subdoc_entity(s, e)
- char *s;
- external_entity_s *e;
-{
- e->name = strsave(scan_token(&s));
- e->type = SGMLS_ENTITY_SUBDOC;
-}
-
-static
-attribute_s *parse_attribute(sp, s)
- struct sgmls *sp;
- char *s;
-{
- attribute_s *a;
- char *type;
-
- a = (attribute_s *)xmalloc(sizeof(*a));
- a->name = strsave(scan_token(&s));
- type = scan_token(&s);
- if (strcmp(type, "CDATA") == 0) {
- unsigned long lineno = 0;
- a->type = SGMLS_ATTR_CDATA;
- a->value.data.n = parse_data(s, &lineno);
- a->value.data.v = copy_data(datav, a->value.data.n);
- }
- else if (strcmp(type, "IMPLIED") == 0) {
- a->type = SGMLS_ATTR_IMPLIED;
- }
- else if (strcmp(type, "NOTATION") == 0) {
- a->type = SGMLS_ATTR_NOTATION;
- a->value.notation = lookup_notation(sp, scan_token(&s));
- }
- else if (strcmp(type, "ENTITY") == 0) {
- int n, i;
- a->type = SGMLS_ATTR_ENTITY;
- n = count_args(s);
- if (n == 0)
- error(E_MISSING);
- a->value.entity.v = (entity_s **)xmalloc(n*sizeof(entity_s *));
- a->value.entity.n = n;
- for (i = 0; i < n; i++)
- a->value.entity.v[i] = lookup_entity(sp, scan_token(&s));
- }
- else if (strcmp(type, "TOKEN") == 0) {
- int n, i;
- a->type = SGMLS_ATTR_TOKEN;
- n = count_args(s);
- if (n == 0)
- error(E_MISSING);
- a->value.token.v = (char **)xmalloc(n * sizeof(char *));
- for (i = 0; i < n; i++)
- a->value.token.v[i] = strsave(scan_token(&s));
- a->value.token.n = n;
- }
- else
- error(E_ATTR);
- return a;
-}
-
-void sgmls_free_attributes(p)
- attribute_s *p;
-{
- while (p) {
- attribute_s *nextp = p->next;
- switch (p->type) {
- case SGMLS_ATTR_CDATA:
- if (p->value.data.v) {
- free(p->value.data.v[0].s);
- free(p->value.data.v);
- }
- break;
- case SGMLS_ATTR_TOKEN:
- {
- int i;
- for (i = 0; i < p->value.token.n; i++)
- free(p->value.token.v[i]);
- xfree(p->value.token.v);
- }
- break;
- case SGMLS_ATTR_ENTITY:
- xfree(p->value.entity.v);
- break;
- case SGMLS_ATTR_IMPLIED:
- case SGMLS_ATTR_NOTATION:
- break;
- }
- free(p->name);
- free(p);
- p = nextp;
- }
-}
-
-static
-data_s *copy_data(v, n)
- data_s *v;
- int n;
-{
- if (n == 0)
- return 0;
- else {
- int i;
- unsigned total;
- char *p;
- data_s *result;
-
- result = (data_s *)xmalloc(n*sizeof(data_s));
- total = 0;
- for (i = 0; i < n; i++)
- total += v[i].len;
- if (!total)
- total++;
- p = xmalloc(total);
- for (i = 0; i < n; i++) {
- result[i].s = p;
- memcpy(result[i].s, v[i].s, v[i].len);
- result[i].len = v[i].len;
- p += v[i].len;
- result[i].is_sdata = v[i].is_sdata;
- }
- return result;
- }
-}
-
-/* Unescape s, and return nul-terminated data. Give an error
-if the data contains 0. */
-
-static
-char *unescape(s)
- char *s;
-{
- int len = unescape1(s);
- if (
-#ifdef __BORLANDC__
- len > 0 &&
-#endif
- memchr(s, '\0', len))
- error(E_NULESCAPE);
- s[len] = '\0';
- return s;
-}
-
-/* Like unescape(), but REs are represented by 012 not 015. */
-
-static
-char *unescape_file(s)
- char *s;
-{
- char *p;
- p = s = unescape(s);
- while ((p = strchr(p, RECHAR)) != 0)
- *p++ = '\n';
- return s;
-
-}
-
-/* Unescape s, and return length of data. The data may contain 0. */
-
-static
-int unescape1(s)
- char *s;
-{
- const char *p;
- char *q;
-
- q = strchr(s, '\\');
- if (!q)
- return strlen(s);
- p = q;
- while (*p) {
- if (*p == '\\') {
- switch (*++p) {
- case '\\':
- *q++ = *p++;
- break;
- case 'n':
- *q++ = RECHAR;
- p++;
- break;
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- {
- int val = *p++ - '0';
- if (*p >= '0' && *p <= '7') {
- val = val*8 + (*p++ - '0');
- if (*p >= '0' && *p <= '7')
- val = val*8 + (*p++ - '0');
- }
- *q++ = (char)val;
- }
- break;
- case '|':
- error(E_SDATA);
- default:
- error(E_BADESCAPE);
- }
- }
- else
- *q++ = *p++;
- }
- return q - s;
-}
-
-static
-char *scan_token(pp)
- char **pp;
-{
- char *start = *pp;
- while (**pp != '\0') {
- if (**pp == ' ') {
- **pp = '\0';
- *pp += 1;
- break;
- }
- *pp += 1;
- }
- if (!*start)
- error(E_MISSING);
- return start;
-}
-
-static
-int count_args(p)
- char *p;
-{
- int n = 0;
-
- while (*p != '\0') {
- n++;
- do {
- ++p;
- if (*p == ' ') {
- p++;
- break;
- }
- } while (*p != '\0');
- }
- return n;
-}
-
-static
-int read_line(sp)
- struct sgmls *sp;
-{
- unsigned i = 0;
- FILE *fp = sp->fp;
- int c;
- char *buf = sp->buf;
- unsigned buf_size = sp->buf_size;
-
- c = getc(fp);
- if (c == EOF) {
- input_lineno = sp->input_lineno;
- if (ferror(fp))
- error(E_SYSTEM);
- return 0;
- }
-
- sp->input_lineno++;
- input_lineno = sp->input_lineno;
- for (;;) {
- if (i >= buf_size) {
- if (buf_size == 0)
- buf_size = 24;
- else if (buf_size > (unsigned)UINT_MAX/2) {
- if (buf_size == (unsigned)UINT_MAX)
- error(E_LINELENGTH);
- buf_size = (unsigned)UINT_MAX;
- }
- else
- buf_size *= 2;
- buf = xrealloc(buf, buf_size);
- sp->buf = buf;
- sp->buf_size = buf_size;
- }
- if (c == '\0')
- error(E_NUL);
- if (c == '\n') {
- buf[i] = '\0';
- break;
- }
- buf[i++] = c;
- c = getc(fp);
- if (c == EOF) {
- if (ferror(fp))
- error(E_SYSTEM);
- else
- error(E_EOF);
- }
- }
- return 1;
-}
-
-static
-notation_s *lookup_notation(sp, name)
-struct sgmls *sp;
-char *name;
-{
- struct notation_list *p
- = (struct notation_list *)list_find((struct list *)sp->notations, name,
- sp->subdoc_level);
- if (!p)
- error(E_BADNOTATION);
- return &p->notation;
-}
-
-static
-entity_s *lookup_entity(sp, name)
-struct sgmls *sp;
-char *name;
-{
- struct entity_list *p
- = (struct entity_list *)list_find((struct list *)sp->entities, name,
- sp->subdoc_level);
- if (!p)
- error(E_BADENTITY);
- return &p->entity;
-}
-
-static
-external_entity_s *lookup_external_entity(sp, name)
-struct sgmls *sp;
-char *name;
-{
- entity_s *p = lookup_entity(sp, name);
- if (p->is_internal)
- error(E_INTERNALENTITY);
- return &p->u.external;
-}
-
-static
-void define_external_entity(sp, e)
-struct sgmls *sp;
-external_entity_s *e;
-{
- struct entity_list *p;
- e->attributes = 0;
- e->filenames = sp->files;
- e->nfilenames = sp->nfiles;
- sp->files = 0;
- sp->nfiles = 0;
- e->pubid = sp->pubid;
- sp->pubid = 0;
- e->sysid = sp->sysid;
- sp->sysid = 0;
- p = (struct entity_list *)xmalloc(sizeof(struct entity_list));
- memcpy((UNIV)&p->entity.u.external, (UNIV)e, sizeof(*e));
- p->entity.is_internal = 0;
- p->subdoc_level = sp->subdoc_level;
- p->next = sp->entities;
- sp->entities = p;
-}
-
-static
-void define_internal_entity(sp, e)
-struct sgmls *sp;
-internal_entity_s *e;
-{
- struct entity_list *p;
- p = (struct entity_list *)xmalloc(sizeof(struct entity_list));
- memcpy((UNIV)&p->entity.u.internal, (UNIV)e, sizeof(*e));
- p->entity.is_internal = 1;
- p->subdoc_level = sp->subdoc_level;
- p->next = sp->entities;
- sp->entities = p;
-}
-
-static
-void define_notation(sp, np)
-struct sgmls *sp;
-notation_s *np;
-{
- struct notation_list *p;
- np->sysid = sp->sysid;
- sp->sysid = 0;
- np->pubid = sp->pubid;
- sp->pubid = 0;
- p = (struct notation_list *)xmalloc(sizeof(struct notation_list));
- memcpy((UNIV)&p->notation, (UNIV)np, sizeof(*np));
- p->subdoc_level = sp->subdoc_level;
- p->next = sp->notations;
- sp->notations = p;
-}
-
-static
-struct list *list_find(p, name, level)
- struct list *p;
- char *name;
- int level;
-{
- for (; p && p->subdoc_level == level; p = p->next)
- if (strcmp(p->name, name) == 0)
- return p;
- return 0;
-}
-
-/* Move all the items in the list whose subdoc level is level to the
-end of the list and make their subdoc_level -1. */
-
-static
-void list_finish_level(listp, level)
- struct list **listp;
- int level;
-{
- struct list **pp, *next_level, *old_level;
- for (pp = listp; *pp && (*pp)->subdoc_level == level; pp = &(*pp)->next)
- (*pp)->subdoc_level = -1;
- next_level = *pp;
- *pp = 0;
- old_level = *listp;
- *listp = next_level;
- for (pp = listp; *pp; pp = &(*pp)->next)
- ;
- *pp = old_level;
-}
-
-static
-void add_attribute(pp, a)
- attribute_s **pp, *a;
-{
-#if 0
- for (; *pp && strcmp((*pp)->name, a->name) < 0; pp = &(*pp)->next)
- ;
-#endif
- a->next = *pp;
- *pp = a;
-}
-
-
-static
-char *strsave(s)
-char *s;
-{
- if (!s)
- return s;
- else {
- char *p = xmalloc(strlen(s) + 1);
- strcpy(p, s);
- return p;
- }
-}
-
-static
-UNIV xmalloc(n)
- unsigned n;
-{
- UNIV p = malloc(n);
- if (!p)
- error(E_NOMEM);
- return p;
-}
-
-/* ANSI C says first argument to realloc can be NULL, but not everybody
- appears to support this. */
-
-static
-UNIV xrealloc(p, n)
- UNIV p;
- unsigned n;
-{
- p = p ? realloc(p, n) : malloc(n);
- if (!p)
- error(E_NOMEM);
- return p;
-}
-
-static
-void error(num)
- enum error_code num;
-{
- (*errhandler)((int)num, errlist[num], input_lineno);
- abort();
-}
-
-static
-void default_errhandler(num, msg, lineno)
- int num;
- char *msg;
- unsigned long lineno;
-{
- fprintf(stderr, "Line %lu: %s\n", lineno, msg);
- exit(1);
-}
diff --git a/usr.bin/sgmls/libsgmls/sgmls.h b/usr.bin/sgmls/libsgmls/sgmls.h
deleted file mode 100644
index 79b2658..0000000
--- a/usr.bin/sgmls/libsgmls/sgmls.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/* sgmls.h
- Interface to a library for reading output of sgmls. */
-
-struct sgmls_data {
- char *s;
- unsigned len;
- char is_sdata;
-};
-
-struct sgmls_notation {
- char *name;
- char *sysid;
- char *pubid;
-};
-
-struct sgmls_internal_entity {
- char *name;
- struct sgmls_data data;
-};
-
-enum sgmls_external_entity_type {
- SGMLS_ENTITY_CDATA,
- SGMLS_ENTITY_SDATA,
- SGMLS_ENTITY_NDATA,
- SGMLS_ENTITY_SUBDOC
- };
-
-struct sgmls_external_entity {
- char *name;
- enum sgmls_external_entity_type type;
- char **filenames;
- int nfilenames;
- char *pubid;
- char *sysid;
- struct sgmls_attribute *attributes;
- struct sgmls_notation *notation;
-};
-
-struct sgmls_entity {
- union {
- struct sgmls_internal_entity internal;
- struct sgmls_external_entity external;
- } u;
- char is_internal;
-};
-
-enum sgmls_attribute_type {
- SGMLS_ATTR_IMPLIED,
- SGMLS_ATTR_CDATA,
- SGMLS_ATTR_TOKEN,
- SGMLS_ATTR_ENTITY,
- SGMLS_ATTR_NOTATION
-};
-
-struct sgmls_attribute {
- struct sgmls_attribute *next;
- char *name;
- enum sgmls_attribute_type type;
- union {
- struct {
- struct sgmls_data *v;
- int n;
- } data;
- struct {
- struct sgmls_entity **v;
- int n;
- } entity;
- struct {
- char **v;
- int n;
- } token;
- struct sgmls_notation *notation;
- } value;
-};
-
-enum sgmls_event_type {
- SGMLS_EVENT_DATA, /* data */
- SGMLS_EVENT_ENTITY, /* external entity reference */
- SGMLS_EVENT_PI, /* processing instruction */
- SGMLS_EVENT_START, /* element start */
- SGMLS_EVENT_END, /* element end */
- SGMLS_EVENT_SUBSTART, /* subdocument start */
- SGMLS_EVENT_SUBEND, /* subdocument end */
- SGMLS_EVENT_APPINFO, /* appinfo */
- SGMLS_EVENT_CONFORMING /* the document was conforming */
- };
-
-struct sgmls_event {
- enum sgmls_event_type type;
- union {
- struct {
- struct sgmls_data *v;
- int n;
- } data;
- struct sgmls_external_entity *entity;
- struct {
- char *s;
- unsigned len;
- } pi;
- struct {
- char *gi;
- struct sgmls_attribute *attributes;
- } start;
- struct {
- char *gi;
- } end;
- char *appinfo;
- } u;
- char *filename; /* SGML filename */
- unsigned long lineno; /* SGML lineno */
-};
-
-#ifdef __STDC__
-void sgmls_free_attributes(struct sgmls_attribute *);
-struct sgmls *sgmls_create(FILE *);
-int sgmls_next(struct sgmls *, struct sgmls_event *);
-void sgmls_free(struct sgmls *);
-typedef void sgmls_errhandler(int, char *, unsigned long);
-sgmls_errhandler *sgmls_set_errhandler(sgmls_errhandler *);
-#else /* not __STDC__ */
-void sgmls_free_attributes();
-struct sgmls *sgmls_create();
-int sgmls_next();
-void sgmls_free();
-typedef void sgmls_errhandler();
-sgmls_errhandler *sgmls_set_errhandler();
-#endif /* not __STDC__ */
diff --git a/usr.bin/sgmls/sgmls.pl b/usr.bin/sgmls/sgmls.pl
deleted file mode 100755
index edb9eb6..0000000
--- a/usr.bin/sgmls/sgmls.pl
+++ /dev/null
@@ -1,247 +0,0 @@
-#! /usr/bin/perl
-
-# This is a skeleton of a perl script for processing the output of
-# sgmls. You must change the parts marked with "XXX".
-
-# XXX This is for troff: in data, turn \ into \e (which prints as \).
-# Backslashes in SDATA entities are left as backslashes.
-
-$backslash_in_data = "\\e";
-
-$prog = $0;
-
-$prog =~ s|.*/||;
-
-$level = 0;
-
-while (<STDIN>) {
- chop;
- $command = substr($_, 0, 1);
- substr($_, 0, 1) = "";
- if ($command eq '(') {
- &start_element($_);
- $level++;
- }
- elsif ($command eq ')') {
- $level--;
- &end_element($_);
- foreach $key (keys %attribute_value) {
- @splitkey = split($;, $key);
- if ($splitkey[0] == $level) {
- delete $attribute_value{$key};
- delete $attribute_type{$key};
- }
- }
- }
- elsif ($command eq '-') {
- &unescape_data($_);
- &data($_);
- }
- elsif ($command eq 'A') {
- @field = split(/ /, $_, 3);
- $attribute_type{$level,$field[0]} = $field[1];
- &unescape_data($field[2]);
- $attribute_value{$level,$field[0]} = $field[2];
- }
- elsif ($command eq '&') {
- &entity($_);
- }
- elsif ($command eq 'D') {
- @field = split(/ /, $_, 4);
- $data_attribute_type{$field[0], $field[1]} = $field[2];
- &unescape_data($field[3]);
- $data_attribute_value{$field[0], $field[1]} = $field[3];
- }
- elsif ($command eq 'N') {
- $notation{$_} = 1;
- if (defined($sysid)) {
- $notation_sysid{$_} = $sysid;
- undef($sysid);
- }
- if (defined($pubid)) {
- $notation_pubid{$_} = $pubid;
- undef($pubid);
- }
- }
- elsif ($command eq 'I') {
- @field = split(/ /, $_, 3);
- $entity_type{$field[0]} = $field[1];
- &unescape($field[2]);
- # You may want to substitute \e for \ if the type is CDATA.
- $entity_text{$field[0]} = $field[2];
- $entity_code{$field[0]} = 'I';
- }
- elsif ($command eq 'E') {
- @field = split(/ /, $_);
- $entity_code{$field[0]} = 'E';
- $entity_type{$field[0]} = $field[1];
- $entity_notation{$field[0]} = $field[2];
- if (defined(@files)) {
- foreach $i (0..$#files) {
- $entity_filename{$field[0], $i} = $files[i];
- }
- undef(@files);
- }
- if (defined($sysid)) {
- $entity_sysid{$field[0]} = $sysid;
- undef($sysid);
- }
- if (defined($pubid)) {
- $entity_pubid{$field[0]} = $pubid;
- undef($pubid);
- }
- }
- elsif ($command eq 'S') {
- $entity_code{$_} = 'S';
- if (defined(@files)) {
- foreach $i (0..$#files) {
- $entity_filename{$_, $i} = $files[i];
- }
- undef(@files);
- }
- if (defined($sysid)) {
- $entity_sysid{$_} = $sysid;
- undef($sysid);
- }
- if (defined($pubid)) {
- $entity_pubid{$_} = $pubid;
- undef($pubid);
- }
- }
- elsif ($command eq '?') {
- &unescape($_);
- &pi($_);
- }
- elsif ($command eq 'L') {
- @field = split(/ /, $_);
- $lineno = $field[0];
- if ($#field >= 1) {
- &unescape($field[1]);
- $filename = $field[1];
- }
- }
- elsif ($command eq 'V') {
- @field = split(/ /, $_, 2);
- &unescape($field[1]);
- $environment{$field[0]} = $field[1];
- }
- elsif ($command eq '{') {
- &start_subdoc($_);
- }
- elsif ($command eq '}') {
- &end_subdoc($_);
- }
- elsif ($command eq 'f') {
- &unescape($_);
- push(@files, $_);
- }
- elsif ($command eq 'p') {
- &unescape($_);
- $pubid = $_;
- }
- elsif ($command eq 's') {
- &unescape($_);
- $sysid = $_;
- }
- elsif ($command eq 'C') {
- $conforming = 1;
- }
- else {
- warn "$prog:$ARGV:$.: unrecognized command \`$command'\n";
- }
-}
-
-sub unescape {
- $_[0] =~ s/\\([0-7][0-7]?[0-7]?|.)/&esc($1)/eg;
-}
-
-sub esc {
- local($_) = $_[0];
- if ($_ eq '012' || $_ eq '12') {
- ""; # ignore RS
- }
- elsif (/^[0-7]/) {
- sprintf("%c", oct);
- }
- elsif ($_ eq 'n') {
- "\n";
- }
- elsif ($_ eq '|') {
- "";
- }
- elsif ($_ eq "\\") {
- "\\";
- }
- else {
- $_;
- }
-}
-
-sub unescape_data {
- local($sdata) = 0;
- $_[0] =~ s/\\([0-7][0-7]?[0-7]?|.)/&esc_data($1)/eg;
-}
-
-sub esc_data {
- local($_) = $_[0];
- if ($_ eq '012' || $_ eq '12') {
- ""; # ignore RS
- }
- elsif (/^[0-7]/) {
- sprintf("%c", oct);
- }
- elsif ($_ eq 'n') {
- "\n";
- }
- elsif ($_ eq '|') {
- $sdata = !$sdata;
- "";
- }
- elsif ($_ eq "\\") {
- $sdata ? "\\" : $backslash_in_data;
- }
- else {
- $_;
- }
-}
-
-
-sub start_element {
- local($gi) = $_[0];
- # XXX
-}
-
-sub end_element {
- local($gi) = $_[0];
- # XXX
-}
-
-sub data {
- local($data) = $_[0];
- # XXX
-}
-
-# A processing instruction.
-
-sub pi {
- local($data) = $_[0];
- # XXX
-}
-
-# A reference to an external entity.
-
-sub entity {
- local($name) = $_[0];
- # XXX
-}
-
-sub start_subdoc {
- local($name) = $_[0];
- # XXX
-}
-
-sub end_subdoc {
- local($name) = $_[0];
- # XXX
-}
-
diff --git a/usr.bin/sgmls/sgmls/Makefile b/usr.bin/sgmls/sgmls/Makefile
deleted file mode 100644
index b46e9f6..0000000
--- a/usr.bin/sgmls/sgmls/Makefile
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Bmakefile for sgmls
-#
-# $Id$
-#
-
-PROG= sgmls
-
-SRCS= lexrf.c pcbrf.c synrf.c context.c md1.c md2.c pars1.c pars2.c serv.c
-SRCS+= sgml1.c sgml2.c sgmlmsg.c sgmlxtrn.c traceset.c entgen.c sgmlio.c
-SRCS+= xfprintf.c main.c unixproc.c sgmldecl.c version.c strerror.c getopt.c
-SRCS+= lineout.c ambig.c lextaba.c catalog.c
-
-CFLAGS+= -I${.CURDIR}/../libsgmls
-
-.include "../Makefile.inc"
-.include <bsd.prog.mk>
-
-
diff --git a/usr.bin/sgmls/sgmls/action.h b/usr.bin/sgmls/sgmls/action.h
deleted file mode 100644
index 03bf478..0000000
--- a/usr.bin/sgmls/sgmls/action.h
+++ /dev/null
@@ -1,180 +0,0 @@
-/* ACTION.H: Symbols for all PCB action codes. */
-/* CONACT.H: Symbols for content parse action names (end with '_').
- There must be no conflict with PARSEACT.H, which
- uses 0 through 19, or SGMLACT.H, which uses 20 through 32
- (except that 31 - 32 can be defined here because they are
- used only by PARSEPRO and do not conflict with SGML.C).
-*/
-#define CIR_ 31 /* Invalid character(s) ignored in MDS; restarting parse. */
-#define DTD_ 32 /* Process DOCTYPE declaration. */
-#define DTE_ 33 /* End of DOCTYPE declaration. */
-#define PEP_ 34 /* TEMP: Previous character ended prolog. */
-#define DAS_ 35 /* Current character begins data. */
-#define FCE_ 36 /* Process free character (SR12-18, 21-30). */
-#define DCE_ 37 /* Data character in element text; change PCB. */
-#define LAS_ 38 /* Start lookahead buffer with current character. */
-#define LAM_ 39 /* Move character to lookahead buffer. */
-#define LAF_ 40 /* Flush the lookahead buffer; REPEATCC. */
-#define NED_ 41 /* Process null end-tag delimiter. */
-#define NET_ 42 /* Process null end-tag. */
-#define NST_ 43 /* Process null start-tag. */
-#define NLF_ 44 /* Flush lookahead buffer except for trailing NET or SR. */
-#define ETC_ 45 /* End-tag in CDATA or RCDATA; treat as data if invalid. */
-#define SRMIN 46 /* Dummy for SHORT REFERENCES: srn = SRn - SRMIN. */
-#define SR1_ 47 /* TAB */
-#define SR2_ 48 /* RE */
-#define SR3_ 49 /* RS */
-#define SR4_ 50 /* Leading blanks */
-#define SR5_ 51 /* Null record */
-#define DAR_ 52 /* Flush data buffer after repeating current character. */
-#define SR7_ 53 /* Trailing blanks */
-#define SR8_ 54 /* Space */
-#define SR9_ 55 /* Two or more blanks */
-#define SR10 56 /* Quotation mark (first data character) */
-#define SR11 57 /* Number sign */
-#define SR12 58 /* FCE CHARACTERS start here */
-/* _ 59 */
-#define BSQ_ 60 /* Blank sequence begun; find its end. */
-/* 61 In use by PARSEACT.H */
-/* 62 In use by PARSEACT.H */
-/* 63 In use by PARSEACT.H */
-/* 64 In use by PARSEACT.H */
-#define SR19 65 /* Hyphen */
-#define SR20 66 /* Two hyphens */
-#define SR25 71 /* Left bracket */
-#define SR26 72 /* Right bracket */
-#define RBR_ 73 /* Two right brackets. */
-#define GTR_ 74 /* EOB with pending data character */
-#define MSP_ 75 /* Marked section start in prolog outside DTD */
-#define APP_ 76 /* APPINFO (other than NONE) */
-#define STE_ 77 /* Start tag ended prolog */
-#define ETE_ 78 /* End tag ended prolog */
-
-/* GRPACT.H: Symbols for group tokenization action names (all alpha).
- There must be no conflict with PARSEACT.H, which
- uses 0 - 19.
-*/
-#define AND 20 /* AND connector found. */
-#define DTAG 21 /* Data tag token group occurred (treat as #CHARS). */
-#define GRPE 22 /* Group ended. */
-#define GRP_ 23 /* Group started. */
-#define NAS_ 24 /* Name started in content model or name group. */
-#define NMT_ 25 /* Name or name token started in name token group. */
-#define OPT 26 /* OPT occurrence indicator for previous token. */
-#define OR 27 /* OR connector found. */
-#define OREP 28 /* OREP occurrence indicator for previous token. */
-#define REP 29 /* REP occurrence indicator for previous token. */
-#define RNS_ 30 /* Reserved name started (#PCDATA). */
-#define SEQ 31 /* SEQ connector found. */
-/* LITACT.H: Symbols for content parse action names (end with '_').
- There must be no conflict with PARSEACT.H, which
- uses 0 through 19.
-*/
-#define MLA_ 20 /* Move character to look-aside data buffer. */
-#define LPR_ 21 /* Move previous character to data buffer. */
-#define RSM_ 22 /* Process record start and move it to data buffer. */
-#define FUN_ 23 /* Replace function character with a space. */
-#define LP2_ 24 /* Move previous two characters to data buffer. */
-#define MLE_ 25 /* Minimum literal error: invalid character ignored. */
-#define RPR_ 26 /* Remove previous character from data buffer; terminate. */
-#define TER_ 27 /* Terminate the parse. */
-/* MDACT.H: Symbols for markup declaration parse action names (all alpha).
- There must be no conflict with PARSEACT.H, which
- uses 0 - 19.
-*/
-#define CDR 20 /* CD[1] (MINUS) occurred previously. */
-#define EMD 21 /* End of markup declaration. */
-#define GRPS 22 /* Group started. */
-#define LIT 23 /* Literal started: character data. */
-#define LITE 24 /* Literal started: character data; LITA is delimiter. */
-#define MGRP 25 /* Minus exception group (MINUS,GRPO). */
-#define NAS 26 /* Name started. */
-#define NMT 27 /* Name token started. */
-#define NUM 28 /* Number or number token started. */
-#define PEN 29 /* Parameter entity name being defined (PERO found). */
-#define PGRP 30 /* Plus exception group (PLUS,GRPO). */
-#define RNS 31 /* Reserved name started. */
-#define MDS 32 /* Markup declaration subset start. */
-#define PENR 33 /* REPEATCC; PERO found. */
-/* PARSEACT.H: Symbols for common parse action names (end with '_').
- There must be no conflict with other action name
- files, which use numbers greater than 19.
-*/
-#define CRA_ 1 /* Character reference: alphabetic. */
-#define CRN_ 2 /* Character reference: numeric; non-char refs o.k.. */
-#define NON_ 3 /* Single byte of non-character data found. */
-#define EOF_ 4 /* Error: illegal entity end; resume old input; return. */
-#define ER_ 5 /* Entity reference; start new input source; continue. */
-#define GET_ 6 /* EOB, EOS, or EE: resume old input source; continue. */
-#define INV_ 7 /* Error: invalid char terminated markup; repeat char. */
-#define LEN_ 8 /* Error: length limit exceeded; end markup; repeat char. */
-#define NOP_ 9 /* No action necessary. */
-#define PCI_ 10 /* Previous character was invalid. */
-#define PER_ 11 /* Parameter reference; start new input source; continue. */
-#define RC2_ 12 /* Back up two characters. */
-#define RCC_ 13 /* Repeat current character. */
-#define RCR_ 14 /* Repeat current character and return to caller. */
-#define EE_ 15 /* EOS or EE: resume old input source; return to caller. */
-#define RS_ 16 /* Record start: ccnt=0; ++rcnt. */
-#define ERX_ 17 /* Entity reference; start new input source; return. */
-#define SYS_ 18 /* Error allowed: SYSCHAR in input stream; replace it. */
-#define EOD_ 19 /* End of document. */
-/* Number way out of order to avoid recompilation. */
-#define NSC_ 58 /* Handle DELNONCH/DELXNONCH when NON_ is allowed */
-#define PEX_ 61 /* Parameter entity ref; start new input source; return. */
-#define DEF_ 62 /* Data entity found. */
-#define PIE_ 63 /* PI entity found (needed in markup). */
-#define LNR_ 64 /* LEN_ error with extra REPEATCC. */
-/* SGMLACT.H: Symbols for content parse action names (end with '_')
- that are returned to SGML.C for processing.
- There must be no conflict with PARSEACT.H, which
- uses 0 through 19, or CONACT.H, which uses 34 and above.
- (Note: 31 is also used in CONACT.H, but no conflict
- is created because they are tested only in PARSEPRO.C, which
- completes before SGML.C starts to examine those codes.
- Also, when EOD_ is returned from PARSECON, it is changed
- to LOP_.)
-*/
-#define CON_ 20 /* Normal content action (one of the following). */
-#define DAF_ 21 /* Data found. */
-#define ETG_ 22 /* Process end-tag. */
-#define MD_ 23 /* Process markup declaration (NAMESTRT found). */
-#define MDC_ 24 /* Process markup declaration comment (CD found). */
-#define MSS_ 25 /* Process marked section start. */
-#define MSE_ 26 /* Process marked section end. */
-#define PIS_ 27 /* Processing instruction (string). */
-#define REF_ 28 /* Record end found. */
-#define STG_ 29 /* Process start-tag. */
-#define RSR_ 30 /* Return RS to effect SGML state transition. */
-#define LOP_ 31 /* Loop for new content without returning anything. */
-/* TAGACT.H: Symbols for tag parse action names (all alpha).
- There must be no conflict with PARSEACT.H, which
- uses 0 - 19.
-*/
-#define AVD 20 /* Delimited attribute value started: normal delimiter. */
-#define AVU 21 /* Undelimited value started. */
-#define ETIC 22 /* Tag closed with ETI. */
-#define NVS 23 /* Name of attribute or value started. */
-#define NASV 24 /* Saved NAS was actually an NTV. */
-#define NTV 25 /* Name token value started; get name and full value. */
-#define TAGC 26 /* Tag closed normally. */
-#define TAGO 27 /* Tag closed implicitly by TAGO character. */
-#define AVDA 28 /* Delimited attribute value started: alternative delim. */
-#define DSC 29 /* Closed by DSC character. */
-/* VALACT.H: Symbols for attribute value tokenization action names (all alpha).
-*/
-#define NOPA 0 /* No action necessary. */
-#define INVA 1 /* Invalid character; terminate parse. */
-#define LENA 2 /* Length limit of token exceeded; terminate parse. */
-#define NASA 3 /* Name started. */
-#define NMTA 4 /* Name token started. */
-#define NUMA 5 /* Number or number token started. */
-
-/* SGML declaration parsing actions. */
-
-#define ESGD 20 /* End of SGML declaration. */
-#define LIT1 21 /* Literal started. */
-#define LIT2 22 /* Literal started with LITA delimiter. */
-#define NUM1 23 /* Number started. */
-#define NAS1 24 /* Name started. */
-#define ISIG 25 /* Insignificant character occurred. */
diff --git a/usr.bin/sgmls/sgmls/adl.h b/usr.bin/sgmls/sgmls/adl.h
deleted file mode 100644
index 930e1e8..0000000
--- a/usr.bin/sgmls/sgmls/adl.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/* ADL.H: Definitions for attribute descriptor list processing.
-*/
-/* N/C/SDATA external entity types for nxetype member of ne structure. */
-#define ESNCDATA 1 /* External character data entity. */
-#define ESNNDATA 2 /* Non-SGML data entity. */
-#define ESNSDATA 3 /* External specific character data entity. */
-#define ESNSUB 4 /* SGML subdocument entity. */
-
-/* N/C/SDATA control block for AENTITY attributes and NDATA returns.*/
-struct ne { /* N/C/SDATA entity control block. */
- UNIV neid; /* Files for NDATA entity. */
- UNCH *nepubid; /* Public identifier if specified. */
- UNCH *nesysid; /* System identifier if specified. */
- PDCB nedcn; /* Data content notation control block. */
- struct ad *neal; /* Data attribute list (NULL if none). */
- UNCH *neename; /* Ptr to entity name (length and EOS). */
- UNCH nextype; /* Entity type: NDATA SDATA CDATA SUBDOC. */
-};
-#define NESZ (sizeof(struct ne))
-typedef struct ne *PNE;
-/* NDATA entity control block fields. */
-#define NEID(p) (((PNE)p)->neid) /* File ID of NDATA entity. */
-#define NESYSID(p) (((PNE)p)->nesysid) /* System ID of NDATA entity. */
-#define NEPUBID(p) (((PNE)p)->nepubid) /* Public ID of NDATA entity. */
-#define NEDCN(p) (((PNE)p)->nedcn->ename) /* Data content notation name. */
-#define NEDCNSYSID(p) (((PNE)p)->nedcn->sysid) /* Notation system ID.*/
-#define NEDCNPUBID(p) (((PNE)p)->nedcn->pubid) /* Notation public ID.*/
-#define NEDCNDEFINED(p) (((PNE)p)->nedcn->defined) /* Notation defined? */
-#define NEDCNADL(p) (((PNE)p)->nedcn->adl) /* Data content notation attlist.*/
-#define NEENAME(p) (((PNE)p)->neename) /* Entity name pointer. */
-#define NEXTYPE(p) (((PNE)p)->nextype) /* External entity type. */
-#define NEAL(p) (((PNE)p)->neal) /* Data attributes (if any). */
-#define NEDCNMARK(p) DCNMARK(((PNE)p)->nedcn)
-
-/* Attribute descriptor list entry. */
-struct ad {
- UNCH *adname; /* Attribute name with length and EOS. */
- UNCH adflags; /* Attribute flags. */
- UNCH adtype; /* Value type. */
- UNS adnum; /* Group size or member pos in grp. */
- UNS adlen; /* Length of default or value (for capacity). */
- UNCH *addef; /* Default value (NULL if REQUIRED or IMPLIED). */
- union {
- PNE n; /* AENTITY: NDATA control block. */
- PDCB x; /* ANOTEGRP: DCN control block. */
- } addata; /* Special data associated with some attributes.*/
-};
-#define ADSZ (sizeof(struct ad)) /* Size of an ad structure. */
-
-/* Attribute flags for entire list adflags: ADLF. */
-#define ADLREQ 0x80 /* Attribute list: 1=REQUIRED att defined. */
-#define ADLNOTE 0x40 /* Attribute list: 1=NOTATION att defined. */
-#define ADLCONR 0x20 /* Attribute list: 1=CONREF att defined. */
-
-/* Attribute flags for list member adflags: ADFLAGS(n). */
-#define AREQ 0x80 /* Attribute: 0=null; 1=required. */
-#define ACURRENT 0x40 /* Attribute: 0=normal; 1=current. */
-#define AFIXED 0x20 /* Attribute: 0=normal; 1=must equal default. */
-#define AGROUP 0x10 /* Attribute: 0=single; 1=group of ad's. */
-#define ACONREF 0x08 /* Attribute: 0=normal; 1=att is CONREF. */
-#define AINVALID 0x04 /* Attribute: 1=value is invalid; 0=o.k. */
-#define AERROR 0x02 /* Attribute: 1=error was specified; 0=o.k. */
-#define ASPEC 0x01 /* Attribute: 1=value was specified; 0=default. */
-
-/* Attribute types for adtype. */
-#define ANMTGRP 0x00 /* Attribute: Name token group or member. */
-#define ANOTEGRP 0x01 /* Attribute: Notation (name group). */
-#define ACHARS 0x02 /* Attribute: Character string. */
-#define AENTITY 0x03 /* Attribute: Data entity (name). */
-#define AID 0x04 /* Attribute: ID value (name). */
-#define AIDREF 0x05 /* Attribute: ID reference value (name). */
-#define ANAME 0x06 /* Attribute: Name. */
-#define ANMTOKE 0x07 /* Attribute: Name token. */
-#define ANUMBER 0x08 /* Attribute: Number. */
-#define ANUTOKE 0x09 /* Attribute: Number token. */
-#define ATKNLIST 0x0A /* Attribute: >= means value is a token list. */
-#define AENTITYS 0x0A /* Attribute: Data entities (name list). */
-#define AIDREFS 0x0B /* Attribute: ID reference value (name list). */
-#define ANAMES 0x0C /* Attribute: Name list. */
-#define ANMTOKES 0x0D /* Attribute: Name token list. */
-#define ANUMBERS 0x0E /* Attribute: Number list. */
-#define ANUTOKES 0x0F /* Attribute: Number token list. */
-
-/* Field definitions for entries in an attribute list.
- The first argument to all of these is the list address.
-*/
-/* Attribute list: flags. */
-#define ADLF(a) ((a)[0].adflags)
-/* Attribute list: number of list members. */
-#define ADN(a) ((a)[0].adtype)
-/* Attribute list: number of attributes. */
-#define AN(a) ((a)[0].adnum)
-/* Nth attribute in list: name. */
-#define ADNAME(a, n) (((a)[n].adname+1))
-/* Nth att in list: number of val)ues. */
-#define ADNUM(a, n) ((a)[n].adnum)
-/* Nth attribute in list: flags. */
-#define ADFLAGS(a, n) ((a)[n].adflags)
-/* Nth attribute in list: type. */
-#define ADTYPE(a, n) ((a)[n].adtype)
-/* Nth attribute in list: len of def or val.*/
-#define ADLEN(a, n) ((a)[n].adlen)
-/* Nth attribute in list: def or value. */
-#define ADVAL(a, n) ((a)[n].addef)
-/* Nth attribute in list: special data. */
-#define ADDATA(a, n) ((a)[n].addata)
-/* Nth att: token at Pth pos in value. */
-#define ADTOKEN(a, n, p)(((a)[n].addef+(p)))
-
-#define IDHASH 101 /* Size of ID hash table. Must be prime. */
-struct id { /* ID attribute control block. */
- struct id *idnext; /* Next ID in chain. */
- UNCH *idname; /* ID name with length prefix and EOS. */
- UNCH iddefed; /* Non-zero if it has been defined. */
- struct fwdref *idrl; /* Chain of forward references to this ID. */
-};
-#define IDSZ sizeof(struct id)
-typedef struct id *PID; /* Ptr to ID attribute control block. */
diff --git a/usr.bin/sgmls/sgmls/alloc.h b/usr.bin/sgmls/sgmls/alloc.h
deleted file mode 100644
index d732178..0000000
--- a/usr.bin/sgmls/sgmls/alloc.h
+++ /dev/null
@@ -1,8 +0,0 @@
-/* alloc.h */
-
-typedef unsigned SIZE_T;
-
-/* Like malloc and realloc, but don't return if no memory is available. */
-
-extern UNIV xmalloc P((SIZE_T));
-extern UNIV xrealloc P((UNIV, SIZE_T));
diff --git a/usr.bin/sgmls/sgmls/ambig.c b/usr.bin/sgmls/sgmls/ambig.c
deleted file mode 100644
index 9da02eb..0000000
--- a/usr.bin/sgmls/sgmls/ambig.c
+++ /dev/null
@@ -1,438 +0,0 @@
-/* ambig.c -
- Content model ambiguity checking.
-
- Written by James Clark (jjc@jclark.com).
-*/
-/*
-This uses the construction in pp8-9 of [1], extended to deal with AND
-groups.
-
-Note that it is not correct for the purposes of ambiguity analysis to
-handle AND groups by turning them into an OR group of SEQ groups
-(consider (a&b?)).
-
-We build an automaton for the entire content model by adding the
-following case for AND:
-
-nullable(v) := nullable(left child) and nullable(right child)
-if nullable(right child) then
- for each x in last(left child) do
- follow(v,x) = follow(left child,x) U first(right child);
-if nullable(left child) then
- for each x in last(right child) do
- follow(v,x) = follow(right child,x) U first(left child);
-first(v) := first(left child) U first(right child);
-last(v) := first(left child) U first(right child);
-
-We also build an automaton for each AND group by building automata for
-each of the members of the AND group using the above procedure and
-then combine the members using:
-
-for each x in last(left child) do
- follow(v,x) = follow(left child,x) U first(right child);
-for each x in last(right child) do
- follow(v,x) = follow(right child,x) U first(left child);
-first(v) := first(left child) U first(right child);
-
-The content model is ambiguous just in case one of these automata is
-non-deterministic. (Note that when checking determinism we need to
-check the `first' set as well as all the `follow' sets.)
-
-Why is this correct? Consider a primitive token in a member of an AND
-group. There are two worst cases for ambiguity: firstly, when none of
-the other members of AND group have been matched; secondly, when just
-the nullable members remain to be matched. The first case is not
-affected by context of the AND group (unless the first case is
-identical to the second case.)
-
-Note that inclusions are not relevant for the purposes of determining
-the ambiguity of content models. Otherwise the case in clause
-11.2.5.1:
-
- An element that can satisfy an element in the content model is
- considered to do so, even if the element is also an inclusion.
-
-could never arise.
-
-[1] Anne Brueggemann-Klein, Regular Expressions into Finite Automata,
-Universitaet Freiburg, Institut fur Informatik, 33 July 1991.
-*/
-
-#include "sgmlincl.h"
-
-/* Sets of states are represented by 0-terminated, ordered lists of
-indexes in gbuf. */
-
-#define MAXSTATES (GRPGTCNT+2)
-#define listcat(x, y) strcat((char *)(x), (char *)(y))
-#define listcpy(x, y) strcpy((char *)(x), (char *)(y))
-
-/* Information about a content token. */
-
-struct contoken {
- UNCH size;
- UNCH nullable;
- UNCH *first;
- UNCH *last;
-};
-
-static VOID contoken P((int, int, struct contoken *));
-static VOID andgroup P((int, int, struct contoken *));
-static VOID orgroup P((int, int, struct contoken *));
-static VOID seqgroup P((int, int, struct contoken *));
-static VOID andambig P((int));
-static int listambig P((UNCH *));
-static VOID listmerge P((UNCH *, UNCH *));
-static struct contoken *newcontoken P((void));
-static VOID freecontoken P((struct contoken *));
-
-
-/* Dynamically allocated vector of follow sets. */
-
-static UNCH **follow;
-static UNCH *mergebuf; /* for use by listmerge */
-
-/* Set to non-zero if the content model is ambiguous. */
-
-static int ambigsw;
-
-/* Check the current content model (in gbuf) for ambiguity. */
-
-VOID ambig()
-{
- struct contoken *s;
- int i;
-
- if (!follow) {
- /* We can't allocate everything in one chunk, because that would
- overflow a 16-bit unsigned if GRPGTCNT was 253. */
- UNCH *ptr;
- follow = (UNCH **)rmalloc(MAXSTATES*sizeof(UNCH *));
- follow[0] = 0;
- ptr = (UNCH *)rmalloc((MAXSTATES - 1)*MAXSTATES);
- for (i = 1; i < MAXSTATES; i++) {
- follow[i] = ptr;
- ptr += MAXSTATES;
- }
- mergebuf = (UNCH *)rmalloc(MAXSTATES);
- }
-
- for (i = 1; i < MAXSTATES; i++)
- follow[i][0] = 0;
-
- ambigsw = 0;
-
- s = newcontoken();
- contoken(1, 1, s);
-
- ambigsw = ambigsw || listambig(s->first);
-
- freecontoken(s);
-
- for (i = 1; !ambigsw && i < MAXSTATES; i++)
- if (listambig(follow[i]))
- ambigsw = 1;
-
- if (ambigsw)
- mderr(137, (UNCH *)0, (UNCH *)0);
-}
-
-/* Free memory used for ambiguity checking. */
-
-VOID ambigfree()
-{
- if (follow) {
- frem((UNIV)follow[1]);
- frem((UNIV)follow);
- frem((UNIV)mergebuf);
- follow = 0;
- }
-}
-
-/* Determine whether a list of primitive content tokens (each
-represented by its index in gbuf) is ambiguous. */
-
-static
-int listambig(list)
-UNCH *list;
-{
- UNCH *p;
- int chars = 0;
- int rc = 0;
-
- for (p = list; *p; p++) {
- if ((gbuf[*p].ttype & TTMASK) == TTETD) {
- struct etd *e = gbuf[*p].tu.thetd;
- if (e->mark) {
- rc = 1;
- break;
- }
- e->mark = 1;
- }
- else {
- assert((gbuf[*p].ttype & TTMASK) == TTCHARS);
- if (chars) {
- rc = 1;
- break;
- }
- chars = 1;
- }
- }
-
- for (p = list; *p; p++)
- if ((gbuf[*p].ttype & TTMASK) == TTETD)
- gbuf[*p].tu.thetd->mark = 0;
-
- return rc;
-}
-
-
-/* Analyze a content token. The `checkand' argument is needed to ensure
-that the algorithm is not exponential in the AND-group nesting depth.
-*/
-
-static
-VOID contoken(m, checkand, res)
-int m; /* Index of content token in gbuf */
-int checkand; /* Non-zero if AND groups should be checked */
-struct contoken *res; /* Result */
-{
- UNCH flags = gbuf[m].ttype;
- switch (flags & TTMASK) {
- case TTCHARS:
- case TTETD:
- res->first[0] = m;
- res->first[1] = 0;
- res->last[0] = m;
- res->last[1] = 0;
- res->size = 1;
- res->nullable = 0;
- break;
- case TTAND:
- if (checkand)
- andambig(m);
- andgroup(m, checkand, res);
- break;
- case TTOR:
- orgroup(m, checkand, res);
- break;
- case TTSEQ:
- seqgroup(m, checkand, res);
- break;
- default:
- abort();
- }
- if (flags & TREP) {
- UNCH *p;
- for (p = res->last; *p; p++)
- listmerge(follow[*p], res->first);
- }
- if (flags & TOPT)
- res->nullable = 1;
-}
-
-/* Check an AND group for ambiguity. */
-
-static
-VOID andambig(m)
-int m;
-{
- int i, tnum;
- int lim;
- struct contoken *curr;
- struct contoken *next;
-
- tnum = gbuf[m].tu.tnum;
- assert(tnum > 0);
- curr = newcontoken();
- next = newcontoken();
- contoken(m + 1, 0, curr);
- i = m + 1 + curr->size;
- curr->size += 1;
- for (--tnum; tnum > 0; --tnum) {
- UNCH *p;
- contoken(i, 0, next);
- curr->size += next->size;
- i += next->size;
- for (p = curr->last; *p; p++)
- listcat(follow[*p], next->first);
- for (p = next->last; *p; p++)
- listmerge(follow[*p], curr->first);
- listcat(curr->first, next->first);
- listcat(curr->last, next->last);
- }
- lim = m + curr->size;
- for (i = m + 1; i < lim; i++) {
- if (listambig(follow[i]))
- ambigsw = 1;
- follow[i][0] = 0;
- }
- freecontoken(curr);
- freecontoken(next);
-}
-
-/* Handle an AND group. */
-
-static
-VOID andgroup(m, checkand, res)
-int m;
-int checkand;
-struct contoken *res;
-{
- int i, tnum;
- /* union of the first sets of nullable members of the group */
- UNCH *nullablefirst;
- struct contoken *next;
-
- tnum = gbuf[m].tu.tnum;
- assert(tnum > 0);
- contoken(m + 1, checkand, res);
- nullablefirst = (UNCH *)rmalloc(MAXSTATES);
- if (res->nullable)
- listcpy(nullablefirst, res->first);
- else
- nullablefirst[0] = 0;
- i = m + 1 + res->size;
- res->size += 1;
- next = newcontoken();
- for (--tnum; tnum > 0; --tnum) {
- UNCH *p;
- contoken(i, checkand, next);
- res->size += next->size;
- i += next->size;
- if (next->nullable)
- for (p = res->last; *p; p++)
- listcat(follow[*p], next->first);
- for (p = next->last; *p; p++)
- listmerge(follow[*p], nullablefirst);
- listcat(res->first, next->first);
- if (next->nullable)
- listcat(nullablefirst, next->first);
- listcat(res->last, next->last);
- res->nullable &= next->nullable;
- }
- frem((UNIV)nullablefirst);
- freecontoken(next);
-}
-
-/* Handle a SEQ group. */
-
-static
-VOID seqgroup(m, checkand, res)
-int m;
-int checkand;
-struct contoken *res;
-{
- int i, tnum;
- struct contoken *next;
-
- tnum = gbuf[m].tu.tnum;
- assert(tnum > 0);
- contoken(m + 1, checkand, res);
- i = m + 1 + res->size;
- res->size += 1;
- next = newcontoken();
- for (--tnum; tnum > 0; --tnum) {
- UNCH *p;
- contoken(i, checkand, next);
- res->size += next->size;
- i += next->size;
- for (p = res->last; *p; p++)
- listcat(follow[*p], next->first);
- if (res->nullable)
- listcat(res->first, next->first);
- if (next->nullable)
- listcat(res->last, next->last);
- else
- listcpy(res->last, next->last);
- res->nullable &= next->nullable;
- }
- freecontoken(next);
-}
-
-/* Handle an OR group. */
-
-static
-VOID orgroup(m, checkand, res)
-int m;
-int checkand;
-struct contoken *res;
-{
- int i, tnum;
- struct contoken *next;
-
- tnum = gbuf[m].tu.tnum;
- assert(tnum > 0);
- contoken(m + 1, checkand, res);
- i = m + 1 + res->size;
- res->size += 1;
- next = newcontoken();
- for (--tnum; tnum > 0; --tnum) {
- contoken(i, checkand, next);
- res->size += next->size;
- i += next->size;
- listcat(res->first, next->first);
- listcat(res->last, next->last);
- res->nullable |= next->nullable;
- }
- freecontoken(next);
-}
-
-
-/* Merge the second ordered list into the first. */
-
-static
-VOID listmerge(p, b)
-UNCH *p, *b;
-{
- UNCH *a = mergebuf;
-
- strcpy((char *)a, (char *)p);
-
- for (;;) {
- if (*a) {
- if (*b) {
- if (*a < *b)
- *p++ = *a++;
- else if (*a > *b)
- *p++ = *b++;
- else
- a++;
- }
- else
- *p++ = *a++;
- }
- else if (*b)
- *p++ = *b++;
- else
- break;
- }
- *p = '\0';
-}
-
-static
-struct contoken *newcontoken()
-{
- struct contoken *p = (struct contoken *)rmalloc(sizeof(struct contoken)
- + MAXSTATES*2);
- p->first = (UNCH *)(p + 1);
- p->last = p->first + MAXSTATES;
- return p;
-}
-
-static
-VOID freecontoken(p)
-struct contoken *p;
-{
- frem((UNIV)p);
-}
-
-/*
-Local Variables:
-c-indent-level: 5
-c-continued-statement-offset: 5
-c-brace-offset: -5
-c-argdecl-indent: 0
-c-label-offset: -5
-End:
-*/
diff --git a/usr.bin/sgmls/sgmls/appl.h b/usr.bin/sgmls/sgmls/appl.h
deleted file mode 100644
index 2513c98..0000000
--- a/usr.bin/sgmls/sgmls/appl.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* appl.h */
-
-enum {
- E_NOMEM = 1,
- E_DOC,
- E_EXEC,
- E_FORK,
- E_WAIT,
- E_SIGNAL,
- E_OPEN,
- E_CAPBOTCH,
- E_SUBDOC
-};
-
-VOID process_document P((int));
-VOID output_conforming P((void));
-
-VOID appl_error VP((int, ...));
-
-#ifdef SUPPORT_SUBDOC
-int run_process P((char **));
-char **make_argv P((UNIV));
-VOID get_subcaps P((void));
-#endif
-
-#ifdef SUPPORT_SUBDOC
-extern int suberr;
-#endif
-
-extern int suppsw;
-extern int locsw;
diff --git a/usr.bin/sgmls/sgmls/catalog.c b/usr.bin/sgmls/sgmls/catalog.c
deleted file mode 100644
index 28077a8..0000000
--- a/usr.bin/sgmls/sgmls/catalog.c
+++ /dev/null
@@ -1,925 +0,0 @@
-/* Normalize public identifiers to handle ISO 8879[-:]1986 problem.
-What should happen if there's a duplicate in a single catalog entry file? */
-
-#include "config.h"
-#include "std.h"
-#include "catalog.h"
-
-#ifdef USE_PROTOTYPES
-#define P(parms) parms
-#else
-#define P(parms) ()
-#endif
-
-#include "alloc.h"
-
-#define MINIMUM_DATA_CHARS \
-"abcdefghijklmnopqrstuvwxyz\
-ABCDEFGHIJKLMNOPQRSTUVWXYZ\
-0123456789-.'()+,/:=?"
-
-#define N_DECL_TYPE 3
-#define PUBLIC_ID_MAP N_DECL_TYPE
-#define N_TABLES (N_DECL_TYPE + 1)
-
-enum literal_type {
- NORMAL_LITERAL,
- MINIMUM_LITERAL
-};
-
-typedef enum {
- EOF_PARAM,
- NAME_PARAM,
- LITERAL_PARAM
-} PARAM_TYPE;
-
-enum catalog_error {
- E_NAME_EXPECTED,
- E_LITERAL_EXPECTED,
- E_ARG_EXPECTED,
- E_MINIMUM_DATA,
- E_EOF_COMMENT,
- E_EOF_LITERAL,
- E_NUL_CHAR,
- E_CANNOT_OPEN,
- E_GETC,
- E_FCLOSE
-};
-
-#define FIRST_SYSTEM_ERROR E_CANNOT_OPEN
-
-#define HASH_TABLE_INITIAL_SIZE 8
-#define HASH_TABLE_MAX_SIZE (((SIZE_T)-1)/sizeof(struct hash_table_entry *))
-
-struct hash_table_entry {
- int file_index;
- const char *key;
- const char *system_id;
-};
-
-/* Number of bytes per string block. */
-#define BLOCK_SIZE 1000
-
-/* Bytes follow the struct. */
-
-struct string_block {
- struct string_block *next;
-};
-
-struct hash_table {
- struct hash_table_entry **v;
- SIZE_T size; /* must be power of 2 */
- SIZE_T used;
- SIZE_T used_limit;
-};
-
-struct catalog {
- struct hash_table tables[N_TABLES];
- char **files;
- int n_files;
- struct string_block *blocks;
- char *block_ptr;
- SIZE_T block_spare;
- CATALOG_ERROR_HANDLER error_handler;
- int loaded;
-};
-
-struct parser {
- FILE *fp;
- struct catalog *cat;
- char *param;
- SIZE_T param_length;
- SIZE_T param_alloc;
- int file_index;
- const char *filename;
- unsigned long newline_count;
- char minimum_data[256];
-};
-
-static
-VOID add_catalog_file P((struct catalog *cat, const char *filename,
- SIZE_T length));
-static
-VOID load P((struct catalog *cat));
-static
-VOID parse_file P((struct parser *parser));
-static
-VOID parse_public P((struct parser *parser));
-static
-VOID parse_name_map P((struct parser *parser,
- int decl_type));
-static
-int parse_arg P((struct parser *parser));
-static
-PARAM_TYPE parse_param P((struct parser *parser, enum literal_type));
-static
-VOID skip_comment P((struct parser *parser));
-static
-PARAM_TYPE parse_literal P((struct parser *parser, int lit,
- enum literal_type));
-static
-PARAM_TYPE parse_name P((struct parser *parser, int first_char));
-static
-VOID param_grow P((struct parser *parser));
-static
-const char *param_save P((struct parser *parser));
-static
-char *alloc_bytes P((struct catalog *catalog, SIZE_T n));
-static
-int param_equal P((struct parser *parser, const char *key));
-static
-int hash_table_add P((struct hash_table *table, const char *s,
- const char *system_id, int file_index));
-static
-struct hash_table_entry *hash_table_lookup P((struct hash_table *table,
- const char *s));
-static
-struct hash_table_entry *hash_table_lookup_subst P((struct hash_table *table,
- const char *subst_table,
- const char *s));
-static
-VOID hash_table_init P((struct hash_table *p));
-static
-VOID hash_table_delete P((struct hash_table *p));
-static
-SIZE_T hash_table_start_index P((struct hash_table *p, const char *s));
-static
-int subst_equal P((const char *subst_table, const char *s1, const char *s2));
-static
-VOID error P((struct parser *parser, enum catalog_error err));
-
-#define param_char(parser, c) \
- ((((parser)->param_length < (parser)->param_alloc) \
- || (param_grow(parser), 1)), \
- ((parser)->param[(parser)->param_length] = (c)), \
- ((parser)->param_length += 1))
-
-#define param_init(parser) ((parser)->param_length = 0)
-#define param_chop(parser) \
- ((parser)->param_length = (parser)->param_length - 1)
-
-const char *catalog_error_text(error_number)
- int error_number;
-{
- static const char *text[] = {
- "Name expected",
- "Literal expected",
- "Missing argument",
- "Only minimum data characters allowed in a public identifier",
- "End of file in comment",
- "End of file in literal",
- "Nul character is not allowed",
- "Cannot open `%s': %s",
- "Error reading `%s': %s",
- "Error closing `%s': %s"
- };
- if (error_number >= 0 && error_number < sizeof(text)/sizeof(text[0]))
- return text[error_number];
- else
- return "(invalid error number)";
-}
-
-
-CATALOG catalog_create(error_handler)
- CATALOG_ERROR_HANDLER error_handler;
-{
- int i;
- struct catalog *p = (struct catalog *)xmalloc(sizeof(struct catalog));
- p->loaded = 0;
- p->n_files = 0;
- p->files = 0;
- p->error_handler = error_handler;
- p->blocks = 0;
- p->block_spare = 0;
- p->block_ptr = 0;
- for (i = 0; i < N_TABLES; i++)
- hash_table_init(p->tables + i);
- return (CATALOG)p;
-}
-
-VOID catalog_delete(cat)
- CATALOG cat;
-{
- int i;
- struct string_block *block;
- struct catalog *catalog = (struct catalog *)cat;
- for (i = 0; i < 4; i++)
- hash_table_delete(catalog->tables + i);
- if (catalog->files)
- free(catalog->files);
- block = catalog->blocks;
- while (block) {
- struct string_block *tem = block;
- block = block->next;
- free((UNIV)tem);
- }
- catalog->blocks = 0;
- free((UNIV)catalog);
-}
-
-VOID catalog_load_file(p, filename)
- CATALOG p;
- const char *filename;
-{
- add_catalog_file((struct catalog *)p, filename, strlen(filename));
-}
-
-int catalog_lookup_entity(cat, public_id, name, decl_type, subst_table,
- system_id, catalog_file)
- CATALOG cat;
- const char *public_id;
- const char *name;
- enum catalog_decl_type decl_type;
- const char *subst_table;
- const char **system_id;
- const char **catalog_file;
-{
- struct catalog *catalog = (struct catalog *)cat;
- const struct hash_table_entry *entry = 0;
- if (!catalog->loaded)
- load(catalog);
- if (public_id)
- entry = hash_table_lookup(catalog->tables + PUBLIC_ID_MAP, public_id);
- if (name
- && decl_type >= 0
- && decl_type < N_DECL_TYPE
- && (!entry || entry->file_index > 0)) {
- const struct hash_table_entry *entity_entry = 0;
- if (!subst_table)
- entity_entry = hash_table_lookup(catalog->tables + decl_type, name);
- else
- entity_entry = hash_table_lookup_subst(catalog->tables + decl_type,
- subst_table, name);
- if (!entry
- || (entity_entry
- && entity_entry->file_index < entry->file_index))
- entry = entity_entry;
- }
- if (!entry)
- return 0;
- *system_id = entry->system_id;
- *catalog_file = catalog->files[entry->file_index];
- return 1;
-}
-
-static
-VOID add_catalog_file(cat, filename, length)
- struct catalog *cat;
- const char *filename;
- SIZE_T length;
-{
- char *s;
- if (!cat->files)
- cat->files = (char **)xmalloc(sizeof(char *));
- else
- cat->files
- = (char **)xrealloc(cat->files, (cat->n_files + 1)*sizeof(char *));
- s = alloc_bytes(cat, length + 1);
- memcpy(s, filename, length);
- s[length] = '\0';
- cat->files[cat->n_files] = s;
- cat->n_files += 1;
-}
-
-static
-VOID load(cat)
- struct catalog *cat;
-{
- int i;
- const char *p;
- struct parser parser;
- const char *env_var;
- int optional_file_index = cat->n_files;
-
- cat->loaded = 1;
- parser.param = 0;
- parser.param_alloc = 0;
- parser.cat = cat;
- for (i = 0; i < 256; i++)
- parser.minimum_data[i] = 0;
- for (p = MINIMUM_DATA_CHARS; *p; p++)
- parser.minimum_data[(unsigned char)*p] = 1;
- env_var = getenv(CATALOG_FILES_ENV_VAR);
- if (!env_var || *env_var == '\0')
- env_var = DEFAULT_CATALOG_FILES;
- for (;;) {
- for (p = env_var; *p && *p != PATH_FILE_SEP; p++)
- ;
- if (p > env_var)
- add_catalog_file(cat, env_var, p - env_var);
- if (!*p)
- break;
- env_var = p + 1;
- }
- for (i = 0; i < cat->n_files; i++) {
- parser.filename = cat->files[i];
- parser.newline_count = 0;
- parser.fp = fopen(cat->files[i], "r");
- if (!parser.fp) {
- if (i < optional_file_index)
- error(&parser, E_CANNOT_OPEN);
- }
- else {
- parser.file_index = i;
- parse_file(&parser);
- errno = 0;
- if (fclose(parser.fp) < 0)
- error(&parser, E_FCLOSE);
- }
- }
- if (parser.param)
- free(parser.param);
-}
-
-static
-VOID parse_file(parser)
- struct parser *parser;
-{
- int skipping = 0;
- for (;;) {
- PARAM_TYPE type = parse_param(parser, NORMAL_LITERAL);
- if (type == NAME_PARAM) {
- if (param_equal(parser, "PUBLIC"))
- parse_public(parser);
- else if (param_equal(parser, "ENTITY"))
- parse_name_map(parser, CATALOG_ENTITY_DECL);
- else if (param_equal(parser, "DOCTYPE"))
- parse_name_map(parser, CATALOG_DOCTYPE_DECL);
- else if (param_equal(parser, "LINKTYPE"))
- parse_name_map(parser, CATALOG_LINKTYPE_DECL);
- else
- skipping = 1;
- }
- else if (type == EOF_PARAM)
- break;
- else if (!skipping) {
- skipping = 1;
- error(parser, E_NAME_EXPECTED);
- }
- }
-}
-
-static
-VOID parse_public(parser)
- struct parser *parser;
-{
- const char *public_id;
-
- if (parse_param(parser, MINIMUM_LITERAL) != LITERAL_PARAM)
- error(parser, E_LITERAL_EXPECTED);
- public_id = param_save(parser);
- if (!parse_arg(parser))
- return;
- hash_table_add(parser->cat->tables + PUBLIC_ID_MAP,
- public_id, param_save(parser), parser->file_index);
-}
-
-static
-VOID parse_name_map(parser, decl_type)
- struct parser *parser;
- int decl_type;
-{
- const char *name;
-
- if (!parse_arg(parser))
- return;
- name = param_save(parser);
- if (!parse_arg(parser))
- return;
- hash_table_add(parser->cat->tables + decl_type,
- name, param_save(parser), parser->file_index);
-}
-
-static
-int parse_arg(parser)
- struct parser *parser;
-{
- PARAM_TYPE parm = parse_param(parser, NORMAL_LITERAL);
- if (parm != NAME_PARAM && parm != LITERAL_PARAM) {
- error(parser, E_ARG_EXPECTED);
- return 0;
- }
- return 1;
-}
-
-static
-PARAM_TYPE parse_param(parser, lit_type)
- struct parser *parser;
- enum literal_type lit_type;
-{
- for (;;) {
- int c = getc(parser->fp);
- switch (c) {
- case EOF:
- if (ferror(parser->fp))
- error(parser, E_GETC);
- return EOF_PARAM;
- case '"':
- case '\'':
- return parse_literal(parser, c, lit_type);
- case '\n':
- parser->newline_count += 1;
- break;
- case '\t':
- case ' ':
- break;
- case '\0':
- error(parser, E_NUL_CHAR);
- break;
- case '-':
- c = getc(parser->fp);
- if (c == '-') {
- skip_comment(parser);
- break;
- }
- ungetc(c, parser->fp);
- c = '-';
- /* fall through */
- default:
- return parse_name(parser, c);
- }
- }
-}
-
-static
-VOID skip_comment(parser)
- struct parser *parser;
-{
- FILE *fp = parser->fp;
- for (;;) {
- int c = getc(fp);
- if (c == '-') {
- c = getc(fp);
- if (c == '-')
- return;
- }
- if (c == EOF) {
- if (ferror(fp))
- error(parser, E_GETC);
- error(parser, E_EOF_COMMENT);
- return;
- }
- if (c == '\n')
- parser->newline_count += 1;
- }
-}
-
-static
-PARAM_TYPE parse_literal(parser, lit, lit_type)
- struct parser *parser;
- int lit;
- enum literal_type lit_type;
-{
- enum { no, yes_begin, yes_middle } skipping = yes_begin;
- FILE *fp = parser->fp;
- param_init(parser);
- for (;;) {
- int c = getc(fp);
- if (c == lit)
- break;
- switch (c) {
- case '\0':
- error(parser, E_NUL_CHAR);
- break;
- case EOF:
- if (ferror(fp))
- error(parser, E_GETC);
- error(parser, E_EOF_LITERAL);
- return LITERAL_PARAM;
- case '\n':
- parser->newline_count += 1;
- /* fall through */
- case ' ':
- if (lit_type == MINIMUM_LITERAL) {
- if (skipping == no) {
- param_char(parser, ' ');
- skipping = yes_middle;
- }
- }
- else
- param_char(parser, c);
- break;
- default:
- if (lit_type == MINIMUM_LITERAL) {
- if (!parser->minimum_data[c])
- error(parser, E_MINIMUM_DATA);
- else {
- skipping = no;
- param_char(parser, c);
- }
- }
- else
- param_char(parser, c);
- break;
- }
- }
- if (skipping == yes_middle)
- param_chop(parser);
- return LITERAL_PARAM;
-}
-
-static
-PARAM_TYPE parse_name(parser, first_char)
- struct parser *parser;
- int first_char;
-{
- FILE *fp = parser->fp;
- param_init(parser);
- param_char(parser, first_char);
- for (;;) {
- int c = getc(fp);
- switch (c) {
- case '\0':
- error(parser, E_NUL_CHAR);
- break;
- case EOF:
- if (ferror(fp))
- error(parser, E_GETC);
- goto done;
- case '\n':
- parser->newline_count += 1;
- goto done;
- case ' ':
- case '\t':
- goto done;
- case '"':
- case '\'':
- ungetc(c, fp);
- goto done;
- default:
- param_char(parser, c);
- }
- }
- done:
- return NAME_PARAM;
-}
-
-static
-VOID param_grow(parser)
- struct parser *parser;
-{
- if (parser->param_alloc == 0) {
- parser->param_alloc = 256;
- parser->param = xmalloc(parser->param_alloc);
- }
- else {
- parser->param_alloc *= 2;
- parser->param = xrealloc(parser->param, parser->param_alloc);
- }
-}
-
-static
-const char *param_save(parser)
- struct parser *parser;
-{
- char *s = alloc_bytes(parser->cat, parser->param_length + 1);
- memcpy(s, parser->param, parser->param_length);
- s[parser->param_length] = '\0';
- return s;
-}
-
-static
-char *alloc_bytes(catalog, n)
- struct catalog *catalog;
- SIZE_T n;
-{
- char *tem;
- if (n > catalog->block_spare) {
- struct string_block *block;
- SIZE_T block_size = n > BLOCK_SIZE ? n : BLOCK_SIZE;
- block
- = (struct string_block *)xmalloc(sizeof(struct string_block)
- + block_size);
- block->next = catalog->blocks;
- catalog->blocks = block;
- catalog->block_ptr = (char *)(block + 1);
- catalog->block_spare = block_size;
- }
- tem = catalog->block_ptr;
- catalog->block_ptr += n;
- catalog->block_spare -= n;
- return tem;
-}
-
-
-/* Return 1 if the current parameter is equal to key. */
-
-static
-int param_equal(parser, key)
- struct parser *parser;
- const char *key;
-{
- const char *param = parser->param;
- SIZE_T param_length = parser->param_length;
- for (; param_length > 0; param++, param_length--, key++) {
- unsigned char c;
- if (*key == '\0')
- return 0;
- c = *param;
- if (islower(c))
- c = toupper(c);
- if (c != (unsigned char)*key)
- return 0;
- }
- return *key == '\0';
-}
-
-/* Return 0 if it was a duplicate. */
-
-static
-int hash_table_add(table, s, system_id, file_index)
- struct hash_table *table;
- const char *s;
- const char *system_id;
- int file_index;
-{
- SIZE_T i;
- struct hash_table_entry *p;
-
- if (table->size > 0) {
- i = hash_table_start_index(table, s);
- while (table->v[i] != 0) {
- if (strcmp(table->v[i]->key, s) == 0)
- return 0;
- if (i == 0)
- i = table->size;
- i--;
- }
- }
- if (table->used >= table->used_limit) {
- SIZE_T j;
- struct hash_table_entry **old_table = table->v;
- SIZE_T old_size = table->size;
- if (old_size == 0) {
- table->size = HASH_TABLE_INITIAL_SIZE;
- table->used_limit = table->size/2;
- }
- else {
- if (old_size > HASH_TABLE_MAX_SIZE/2) {
- if (old_size == HASH_TABLE_MAX_SIZE)
- return 0; /* FIXME: give an error? */
- table->size = HASH_TABLE_MAX_SIZE;
- table->used_limit = HASH_TABLE_MAX_SIZE - 1;
- }
- else {
- table->size = (old_size << 1);
- table->used_limit = table->size/2;
- }
- }
- table->v
- = (struct hash_table_entry **)xmalloc(sizeof(struct hash_table_entry *)
- * table->size);
- for (j = 0; j < table->size; j++)
- table->v[j] = 0;
- for (j = 0; j < old_size; j++)
- if (old_table[j]) {
- SIZE_T k = hash_table_start_index(table, old_table[j]->key);
- while (table->v[k] != 0) {
- if (k == 0)
- k = table->size;
- k--;
- }
- table->v[k] = old_table[j];
- }
- if (old_table)
- free((UNIV)old_table);
- i = hash_table_start_index(table, s);
- while (table->v[i] != 0) {
- if (i == 0)
- i = table->size;
- i--;
- }
- }
- p = (struct hash_table_entry *)xmalloc(sizeof(struct hash_table_entry));
- p->key = s;
- p->system_id = system_id;
- p->file_index = file_index;
- table->v[i] = p;
- table->used += 1;
- return 1;
-}
-
-static
-struct hash_table_entry *hash_table_lookup(table, s)
- struct hash_table *table;
- const char *s;
-{
- if (table->size > 0) {
- SIZE_T i;
- i = hash_table_start_index(table, s);
- while (table->v[i] != 0) {
- if (strcmp(table->v[i]->key, s) == 0)
- return table->v[i];
- if (i == 0)
- i = table->size;
- i--;
- }
- }
- return 0;
-}
-
-static
-struct hash_table_entry *hash_table_lookup_subst(table, subst_table, s)
- struct hash_table *table;
- const char *subst_table;
- const char *s;
-{
- SIZE_T i;
- for (i = 0; i < table->size; i++) {
- struct hash_table_entry *p = table->v[i];
- if (p && subst_equal(subst_table, s, p->key))
- return p;
- }
- return 0;
-}
-
-static
-VOID hash_table_init(p)
- struct hash_table *p;
-{
- p->v = 0;
- p->size = 0;
- p->used = 0;
- p->used_limit = 0;
-}
-
-static
-VOID hash_table_delete(p)
- struct hash_table *p;
-{
- if (p->v) {
- SIZE_T i;
- for (i = 0; i < p->size; i++)
- if (p->v[i])
- free(p->v[i]);
- free(p->v);
- }
-}
-
-static
-SIZE_T hash_table_start_index(p, s)
- struct hash_table *p;
- const char *s;
-{
- unsigned long h = 0;
- while (*s)
- h = (h << 5) + h + (unsigned char)*s++;
- return (h & (p->size - 1));
-}
-
-/* s1 has already been substituted; s2 has not */
-
-static
-int subst_equal(subst_table, s1, s2)
- const char *subst_table;
- const char *s1;
- const char *s2;
-{
- for (; *s1 == subst_table[(unsigned char)*s2]; s1++, s2++)
- if (*s1 == '\0')
- return 1;
- return 0;
-}
-
-static
-VOID error(parser, err)
- struct parser *parser;
- enum catalog_error err;
-{
- (*parser->cat->error_handler)(parser->filename,
- parser->newline_count + 1,
- err,
- (err >= FIRST_SYSTEM_ERROR
- ? CATALOG_SYSTEM_ERROR
- : 0),
- (err >= FIRST_SYSTEM_ERROR
- ? errno
- : 0));
-}
-
-#ifdef MAIN
-
-static const char *program_name;
-
-#include "getopt.h"
-
-static VOID usage P((void));
-static VOID out_of_memory P((void));
-static VOID handle_catalog_error P((const char *filename,
- unsigned long lineno,
- int error_number,
- unsigned flags,
- int sys_errno));
-
-int main(argc, argv)
- int argc;
- char **argv;
-{
- int entity_flag = 0;
- enum catalog_decl_type entity_type = CATALOG_NO_DECL;
- char *public_id = 0;
- char *name = 0;
- int exit_status;
- int opt;
- CATALOG catalog;
- int i;
- const char *file;
- const char *system_id;
-
- program_name = argv[0];
-
- while ((opt = getopt(argc, argv, "edl")) != -1)
- switch (opt) {
- case 'e':
- entity_flag = 1;
- entity_type = CATALOG_ENTITY_DECL;
- break;
- case 'd':
- entity_flag = 1;
- entity_type = CATALOG_DOCTYPE_DECL;
- break;
- case 'l':
- entity_flag = 1;
- entity_type = CATALOG_LINKTYPE_DECL;
- break;
- case '?':
- usage();
- }
- if (argc - optind < 2)
- usage();
- if (entity_flag)
- name = argv[optind];
- else
- public_id = argv[optind];
-
- catalog = catalog_create(handle_catalog_error);
- for (i = optind + 1; i < argc; i++)
- catalog_load_file(catalog, argv[i]);
- if (catalog_lookup_entity(catalog, public_id, name, entity_type, (char *)0,
- &system_id, &file)) {
- exit_status = 0;
- fprintf(stderr, "%s (%s)\n", system_id, file);
- }
- else {
- fprintf(stderr, "not found\n");
- exit_status = 1;
- }
- catalog_delete(catalog);
- return exit_status;
-}
-
-static
-VOID usage()
-{
- fprintf(stderr, "usage: %s [-e] [-d] [-l] id file ...\n",
- program_name);
- exit(1);
-}
-
-static
-VOID handle_catalog_error(filename, lineno, error_number, flags, sys_errno)
- const char *filename;
- unsigned long lineno;
- int error_number;
- unsigned flags;
- int sys_errno;
-{
- fprintf(stderr, "%s:", program_name);
- if (flags & CATALOG_SYSTEM_ERROR) {
- putc(' ', stderr);
- fprintf(stderr, catalog_error_text(error_number), filename);
- putc('\n', stderr);
- }
- else
- fprintf(stderr, "%s:%lu: %s\n", filename, lineno,
- catalog_error_text(error_number));
- fflush(stderr);
-}
-
-UNIV xmalloc(n)
- SIZE_T n;
-{
- UNIV p = malloc(n);
- if (!p)
- out_of_memory();
- return p;
-}
-
-UNIV xrealloc(p, n)
- UNIV p;
- SIZE_T n;
-{
- p = realloc(p, n);
- if (!p)
- out_of_memory();
- return p;
-}
-
-static
-VOID out_of_memory()
-{
- fprintf(stderr, "%s: out of memory\n", program_name);
- exit(1);
-}
-
-#endif /* MAIN */
diff --git a/usr.bin/sgmls/sgmls/catalog.h b/usr.bin/sgmls/sgmls/catalog.h
deleted file mode 100644
index b9509a5..0000000
--- a/usr.bin/sgmls/sgmls/catalog.h
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifndef CATALOG_H
-#define CATALOG_H 1
-
-enum catalog_decl_type {
- CATALOG_NO_DECL = -1,
- CATALOG_ENTITY_DECL,
- CATALOG_DOCTYPE_DECL,
- CATALOG_LINKTYPE_DECL
-};
-
-#define CATALOG_SYSTEM_ERROR 1
-
-#ifdef __STDC__
-
-typedef void *CATALOG;
-typedef void (*CATALOG_ERROR_HANDLER)(const char *filename,
- unsigned long lineno,
- int error_number,
- unsigned flags,
- int sys_errno);
-CATALOG catalog_create(CATALOG_ERROR_HANDLER);
-void catalog_load_file(CATALOG, const char *);
-void catalog_delete(CATALOG);
-int catalog_lookup_entity(CATALOG,
- const char *public_id,
- const char *name,
- enum catalog_decl_type,
- const char *subst_table,
- const char **system_id,
- const char **catalog_file);
-const char *catalog_error_text(int error_number);
-
-#else /* not __STDC__ */
-
-typedef char *CATALOG;
-typedef void (*CATALOG_ERROR_HANDLER)();
-CATALOG catalog_create();
-void catalog_load_file();
-void catalog_delete();
-int catalog_lookup_entity();
-char *catalog_error_text();
-
-#endif /* not __STDC__ */
-
-#endif /* not CATALOG_H */
diff --git a/usr.bin/sgmls/sgmls/config.h b/usr.bin/sgmls/sgmls/config.h
deleted file mode 100644
index a7fa92c..0000000
--- a/usr.bin/sgmls/sgmls/config.h
+++ /dev/null
@@ -1,158 +0,0 @@
-/* unix.cfg: Configuration file for sgmls on Unix. */
-
-/* A list of filename templates to use for searching for external entities.
-The filenames are separated by the character specified in PATH_FILE_SEP.
-See sgmls.man for details. */
-#define DEFAULT_PATH "/usr/share/sgml/%O/%C/%T:%N.%X:%N.%D"
-/* The character that separates the filenames templates. */
-#define PATH_FILE_SEP ':'
-/* The character that separates filenames in a system identifier.
-Usually the same as PATH_FILE_SEP. */
-#define SYSID_FILE_SEP ':'
-/* The environment variable that contains the list of filename templates. */
-#define PATH_ENV_VAR "SGML_PATH"
-/* A macro that returns non-zero if the filename is relative to the
- current directory. */
-#define FILE_IS_RELATIVE(p) ((p)[0] != '/')
-/* A string containing the characters that can separate the directory
- part of a filename from the basename. */
-#define DIR_BASE_SEP "/"
-/* The environment variable that contains the list of catalog entry files.
- Filenames are separated by PATH_FILE_SEP. */
-#define CATALOG_FILES_ENV_VAR "SGML_CATALOG_FILES"
-/* Default list of catalog entry files. */
-#define DEFAULT_CATALOG_FILES "CATALOG:/usr/share/sgml/CATALOG"
-
-/* MIN_DAT_SUBS_FROM and MIN_DATS_SUBS_TO tell sgmls how to transform a name
-or system identifier into a legal filename. A character in
-MIN_DAT_SUBS_FROM will be transformed into the character in the
-corresponding position in MIN_DAT_SUBS_TO. If there is no such
-position, then the character is removed. */
-/* This says that spaces should be transformed to underscores, and
-slashes to percents. */
-#define MIN_DAT_SUBS_FROM " /"
-#define MIN_DAT_SUBS_TO "_%"
-
-/* Define this to allow tracing. */
-/* #define TRACE 1 */
-
-/* Define this you want support for subdocuments. This is implemented
-using features that are not part of Standard C, so you might not want
-to define it if you are porting to a new system. Otherwise I suggest
-you leave it defined. */
-#define SUPPORT_SUBDOC 1
-
-/* Define HAVE_EXTENDED_PRINTF if your *printf functions supports
-X/Open extensions; if they do, then, for example,
-
- printf("%2$s%1$s", "bar", "foo")
-
-should print `foobar'. */
-
-/* #define HAVE_EXTENDED_PRINTF 1 */
-
-/* Define HAVE_CAT if your system provides the X/Open message
-catalogue functions catopen() and catgets(), and you want to use them.
-An implementations of these functions is included and will be used if
-you don't define this. On SunOS 4.1.1, if you do define this you
-should set CC=/usr/xpg2bin/cc in the makefile. */
-
-#define HAVE_CAT 1
-
-#ifdef __STDC__
-/* Define this if your compiler supports prototypes. */
-#define USE_PROTOTYPES 1
-#endif
-
-/* Can't use <stdarg.h> without prototypes. */
-#ifndef USE_PROTOTYPES
-#define VARARGS 1
-#endif
-
-/* If your compiler defines __STDC__ but doesn't provide <stdarg.h>,
-you must define VARARGS yourself here. */
-/* #define VARARGS 1 */
-
-/* Define this if you do not have strerror(). */
-/* #define STRERROR_MISSING 1 */
-
-/* Define this unless the character testing functions in ctype.h
-are defined for all values representable as an unsigned char. You do
-not need to define this if your system is ANSI C conformant. You
-should define for old Unix systems. */
-/* #define USE_ISASCII 1 */
-
-/* Define this if your system provides the BSD style string operations
-rather than ANSI C ones (eg bcopy() rather than memcpy(), and index()
-rather than strchr()). */
-/* #define BSD_STRINGS 1 */
-
-/* Define this if you have getopt(). */
-#define HAVE_GETOPT 1
-
-/* Define this if you have access(). */
-#define HAVE_ACCESS 1
-
-/* Define this if you have <unistd.h>. */
-#define HAVE_UNISTD_H 1
-
-/* Define this if you have <sys/stat.h>. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define this if you have waitpid(). */
-#define HAVE_WAITPID 1
-
-/* Define this if your system is POSIX.1 (ISO 9945-1:1990) compliant. */
-#define POSIX 1
-
-/* Define this if you have the vfork() system call. */
-#define HAVE_VFORK 1
-
-/* Define this if you have <vfork.h>. */
-/* #define HAVE_VFORK_H 1 */
-
-/* Define this if you don't have <stdlib.h> */
-/* #define STDLIB_H_MISSING 1 */
-
-/* Define this if you don't have <stddef.h> */
-/* #define STDDEF_H_MISSING 1 */
-
-/* Define this if you don't have <limits.h> */
-/* #define LIMITS_H_MISSING 1 */
-
-/* Define this if you don't have remove(); unlink() will be used instead. */
-/* #define REMOVE_MISSING 1 */
-
-/* Define this if you don't have raise(); kill() will be used instead. */
-/* #define RAISE_MISSING 1 */
-
-/* Define this if you don't have fsetpos() and fgetpos(). */
-/* #define FPOS_MISSING 1 */
-
-/* Universal pointer type. */
-/* If your compiler doesn't fully support void *, change `void' to `char'. */
-typedef void *UNIV;
-
-/* If your compiler doesn't support void as a function return type,
-change `void' to `int'. */
-typedef void VOID;
-
-/* If you don't have an ANSI C conformant <limits.h>, define
-CHAR_SIGNED as 1 or 0 according to whether the `char' type is signed.
-The <limits.h> on some versions of System Release V 3.2 is not ANSI C
-conformant: the value of CHAR_MIN is 0 even though the `char' type is
-signed. */
-
-/* #define CHAR_SIGNED 1 */
-/* #define CHAR_SIGNED 0 */
-#ifndef CHAR_SIGNED
-#include <limits.h>
-#if CHAR_MIN < 0
-#define CHAR_SIGNED 1
-#else
-#define CHAR_SIGNED 0
-#endif
-#endif /* not CHAR_SIGNED */
-
-/* Assume the system character set is ISO Latin-1. */
-#include "latin1.h"
diff --git a/usr.bin/sgmls/sgmls/context.c b/usr.bin/sgmls/sgmls/context.c
deleted file mode 100644
index 10a123a..0000000
--- a/usr.bin/sgmls/sgmls/context.c
+++ /dev/null
@@ -1,451 +0,0 @@
-#include "sgmlincl.h" /* #INCLUDE statements for SGML parser. */
-#include "context.h"
-
-#define GI (tags[ts].tetd->etdgi+1) /* GI of current element. */
-#define NEWGI (newetd->etdgi+1) /* GI of new tag. */
-#define STATUS (*statuspt) /* Token status: RCHIT RCMISS RCEND RCREQ RCNREQ*/
-#define PEX (-1) /* GI is a plus exception and not a minus. */
-
-#define ANYHIT(h) (grplongs == 1 ? ((h)[0] != 0) : anyhit(h))
-#define HITSET(h, n) (h[(unsigned)(n-1)>>LONGPOW] \
- |= (1L<<((n-1)&(LONGBITS-1))))
-#define HITON(h, n) (h[(unsigned)(n-1)>>LONGPOW] & (1L<<((n-1)&(LONGBITS-1))))
-
-#define HITOFF(h, n) (!(HITON(h, n)))
-
-#define TOKENHIT HITON(H,T)
-
-static
-VOID copypos(to, from)
-struct mpos *to, *from;
-{
- int i;
- for (i = 0; i <= (int)from[0].t; i++) {
- to[i].g = from[i].g;
- to[i].t = from[i].t;
- memcpy(to[i].h, from[i].h, grplongs*sizeof(unsigned long));
- }
-}
-
-/* CONTEXT: Determine whether a GI is valid in the present structural context.
- Returns RCHIT if valid, RCEND if element has ended, RCREQ if a
- different element is required, and RCMISS if it is totally invalid.
- On entry, pos points to the model token to be tested against the GI.
- TO DO: Save allowed GIs for an error message on an RCMISS.
- Support a "query" mode (what is allowed now?) by working
- with a copy of pos.
-*/
-int context(gi, mod, pos, statuspt, mexts)
-struct etd *gi; /* ETD of new GI. */
-struct thdr mod[]; /* Model of current open element. */
-struct mpos pos[]; /* Position in open element's model. */
-UNCH *statuspt; /* Token status: RCHIT RCMISS RCEND RCREQ RCNREQ*/
-int mexts; /* >0=stack level of minus grp; -1=plus; 0=none.*/
-{
- UNCH toccsv, gtypesv; /* Save token's TOCC and GTYPE in case grp ends.*/
-
- if (mexts != 0) {
- if (mexts == -1 && STATUS == RCEND)
- return RCPEX;
- copypos(savedpos, pos);
- }
- Tstart = T; /* Save starting token for AND group testing. */
- while (STATUS!=RCMISS && STATUS!=RCEND) {
- TRACEGI("CONTEXT", gi, mod, pos);
- while (TTYPE==TTOR || TTYPE==TTSEQ || TTYPE==TTAND) {
- pos[P+1].g = M++; pos[++P].t = 1; HITCLEAR(H);
- Tstart = T; /* Save starting token for AND group testing. */
- TRACEGI("OPENGRP", gi, mod, pos);
- }
- STATUS = (UNCH)tokenreq(gi, mod, pos);
- TRACEGI("STATUS", gi, mod, pos);
- if (gi==TOKEN.tu.thetd) { /* Hit in model. */
- STATUS = (UNCH)RCHIT;
- gtypesv = GTYPE; toccsv = TOCC;
- newtoken(mod, pos, statuspt);
- if (mexts <= 0)
- return RCHIT;
- else if (gtypesv==TTOR || BITON(toccsv, TOPT)) {
- /* restore position */
- copypos(pos, savedpos);
- return RCMEX;
- }
- else
- return RCHITMEX;
- }
- if (STATUS==RCREQ) {
- if (mexts == -1)
- break;
- STATUS = RCHIT;
- nextetd = TOKEN.tu.thetd;
- newtoken(mod, pos, statuspt);
- return(RCREQ);
- }
- /* else if (STATUS==RCNREQ) */
- if (mexts>0) return(RCMEX);
- newtoken(mod, pos, statuspt);
- }
- if (mexts == -1) {
- copypos(pos, savedpos);
- return STATUS = RCPEX;
- }
- return((int)STATUS);
-}
-/* ECONTEXT: Determine whether the current element can be ended, or whether
- non-optional tokens remain at the current level or higher.
- Returns 1 if element can be ended, or 0 if tokens remain.
- On entry, STATUS==RCEND if there are no tokens left; if not,
- pos points to the next model token to be tested.
- TO DO: Support a "query" mode (what is required now?) by working
- with a copy of pos.
-*/
-int econtext(mod, pos, statuspt)
-struct thdr mod[]; /* Model of current open element. */
-struct mpos pos[]; /* Position in open element's model. */
-UNCH *statuspt; /* Token status: RCHIT RCMISS RCEND RCREQ RCNREQ*/
-{
- unsigned next; /* Position in AND group of next testable token.*/
-
- Tstart = T;
- TRACEEND("ECONT", mod, pos, 0, 0);
- if (P<=1) {nextetd = 0; return(TOKENHIT || BITON(TOCC, TOPT));}
- nextetd = TTYPE == TTETD ? TOKEN.tu.thetd : 0;
- while (STATUS!=RCMISS && STATUS!=RCEND) {
- STATUS = (UNCH)testend(mod, pos, 0, 0);
- TRACEEND("ECONTEND", mod, pos, 0, 0);
- nextetd = P<=1 || TTYPE != TTETD ? 0 : TOKEN.tu.thetd;
- if (STATUS==RCEND) return(1);
- if (P<=1) return(TOKENHIT || BITON(TOCC, TOPT));
- if (STATUS==RCMISS) {
- if (BITON(TOCC, TOPT)) nextetd = 0;
- return(0);
- }
- if (!tokenopt(mod, pos)) return(0);
-
- STATUS = RCNREQ;
- if (GTYPE!=TTAND) ++T; /* T!=GNUM or group would have ended. */
- else T = (UNCH)(((next = (UNS)offbit(H, (int)T, GNUM))!=0) ?
- next : offbit(H, 0, GNUM));
-
- M = G + grpsz(&GHDR, (int)T-1) + 1;
- TRACEEND("ECONTNEW", mod, pos, 0, 0);
- }
- if (STATUS==RCMISS) {
- if (BITON(TOCC, TOPT)) nextetd = 0;
- return(0);
- }
- return(1); /* STATUS==RCEND */
-}
-/* NEWTOKEN: Find the next token to test. Set STATUS to indicate results:
- RCEND if element has ended (no more tokens to test);
- RCREQ if required new token was found;
- RCNREQ if non-required new token was found;
- RCHIT if a hit token was repeated (now non-required);
- and RCMISS if a new token can't be found because current token
- (which was not hit) was neither unconditionally required nor
- optional.
-*/
-VOID newtoken(mod, pos, statuspt)
-struct thdr mod[]; /* Model of current open element. */
-struct mpos pos[]; /* Position in open element's model. */
-UNCH *statuspt; /* Token status: RCHIT RCMISS RCEND RCREQ RCNREQ*/
-{
- unsigned nextand = 0; /* Position in AND group of next testable token.*/
- int currhit = (STATUS==RCHIT); /* 1=current GI hit; 0=not. */
-
- /* If the GI was a hit, turn on the hit bit and set the status to
- assume that the token to be tested against the next GI will
- be non-required. If the current token is repeatable, exit so
- it will stand as the next token to test.
- */
- if (STATUS==RCHIT) {
- HITSET(H, T);
- STATUS = RCNREQ;
- if (BITON(TOCC, TREP)) return;
- }
- /* At this point, we must determine the next token to test:
- either against the next GI, if this one was a hit, or
- against the same GI if conditions permit a retry.
- To find the next token, we must first end the current group,
- if possible, and any we can that contain it.
- If the outermost group was a hit and is repeatable, or
- if the element has ended, we exit now.
- If it hasn't ended, or was optional and ended with a miss,
- we can retry the GI against the next token.
- */
- if ((STATUS = (UNCH)testend(mod, pos, 1, 1))!=RCNREQ) return;
-
- /* At this point, the "current token" is either the original one,
- or the token for the highest level unhit group that it ended.
- We will retry a missed GI, by testing it against the next
- token, if the current token:
- 1. Is optional;
- 2. Was hit (i.e., because it is repeatable and was hit by a
- previous GI or because it is a hit group that just ended);
- 3. Is in an AND or OR group and is not the last testable token.
-
- It will be the next sequential one (unhit one, in an AND group);
- if there are none left, use the first unhit token in the group.
- In either case, set M to correspond to the new T.
- */
- retest:
- TRACEEND("RETEST", mod, pos, (int)nextand, 1);
- if (GTYPE==TTAND) {
- nextand = offbit(H, (int)T, GNUM);
- if (!nextand)
- nextand = offbit(H, 0, GNUM);
- }
- if ( BITON(TOCC, TOPT)
- || TOKENHIT
- || GTYPE==TTOR /* T!=GNUM or group would have ended. */
- || nextand ) {
- if (GTYPE!=TTAND) ++T; /* T!=GNUM or group would have ended. */
- else T = nextand;
- M = G + grpsz(&GHDR, (int)T-1) + 1;
- if (GTYPE==TTAND) {
- /* If AND group wrapped, it can end if all non-optionals were
- hit. */
- if (T==Tstart && !currhit) {
- UNCH Psave = P;
- int rc = testend(mod, pos, 0, 1);
- if (Psave!=P) {if ((STATUS = (UNCH)rc)==RCNREQ) goto retest;}
- else STATUS = RCMISS;
- }
-
- /* We only test unhit tokens, so we must use an unhit token
- as Tstart (which is used to detect when the AND group has
- wrapped). */
- else if (HITON(H,Tstart)) Tstart = T;
- }
- }
- else STATUS = RCMISS;
- TRACEEND("NEWTOKEN", mod, pos, (int)nextand, 1);
-}
-/* TESTEND: End the current group, if possible, and any that it is nested in.
- The current token will either be a group header, or some token
- that could not end its group. Return 1 if the (possibly new)
- current token is repeatable; 0 if it is not.
-*/
-int testend(mod, pos, andoptsw, newtknsw)
-struct thdr mod[]; /* Model of current open element. */
-struct mpos pos[]; /* Position in open element's model. */
-int andoptsw; /* 1=test optional AND members; 0=ignore. */
-int newtknsw; /* 1=new token test; 0=end element test. */
-{
- int rc = 0; /* Return code: RCNREQ RCHIT RCMISS RCEND */
-
- while (!rc) {
- TRACEEND("TRACEEND", mod, pos, rc, andoptsw);
- /* TESTMISS:
- If we've hit no tokens yet in the current group, and
- the current token is the last unhit one in the group we can test,
- we will end the group (it may never really have started!)
- because we might be able to try the token that follows it.
- In any group, a token is the last testable unhit token if it
- is the last sequential one, as the GI was already tested against
- the preceding unhit tokens. In addition,
- in a SEQ group, it is the last testable unhit token if it isn't
- optional, because we can't skip past it to the following ones.
- If we end the group, before popping the level, set M to G, as this
- level`s group header will be the next level's current token.
- */
- if (!ANYHIT(H) && (T==GNUM
- || (GTYPE==TTSEQ && BITOFF(TOCC, TOPT)))) {
- M = G; --P;
- if (P<=1) {
- if (BITON(TOCC, TOPT) || TOKENHIT) rc = RCEND;
- else rc = RCMISS;
- }
- continue;
- }
- /* TESTHIT:
- See if we've hit all the non-optional tokens in the group.
- If so, pop to the previous level and set the group's hit bit.
- If we were called from NEWTOKEN we are trying to find the token
- to test against the next start-tag, so if the group is repeatable,
- process it again. (If not, we were called from ECONTEXT and
- are testing whether the element can be ended.)
- Otherwise, if we are at the first level, the element is over.
- */
- if ((GTYPE==TTOR && TOKENHIT)
- || (GTYPE==TTSEQ && T==(UNCH)GNUM
- && (TOKENHIT || BITON(TOCC, TOPT)))
- || (GTYPE==TTAND && allhit(&GHDR, H, 0, andoptsw))) {
- M = G;
- --P;
- HITSET(H, T);
- Tstart = T;
- if (newtknsw && BITON(TOCC, TREP)) rc = RCHIT;
- else if (P<=1) rc = RCEND;
- /* If we are looking for a new token to test against the next
- start-tag, then we need to consider optional and members
- in this group, even if we didn't need to consider them
- in the group that we just ended because that group had
- wrapped. */
- else if (newtknsw) andoptsw = 1;
- /* Else loop to test new outer group. */
- }
- else rc = RCNREQ; /* No group ended this time, so return. */
- }
- TRACEEND("ENDFOUND", mod, pos, rc, andoptsw);
- return(rc);
-}
-/* TOKENOPT: Return 1 if current token is contextually optional;
- otherwise, return 0.
-*/
-int tokenopt(mod, pos)
-struct thdr mod[]; /* Model of current open element. */
-struct mpos pos[]; /* Position in open element's model. */
-{
- TRACEEND("TOKENOPT", mod, pos, 0, 0);
- return (BITON(TOCC, TOPT) /* Inherently optional. */
- || TOKENHIT /* Was hit (handles "plus" suffix case). */
- || (!ANYHIT(H) && groupopt(mod, pos)));
- /* In optional group with no hits. */
-}
-/* GROUPOPT: Temporarily makes the current group be the current token so that
- TOKENOPT() can be applied to it. Returns the value returned
- by TOKENOPT.
-*/
-int groupopt(mod, pos)
-struct thdr mod[]; /* Model of current open element. */
-struct mpos pos[]; /* Position in open element's model. */
-{
- UNCH saveM; /* Save M when testing if group is not required.*/
- int rc; /* 1=contextually optional; 0=not. */
-
- if (P==1) return(BITON(GOCC, TOPT) || TOKENHIT);
- saveM = M; M = G; --P;
- rc = tokenopt(mod, pos);
- ++P; G = M; M = saveM;
- return(rc);
-}
-/* TOKENREQ: Returns RCREQ if the current token is "contextually required".
- That is, it is not contextually optional and
- 1) it is a member of a "seq" group that is either required
- or has at least 1 hit token.
- 2) it is a member of an "and" group in which all other
- tokens were hit.
- Optional tokens are not counted
- if GI is ETDCDATA, as we are looking for an
- omitted start-tag. Otherwise, they are counted,
- as the GI might match one of them.
- Returns RCNREQ if the current token is "not required".
-*/
-int tokenreq(gi, mod, pos)
-struct etd *gi; /* ETD of new GI. */
-struct thdr mod[]; /* Model of current open element. */
-struct mpos pos[]; /* Position in open element's model. */
-{
- TRACEGI("TOKENREQ", gi, mod, pos);
- return( tokenopt(mod, pos) ? RCNREQ
- : ( GTYPE==TTSEQ && (ANYHIT(H) || groupreq(gi, mod, pos)==RCREQ)
-#if 0
- || (GTYPE==TTAND && allhit(&GHDR, H, T, \*gi!=ETDCDATA*\ 1))
-#endif
- )
- ? RCREQ : RCNREQ );
-}
-/* GROUPREQ: Temporarily makes the current group be the current token so that
- TOKENREQ() can be applied to it. Returns the value returned
- by TOKENREQ.
-*/
-int groupreq(gi, mod, pos)
-struct etd *gi; /* ETD of new GI. */
-struct thdr mod[]; /* Model of current open element. */
-struct mpos pos[]; /* Position in open element's model. */
-{
- UNCH saveM; /* Save M when testing if group is not required.*/
- int rc; /* Return code: RCREQ RCNREQ */
-
- if (P==1) return(BITOFF(GOCC, TOPT) ? RCREQ : RCNREQ);
- saveM = M; M = G; --P;
- rc = tokenreq(gi, mod, pos);
- ++P; G = M; M = saveM;
- return(rc);
-}
-/* GRPSZ: Returns the number of tokens spanned by a group in the model (M),
- from the group's start (G) to a specified index within the group (T).
- M = 0, plus 1 for each token in the group, plus the size of
- any subgroups (gotten by calling GRPSZ recursively). On entry,
- M must be equal to G at the current level.
-*/
-int grpsz(g, t)
-struct thdr *g; /* mod[G]: Ptr to group in the model. */
-int t; /* T: Index of last token in the group. */
-{
- struct thdr *p = g; /* Ptr to current token in the model. */
- int m = 0; /* Size of group (including nested groups). */
- int i = 0; /* Number of group members (loop counter). */
- UNS type; /* Token type (without TOREP bits). */
-
- while (++i<=t) {
- ++p; ++m;
- type = GET(p->ttype, TTMASK);
- if (type==TTOR || type==TTSEQ || type==TTAND) {
- m += grpsz(p, p->tu.tnum);
- p = g+m;
- }
- }
- return(m);
-}
-/* ALLHIT: Returns 1 if all hit bits for the specified group are turned on,
- (other than those that correspond to optional tokens if "opt" is
- 0) and the "but" bit (all bits if "but" bit is zero). Otherwise,
- returns 0. GRPSZ is used to skip past subgroup tokens.
-*/
-int allhit(p, hits, but, opt)
-struct thdr *p; /* mod[G]: Ptr to group in the model. */
-unsigned long *hits; /* H: Hit bits to be tested. */
-int but; /* Index of bit to ignore; 0=test all. */
-int opt; /* 1=optional tokens must be hit; 0=ignore. */
-{
- int b = 0; /* Index of bit being tested in hits. */
- int e = p->tu.tnum; /* Ending index (number of bits to test). */
- unsigned type; /* Token type (without TOREP bits). */
-
- while (++p, ++b<=e) {
- if (HITOFF(hits,b) && (opt || BITOFF(p->ttype,TOPT)) && b!=but)
- return 0;
- if ((type = GET(p->ttype,TTMASK))==TTOR || type==TTSEQ || type==TTAND)
- p += grpsz(p, p->tu.tnum);
- }
- return 1;
-}
-/* OFFBIT: Returns the index of the first unset bit after (i.e., not including)
- the caller's "first" bit. If all bits through the
- specified last bit are on, it returns 0.
-*/
-int offbit(bits, first, last)
-unsigned long *bits; /* Bits to be tested. */
-int first; /* Index of first bit to be tested in bits. */
-int last; /* Index of last bit to be tested in bits. */
-{
- while (++first <= last)
- if (HITOFF(bits, first))
- return first;
- return 0;
-}
-
-/* ANYHIT: Return 1 if any bit is set. */
-
-int anyhit(bits)
-unsigned long *bits;
-{
- int i;
- for (i = 0; i < grplongs; i++)
- if (bits[i] != 0)
- return 1;
- return 0;
-}
-
-/*
-Local Variables:
-c-indent-level: 5
-c-continued-statement-offset: 5
-c-brace-offset: -5
-c-argdecl-indent: 0
-c-label-offset: -5
-comment-column: 30
-End:
-*/
diff --git a/usr.bin/sgmls/sgmls/context.h b/usr.bin/sgmls/sgmls/context.h
deleted file mode 100644
index 01f4383..0000000
--- a/usr.bin/sgmls/sgmls/context.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/* context.h */
-
-#define M pos[0].g /* Index of current token in model. */
-#ifdef P
-#undef P
-#endif
-#define P pos[0].t /* Index of current group in pos. */
-#define G pos[P].g /* Index of current group in model. */
-#define T pos[P].t /* Index of current token in its group. */
-#define Tstart pos[P].tstart /* Index of starting token in its group
- for AND group testing. */
-#define H pos[P].h /* Pointer to hit bits for current group. */
-#define GHDR mod[G] /* Current group header. */
-#define TOKEN mod[M] /* Current token. */
-#define TTYPE (GET(TOKEN.ttype, TTMASK)) /* Token type of current token. */
-#define TOCC (GET(TOKEN.ttype, TOREP)) /* Occurrence for current token. */
-#define GTYPE (GET(GHDR.ttype, TTMASK)) /* Token type of current group. */
-#define GOCC (GET(GHDR.ttype, TOREP)) /* Occurrence for current group. */
-#define GNUM GHDR.tu.tnum /* Number of tokens in current grp. */
diff --git a/usr.bin/sgmls/sgmls/dosproc.c b/usr.bin/sgmls/sgmls/dosproc.c
deleted file mode 100644
index 99b526d..0000000
--- a/usr.bin/sgmls/sgmls/dosproc.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/* dosproc.c -
-
- MS-DOS implementation of run_process().
-
- Written by James Clark (jjc@jclark.com).
-*/
-
-#include "config.h"
-
-#ifdef SUPPORT_SUBDOC
-
-#include "std.h"
-#include "entity.h"
-#include "appl.h"
-
-#include <process.h>
-
-int run_process(argv)
-char **argv;
-{
- int ret;
- fflush(stdout);
- fflush(stderr);
- ret = spawnvp(P_WAIT, argv[0], argv);
- if (ret < 0)
- appl_error(E_EXEC, argv[0], strerror(errno));
- return ret;
-}
-
-#endif /* SUPPORT_SUBDOC */
-
-/*
-Local Variables:
-c-indent-level: 5
-c-continued-statement-offset: 5
-c-brace-offset: -5
-c-argdecl-indent: 0
-c-label-offset: -5
-End:
-*/
diff --git a/usr.bin/sgmls/sgmls/ebcdic.c b/usr.bin/sgmls/sgmls/ebcdic.c
deleted file mode 100644
index b8188c7..0000000
--- a/usr.bin/sgmls/sgmls/ebcdic.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/* ASCII to EBCDIC (ISO 8859-1 to IBM CP 37v2) table. */
-/* Contributed by C. M. Sperberg-McQueen <u35395@uicvm.uic.edu>. */
-
-/* The mapping must be 1 to 1. The positions of *CHAR and *CH in the table
-must not be changed, although the values in ebcdic.h can be. */
-
-#include "ebcdic.h"
-
-unsigned char charset[] = {
- 0, 1, 2, 3, 55, 45, 46, 47,
- GENRECHAR, TABCHAR, RSCHAR, 11, 12, RECHAR, 14, 15,
- 16, 17, 18, 19, 60, 61, 50, 38,
- 24, 25, EOFCHAR, 39, EOBCHAR, DELCDATA, DELSDATA, DELNONCH,
- SPCCHAR, 90, 127, 123, 91, 108, 80, 125,
- 77, 93, 92, 78, 107, 96, 75, 97,
-240, 241, 242, 243, 244, 245, 246, 247,
-248, 249, 122, 94, 76, 126, 110, 111,
-124, 193, 194, 195, 196, 197, 198, 199,
-200, 201, 209, 210, 211, 212, 213, 214,
-215, 216, 217, 226, 227, 228, 229, 230,
-231, 232, 233, 173, 224, 189, 176, 109,
-121, 129, 130, 131, 132, 133, 134, 135,
-136, 137, 145, 146, 147, 148, 149, 150,
-151, 152, 153, 162, 163, 164, 165, 166,
-167, 168, 169, 192, 79, 208, 161, 7,
- 4, 6, 8, 9, 10, 20, 21, 23,
- 26, 27, 32, 33, 34, 35, 36, 40,
- 41, 42, 43, 44, 48, 49, 51, 52,
- 53, 54, 56, 57, 58, 59, 62, 255,
- 65, 170, 74, 177, 159, 178, 106, 181,
-187, 180, 154, 138, 95, 202, 175, 188,
-144, 143, 234, 250, 190, 160, 182, 179,
-157, 218, 155, 139, 183, 184, 185, 171,
-100, 101, 98, 102, 99, 103, 158, 104,
-116, 113, 114, 115, 120, 117, 118, 119,
-172, 105, 237, 238, 235, 239, 236, 191,
-128, 253, 254, 251, 252, 186, 174, 89,
- 68, 69, 66, 70, 67, 71, 156, 72,
- 84, 81, 82, 83, 88, 85, 86, 87,
-140, 73, 205, 206, 203, 207, 204, 225,
-112, 221, 222, 219, 220, 141, 142, 223,
-};
diff --git a/usr.bin/sgmls/sgmls/ebcdic.h b/usr.bin/sgmls/sgmls/ebcdic.h
deleted file mode 100644
index 3e0f3bd..0000000
--- a/usr.bin/sgmls/sgmls/ebcdic.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* SGML Character Use: EBCDIC
-*/
-
-#define EOFCHAR '\077' /* FUNCTION: EE (entity end: files). */
-#define EOBCHAR '\034' /* NONCHAR: EOB (file entity: end of buffer. */
-#define RSCHAR '\045' /* FUNCTION: RS (record start). */
-#define RECHAR '\015' /* FUNCTION: RE (record end). */
-#define TABCHAR '\005' /* FUNCTION: TAB (horizontal tab). */
-#define SPCCHAR '\100' /* FUNCTION: SPACE (horizontal space). */
-#define GENRECHAR '\026' /* NONCHAR: Generated RE. */
-#define DELCDATA '\035' /* NONCHAR: Delimiter for CDATA entity in
- attribute value. */
-#define DELSDATA '\036' /* NONCHAR: Delimiter for SDATA entity in
- attribute value. */
-#define DELNONCH '\037' /* NONCHAR: non-SGML character prefix. */
-
-/* This should work for EBCDIC. See comment in latin1.h. */
-#define SHIFTNON(ch) ((UNCH)(ch) | 0200)
-#define UNSHIFTNON(ch) ((UNCH)(ch) & ~0200)
-
-/* See comment in latin1.h. */
-#define CANON_NONSGML 255
-
-/* See comment in latin1.h. */
-#define CANON_DATACHAR 254
diff --git a/usr.bin/sgmls/sgmls/entgen.c b/usr.bin/sgmls/sgmls/entgen.c
deleted file mode 100644
index 2146829..0000000
--- a/usr.bin/sgmls/sgmls/entgen.c
+++ /dev/null
@@ -1,517 +0,0 @@
-/* entgen.c -
-
- Implement entgen() which generates a list of filenames from a struct fpi.
-
- Written by James Clark (jjc@jclark.com).
-*/
-
-#include "config.h"
-
-#ifdef HAVE_ACCESS
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h> /* For R_OK. */
-#endif /* HAVE_UNISTD_H */
-
-#ifndef R_OK
-#define R_OK 4
-#endif /* not R_OK */
-
-#endif /* HAVE_ACCESS */
-
-#include "sgmlaux.h"
-
-/* Environment variable that contains path. */
-#ifndef PATH_ENV_VAR
-#define PATH_ENV_VAR "SGML_PATH"
-#endif
-/* Default search path. See field() for interpretation of %*. */
-#ifndef DEFAULT_PATH
-#define DEFAULT_PATH "/usr/local/lib/sgml/%O/%C/%T:%N.%X:%N.%D"
-#endif
-
-#ifndef PATH_FILE_SEP
-#define PATH_FILE_SEP ':'
-#endif
-
-#ifndef SYSID_FILE_SEP
-#define SYSID_FILE_SEP ':'
-#endif
-
-/* This says: change space to underscore, slash to percent. */
-
-#ifndef MIN_DAT_SUBS_FROM
-#define MIN_DAT_SUBS_FROM " /"
-#endif
-#ifndef MIN_DAT_SUBS_TO
-#define MIN_DAT_SUBS_TO "_%"
-#endif
-
-static int field P((struct fpi *, int, char *));
-static int mindatcpy P((char *, char *, int, int));
-static int testopen P((char *));
-static UNIV sysidgen P((char *));
-static UNIV catsysidgen P((const char *, const char *));
-static const char *basename P((const char *));
-
-static char *path = 0;
-
-/* Non-zero if searching should be performed when a system identifier
-is specified. */
-static int sysidsrch = 0;
-
-#define EMPTY_VERSION "default"
-
-static char *classes[] = {
- "capacity",
- "charset",
- "notation",
- "syntax",
- "document",
- "dtd",
- "elements",
- "entities",
- "lpd",
- "nonsgml",
- "shortref",
- "subdoc",
- "text"
- };
-
-/* This is mainly for compatibility with arcsgml. */
-
-static char *genext[] = {
- "nsd", /* Non-SGML data entity. */
- "gml", /* GML document or text entity. */
- "spe", /* System parameter entity. */
- "dtd", /* Document type definition. */
- "lpd", /* Link process definition. */
- "pns", /* Public non-SGML data entity. */
- "pge", /* Public general entity. */
- "ppe", /* Public parameter entity. */
- "pdt", /* Public document type definition. */
- "plp", /* Public link process definition. */
- "vns", /* Display version non-SGML data entity. */
- "vge", /* Display version general entity. */
- "vpe", /* Display version parameter entity. */
- "vdt", /* Display version document type definition.*/
- "vlp", /* Display version link process definition.*/
-};
-
-static char *ext[] = {
- "sgml", /* SGML subdocument */
- "data", /* Data */
- "text", /* General text */
- "parm", /* Parameter entity */
- "dtd", /* Document type definition */
- "lpd", /* Link process definition */
-};
-
-static CATALOG catalog;
-
-VOID entginit(swp)
-struct switches *swp;
-{
- catalog = swp->catalog;
-}
-
-/* Like memcpy, but substitute, fold to lower case (if fold is
-non-zero) and null terminate. This is used both for minimum data and
-for names. If p is NULL, do nothing. Return len. */
-
-static int mindatcpy(p, q, len, fold)
-char *p, *q;
-int len;
-int fold;
-{
- static char subsfrom[] = MIN_DAT_SUBS_FROM;
- static char substo[] = MIN_DAT_SUBS_TO;
- int n;
-
- if (!p)
- return len;
- for (n = len; --n >= 0; q++) {
- char *r = strchr(subsfrom, *q);
- if (!r) {
- if (fold && ISASCII(*q) && isupper((UNCH)*q))
- *p++ = tolower((UNCH)*q);
- else
- *p++ = *q;
- }
- else {
- int i = r - subsfrom;
- if (i < sizeof(substo) - 1)
- *p++ = substo[i];
- }
- }
- *p = '\0';
- return len;
-}
-
-
-/* Return length of field. Copy into buf if non-NULL. */
-
-static int field(f, c, buf)
-struct fpi *f;
-int c;
-char *buf;
-{
- int n;
-
- switch (c) {
- case '%':
- if (buf) {
- buf[0] = '%';
- buf[1] = '\0';
- }
- return 1;
- case 'N': /* the entity, document or dcn name */
- return mindatcpy(buf, (char *)f->fpinm, ustrlen(f->fpinm),
- (f->fpistore != 1 && f->fpistore != 2 && f->fpistore != 3
- ? NAMECASE
- : ENTCASE));
- case 'D': /* dcn name */
- if (f->fpistore != 1) /* not a external data entity */
- return -1;
- if (f->fpinedcn == 0) /* it's a SUBDOC */
- return -1;
- return mindatcpy(buf, (char *)f->fpinedcn, ustrlen(f->fpinedcn),
- NAMECASE);
- case 'X':
- /* This is for compatibility with arcsgml */
- if (f->fpistore < 1 || f->fpistore > 5)
- return -1;
- n = (f->fpipubis != 0)*(f->fpiversw > 0 ? 2 : 1)*5+f->fpistore - 1;
- if (buf)
- strcpy(buf, genext[n]);
- return strlen(genext[n]);
- case 'Y': /* tYpe */
- n = f->fpistore;
- if (n < 1 || n > 5)
- return -1;
- if (n == 1 && f->fpinedcn == 0) /* it's a SUBDOC */
- n = 0;
- if (buf)
- strcpy(buf, ext[n]);
- return strlen(ext[n]);
- case 'P': /* public identifier */
- if (!f->fpipubis)
- return -1;
- return mindatcpy(buf, (char *)f->fpipubis, ustrlen(f->fpipubis), 0);
- case 'S': /* system identifier */
- if (!f->fpisysis)
- return -1;
- else {
- UNCH *p;
- n = 0;
- for (p = f->fpisysis; *p; p++)
- if (*p != RSCHAR) {
- if (buf)
- buf[n] = *p == RECHAR ? '\n' : *p;
- n++;
- }
- return n;
- }
- }
- /* Other fields need a formal public identifier. */
- /* return -1 if the formal public identifier was invalid or missing. */
- if (f->fpiversw < 0 || !f->fpipubis)
- return -1;
-
- switch (c) {
- case 'A': /* Is it available? */
- return f->fpitt == '+' ? 0 : -1;
- case 'I': /* Is it ISO? */
- return f->fpiot == '!' ? 0 : -1;
- case 'R': /* Is it registered? */
- return f->fpiot == '+' ? 0 : -1;
- case 'U': /* Is it unregistered? */
- return f->fpiot == '-' ? 0 : -1;
- case 'L': /* public text language */
- if (f->fpic == FPICHARS)
- return -1;
- /* it's entered in all upper case letters */
- return mindatcpy(buf, (char *)f->fpipubis + f->fpil, f->fpill, 1);
- case 'O': /* owner identifier */
- return mindatcpy(buf, (char *)f->fpipubis + f->fpio, f->fpiol, 0);
- case 'C': /* public text class */
- n = f->fpic - 1;
- if (n < 0 || n >= sizeof(classes)/sizeof(classes[0]))
- return -1;
- if (buf)
- strcpy(buf, classes[n]);
- return strlen(classes[n]);
- case 'T': /* text description */
- return mindatcpy(buf, (char *)f->fpipubis + f->fpit, f->fpitl, 0);
- case 'V':
- if (f->fpic < FPICMINV) /* class doesn't have version */
- return -1;
- if (f->fpiversw > 0) /* no version */
- return -1;
- if (f->fpivl == 0) { /* empty version: */
- /* use device-independent version*/
- if (buf)
- strcpy(buf, EMPTY_VERSION);
- return strlen(EMPTY_VERSION);
- }
- return mindatcpy(buf, (char *)f->fpipubis + f->fpiv, f->fpivl, 0);
- case 'E': /* public text designating (escape) sequence */
- if (f->fpic != FPICHARS)
- return -1;
- return mindatcpy(buf, (char *)f->fpipubis + f->fpil, f->fpill, 0);
- default:
- break;
- }
- return -1;
-}
-
-static int testopen(pathname)
-char *pathname;
-{
-#ifdef HAVE_ACCESS
- return access(pathname, R_OK) >= 0;
-#else /* not HAVE_ACCESS */
- FILE *fp;
- fp = fopen(pathname, "r");
- if (!fp)
- return 0;
- fclose(fp);
- return 1;
-#endif /* not HAVE_ACCESS */
-}
-
-/* Return a pointer to an dynamically-allocated buffer that contains
- the names of the files containing this entity, with each filename
- terminated by a '\0', and with the list of filenames terminated by
- another '\0'. */
-
-UNIV entgen(f)
-struct fpi *f;
-{
- char *qname;
- char *file;
- enum catalog_decl_type dtype;
- char *subst = 0;
- const char *sysid;
- const char *catfile;
-
- assert(f->fpistore != 6); /* Musn't call entgen for a notation. */
- if (!path) {
- char *p;
- char c;
- path = getenv(PATH_ENV_VAR);
- if (!path)
- path = DEFAULT_PATH;
- p = path;
-
- /* Only search for system identifiers if path uses %S. */
- while ((c = *p++) != '\0')
- if (c == '%') {
- if (*p == 'S') {
- sysidsrch = 1;
- break;
- }
- if (*p != '\0' && *p != PATH_FILE_SEP)
- p++;
- }
- }
-
- if (f->fpisysis && !sysidsrch)
- return sysidgen((char *)f->fpisysis);
-
- qname = (char *)f->fpinm;
-
- switch (f->fpistore) {
- case 3:
- /* fall through */
- qname--; /* hack */
- case 1:
- case 2:
- dtype = CATALOG_ENTITY_DECL;
- if (ENTCASE)
- subst = getsubst();
- break;
- case 4:
- dtype = CATALOG_DOCTYPE_DECL;
- if (NAMECASE)
- subst = getsubst();
- break;
- default:
- dtype = CATALOG_NO_DECL;
- }
-
- if (catalog_lookup_entity(catalog,
- (char *)f->fpipubis,
- qname,
- dtype,
- (char *)subst,
- &sysid,
- &catfile))
- return catsysidgen(sysid, catfile);
- if (f->fpisysis
- && (strchr((char *)f->fpisysis, SYSID_FILE_SEP)
- || strcmp((char *)f->fpisysis, STDINNAME) == 0))
- return sysidgen((char *)f->fpisysis);
-
- file = path;
-
- for (;;) {
- char *p;
- int len = 0;
- char *fileend = strchr(file, PATH_FILE_SEP);
- if (!fileend)
- fileend = strchr(file, '\0');
-
- /* Check that all substitutions are non-null, and calculate
- the resulting total length of the filename. */
- for (p = file; p < fileend; p++)
- if (*p == '%') {
- int n;
- /* Set len to -1 if a substitution is invalid. */
- if (++p >= fileend) {
- len = -1;
- break;
- }
- n = field(f, *p, (char *)0);
- if (n < 0) {
- len = -1;
- break;
- }
- len += n;
- }
- else
- len++;
-
- if (len > 0) {
- /* We've got a valid non-empty filename. */
- char *s;
- char *buf;
-
- s = buf = (char *)rmalloc(len + 2);
- for (p = file; p < fileend; p++)
- if (*p == '%')
- s += field(f, *++p, s);
- else
- *s++ = *p;
- *s++ = '\0';
- if (testopen(buf)) {
- /* Terminate the array of filenames. */
- *s++ = '\0';
- return buf;
- }
- free((UNIV)buf);
- }
- if (*fileend == '\0')
- break;
- file = ++fileend;
- }
- return 0;
-}
-
-/* Handle a system identifier without searching. */
-
-static
-UNIV sysidgen(s)
-char *s;
-{
- char *buf, *p;
-
- buf = (char *)rmalloc(strlen(s) + 2);
-
- for (p = buf; *s; s++) {
- if (*s == SYSID_FILE_SEP) {
- if (p > buf && p[-1] != '\0')
- *p++ = '\0';
- }
- else if (*s == RECHAR)
- *p++ = '\n';
- else if (*s != RSCHAR)
- *p++ = *s;
- }
- /* Terminate this filename. */
- if (p > buf && p[-1] != '\0')
- *p++ = '\0';
- if (p == buf) {
- /* No filenames. */
- frem((UNIV)buf);
- return 0;
- }
- /* Terminate the list. */
- *p++ = '\0';
- return buf;
-}
-
-/* Handle a system id in a catalog entry file. */
-static
-UNIV catsysidgen(s, catfile)
-const char *s;
-const char *catfile;
-{
- const char *p;
- char *bufp;
- char *buf;
- int nrelative = 0;
- int catdirlen = 0;
- if (FILE_IS_RELATIVE(s))
- nrelative++;
- for (p = s; *p; p++)
- if (*p == SYSID_FILE_SEP
- && FILE_IS_RELATIVE(p + 1))
- nrelative++;
- if (nrelative) {
- const char *base = basename(catfile);
- catdirlen = base - catfile;
- }
- buf = (char *)rmalloc(p - s + 2 + nrelative*catdirlen);
- bufp = buf;
- for (;;) {
- if (!*s)
- break;
- if (*s != SYSID_FILE_SEP && FILE_IS_RELATIVE(s)) {
- memcpy(bufp, catfile, catdirlen);
- bufp += catdirlen;
- }
- for (;;) {
- if (*s == SYSID_FILE_SEP) {
- s++;
- break;
- }
- *bufp++ = *s++;
- if (*s == '\0')
- break;
- }
- if (bufp > buf && bufp[-1] != '\0')
- *bufp++ = '\0';
- }
- if (bufp == buf) {
- frem((UNIV)buf);
- return 0;
- }
- *bufp++ = '\0';
- return buf;
-}
-
-static
-const char *basename(s)
-const char *s;
-{
- const char *p = s;
- while (*p)
- p++;
- if (p > s) {
- while (--p > s)
- if (strchr(DIR_BASE_SEP, *p))
- return p + 1;
- }
- return s;
-}
-
-/*
-Local Variables:
-c-indent-level: 5
-c-continued-statement-offset: 5
-c-brace-offset: -5
-c-argdecl-indent: 0
-c-label-offset: -5
-End:
-*/
diff --git a/usr.bin/sgmls/sgmls/entity.h b/usr.bin/sgmls/sgmls/entity.h
deleted file mode 100644
index 84a3515..0000000
--- a/usr.bin/sgmls/sgmls/entity.h
+++ /dev/null
@@ -1,192 +0,0 @@
-/* Struct dcncb: attribute list added to support data attributes. */
-#ifndef ENTITY_H /* Don't include this file more than once. */
-#define ENTITY_H
-/* ENTITY.H: Definitions and control block templates for entity management.
-*/
-#include "tools.h" /* Definitions for type declarations, etc. */
-#include "msgcat.h"
-#include "catalog.h"
-
-#define STDINNAME "-" /* File name that refers to standard input. */
-
-#define EOS '\0' /* NONCHAR: EE (entity end: strings). */
-
-#define AVALCASE 2 /* 2=untranslated string of name characters. */
-
-#define REFNAMELEN 8 /* reference quantity set NAMELEN */
-#define REFLITLEN 240 /* reference quantity set LITLEN */
-
-/* Minimization status of returned tags.
-*/
-#define MINNONE 0 /* Minimization: tag not minimized. */
-#define MINNULL 1 /* Minimization: tag was null. */
-#define MINNET 2 /* Minimization: end-tag was NET delimiter. */
-#define MINDATA 3 /* Minimization: end-tag was data tag. */
-#define MINSTAG 4 /* Minimization: tag implied by start-tag. */
-#define MINETAG 5 /* Minimization: end-tag implied by end-tag. */
-
-/* Formal public identifier public text classes.
-*/
-#define FPICAP 1
-#define FPICHARS 2
-#define FPINOT 3
-#define FPISYN 4
-#define FPICMINV 5 /* Minimum fpic value for versionable text. */
-#define FPIDOC 5
-#define FPIDTD 6
-#define FPIELEM 7
-#define FPIENT 8
-#define FPILPD 9
-#define FPINON 10
-#define FPISHORT 11
-#define FPISUB 12
-#define FPITEXT 13
-struct fpi { /* Formal public identifier. */
- UNCH fpiot; /* Owner type: + or - or ! (for ISO). */
- UNS fpiol; /* Length of owner identifier. */
- UNS fpio; /* Offset in pubis of owner identifier (no EOS).*/
- int fpic; /* Public text class. */
- UNCH fpitt; /* Text type: - or + (for available). */
- UNS fpitl; /* Length of text identifier. */
- UNS fpit; /* Offset in pubis of text identifier (no EOS). */
- UNS fpill; /* Language/designating sequence length. */
- UNS fpil; /* Offset in pubis of language. */
- UNS fpivl; /* Length of display version . */
- UNS fpiv; /* Offset in pubis of display version (no EOS). */
- int fpiversw; /* 1=use best ver; 0=use stated ver; -1=error. */
- UNCH *fpinm; /* Entity/DCN name (EOS, no length). */
- UNCH fpistore; /* 1=NDATA 2=general 3=parm 4=DTD 5=LPD 6=DCN. */
- /* Name of the entity's DCN. Valid only when fpistore == 1.
- NULL if it's a SUBDOC. */
- UNCH *fpinedcn;
- UNCH *fpipubis; /* Public ID string (EOS). */
- UNCH *fpisysis; /* System ID string (EOS). */
-};
-#define FPISZ sizeof(struct fpi)
-typedef struct fpi *PFPI; /* Ptr to FPI control block. */
-
-/* General control blocks.
-*/
-#define NONONCH 1 /* Character references to non-chars invalid. */
-#define OKNONCH 0 /* Character references to non-chars allowed. */
-struct parse { /* Parse control block. */
- char *pname; /* Parse name; content, tag, etc. */
- UNCH *plex; /* Lexical analysis table. */
- UNCH **ptab; /* State and action table. */
- UNS state; /* State. */
- UNS input; /* Input. */
- UNS action; /* Action. */
- UNS newstate; /* Next state. */
-};
-struct restate {
- UNS sstate; /* State. */
- UNS sinput; /* Input. */
- UNS saction; /* Action. */
- UNS snext; /* Next state. */
-};
-struct map {
- UNCH *mapnm; /* Name followed by EOS. */
- int mapdata; /* Data associated with that name. */
-};
-struct hash { /* Dummy structure for function arguments. */
- struct hash *enext; /* Next entry in chain. */
- UNCH *ename; /* Entry name with size and EOS. */
-};
-typedef struct hash *PHASH; /* Ptr to hash table entry. */
-typedef struct hash **THASH; /* Ptr to hash table. */
-
-struct fwdref { /* A forward id reference. */
- struct fwdref *next; /* Pt to next reference in chain. */
- UNIV msg; /* Ptr to saved error messsage. */
-};
-#define FWDREFSZ sizeof(struct fwdref)
-
-struct dcncb { /* Data content notation control block. */
- struct dcncb *enext; /* Next DCN in chain. */
- UNCH *ename; /* Notation name followed by EOS. */
- UNCH mark; /* For use by application. */
- UNCH entsw; /* Entity defined with this notation? */
- UNCH defined; /* Has this notation been defined. */
- UNCH *sysid; /* System identifier of notation. */
- UNCH *pubid; /* Public identifier of notation. */
- struct ad *adl; /* Data attribute list (NULL if none). */
-};
-#define DCBSZ sizeof(struct dcncb)
-#define DCNMARK(p) ((p)->mark ? 1 : ((p)->mark = 1, 0))
-
-typedef struct dcncb *PDCB; /* Ptr to DCN control block. */
-
-/* Number of capacities in a capacity set. */
-
-#define NCAPACITY 17
-
-struct sgmlcap {
- char **name;
- UNCH *points;
- long *number;
- long *limit;
-};
-
-struct sgmlstat { /* Document statistics. */
- UNS dcncnt; /* Number of data content notations defined. */
- UNS pmexgcnt; /* Number of plus or minus exception groups. */
- UNS etdcnt; /* Number of element types declared. */
- UNS etdercnt; /* Number of element types defined by default. */
- UNS pmexcnt; /* Number of plus/minus exception grp members. */
- UNS modcnt; /* Number of content model tokens defined. */
- UNS attcnt; /* Number of attributes defined. */
- UNS attdef; /* Characters of attribute defaults defined. */
- UNS attgcnt; /* Number of att value grp members (incl dcn). */
- UNS idcnt; /* Number of ID attributes specified. */
- UNS idrcnt; /* Number of ID references specified. */
- UNS ecbcnt; /* Number of entities declared. */
- UNS ecbtext; /* Characters of entity text defined. */
- UNS srcnt; /* Number of short reference tables defined. */
- UNS dcntext; /* Characters of notation identifiers defined. */
-};
-struct switches { /* Parser control switches (1=non-standard). */
- int swdupent; /* 1=msg if duplicate ENTITY def attempted;0=no.*/
- int swcommnt; /* 1=return comment declarations as data; 0=no. */
- int swrefmsg; /* 1=msg if undeclared ref is defaulted; 0=no. */
- UNS swbufsz; /* Size of source file buffer for READ(). */
- int swenttr; /* 1=trace entity stack in error messages; 0=no.*/
- int sweltr; /* 1=trace element stack in error messages; 0=no. */
- int swambig; /* 1=check content model ambiguity */
- int swundef; /* 1=warn about undefined elements. */
- int swcap; /* 1=report capcity errors */
- char *prog; /* Program name for error messages. */
-#ifdef TRACE
- char *trace; /* What to trace in the body. */
- char *ptrace; /* What to trace in the prolog. */
-#endif /* TRACE */
- nl_catd catd; /* Message catalog descriptor. */
- long nopen; /* Number of open document entities */
- int onlypro; /* Parse only the prolog. */
- char **includes; /* List of parameter entities to be defined
- as "INCLUDE"; NULL terminated.*/
- VOID (*die) P((void)); /* Function to call on fatal error. */
- CATALOG catalog; /* Catalog for generating system identifiers. */
-};
-struct markup { /* Delimiter strings for text processor. */
- UNCH *cro; /* LEXCON markup string: CRO */
- UNCH *dso; /* LEXCON markup string: DSO */
- UNCH *ero; /* LEXCON markup string: ERO */
- UNCH *etag; /* LEXMARK markup string: end-tag */
- UNCH *lit; /* LEXMARK markup string: LIT */
- UNCH *lita; /* LEXMARK markup string: LITA */
- UNCH *mdc; /* LEXCON markup string: MDC */
- UNCH *mdo; /* LEXCON markup string: MDO */
- UNCH *mse; /* LEXCON markup string: mse */
- UNCH *mss; /* LEXCON markup string: mss */
- UNCH *mssc; /* LEXCON markup string: mss CDATA */
- UNCH *mssr; /* LEXCON markup string: mss RCDATA */
- UNCH *pic; /* LEXCON markup string: PIC */
- UNCH *pio; /* LEXCON markup string: PIO */
- UNCH *refc; /* LEXGRP markup string: REFC */
- UNCH *stag; /* LEXMARK markup string: start-tag */
- UNCH *tagc; /* LEXMARK markup string: TAGC */
- UNCH *vi; /* LEXMARK markup string: VI */
- int lennet; /* LEXMARK markup string length: null end-tag. */
- int lennst; /* LEXMARK markup string length: null start-tag.*/
-};
-#endif /* ndef ENTITY_H */
diff --git a/usr.bin/sgmls/sgmls/error.h b/usr.bin/sgmls/sgmls/error.h
deleted file mode 100644
index d37d493..0000000
--- a/usr.bin/sgmls/sgmls/error.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* ERROR.H: Symbols for SGML error codes (start with 'E_').
- Numbers 46 - 56 are generated by ERROR.C.
- Later numbers are coded directly.
-*/
-/* SGMLERR.C: General errors and syntax errors.
-*/
-#define E_CONTEXT 1 /* W GI not allowed at this point in structure. */
-#define E_MDNAME 2 /* E Invalid markup declaration name. */
-/*efine E_LEN 3 E Syntax error: length exceeded. */
-#define E_SYS 4 /* W Illegal system character. */
-#define E_ETAG 5 /* E End-tag does not match any open start-tag. */
-#define E_STAGMAX 6 /* E Maximum number of open elements exceeded. */
-/* E_ALLNULL 7 W Start- and end-tag omitted with null content. */
-#define E_EOF 8 /* E/W Illegal entity end in markup or delimited text. */
-/* fine E_INV 9 E Markup error: invalid character. */
-#define E_CHARS 10 /* W Data found in content that doesn't allow it. */
-/* fine E_NOETDE 11 E End-tag GI not defined by element declaration. */
-#define E_BADNM 12 /* E Name is not syntactically valid. */
-#define E_BADATT 13 /* E Attribute was not defined by element declaration. */
-#define E_VALINV 14 /* W Att value/declaration conflict: invalid char. */
-#define E_VALLEN 15 /* W Att value/declaration conflict: token too long. */
-#define E_VALCNT 16 /* W Att value/declaration conflict: too many tokens. */
-#define E_VALTYPE 17 /* W Att value/declaration conflict: wrong token type.*/
-#define E_VALGRP 18 /* W Att value/declaration conflict: token not in grp.*/
-#define E_VALREQ 19 /* W Att value/declaration conflict: req unspecified. */
-/* E_EMIN 20 W End-tag implied by end-tag; not minimizable. */
-/* E_SMIN 21 W Omitted start-tag was not minimizable. */
-#define E_POSSATT 22 /* E Possible att found but not defined; used as data.*/
-/* Late additions numbered out of order to avoid recompilation. */
-/*efine E_ENTSYNC 37 E Entity and group nesting levels out of sync. */
-#define E_BADVAL 25 /* W Att value omitted (null); default used. */
-/* E_ECONTXT 30 W Element ended prematurely (some content omitted).*/
-/* E_EMINST 39 W End-tag implied by start-tag; not minimizable. */
-/* E_MEXTAG 40 W *** In Use *** */
-#define E_MEXERR 41 /* W Attempt to exclude contextually required element.*/
-#define E_DOCTYPE 42 /* W No document type defined; *DOCTYPE assumed. */
-/* E_NOETDS 43 E Start-tag GI not defined by element declaration. */
-#define E_RESTART 44 /* E Invalid chars ignored; trying to restart parse. */
-
-/* MDERROR.C: Errors in markup declarations.
-*/
-/*efine E_DUP 23 E Duplicate specification. */
-/*efine E_KEY 24 E Incorrect keyword for parameter. */
-/*efine E_MSE 26 E MSE occurred with no corresponding MS. */
-/*efine E_MSS 27 E MSS exceeded maximum nesting level. */
-/*efine E_NUM 28 E Incorrect number of parameters. */
-#define E_TYPE 29 /* E Incorrect parameter type. */
-/* Late additions numbered out of order to avoid recompilation. */
-/*efine E_VAL 38 W Incorrect parameter value. */
-
-/* RESERROR.C: Errors in resource routines.
-*/
-/* Unused I End of primary source entity. */
-/* fine E_FILBUF 31 E Could not read next buffer. */
-/* fine E_ERFILE 32 E Could not open file. */
-/* fine E_MALLOC 33 T Could not obtain required main storage. */
-/* fine E_ERMAX 34 E Maximum number of open entities exceeded. */
-/* fine E_ERNAME 35 E Referenced entity undeclared. */
-/* fine E_ERLOOP 36 E Entity referenced within itself: ref ignored. */
-/* Late additions numbered out of order to avoid recompilation. */
-/* E_ERDEF 45 E Referenced entity undeclared; SYSTEM assumed. */
diff --git a/usr.bin/sgmls/sgmls/etype.h b/usr.bin/sgmls/sgmls/etype.h
deleted file mode 100644
index 8ec64c1..0000000
--- a/usr.bin/sgmls/sgmls/etype.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* ETYPE.H: Definitions for element type and group processing.
-*/
-#define MCHARS 0x80 /* Model: contains #CHARS. */
-#define MGI 0x40 /* Model: contains GI names. */
-#define MPHRASE 0x20 /* Model: first token is #CHARS. */
-#define MKEYWORD 0x1F /* Model: defined with single keyword. */
-#define MNONE 0x10 /* Model: contains no GIs or #CHARS. */
-#define MANY 0x08 /* Model: contains any GIs or #CHARS. */
-#define MRCDATA 0x04 /* Model: contains RCDATA. */
-#define MCDATA 0x02 /* Model: contains CDATA. */
-
-#define TOREP (TOPT+TREP) /* 11000000 Optional and repeatable. */
-#define TOPT 0x80 /* Token: 1=optional; 0=required. */
-#define TREP 0x40 /* Token: 1=repeatable; 0=not. */
-#define TXOREP (TXOPT+TXREP) /* * explicitly specified */
-#define TXOPT 0x20 /* ? explicitly specified */
-#define TXREP 0x10 /* + explicitly specified */
-#define TTMASK 0x0F /* 00001111 Mask for testing token type. */
-#define TTETD 4 /* 00000100 Token is an ETD. */
-#define TTAND 3 /* 00000011 Token is an AND group. */
-#define TTSEQ 2 /* 00000010 Token is a sequence group. */
-#define TTOR 1 /* 00000001 Token is an OR group. */
-#define TTCHARS 0 /* 00000000 Token is #CHARS. */
-
-struct thdr { /* Token header or model header. */
- UNCH ttype; /* Token type attributes or model content. */
- union {
- int tnum; /* Group token: tokens in group.
- Model header: content tokens at any level. */
- struct etd *thetd; /* GI token: ptr to etd. */
- } tu;
-};
-#define THSZ (sizeof(struct thdr))
-
-#define ETDHASH 211 /* Size of element hash table. Must be prime. */
-#define SMO 0x40 /* ETDMIN: Start-tag O minimization. */
-#define EMO 0x04 /* ETDMIN: End-tag O minimization. */
-#define EMM 0x02 /* ETDMIN: End-tag minimization explicitly
- specified to be minus */
-#define ETDDCL 0x80 /* ETDMIN: Element was declared. */
-#define ETDUSED 0x20 /* ETDMIN: Element used in another declaration. */
-#define ETDOCC 0x10 /* ETDMIN: Element occurred in document. */
-
-struct etd { /* Element type definition. */
- struct etd *etdnext; /* Next element type definition in hash chain. */
- UNCH *etdgi; /* GI preceded by its length, followed by EOS. */
- UNCH etdmin; /* Flag bits: minimization. */
- UNCH mark; /* Mark bit: for ambiguity checking */
- struct thdr *etdmod; /* Content model. */
- struct etd **etdmex; /* Minus exceptions. */
- struct etd **etdpex; /* Plus exceptions. */
- struct ad *adl; /* Attribute descriptor list. */
- struct entity **etdsrm; /* Short reference map. */
-};
-#define ETDSZ (sizeof(struct etd))
-typedef struct etd *PETD;
-extern struct etd dumetd[];
-
-/* Number of bits in a long must be >= 1<<LONGPOW */
-#define LONGPOW 5
-
-#define LONGBITS (1<<LONGPOW)
-
-struct mpos { /* Position of current element in model. */
- UNCH g; /* Index of this group in the model. */
- UNCH t; /* Index of the current token in this group. */
- UNCH tstart; /* Index of starting token for AND group
- testing. */
- unsigned long *h; /* Hit bits of this group's tokens. */
-};
-
-#define HITCLEAR(h) MEMZERO((UNIV)(h), grplongs*sizeof(unsigned long))
-
-#define TAGCONER 0x01 /* 00000001 (contersw) Tag was out of context. */
-#define TAGNET 0x02 /* 00000010 (etisw) Tag has NET enabled. */
-#define TAGPEX 0x04 /* 00000100 (pexsw) Tag was plus exception. */
-#define TAGREF 0x08 /* 00001000 (conrefsw) Tag had CONREF or EMPTY.*/
-struct tag { /* Tag control block. */
- UNCH status; /* Status of context check. */
- UNCH tflags; /* Flags: TAGCONER TAGNET TAGPEX TAGREF */
- struct etd *tetd; /* Element type definition for tag. */
- struct entity **tsrm; /* Current short reference map. */
- struct mpos *tpos; /* Position of next tag in this model. */
-};
-
-#define RCEND 1 /* No more tokens: end element and retry GI. */
-#define RCREQ 2 /* Required GI must precede proposed GI. */
-#define RCMISS 3 /* GI invalid: not element end; no required GI. */
-#define RCHIT 4 /* GI is the one expected next. */
-#define RCMEX 5 /* GI invalid: minus exception. */
-#define RCHITMEX 6 /* RCMEX with invalid attempted minus exclusion.*/
-#define RCPEX 7 /* GI is valid solely because of plus exclusion.*/
-#define RCNREQ 8 /* Token is not required; can retry invalid GI. */
diff --git a/usr.bin/sgmls/sgmls/exclude.c b/usr.bin/sgmls/sgmls/exclude.c
deleted file mode 100644
index 7d72cc0..0000000
--- a/usr.bin/sgmls/sgmls/exclude.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/* exclude.c -
- Exclusion checking.
-
- Written by James Clark (jjc@jclark.com).
-*/
-
-#include "sgmlincl.h"
-
-static int excktok P((struct thdr *, int, int *));
-static int exmark P((int));
-
-/* Check that the current exclusions are legal for the content model
-of the current element. */
-
-VOID exclude()
-{
- struct thdr *mod = tags[ts].tetd->etdmod;
-
- if ((mod->ttype & MKEYWORD) == 0 && exmark(1)) {
- int excl;
-
- excktok(mod + 1, 0, &excl);
- exmark(0);
- }
-}
-
-/* Set the mark field of all current exclusions to val. Return 1 if
-there are some current exclusions. */
-
-static
-int exmark(val)
-int val;
-{
- int i;
- int gotone = 0;
-
- for (i = ts; i > 0; --i) {
- struct etd **p = tags[i].tetd->etdmex;
- if (p) {
- for (; *p; p++)
- (*p)->mark = val;
- gotone = 1;
- }
- }
- return gotone;
-}
-
-/* Check exclusions for this token. Return size of token. */
-
-static
-int excktok(t, orgrp, excl)
-struct thdr *t;
-int orgrp; /* 1 if token is member of or group */
-int *excl; /* Set to 1 if token is excluded. */
-{
- int size;
- struct thdr *tem;
- int tnum;
- int optional = 0;
- int hadopt, hadreq;
-
- *excl = 0;
-
- switch (t->ttype & TTMASK) {
- case TTETD:
- if (t->tu.thetd->mark) {
- if (orgrp || (t->ttype & TOPT))
- *excl = 1;
- else
- sgmlerr(217, &pcbstag, t->tu.thetd->etdgi + 1,
- tags[ts].tetd->etdgi + 1);
- }
- /* fall through */
- case TTCHARS:
- size = 1;
- break;
- case TTOR:
- case TTAND:
- case TTSEQ:
- tem = t + 1;
- hadopt = 0;
- hadreq = 0;
- for (tnum = t->tu.tnum; tnum > 0; --tnum) {
- int ex;
- int n = excktok(tem, (t->ttype & TTMASK) == TTOR, &ex);
- if (!ex) {
- if (tem->ttype & TOPT)
- hadopt = 1;
- else
- hadreq = 1;
- }
- tem += n;
- }
- size = tem - t;
- if ((t->ttype & TTMASK) == TTOR)
- optional = hadreq ? hadopt : 1;
- else
- optional = !hadreq;
- break;
- default:
- abort();
- }
-
- /* Was required, but exclusions have made it optional.
- eg <!element foo - - (a | b) -(a, b)> */
-
- if (optional && !(t->ttype & TOPT))
- sgmlerr(216, &pcbstag, tags[ts].tetd->etdgi + 1, (UNCH *)0);
-
- return size;
-}
-
-/*
-Local Variables:
-c-indent-level: 5
-c-continued-statement-offset: 5
-c-brace-offset: -5
-c-argdecl-indent: 0
-c-label-offset: -5
-End:
-*/
diff --git a/usr.bin/sgmls/sgmls/genlex.c b/usr.bin/sgmls/sgmls/genlex.c
deleted file mode 100644
index b653d14..0000000
--- a/usr.bin/sgmls/sgmls/genlex.c
+++ /dev/null
@@ -1,140 +0,0 @@
-/* genlex: Generate lexical tables for non-ASCII charsets. */
-
-#include "config.h"
-#include "std.h"
-#include "tools.h"
-
-#define CANON_ASCII_NONSGML 255 /* Canonical non-SGML character in ASCII. */
-#define CANON_ASCII_DATACHAR 254 /* Canonical DATACHAR in ASCII. */
-
-extern unsigned char charset[];
-extern UNCH *lextabs[];
-extern UNCH lextran[];
-
-static char *lextabnames[] = {
- "lexcnm", "lexcon", "lexgrp", "lexlms", "lexmark", "lexsd", "lextoke",
- "lexmin"
-};
-
-#define UNUSED -1
-
-extern int iso646charset[];
-extern int iso646G0charset[];
-extern int iso646C0charset[];
-extern int iso8859_1charset[];
-extern int iso6429C1charset[];
-
-static struct {
- char *name;
- int *map;
-} charsets[] = {
- { "iso646charset", iso646charset },
- { "iso646G0charset", iso646G0charset },
- { "iso646G0charset", iso646G0charset },
- { "iso8859_1charset", iso8859_1charset },
- { "iso646C0charset", iso646C0charset },
- { "iso6429C1charset", iso6429C1charset },
-};
-
-static VOID print_tab(s, t)
- char *s;
- UNCH *t;
-{
- int i;
- printf("UNCH %s[] = {\n", s);
- for (i = 0; i < 256; i++)
- printf("%2d,%c", t[i], (i + 1) % 16 == 0 ? '\n' : ' ');
- fputs("};\n\n", stdout);
-}
-
-int main(argc, argv)
- int argc;
- char **argv;
-{
- int i;
- UNCH tab[256];
- char special[256];
- /* Shunned character numbers in the reference concrete syntax. */
- static UNCH refshun[] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
- 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 127, 255
- };
- char shunned[256];
- char *program_name;
-
- program_name = strrchr(argv[0], '/');
- if (program_name)
- program_name++;
- else
- program_name = argv[0];
-
- /* Check that the mapping is 1-1. */
- for (i = 0; i < 256; i++)
- tab[i] = 0;
- for (i = 0; i < 256; i++)
- tab[charset[i]] = 1;
- for (i = 0; i < 256; i++)
- if (!tab[i]) {
- fprintf(stderr, "%s: bad mapping: no character mapped to %d\n",
- program_name, i);
- exit(EXIT_FAILURE);
- }
-
- /* Compute special. */
- for (i = 0; i < 256; i++)
- special[i] = 0;
- for (i = 0; lextabs[i]; i++) {
- int j;
- for (j = 0; j < 256; j++)
- if (lextabs[i][j] != lextabs[i][CANON_ASCII_NONSGML]
- && lextabs[i][j] != lextabs[i][CANON_ASCII_DATACHAR])
- special[charset[j]] = 1;
- }
-
- /* Compute shunned. */
- for (i = 0; i < 256; i++)
- shunned[i] = 0;
- for (i = 0; i < sizeof(refshun); i++)
- shunned[refshun[i]] = 1;
-
- printf("/* This file was automatically generated by %s. Do not edit. */\n\n",
- program_name);
- fputs("#include \"config.h\"\n#include \"entity.h\"\n#include \"sgmldecl.h\"\n\n",
- stdout);
-
- /* Generate each of the lexical tables. */
- for (i = 0; lextabs[i]; i++) {
- int j;
- for (j = 0; j < 256; j++)
- tab[charset[j]] = lextabs[i][j];
-
- for (j = 0; j < 256; j++)
- if (!special[j]) {
- if (shunned[j])
- tab[j] = lextabs[i][CANON_ASCII_NONSGML];
- else
- tab[j] = lextabs[i][CANON_ASCII_DATACHAR];
- }
- print_tab(lextabnames[i], tab);
- }
-
- /* Generate lextran. */
- for (i = 0; i < 256; i++)
- tab[charset[i]] = charset[lextran[i]];
- print_tab("lextran", tab);
-
- /* Generate charsets. */
- for (i = 0; i < sizeof(charsets)/sizeof(charsets[0]); i++) {
- int j;
- int *map = charsets[i].map;
- printf("\nint %s[] = {\n", charsets[i].name);
- for (j = 0; j < 256; j++)
- if (map[j] == UNUSED)
- printf("UNUSED,%c", (j + 1) % 8 == 0 ? '\n' : ' ');
- else
- printf("%3d,%c", charset[map[j]], (j + 1) % 16 == 0 ? '\n' : ' ');
- fputs("};\n", stdout);
- }
-
- exit(EXIT_SUCCESS);
-}
diff --git a/usr.bin/sgmls/sgmls/getopt.c b/usr.bin/sgmls/sgmls/getopt.c
deleted file mode 100644
index 9a218b3..0000000
--- a/usr.bin/sgmls/sgmls/getopt.c
+++ /dev/null
@@ -1,166 +0,0 @@
-/* getopt.c -
- getopt() for those systems that don't have it.
-
- Derived from comp.sources.unix/volume3/att_getopt.
- Modified by James Clark (jjc@jclark.com).
-*/
-
-#include "config.h"
-
-#ifndef HAVE_GETOPT
-
-#include "std.h"
-#include "getopt.h"
-
-#ifdef SWITCHAR
-#include <dos.h>
-#endif
-
-int opterr = 1;
-int optind = 1;
-int optopt;
-char *optarg;
-
-#ifndef OPTION_CHAR
-#define OPTION_CHAR '-'
-#endif
-
-int getopt(argc, argv, opts)
-int argc;
-char **argv;
-char *opts;
-{
-#ifdef SWITCHAR
- union REGS regs;
- static char switchar = '\0';
-#endif
- static int sp = 1;
- register int c;
- register char *cp;
- char *message;
-#ifdef SWITCHAR
- if (switchar == '\0') {
- regs.x.ax = 0x3700;
- intdos(&regs, &regs);
- if (!regs.x.cflag)
- switchar = regs.h.dl;
- else
- switchar = '/';
- }
-#endif
- if (sp == 1) {
- if (optind >= argc)
- return EOF;
- if ((
-#ifdef SWITCHAR
- argv[optind][0] != switchar &&
-#endif
- argv[optind][0] != OPTION_CHAR) || argv[optind][1] == '\0') {
-#ifdef REORDER_ARGS
- int i;
- for (i = optind; i < argc; i++)
- if ((
-#ifdef SWITCHAR
- argv[i][0] == switchar ||
-#endif
- argv[i][0] == OPTION_CHAR) && argv[i][1] != '\0')
- break;
- if (i < argc) {
- c = argv[i][1];
-#ifdef CASE_INSENSITIVE_OPTIONS
- if (isupper(c))
- c = tolower(c);
-#endif
- if (c != ':' && c != OPTION_CHAR && (cp = strchr(opts, c)) != NULL
- && cp[1] == ':' && argv[i][2] == 0 && i < argc - 1) {
- int j;
- char *temp1 = argv[i];
- char *temp2 = argv[i+1];
- for (j = i - 1; j >= optind; j--)
- argv[j+2] = argv[j];
- argv[optind] = temp1;
- argv[optind+1] = temp2;
- }
- else {
- int j;
- char *temp = argv[i];
- for (j = i - 1; j >= optind; j--)
- argv[j+1] = argv[j];
- argv[optind] = temp;
- }
- }
- else
-#endif
- return EOF;
- }
- if ((argv[optind][0] == OPTION_CHAR && argv[optind][1] == OPTION_CHAR
- && argv[optind][2] == '\0')
-#ifdef SWITCHAR
- || (argv[optind][0] == switchar && argv[optind][1] == switchar
- && argv[optind][2] == '\0')
-#endif
- ) {
- optind++;
- return(EOF);
- }
- }
- optopt = c = argv[optind][sp];
-#ifdef CASE_INSENSITIVE_OPTIONS
- if (
-#ifdef USE_ISASCII
- isascii(c) &&
-#endif /* USE_ISASCII */
- isupper((unsigned char)c))
- optopt = c = tolower((unsigned char)c);
-#endif /* CASE_INSENSITIVE_OPTIONS */
- if (c == ':' || (cp = strchr(opts, c)) == NULL) {
- if (argv[optind][++sp] == '\0') {
- optind++;
- sp = 1;
- }
- message = ": illegal option -- ";
- goto bad;
- }
- if (*++cp == ':') {
- if (argv[optind][sp+1] != '\0')
- optarg = &argv[optind++][sp+1];
- else if (++optind >= argc) {
- sp = 1;
- message = ": option requires an argument -- ";
- goto bad;
- }
- else
- optarg = argv[optind++];
- sp = 1;
- }
- else {
- if (argv[optind][++sp] == '\0') {
- sp = 1;
- optind++;
- }
- optarg = NULL;
- }
- return c;
-bad:
- if (opterr) {
- fputs(argv[0], stderr);
- fputs(message, stderr);
- fputc(optopt, stderr);
- fputc('\n', stderr);
- }
- return '?';
-}
-
-#endif /* not HAVE_GETOPT */
-
-/*
-Local Variables:
-c-indent-level: 4
-c-continued-statement-offset: 4
-c-brace-offset: 4
-c-argdecl-indent: 4
-c-label-offset: -4
-tab-width: 4
-End:
-*/
-
diff --git a/usr.bin/sgmls/sgmls/getopt.h b/usr.bin/sgmls/sgmls/getopt.h
deleted file mode 100644
index 4856560..0000000
--- a/usr.bin/sgmls/sgmls/getopt.h
+++ /dev/null
@@ -1,11 +0,0 @@
-/* Declare getopt() and associated variables. */
-
-/* Don't use prototypes in case some system header file has a
-conflicting definition. Systems differ on how they declare the second
-parameter. */
-
-extern int getopt();
-
-extern char *optarg;
-extern int optind;
-extern int opterr;
diff --git a/usr.bin/sgmls/sgmls/keyword.h b/usr.bin/sgmls/sgmls/keyword.h
deleted file mode 100644
index 6c092f0..0000000
--- a/usr.bin/sgmls/sgmls/keyword.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/* KEYWORD.H: Definitions for markup declaration keyword processing.
-*/
-/* Default value types for attribute definition list declaration.
-*/
-#define DNULL 1 /* Default value: implied attribute. */
-#define DREQ 2 /* Default value: required attribute. */
-#define DCURR 3 /* Default value: current attribute. */
-#define DCONR 4 /* Default value: content reference attribute. */
-#define DFIXED 5 /* Default value: fixed attribute. */
-
-/* External identifier types for entity and notation declarations.
-*/
-#define EDSYSTEM 1 /* SYSTEM (but not PUBLIC) identifier specified.*/
-#define EDPUBLIC 2 /* PUBLIC (but not SYSTEM) identifier specified.*/
-#define EDBOTH 3 /* PUBLIC and also SYSTEM identifiers specified.*/
-
-/* Marked section keywords.
-*/
-#define MSTEMP 1
-#define MSRCDATA 2
-#define MSCDATA 3
-#define MSIGNORE 4
diff --git a/usr.bin/sgmls/sgmls/latin1.h b/usr.bin/sgmls/sgmls/latin1.h
deleted file mode 100644
index c6df696..0000000
--- a/usr.bin/sgmls/sgmls/latin1.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* SGML Character Use: ISO Latin 1.
-*/
-#define EOFCHAR '\032' /* FUNCTION: EE (entity end: files). */
-#define EOBCHAR '\034' /* NONCHAR: EOB (file entity: end of buffer. */
-#define RSCHAR '\012' /* FUNCTION: RS (record start). */
-#define RECHAR '\015' /* FUNCTION: RE (record end). */
-#define TABCHAR '\011' /* FUNCTION: TAB (horizontal tab). */
-#define SPCCHAR '\040' /* FUNCTION: SPACE (horizontal space). */
-#define GENRECHAR '\010' /* NONCHAR: Generated RE. */
-#define DELCDATA '\035' /* NONCHAR: Delimiter for CDATA entity in
- attribute value. */
-#define DELSDATA '\036' /* NONCHAR: Delimiter for SDATA entity in
- attribute value. */
-#define DELNONCH '\037' /* NONCHAR: non-SGML character prefix. */
-
-/* These two macros are used to handle non-SGML characters. A non-SGML
-by character is represented by a DELNONCH character followed by
-SHIFTNON(original_character). SHIFTNON must transform any character
-in the set 0, EOFCHAR, EOBCHAR, GENRECHAR, DELCDATA, DELSDATA,
-DELNONCH into a character that is not one of the set 0, EOFCHAR,
-EOBCHAR. Furthermore UNSHIFTNON(SHIFTNON(c)) must be equal to c for
-every character c in the former set. */
-/* This is a simple definition that works for ASCII-like character sets. */
-#define SHIFTNON(ch) ((UNCH)(ch) | 0100)
-#define UNSHIFTNON(ch) ((UNCH)(ch) & ~0100)
-
-/* A canonical NONSGML character. The character number that is shunned
-in the reference concrete syntax and is not the number of a
-significant (in the reference concrete syntax) character nor one of
-the above characters nor 0. */
-#define CANON_NONSGML 255
-
-/* A canonical DATACHAR character. The character number that is not
-shunned in the reference concrete syntax and is not the number of a
-significant (in the reference concrete syntax) SGML character nor one
-of the above characters. */
-#define CANON_DATACHAR 254
diff --git a/usr.bin/sgmls/sgmls/lexcode.h b/usr.bin/sgmls/sgmls/lexcode.h
deleted file mode 100644
index d34e3e6..0000000
--- a/usr.bin/sgmls/sgmls/lexcode.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/* Definitions of lexical codes needed by both lextaba.c and lexrf.c. */
-
-#define FCE 27 /* FRE Free character in use as an entity reference */
-#define FRE 0 /* FREECHAR that is not in a CON delimiter-in-context. */
-#define LITC 21 /* LIT LITA PIC or EE in use as a literal terminator */
-#define MINLITC 13 /* LIT LITA as literal terminator in minimum data */
-#define MSC3 15 /* ] Also MSC[2]. */
-#define NET 17 /* / When enabled. */
-#define ETI 16 /* / Actually ETAGO[2] */
-#define SPCR 19 /* Space in use as SR8. */
-#define TGO2 25 /* < TAGO; also MDO[1], PIO[1] */
-#define CDE 11 /* NONSGML delcdata CDATA/SDATA delimiter */
diff --git a/usr.bin/sgmls/sgmls/lexrf.c b/usr.bin/sgmls/sgmls/lexrf.c
deleted file mode 100644
index 643b336..0000000
--- a/usr.bin/sgmls/sgmls/lexrf.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/* LEXRF: Lexical tables for reference concrete syntax.
-*/
-
-#include "config.h"
-#include "entity.h" /* Templates for entity control blocks. */
-#include "synxtrn.h" /* Declarations for concrete syntax constants. */
-#include "action.h" /* Action names for all parsing. */
-#include "lexcode.h"
-
-static UNCH SRTAB[] = { TABCHAR, '\0' };
-static UNCH SRRE[] = { RECHAR, '\0' };
-static UNCH SRRS[] = { RSCHAR, '\0' };
-static UNCH SRRSB[] = { RSCHAR, 'B', '\0' };
-static UNCH SRRSRE[] = { RSCHAR, RECHAR, '\0' };
-static UNCH SRRSBRE[] = { RSCHAR, 'B', RECHAR, '\0' };
-static UNCH SRBRE[] = { 'B', RECHAR, '\0' };
-
-struct lexical lex = { /* Delimiter set constants for parser use. */
- { /* Markup strings for text processor use. */
- (UNCH *)"\4&#", /* LEXCON markup string: CRO */
- (UNCH *)"[", /* LEXCON markup string: DSO */
- (UNCH *)"\3&", /* LEXCON markup string: ERO */
- (UNCH *)"\4</", /* LEXMARK markup string: end-tag */
- (UNCH *)"\3\"", /* LEXMARK markup string: LIT */
- (UNCH *)"\3'", /* LEXMARK markup string: LITA */
- (UNCH *)"\3>", /* LEXCON markup string: MDC */
- (UNCH *)"\4<!", /* LEXCON markup string: MDO */
- (UNCH *)"\5]]>", /* LEXCON markup string: mse */
- (UNCH *)"\5<![", /* LEXCON markup string: mss */
- (UNCH *)"\13<![CDATA[", /* LEXCON markup string: mss CDATA */
- (UNCH *)"\14<![RCDATA[", /* LEXCON markup string: mss RCDATA */
- (UNCH *)"\3>", /* LEXCON markup string: PIC */
- (UNCH *)"\4<?", /* LEXCON markup string: PIO */
- (UNCH *)"\3;", /* LEXGRP markup string: ref close. */
- (UNCH *)"\3<", /* LEXMARK markup string: start-tag */
- (UNCH *)"\3>", /* LEXMARK markup string: TAGC */
- (UNCH *)"\3=", /* LEXMARK markup string: VI */
- 3, /* LEXMARK: length of null end-tag. */
- 2 /* LEXMARK: length of null start-tag. */
- },
- { /* Short reference delimiters. */
- { /* Short reference delimiter table. */
- {(UNCH *)"", SRCT}, /* Dummy entry to store SR count. */
- {SRTAB, 1}, /* TAB */
- {SRRE, 2}, /* RE */
- {SRRS, 3}, /* RS */
- {SRRSB, 4}, /* Leading blanks */
- {SRRSRE, 5}, /* Null record */
- {SRRSBRE, 6}, /* Blank record */
- {SRBRE, 7}, /* Trailing blanks */
- {(UNCH *)" ", 8}, /* Space */
- {(UNCH *)"BB", 9}, /* Two or more blanks */
- {(UNCH *)"\"", 10}, /* Quotation mark (first data character) */
- {(UNCH *)"#", 11}, /* Number sign */
- {(UNCH *)"%", 12}, /* FCE CHARACTERS start here */
- {(UNCH *)"'", 13},
- {(UNCH *)"(", 14},
- {(UNCH *)")", 15},
- {(UNCH *)"*", 16},
- {(UNCH *)"+", 17},
- {(UNCH *)",", 18},
- {(UNCH *)"-", 19}, /* Hyphen */
- {(UNCH *)"--", 20}, /* Two hyphens */
- {(UNCH *)":", 21},
- {(UNCH *)";", 22},
- {(UNCH *)"=", 23},
- {(UNCH *)"@", 24},
- {(UNCH *)"[", 25},
- {(UNCH *)"]", 26},
- {(UNCH *)"^", 27},
- {(UNCH *)"_", 28}, /* Low line */
- {(UNCH *)"{", 29},
- {(UNCH *)"|", 30},
- {(UNCH *)"}", 31},
- {(UNCH *)"~", 32},
- {0, 0}
- },
- { /* Printable form of unprintable SR delims.*/
- "", /* Dummy entry to balance s.dtb. */
- "&#TAB;", /* TAB */
- "&#RE;", /* RE */
- "&#RS;", /* RS */
- "&#RS;B", /* Leading blanks */
- "&#RS;&#RE;", /* Null record */
- "&#RS;B&#RE;", /* Blank record */
- "B&#RE;", /* Trailing blanks */
- "&#SPACE;" /* Space */
- },
- 12, /* LEXCNM: Index of first FCE in srdeltab. */
- 20, /*LEXCNM:Index of "two hyphens" in srdeltab*/
- 10, /* LEXCNM: Index of first SR with data char. */
- 19, /* LEXCNM: Index of hyphen in srdeltab. */
- SRNPRT+1, /* LEXCNM: Index of 1st printable SR. */
- 8, /* LEXCNM: Index of space in srdeltab. */
- 25, /* LEXCNM: Index of left bracket in srdeltab. */
- 26, /* LEXCNM: Index of right bracket in srdeltab. */
- }, /* End of short reference delimiters. */
- { /* General delimiter characters. */
- GENRECHAR, /*LEXCNM:(BS)Generated RE; can't be markup.*/
- '"', /* LEXMARK: Char used as LIT delimiter.*/
- '\'', /* LEXMARK: Char used as LITA delimiter.*/
- '>', /* LEXLMS: Char used as MDC delimiter.*/
- ']', /* LEXLMS: Char used as MSC when enabled.*/
- '/', /* LEXCON: Char used as NET when enabled.*/
- '%', /* LEXMARK: Char used as PERO delimiter. */
- '>', /* LEXCON: Char used as PIC delimiter.*/
- '<' /* LEXCON: Char used as TAGO when enabled.*/
- },
- { /* Lexical table code assignments. */
- FCE, /* LEXCNM: FRE char as entity reference.*/
- FRE, /* LEXLMS: Free character not an entity ref.*/
- LITC, /* LEXLMS: Literal close delimiter enabled. */
- MINLITC, /* LEXMIN: Literal close delimiter enabled. */
- MSC3, /* LEXLMS: Marked section close delim enabled. */
- NET, /* LEXCON: Null end-tag delimiter enabled. */
- ETI, /* LEXCON: NET disabled; still used as ETI. */
- SPCR, /* LEXCNM: Space in use as SHORTREF delim. */
- TGO2, /* LEXCON: Tag open delimiter enabled. */
- CDE /* LEXLMS: CDATA/SDATA delimiters. */
- }
-};
-
-UNCH *lextabs[] = {
- lexcnm, lexcon, lexgrp, lexlms, lexmark, lexsd, lextoke, lexmin, 0
-};
diff --git a/usr.bin/sgmls/sgmls/lextaba.c b/usr.bin/sgmls/sgmls/lextaba.c
deleted file mode 100644
index a851d85..0000000
--- a/usr.bin/sgmls/sgmls/lextaba.c
+++ /dev/null
@@ -1,750 +0,0 @@
-/* lextaba.c: lexical tables for ASCII. */
-
-/* These tables are munged by setnonsgml(). */
-
-#include "config.h"
-#include "entity.h"
-#include "lexcode.h"
-#include "sgmldecl.h"
-
-/* LEXCNM: Lexical table for mixed content (PCBCONM) parse.
-*/
-/* Symbols for SGML character set divisions and function characters. */
-#define NU 1 /* NUMERAL Numerals */
-#define NMC 2 /* LC/UCNMCHAR . - Period and hyphen */
-#define NMS 3 /* LC/UCNMSTRT Lower and uppercase letters */
-#define SPC 4 /* SPACE 32 Space */
-#define NON 5 /* NONSGML 0-31 127 255 Unused, except for: */
-#define EE 6 /* NONSGML 00 26 Entity end (end of file) */
-#define EOB 7 /* NONSGML 28 End disk buffer */
-#define RS 8 /* Function 10 Line feed */
-#define RE 9 /* Function 13 Carrier return */
-#define SEP 10 /* SEPCHAR 09 TAB: horizontal tab */
-#define NSC 12 /* NONSGML delnonch Non-SGML character prefix */
-
-/* Symbols for SGML delimiter roles in CON and CXT.
- ETI and NET must be the same in LEXCNM and LEXCON.
- FRE characters are changed to FCE if an FCE entity is declared.
- They are changed back to FRE when the entity is canceled.
-*/
-#define ERO 13 /* & Also CRO[1] */
-#define NMRE 14 /* 08 Generated non-markup RE */
-#define COM 15 /* - For MDO context; also SR19 and SR20. */
-#undef LIT1
-#define LIT1 18 /* " SR10 */
-#define MDO 20 /* ! Actually MDO[2] */
-#define MSC1 21 /* ] Both MSC[1] and MSC[2]; also SR26. */
-#define MSO 22 /* [ For MDO context; also SR25. */
-#define PIO 23 /* ? Actually PIO[2] */
-#define RNI 24 /* # For CRO[2]; also SR11. */
-#define TGC1 25 /* > For TAGO and MSC context; also MDC, PIC */
-#define TGO1 26 /* < TAGO; also MDO[1], PIO[1] */
-
-UNCH lexcnm[256] = { /*
-000 001       bs tab lf home ff cr so si */
-EE, NON, NON, NON, NON, NON, NON, NON, NMRE,SEP, RS, NON, NON, RE, NON, NON, /*
-          eof esc rt left up down */
-NON, NON, NON, NON, NON, NON, NON, NON, NON, NON, EE, NON, EOB, NON, NON, NSC, /*
-032 ! " # $ % & ' ( ) * + , - . / */
-SPC, MDO, LIT1,RNI, FRE, FRE ,ERO, FRE, FRE, FRE, FRE, FRE, FRE, COM, NMC, ETI, /*
-0 1 2 3 4 5 6 7 8 9 : ; < = > ? */
-NU , NU , NU , NU , NU , NU , NU , NU , NU , NU , FRE, FRE, TGO1,FRE, TGC1,PIO, /*
-@ A B C D E F G H I J K L M N O */
-FRE, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
-P Q R S T U V W X Y Z [ \ ] ^ _ */
-NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, MSO, FRE, MSC1,FRE, FRE, /*
-` a b c d e f g h i j k l m n o */
-FRE, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
-p q r s t u v w x y z { | } ~ 127 */
-NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, FRE, FRE, FRE, FRE, NON,
-FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
-FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
-FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
-FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
-FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
-FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
-FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
-FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, NON
-};
-/* free nu nmc nms spc non ee eob rs re sep cde nsc ero
- nmre com eti lit spcr mdo msc mso net pio rni tagc tago fce */
-#undef ERO
-#undef NMRE
-#undef COM
-#undef LIT1
-/* def SPCR*/
-#undef MDO
-#undef MSC1
-#undef MSO
-#undef PIO
-#undef RNI
-#undef TGC1
-/* def TGO1*/
-/* def FCE*/
-/* LEXCON: Lexical table for RCDATA and CDATA content (PCBCON?),
- prolog (PCBPRO), and nested declaration set (PCBMDS) parses.
- Note: NMC is same as FRE; kept for consistency with LEXCNM and LEXLMS.
-*/
-/* Symbols for SGML character set divisions and function characters. */
-/* Same as for LEXCNM. */
-
-/* Symbols for SGML delimiter roles in CON, CXT, and DS.
- ETI and NET must be the same in LEXCNM and LEXCON.
- FRE characters are changed to FCE if an FCE entity is declared.
- They are changed back to FRE when the entity is canceled.
-*/
-#define ERO 13 /* & Also CRO[1] */
-#define NMRE 14 /* 08 Generated non-markup RE */
-#define COM 15 /* - For MDO context. */
-/*#define ETI 16 / Actually ETAGO[2] */
-/*#define NET 17 / When enabled. */
-#define MDO 18 /* ! Actually MDO[2] */
-#define MSC2 19 /* ] Both MSC[1] and MSC[2]. */
-#define MSO 20 /* [ For MDO context. */
-#define PERO 21 /* % For prolog */
-#define PIO 22 /* ? Actually PIO[2] */
-#define RNI 23 /* # For CRO[2]. */
-#define TGC2 24 /* > For TAGO and MSC context; also MDC, PIC */
-
-UNCH lexcon[256] = { /*
-000 001       bs tab lf home ff cr so si */
-EE, NON, NON, NON, NON, NON, NON, NON, NMRE,SEP, RS, NON, NON, RE, NON, NON, /*
-          eof esc rt left up down */
-NON, NON, NON, NON, NON, NON, NON, NON, NON, NON, EE, NON, EOB, NON, NON, NSC, /*
-032 ! " # $ % & ' ( ) * + , - . / */
-SPC, MDO, FRE, RNI, FRE, PERO,ERO, FRE, FRE, FRE, FRE, FRE, FRE, COM, NMC, ETI, /*
-0 1 2 3 4 5 6 7 8 9 : ; < = > ? */
-NU , NU , NU , NU , NU , NU , NU , NU , NU , NU , FRE, FRE, TGO2,FRE, TGC2,PIO, /*
-@ A B C D E F G H I J K L M N O */
-FRE, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
-P Q R S T U V W X Y Z [ \ ] ^ _ */
-NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, MSO, FRE, MSC2,FRE, FRE, /*
-` a b c d e f g h i j k l m n o */
-FRE, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
-p q r s t u v w x y z { | } ~ 127 */
-NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, FRE, FRE, FRE, FRE, NON,
-FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
-FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
-FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
-FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
-FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
-FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
-FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
-FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, NON
-};
-/* free nu nmc nms spc non ee eob rs re sep cde nsc ero
- nmre com eti net mdo msc mso pero pio rni tagc tago */
-#undef FRE
-#undef NU
-#undef NMC
-#undef NMS
-#undef SPC
-#undef NON
-#undef EE
-#undef EOB
-#undef RS
-#undef RE
-#undef SEP
-#undef NSC
-#undef ERO
-#undef NMRE
-#undef COM
-/* def ETI*/
-/* def NET*/
-#undef MDO
-#undef MSC2
-#undef MSO
-#undef PERO
-#undef PIO
-#undef RNI
-#undef TGC2
-/* LEXGRP: Lexical table for group parses, including PCBREF.
-*/
-/* Symbols for SGML character set divisions. */
-#define BIT 0 /* Bit combinations (not NONCHAR) not allowed in a group. */
-#define NMC 1 /* NAMECHAR . - Period, underscore, and numerals */
-#define NMS 2 /* NAMESTRT Lower and uppercase letters */
-#define RE 3 /* Function 13 Carrier return */
-#define SPC 4 /* SPACE 32 09 Space; includes TAB */
-#define NON 5 /* NONCHAR 0-31 127 255 Unused, except for: */
-#define EE 6 /* Function 26 00 EE: entity end (end of file) */
-#define EOB 7 /* NONCHAR 28 End disk buffer. */
-#define RS 8 /* Function 10 RS: record start (line feed) */
-
-/* Symbols for SGML delimiter roles in GRP. */
-#define AND1 9 /* & */
-#define GRPC 10 /* ) */
-#define GRPO 11 /* ( */
-#undef LIT2
-#define LIT2 12 /* " For datatags. */
-#define LITA 13 /* ' For datatags. */
-#define DTGC 14 /* ] For datatags. */
-#define DTGO 15 /* [ For datatags. */
-#define OPT1 16 /* ? */
-#define OR1 17 /* | */
-#define PERO 18 /* % */
-#define PLUS 19 /* + */
-#define REP1 20 /* * */
-#define RNI 21 /* # For #CHARS */
-#define SEQ1 22 /* , */
-#define REFC 23 /* ; For references */
-
-UNCH lexgrp[256] = { /*
-000 001       bs tab lf home ff cr so si */
-EE , NON, NON, NON, NON, NON, NON, NON, NON, SPC, RS, NON, NON, RE, NON, NON, /*
-          eof esc rt left up down */
-NON, NON, NON, NON, NON, NON, NON, NON, NON, NON, EE , NON, EOB, NON, NON, NON, /*
-032 ! " # $ % & ' ( ) * + , - . / */
-SPC, BIT, LIT2,RNI, BIT, PERO,AND1,LITA,GRPO,GRPC,REP1,PLUS,SEQ1,NMC, NMC, BIT, /*
-0 1 2 3 4 5 6 7 8 9 : ; < = > ? */
-NMC, NMC, NMC, NMC, NMC, NMC, NMC, NMC, NMC, NMC, BIT, REFC,BIT, BIT, BIT, OPT1,/*
-@ A B C D E F G H I J K L M N O */
-BIT, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
-P Q R S T U V W X Y Z [ \ ] ^ _ */
-NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, DTGO,BIT, DTGC,BIT, BIT, /*
-` a b c d e f g h i j k l m n o */
-BIT, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
-p q r s t u v w x y z { | } ~ 127 */
-NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, BIT, OR1, BIT, BIT, NON,
-BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
-BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
-BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
-BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
-BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
-BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
-BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
-BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, NON
-};
-/* bit nmc nms re spc non ee eob rs and grpc grpo lit lita
- dtgc dtgo opt or pero plus rep rni seq refc */
-#undef BIT
-#undef NMC
-#undef NMS
-#undef RE
-#undef SPC
-#undef NON
-#undef EE
-#undef EOB
-#undef RS
-#undef AND1
-#undef GRPC
-#undef GRPO
-#undef LIT2
-#undef LITA
-#undef DTGC
-#undef DTGO
-#undef OPT1
-#undef OR1
-#undef PERO
-#undef PLUS
-#undef REP1
-#undef RNI
-#undef SEQ1
-#undef REFC
-/* LEXLMS: Lexical table for literal parses and marked sections.
-*/
-/* Symbols for SGML character set divisions and function characters.
-*/
-#define FRE 0 /* Free char: not in a delimiter or minimum literal. */
-#define NU 1 /* Numeral Numerals */
-#undef MIN
-#define MIN 2 /* Minimum literal '()+,-./:?= */
-#define NMS 3 /* LC/UCNMSTRT Lower and uppercase letters */
-#define SPC 4 /* SPACE 32 Space */
-#define NON 5 /* NONSGML 0-31 127 255 Unused, except for: */
-#define EE 6 /* NONSGML 00 26 Entity end (end of file) */
-#define EOB 7 /* NONSGML 28 End disk buffer */
-#define RS 8 /* Function 10 Line feed */
-#define RE 9 /* Function 13 Carrier return */
-#define SEP 10 /* SEPCHAR 09 TAB: horizontal tab */
-/*#define CDE 11 NONSGML delcdata CDATA/SDATA delimiter */
-#define NSC 12 /* NONSGML delnonch Non-SGML character prefix */
-/* Symbols for SGML delimiter roles in LIT, PI, and marked sections.
- Either LIT, LITA, PIC, or EE, is changed to LITC when a literal is begun.
- It is changed back when the LITC occurs (i.e., when the literal ends).
-*/
-#define ERO 13 /* & */
-#define MDO 14 /* ! Actually MDO[2] */
-#define MSO 16 /* [ For MDO context. */
-#define PERO 17 /* % For prolog. */
-#define RNI 18 /* # For CRO[2] */
-#define TGC3 19 /* > Also MDC for MSC context. */
-#define TGO3 20 /* < TAGO; also MDO[1] */
-
-/* Room has been left in the parse tables in case re-parsing of text
- is eventually supported (i.e., saved parsed text is used by the
- application to create a new SGML document, but CDATA and SDATA
- entities in literals, and non-SGML characters, are left in their
- parsed state to avoid the overhead of reconstituting the original
- markup). In such a case, the two non-SGML characters DELCDATA and
- DELSDATA are changed to CDE.
- NOTE: The idea is a bad one, because the generated document would
- be non-conforming, as it would contain non-SGML characters.
-*/
-UNCH lexlms[256] = { /*
-000 001       bs tab lf home ff cr so si */
-EE, NON, NON, NON, NON, NON, NON, NON, NON ,SEP, RS, NON, NON, RE, NON, NON, /*
-          eof esc rt left up down */
-NON, NON, NON, NON, NON, NON, NON, NON, NON, NON, EE, NON, EOB, NON, NON, NSC, /*
-032 ! " # $ % & ' ( ) * + , - . / */
-SPC, MDO, FRE, RNI, FRE, PERO,ERO, MIN, MIN, MIN, FRE, MIN, MIN, MIN, MIN, MIN, /*
-0 1 2 3 4 5 6 7 8 9 : ; < = > ? */
-NU , NU , NU , NU , NU , NU , NU , NU , NU , NU , MIN, FRE, TGO3,MIN, TGC3,MIN, /*
-@ A B C D E F G H I J K L M N O */
-FRE, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
-P Q R S T U V W X Y Z [ \ ] ^ _ */
-NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, MSO, FRE, MSC3,FRE, FRE, /*
-` a b c d e f g h i j k l m n o */
-FRE, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
-p q r s t u v w x y z { | } ~ 127 */
-NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, FRE, FRE, FRE, FRE, NON,
-FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
-FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
-FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
-FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
-FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
-FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
-FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
-FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, NON
-};
-/* free nu min nms spc non ee eob rs re sep cde nsc ero
- mdo msc mso pero rni tago tagc litc */
-/* def FRE*/
-#undef NU
-#undef MIN
-#undef NMS
-#undef SPC
-#undef NON
-#undef EE
-#undef EOB
-#undef RS
-#undef RE
-#undef SEP
-/* def CDE*/
-/* def NSC*/
-#undef ERO
-#undef MDO
-/* def MSC3*/
-#undef MSO
-#undef PERO
-#undef RNI
-#undef TGC3
-#undef TGO3
-/* def LITC*/
-/* LEXMIN: Lexical table for minimum data literals.
-*/
-/* Symbols for SGML character set divisions and function characters.
-*/
-#define FRE 0 /* Free char: not in a delimiter or minimum literal. */
-#define NU 1 /* Numeral Numerals */
-#undef MIN
-#define MIN 2 /* Minimum literal '()+,-./:?= */
-#define NMS 3 /* LC/UCNMSTRT Lower and uppercase letters */
-#define SPC 4 /* SPACE 32 Space */
-#define NON 5 /* NONSGML 0-31 127 255 Unused, except for: */
-#define EE 6 /* NONSGML 00 26 Entity end (end of file) */
-#define EOB 7 /* NONSGML 28 End disk buffer */
-#define RS 8 /* Function 10 Line feed */
-#define RE 9 /* Function 13 Carrier return */
-#define SEP 10 /* SEPCHAR 09 TAB: horizontal tab */
-/*#define CDE 11 NONSGML delcdata CDATA/SDATA delimiter */
-#define NSC 12 /* NONSGML delnonch Non-SGML character prefix */
-/* Either LIT or LITA changed to LITC when a literal is begun.
- It is changed back when the LITC occurs (i.e., when the literal ends).
-*/
-UNCH lexmin[256] = { /*
-000 001       bs tab lf home ff cr so si */
-EE, NON, NON, NON, NON, NON, NON, NON, NON ,SEP, RS, NON, NON, RE, NON, NON, /*
-          eof esc rt left up down */
-NON, NON, NON, NON, NON, NON, NON, NON, NON, NON, EE, NON, EOB, NON, NON, NSC, /*
-032 ! " # $ % & ' ( ) * + , - . / */
-SPC, FRE, FRE, FRE, FRE, FRE, FRE, MIN, MIN, MIN, FRE, MIN, MIN, MIN, MIN, MIN, /*
-0 1 2 3 4 5 6 7 8 9 : ; < = > ? */
-NU , NU , NU , NU , NU , NU , NU , NU , NU , NU , MIN, FRE, FRE, MIN, FRE, MIN, /*
-@ A B C D E F G H I J K L M N O */
-FRE, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
-P Q R S T U V W X Y Z [ \ ] ^ _ */
-NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, FRE, FRE, FRE, FRE, FRE, /*
-` a b c d e f g h i j k l m n o */
-FRE, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
-p q r s t u v w x y z { | } ~ 127 */
-NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, FRE, FRE, FRE, FRE, NON,
-FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
-FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
-FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
-FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
-FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
-FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
-FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
-FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, NON
-};
-/* free nu min nms spc non ee eob rs re sep cde nsc ero
- mdo msc mso pero rni tago tagc litc */
-/* def FRE*/
-#undef NU
-#undef MIN
-#undef NMS
-#undef SPC
-#undef NON
-#undef EE
-#undef EOB
-#undef RS
-#undef RE
-#undef SEP
-/* def CDE*/
-/* def NSC*/
-/* def LITC*/
-/* LEXMARK: Lexical scan table for markup: PCBMD? and PCB?TAG.
-*/
-/* Symbols for SGML character set divisions. */
-#define BIT 0 /* Bit combinations not allowed; includes ESC SO SI */
-#define NMC 1 /* NAMECHAR . _ Period and underscore */
-#define NU 2 /* NUMERAL Numerals */
-#define NMS 3 /* NAMESTRT Lower and uppercase letters */
-#define SPC 4 /* SPACE 32 13 09 Space; includes RE TAB */
-#define NON 5 /* NONCHAR 0-31 127 255 Unused, except for: */
-#define EE 6 /* Function 26 00 EE: entity end (end of file) */
-#define EOB 7 /* NONCHAR 28 End disk buffer. */
-#define RS 8 /* Function 10 RS: record start (line feed) */
-
-/* Symbols for SGML delimiter roles in MD and TAG. */
-#define COM1 9 /* - Actually COM[1]; also COM[2], MINUS. */
-#define ETIB 10 /* / ETI; actually ETAGO[2]. */
-#define GRPO 11 /* ( */
-#define LIT3 12 /* " */
-#define LITA 13 /* ' */
-#define DSO 14 /* [ */
-#define DSC1 15 /* ] For data attribute specifications */
-#define PERO 16 /* % */
-#define PLUS 17 /* + */
-#define REFC 18 /* ; For references */
-#define RNI 19 /* # Also CRO[2] */
-#define TGC4 20 /* > Also MDC, PIC */
-#define TGO4 21 /* < TAGO; also MDO[1] */
-#define VI 22 /* = */
-
-UNCH lexmark[256] = { /*
-000 001       bs tab lf home ff cr so si */
-EE , NON, NON, NON, NON, NON, NON, NON, NON, SPC, RS, NON, NON, SPC, NON, NON, /*
-          eof esc rt left up down */
-NON, NON, NON, NON, NON, NON, NON, NON, NON, NON, EE , NON, EOB, NON, NON, NON, /*
-032 ! " # $ % & ' ( ) * + , - . / */
-SPC, BIT, LIT3,RNI, BIT, PERO,BIT, LITA,GRPO,BIT, BIT, PLUS,BIT, COM1,NMC ,ETIB,/*
-0 1 2 3 4 5 6 7 8 9 : ; < = > ? */
-NU, NU, NU, NU, NU, NU, NU, NU, NU, NU, BIT, REFC,TGO4,VI, TGC4,BIT, /*
-@ A B C D E F G H I J K L M N O */
-BIT, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
-P Q R S T U V W X Y Z [ \ ] ^ _ */
-NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, DSO, BIT, DSC1, BIT, BIT, /*
-` a b c d e f g h i j k l m n o */
-BIT, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
-p q r s t u v w x y z { | } ~ 127 */
-NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, BIT, BIT, BIT, BIT, NON,
-BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
-BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
-BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
-BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
-BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
-BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
-BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
-BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, NON
-};
-/* bit nmc nu nms spc non ee eob rs com eti grpo lit lita
- dso pero plus refc rni tagc tago vi */
-#undef BIT
-#undef NMC
-#undef NU
-#undef NMS
-#undef SPC
-#undef NON
-#undef EE
-#undef EOB
-#undef RS
-#undef COM1
-#undef ETIB
-#undef GRPO
-#undef LIT3
-#undef LITA
-#undef DSO
-#undef DSC
-#undef PERO
-#undef PLUS
-#undef REFC
-#undef RNI
-#undef TGC4
-#undef TGO4
-#undef VI
-/* LEXSD: Lexical scan table for SGML declaration.
-*/
-
-/* Symbols for SGML character set divisions. */
-#define SIG 0 /* Significant SGML characters. */
-#define DAT 1 /* DATACHAR Not significant, and not non-sgml. */
-#define NU 2 /* NUMERAL Numerals */
-#define NMS 3 /* NAMESTRT Lower and uppercase letters */
-#define SPC 4 /* SPACE 32 13 09 Space; includes RE TAB */
-#define NON 5 /* NONCHAR NONSGML */
-#define EE 6 /* Function 26 00 EE: entity end (end of file) */
-#define EOB 7 /* NONCHAR 28 End disk buffer. */
-#define RS 8 /* Function 10 RS: record start (line feed) */
-/* Symbols for SGML delimiter roles in SGML declaration. */
-#define COM1 9 /* - Actually COM[1]; also COM[2]. */
-#define LIT3 10 /* " */
-#define LITA 11 /* ' */
-#define TGC4 12 /* > Also MDC, PIC */
-
-UNCH lexsd[256] = { /*
-000 001       bs tab lf home ff cr so si */
-EE , NON, NON, NON, NON, NON, NON, NON, NON, SPC, RS, NON, NON, SPC, NON, NON, /*
-          eof esc rt left up down */
-NON, NON, NON, NON, NON, NON, NON, NON, NON, NON, EE , NON, EOB, NON, NON, NON, /*
-032 ! " # $ % & ' ( ) * + , - . / */
-SPC, SIG, LIT3,SIG, DAT, SIG ,SIG, LITA,SIG, SIG, SIG, SIG, SIG, COM1,SIG ,SIG,/*
-0 1 2 3 4 5 6 7 8 9 : ; < = > ? */
-NU, NU, NU, NU, NU, NU, NU, NU, NU, NU, SIG, SIG, SIG, SIG, TGC4,SIG, /*
-@ A B C D E F G H I J K L M N O */
-SIG, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
-P Q R S T U V W X Y Z [ \ ] ^ _ */
-NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, SIG, DAT, SIG, SIG, SIG, /*
-` a b c d e f g h i j k l m n o */
-DAT, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
-p q r s t u v w x y z { | } ~ 127 */
-NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, SIG, SIG, SIG, SIG, NON,
-DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT,
-DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT,
-DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT,
-DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT,
-DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT,
-DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT,
-DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT,
-DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, NON
-};
-
-#undef SIG
-#undef DAT
-#undef NON
-#undef NU
-#undef NMS
-#undef SPC
-#undef EE
-#undef EOB
-#undef RS
-#undef COM1
-#undef LIT3
-#undef LITA
-#undef TGC4
-
-/* LEXTRAN: Translation table for SGML names.
-*/
-UNCH lextran[256] = { /*
-000 001       bs tab lf home ff cr so si */
-0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , /*
-          eof esc rt left up down */
-16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , /*
-space! " # $ % & ' ( ) * + , - . / */
-32 , 33 , 34 , 35 , 36 , 37 , 38 , 39 , 40 , 41 , 42 , 43 , 44 , 45 , 46 , 47 , /*
-0 1 2 3 4 5 6 7 8 9 : ; < = > ? */
-48 , 49 , 50 , 51 , 52 , 53 , 54 , 55 , 56 , 57 , 58 , 59 , 60 , 61 , 62 , 63 , /*
-@ A B C D E F G H I J K L M N O */
-64 , 65 , 66 , 67 , 68 , 69 , 70 , 71 , 72 , 73 , 74 , 75 , 76 , 77 , 78 , 79 , /*
-P Q R S T U V W X Y Z [ \ ] ^ _ */
-80 , 81 , 82 , 83 , 84 , 85 , 86 , 87 , 88 , 89 , 90 , 91 , 92 , 93 , 94 , 95 , /*
-` a b c d e f g h i j k l m n o */
-96 , 65 , 66 , 67 , 68 , 69 , 70 , 71 , 72 , 73 , 74 , 75 , 76 , 77 , 78 , 79 , /*
-p q r s t u v w x y z { | } ~ 127 */
-80 , 81 , 82 , 83 , 84 , 85 , 86 , 87 , 88 , 89 , 90 , 123, 124, 125, 126, 127,
-128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
-144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
-160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
-176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
-192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
-208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
-224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
-240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
-};
-/* LEXTOKE: Lexical class table for tokenization scan.
-*/
-#include "lextoke.h" /* Symbols for tokenization lexical classes. */
-UNCH lextoke[256] = { /*
-
-000 001       bs tab lf home ff cr   */
-INV, INV, INV, INV, INV, INV, INV, INV, INV, SEP, REC, INV, INV, REC, INV, INV, /*
-          eof esc rt left up down */
-INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, EOB, INV, INV, INV, /*
-space! " # $ % & ' ( ) * + , - . / */
-SP , INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, NMC, NMC, INV, /*
-0 1 2 3 4 5 6 7 8 9 : ; < = > ? */
-NU , NU , NU , NU , NU , NU , NU , NU , NU , NU , INV, INV, INV, INV, INV, INV, /*
-@ A B C D E F G H I J K L M N O */
-INV, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
-P Q R S T U V W X Y Z [ \ ] ^ _ */
-NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, INV, INV, INV, INV, INV, /*
-` a b c d e f g h i j k l m n o */
-INV, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
-p q r s t u v w x y z { | } ~ 127 */
-NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, INV, INV, INV, INV, INV,
-INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV,
-INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV,
-INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV,
-INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV,
-INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV,
-INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV,
-INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV,
-INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV
-};
-
-/* This table maps ASCII to the system character set. */
-int iso646charset[] = {
-0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
-16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
-32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
-48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
-64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
-80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
-96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
-112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-};
-
-/* This table maps the C0 part of ISO646 to the system character set. */
-/* We through in 32 and 127 for free, since ISO 2022 maps them in
-automatically. */
-int iso646C0charset[] = {
-0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
-16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
-32, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, 127,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-};
-
-/* This table maps the G0 part of ISO646 to the system character set. */
-int iso646G0charset[] = {
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
-48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
-64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
-80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
-96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
-112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-};
-
-int iso8859_1charset[] = {
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
-176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
-192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
-208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
-224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
-240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-};
-
-int iso6429C1charset[] = {
-128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
-144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-};
diff --git a/usr.bin/sgmls/sgmls/lextabe.c b/usr.bin/sgmls/sgmls/lextabe.c
deleted file mode 100644
index 5cfe0de..0000000
--- a/usr.bin/sgmls/sgmls/lextabe.c
+++ /dev/null
@@ -1,357 +0,0 @@
-/* This file was automatically generated by genlex. Do not edit. */
-
-#include "config.h"
-#include "entity.h"
-#include "sgmldecl.h"
-
-UNCH lexcnm[] = {
- 6, 5, 5, 5, 5, 10, 5, 5, 5, 5, 5, 5, 5, 9, 5, 5,
- 5, 5, 5, 5, 5, 5, 14, 5, 5, 5, 5, 5, 7, 5, 5, 12,
- 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6,
- 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 26, 0, 0, 0,
-13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0,
-15, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, 23,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 18,
- 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0,
- 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0,
- 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 22, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0,
- 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0,
- 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0,
- 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 5,
-};
-
-UNCH lexcon[] = {
- 6, 5, 5, 5, 5, 10, 5, 5, 5, 5, 5, 5, 5, 9, 5, 5,
- 5, 5, 5, 5, 5, 5, 14, 5, 5, 5, 5, 5, 7, 5, 5, 12,
- 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6,
- 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 25, 0, 0, 0,
-13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 0, 0,
-15, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 0, 24, 22,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 0, 0, 0, 0,
- 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0,
- 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0,
- 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 20, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0,
- 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0,
- 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0,
- 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 5,
-};
-
-UNCH lexgrp[] = {
- 6, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, 3, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 7, 5, 5, 5,
- 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6,
- 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 11, 19, 17,
- 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 10, 23, 0,
- 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22, 18, 0, 0, 16,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 0, 13, 0, 12,
- 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0,
- 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0,
- 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 15, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 0,
- 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0,
- 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0,
- 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 5,
-};
-
-UNCH lexlms[] = {
- 6, 5, 5, 5, 5, 10, 5, 5, 5, 5, 5, 5, 5, 9, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 7, 5, 5, 12,
- 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6,
- 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 20, 2, 2, 0,
-13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 0, 2, 0, 0,
- 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 17, 0, 19, 2,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 18, 0, 2, 2, 0,
- 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0,
- 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0,
- 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 16, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0,
- 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0,
- 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0,
- 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 5,
-};
-
-UNCH lexmark[] = {
- 6, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, 4, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 7, 5, 5, 5,
- 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6,
- 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 21, 11, 17, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0,
- 9, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 20, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 13, 22, 12,
- 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0,
- 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0,
- 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 14, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0,
- 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0,
- 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0,
- 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 5,
-};
-
-UNCH lexsd[] = {
- 6, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, 4, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 7, 5, 5, 5,
- 1, 1, 1, 1, 1, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6,
- 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
- 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1,
- 9, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 12, 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 11, 0, 10,
- 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1,
- 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1,
- 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 0, 1, 1,
- 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1,
- 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1,
- 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1,
- 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 5,
-};
-
-UNCH lextoke[] = {
- 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0,
- 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0,
- 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0,
- 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0,
- 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0,
- 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 0, 0, 0, 0, 0, 0,
-};
-
-UNCH lexmin[] = {
- 6, 5, 5, 5, 5, 10, 5, 5, 5, 5, 5, 5, 5, 9, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 7, 5, 5, 12,
- 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6,
- 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 2, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0,
- 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 2,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 2, 2, 0,
- 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0,
- 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0,
- 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0,
- 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0,
- 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 5,
-};
-
-UNCH lextran[] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
-16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
-32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
-48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
-64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
-80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
-96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
-112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
-128, 193, 194, 195, 196, 197, 198, 199, 200, 201, 138, 139, 140, 141, 142, 143,
-144, 209, 210, 211, 212, 213, 214, 215, 216, 217, 154, 155, 156, 157, 158, 159,
-160, 161, 226, 227, 228, 229, 230, 231, 232, 233, 170, 171, 172, 173, 174, 175,
-176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
-192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
-208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
-224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
-240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255,
-};
-
-
-int iso646charset[] = {
- 0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 37, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31,
- 64, 90, 127, 123, 91, 108, 80, 125, 77, 93, 92, 78, 107, 96, 75, 97,
-240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 122, 94, 76, 126, 110, 111,
-124, 193, 194, 195, 196, 197, 198, 199, 200, 201, 209, 210, 211, 212, 213, 214,
-215, 216, 217, 226, 227, 228, 229, 230, 231, 232, 233, 173, 224, 189, 176, 109,
-121, 129, 130, 131, 132, 133, 134, 135, 136, 137, 145, 146, 147, 148, 149, 150,
-151, 152, 153, 162, 163, 164, 165, 166, 167, 168, 169, 192, 79, 208, 161, 7,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-};
-
-int iso646G0charset[] = {
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
- 64, 90, 127, 123, 91, 108, 80, 125, 77, 93, 92, 78, 107, 96, 75, 97,
-240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 122, 94, 76, 126, 110, 111,
-124, 193, 194, 195, 196, 197, 198, 199, 200, 201, 209, 210, 211, 212, 213, 214,
-215, 216, 217, 226, 227, 228, 229, 230, 231, 232, 233, 173, 224, 189, 176, 109,
-121, 129, 130, 131, 132, 133, 134, 135, 136, 137, 145, 146, 147, 148, 149, 150,
-151, 152, 153, 162, 163, 164, 165, 166, 167, 168, 169, 192, 79, 208, 161, 7,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-};
-
-int iso646G0charset[] = {
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
- 64, 90, 127, 123, 91, 108, 80, 125, 77, 93, 92, 78, 107, 96, 75, 97,
-240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 122, 94, 76, 126, 110, 111,
-124, 193, 194, 195, 196, 197, 198, 199, 200, 201, 209, 210, 211, 212, 213, 214,
-215, 216, 217, 226, 227, 228, 229, 230, 231, 232, 233, 173, 224, 189, 176, 109,
-121, 129, 130, 131, 132, 133, 134, 135, 136, 137, 145, 146, 147, 148, 149, 150,
-151, 152, 153, 162, 163, 164, 165, 166, 167, 168, 169, 192, 79, 208, 161, 7,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-};
-
-int iso8859_1charset[] = {
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
- 65, 170, 74, 177, 159, 178, 106, 181, 187, 180, 154, 138, 95, 202, 175, 188,
-144, 143, 234, 250, 190, 160, 182, 179, 157, 218, 155, 139, 183, 184, 185, 171,
-100, 101, 98, 102, 99, 103, 158, 104, 116, 113, 114, 115, 120, 117, 118, 119,
-172, 105, 237, 238, 235, 239, 236, 191, 128, 253, 254, 251, 252, 186, 174, 89,
- 68, 69, 66, 70, 67, 71, 156, 72, 84, 81, 82, 83, 88, 85, 86, 87,
-140, 73, 205, 206, 203, 207, 204, 225, 112, 221, 222, 219, 220, 141, 142, 223,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-};
-
-int iso646C0charset[] = {
- 0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 37, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31,
- 64, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, 7,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-};
-
-int iso6429C1charset[] = {
- 4, 6, 8, 9, 10, 20, 21, 23, 26, 27, 32, 33, 34, 35, 36, 40,
- 41, 42, 43, 44, 48, 49, 51, 52, 53, 54, 56, 57, 58, 59, 62, 255,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED,
-};
diff --git a/usr.bin/sgmls/sgmls/lextoke.h b/usr.bin/sgmls/sgmls/lextoke.h
deleted file mode 100644
index d2bcfa0..0000000
--- a/usr.bin/sgmls/sgmls/lextoke.h
+++ /dev/null
@@ -1,10 +0,0 @@
-/* LEXTOKE.H: Symbols for tokenization lexical classes.
-*/
-#define INV 0 /* Invalid Chars Not allowed in an SGML name. */
-#define REC 1 /* Record Boundary RS and RE. */
-#define SEP 2 /* Separator TAB. */
-#define SP 3 /* SPACE */
-#define NMC 4 /* NAMECHAR . _ Period, underscore (plus NMS, NUM). */
-#define NMS 5 /* NAMESTRT Lower and uppercase letters */
-#define NU 6 /* NUMERAL Numerals */
-#define EOB 7 /* NONCHAR 28 End disk buffer. */
diff --git a/usr.bin/sgmls/sgmls/lineout.c b/usr.bin/sgmls/sgmls/lineout.c
deleted file mode 100644
index 794eff8..0000000
--- a/usr.bin/sgmls/sgmls/lineout.c
+++ /dev/null
@@ -1,656 +0,0 @@
-/* lineout.c -
- Implements line-oriented output format.
-
- Written by James Clark (jjc@jclark.com).
-*/
-
-#include "config.h"
-#include "std.h"
-#include "entity.h" /* Templates for entity control blocks. */
-#include "adl.h" /* Definitions for attribute list processing. */
-#include "sgmlmain.h" /* Main interface to SGML services. */
-#include "lineout.h"
-#include "appl.h"
-
-static VOID flush_data P((void));
-static VOID define_external_entity P((PNE));
-static VOID define_entity P((UNCH *));
-static VOID handle_attributes P((UNCH *, struct ad *));
-static VOID handle_token_list P((UNCH *, struct ad *, int));
-static VOID handle_single_token P((UNCH *, struct ad *, int));
-static VOID output_notation P((UNCH *, UNCH *, UNCH *));
-static VOID output_internal_entity P((UNCH *, int, UNCH *));
-static VOID output_external_entity P((UNCH *, int, UNIV, UNCH *, UNCH *,
- UNCH *));
-static VOID output_subdoc P((UNCH *, UNIV, UNCH *, UNCH *));
-#ifdef SUPPORT_SUBDOC
-static VOID process_subdoc P((UNCH *, UNIV));
-#endif /* SUPPORT_SUBDOC */
-static VOID output_record_end P((void));
-static VOID output_pcdata P((UNS, UNCH *));
-static VOID output_cdata P((UNS, UNCH *));
-static VOID output_sdata P((UNS, UNCH *));
-static VOID output_entity_reference P((UNCH *));
-static VOID output_start_tag P((UNCH *));
-static VOID output_end_tag P((UNCH *));
-static VOID output_processing_instruction P((UNS, UNCH *));
-static VOID output_implied_attribute P((UNCH *, UNCH *));
-static char *attribute_type_string P((int));
-static VOID output_begin_attribute P((UNCH *, UNCH *, int));
-static VOID output_attribute_token P((UNS, UNCH *));
-static VOID output_end_attribute P((void));
-static VOID print_data P((UNS, UNCH *, int));
-static VOID print_string P((UNS, UNCH *, int));
-static VOID print_id P((UNIV, UNCH *, UNCH *));
-static VOID print_filename P((char *));
-static VOID output_location P((void));
-static VOID output_appinfo P((UNS, UNCH *));
-
-static int have_data = 0;
-static char *current_filename = 0;
-static unsigned long current_lineno = 0;
-
-VOID process_document(subdocsw)
-int subdocsw;
-{
- enum sgmlevent rc;
- struct rcbtag rcbtag;
- struct rcbdata rcbdaf;
-
- while ((rc = sgmlnext(&rcbdaf, &rcbtag)) != SGMLEOD) {
-#ifdef SUPPORT_SUBDOC
- if (rc == SGMLDAF && !CONTERSW(rcbdaf) && NDESW(rcbdaf)
- && NEXTYPE(NEPTR(rcbdaf)) == ESNSUB) {
- if (!suppsw && !sgmlment(NEENAME(NEPTR(rcbdaf))))
- define_external_entity(NEPTR(rcbdaf));
- process_subdoc(NEENAME(NEPTR(rcbdaf)) + 1,
- NEID(NEPTR(rcbdaf)));
- continue;
- }
-#endif /* SUPPORT_SUBDOC */
- if (!suppsw)
- switch (rc) {
- case SGMLDAF:
- if (CONTERSW(rcbdaf))
- break;
- if (CDESW(rcbdaf))
- output_cdata(CDATALEN(rcbdaf), CDATA(rcbdaf));
- else if (SDESW(rcbdaf))
- output_sdata(CDATALEN(rcbdaf), CDATA(rcbdaf));
- else if (NDESW(rcbdaf)) {
- assert(NEXTYPE(NEPTR(rcbdaf)) != ESNSUB);
- if (!sgmlment(NEENAME(NEPTR(rcbdaf))))
- define_external_entity(NEPTR(rcbdaf));
- output_entity_reference(NEENAME(NEPTR(rcbdaf)) + 1);
- }
- else
- output_pcdata(CDATALEN(rcbdaf), CDATA(rcbdaf));
- break;
- case SGMLSTG:
- if (CONTERSW(rcbtag))
- break;
- if (ALPTR(rcbtag))
- handle_attributes((UNCH *)NULL, ALPTR(rcbtag));
- output_start_tag(CURGI(rcbtag));
- break;
- case SGMLETG:
- if (CONTERSW(rcbtag))
- break;
- output_end_tag(CURGI(rcbtag));
- break;
- case SGMLPIS:
- if (CONTERSW(rcbdaf))
- break;
- output_processing_instruction(PDATALEN(rcbdaf),
- PDATA(rcbdaf));
- break;
- case SGMLREF:
- if (CONTERSW(rcbdaf))
- break;
- output_record_end();
- break;
- case SGMLAPP:
- if (CONTERSW(rcbdaf))
- break;
- if (!subdocsw)
- output_appinfo(ADATALEN(rcbdaf), ADATA(rcbdaf));
- break;
- default:
- abort();
- }
- }
-}
-
-/* Output an indication that the document was conforming. */
-
-VOID output_conforming()
-{
- if (!suppsw)
- printf("%c\n", CONFORMING_CODE);
-}
-
-static VOID define_external_entity(p)
-PNE p;
-{
- if (NEXTYPE(p) == ESNSUB)
- output_subdoc(NEENAME(p) + 1, NEID(p), NEPUBID(p), NESYSID(p));
- else {
- if (!NEDCNMARK(p))
- output_notation(NEDCN(p) + 1, NEDCNPUBID(p), NEDCNSYSID(p));
- output_external_entity(NEENAME(p) + 1, NEXTYPE(p), NEID(p),
- NEPUBID(p), NESYSID(p), NEDCN(p) + 1);
- if (NEAL(p))
- handle_attributes(NEENAME(p) + 1, NEAL(p));
- }
-}
-
-static VOID define_entity(ename)
-UNCH *ename;
-{
- int rc;
- PNE np;
- UNCH *tp;
-
- if (sgmlment(ename)) /* already defined it */
- return;
- rc = sgmlgent(ename, &np, &tp);
- switch (rc) {
- case 1:
- define_external_entity(np);
- break;
- case 2:
- case 3:
- output_internal_entity(ename + 1, rc == 3, tp);
- break;
- }
-}
-
-/* ENT is the name of the entity with which these attributes are associated;
-if it's NULL, they're associated with the next start tag. */
-
-static VOID handle_attributes(ent, al)
-UNCH *ent;
-struct ad *al;
-{
- int aln;
-
- for (aln = 1; aln <= ADN(al); aln++) {
- if (GET(ADFLAGS(al, aln), AERROR))
- ;
- else if (GET(ADFLAGS(al, aln), AINVALID))
- ;
- else if (ADVAL(al, aln) == NULL)
- output_implied_attribute(ent, ADNAME(al, aln));
- else if (ADTYPE(al, aln) >= ATKNLIST)
- handle_token_list(ent, al, aln);
- else
- handle_single_token(ent, al, aln);
- if (BITON(ADFLAGS(al, aln), AGROUP))
- aln += ADNUM(al, aln);
- }
-}
-
-static VOID handle_token_list(ent, al, aln)
-UNCH *ent;
-struct ad *al;
-int aln;
-{
- UNCH *ptr;
- int i;
- if (ADTYPE(al, aln) == AENTITYS) {
- ptr = ADVAL(al, aln);
- for (i = 0; i < ADNUM(al, aln); i++) {
- /* Temporarily make token look like normal
- name with length and EOS. */
- UNCH c = ptr[*ptr + 1];
- ptr[*ptr + 1] = '\0';
- *ptr += 2;
- define_entity(ptr);
- *ptr -= 2;
- ptr += *ptr + 1;
- *ptr = c;
- }
- }
- output_begin_attribute(ent, ADNAME(al, aln), ADTYPE(al, aln));
- ptr = ADVAL(al, aln);
- for (i = 0; i < ADNUM(al, aln); i++) {
- /* The first byte is a length NOT including the length
- byte; the tokens are not EOS terminated. */
- output_attribute_token(*ptr, ptr + 1);
- ptr += *ptr + 1;
- }
- output_end_attribute();
-}
-
-static VOID handle_single_token(ent, al, aln)
-UNCH *ent;
-struct ad *al;
-int aln;
-{
- if (ADTYPE(al, aln) == ANOTEGRP && !DCNMARK(ADDATA(al, aln).x))
- output_notation(ADVAL(al, aln) + 1,
- ADDATA(al, aln).x->pubid,
- ADDATA(al, aln).x->sysid);
- else if (ADTYPE(al, aln) == AENTITY)
- define_entity(ADVAL(al, aln));
- output_begin_attribute(ent, ADNAME(al, aln), ADTYPE(al, aln));
- if (ADTYPE(al, aln) == ACHARS) {
- putchar(' ');
- print_string(ustrlen(ADVAL(al, aln)), ADVAL(al, aln), 0);
- }
- else
- output_attribute_token(*ADVAL(al, aln) - 2, ADVAL(al, aln) + 1);
- output_end_attribute();
-}
-
-static VOID output_notation(name, pubid, sysid)
-UNCH *name;
-UNCH *pubid, *sysid;
-{
- flush_data();
- print_id((UNIV)0, pubid, sysid);
- printf("%c%s\n", DEFINE_NOTATION_CODE, name);
-}
-
-static VOID output_internal_entity(ename, is_sdata, text)
-UNCH *ename;
-int is_sdata;
-UNCH *text;
-{
- flush_data();
- printf("%c%s %s ", DEFINE_INTERNAL_ENTITY_CODE, ename,
- is_sdata ? "SDATA" : "CDATA");
- print_string(text ? ustrlen(text) : 0, text, 0);
- putchar('\n');
-}
-
-static VOID output_subdoc(nm, id, pubid, sysid)
-UNCH *nm;
-UNIV id;
-UNCH *pubid, *sysid;
-{
- flush_data();
- print_id(id, pubid, sysid);
- printf("%c%s\n", DEFINE_SUBDOC_ENTITY_CODE, nm);
-}
-
-#ifdef SUPPORT_SUBDOC
-
-static VOID process_subdoc(nm, id)
-UNCH *nm;
-UNIV id;
-{
- if (!suppsw) {
- flush_data();
- output_location();
- printf("%c%s\n", START_SUBDOC_CODE, nm);
- fflush(stdout);
- }
- fflush(stderr);
-
- if (id) {
- char **argv;
- int ret;
-
- argv = make_argv(id);
- ret = run_process(argv);
- if (ret != 0)
- suberr++;
-
- current_filename = 0;
- free(argv);
- if (ret == 0)
- get_subcaps();
- }
- else {
- suberr++;
- appl_error(E_SUBDOC, nm);
- }
-
- if (!suppsw)
- printf("%c%s\n", END_SUBDOC_CODE, nm);
-}
-
-#endif /* SUPPORT_SUBDOC */
-
-static VOID output_external_entity(nm, xtype, id, pubid, sysid, dcn)
-UNCH *nm, *dcn;
-UNIV id;
-UNCH *pubid, *sysid;
-int xtype;
-{
- char *type;
-
- flush_data();
-
- print_id(id, pubid, sysid);
-
- switch (xtype) {
- case ESNCDATA:
- type = "CDATA";
- break;
- case ESNNDATA:
- type = "NDATA";
- break;
- case ESNSDATA:
- type = "SDATA";
- break;
- default:
- return;
- }
- printf("%c%s %s %s\n", DEFINE_EXTERNAL_ENTITY_CODE, nm, type, dcn);
-}
-
-static VOID output_record_end()
-{
- static UNCH re = RECHAR;
- print_data(1, &re, 0);
-}
-
-static VOID output_pcdata(n, s)
-UNS n;
-UNCH *s;
-{
- print_data(n, s, 0);
-}
-
-static VOID output_cdata(n, s)
-UNS n;
-UNCH *s;
-{
- print_data(n, s, 0);
-}
-
-static VOID output_sdata(n, s)
-UNS n;
-UNCH *s;
-{
- print_data(n, s, 1);
-}
-
-static VOID output_entity_reference(s)
-UNCH *s;
-{
- flush_data();
- output_location();
- printf("%c%s\n", REFERENCE_ENTITY_CODE, s);
-}
-
-static VOID output_start_tag(s)
-UNCH *s;
-{
- flush_data();
- output_location();
- printf("%c%s\n", START_CODE, s);
-}
-
-static VOID output_end_tag(s)
-UNCH *s;
-{
- flush_data();
- printf("%c%s\n", END_CODE, s);
-}
-
-static VOID output_processing_instruction(n, s)
-UNS n;
-UNCH *s;
-{
- flush_data();
- output_location();
- putchar(PI_CODE);
- print_string(n, s, 0);
- putchar('\n');
-}
-
-static VOID output_appinfo(n, s)
-UNS n;
-UNCH *s;
-{
- flush_data();
- output_location();
- putchar(APPINFO_CODE);
- print_string(n, s, 0);
- putchar('\n');
-}
-
-
-static VOID output_implied_attribute(ent, aname)
-UNCH *ent, *aname;
-{
- flush_data();
- if (ent)
- printf("%c%s %s IMPLIED\n", DATA_ATTRIBUTE_CODE, ent, aname);
- else
- printf("%c%s IMPLIED\n", ATTRIBUTE_CODE, aname);
-}
-
-static char *attribute_type_string(type)
-int type;
-{
- switch (type) {
- case ANMTGRP:
- case ANAME:
- case ANMTOKE:
- case ANUTOKE:
- case ANUMBER:
- case ANAMES:
- case ANMTOKES:
- case ANUTOKES:
- case ANUMBERS:
- case AID:
- case AIDREF:
- case AIDREFS:
- return "TOKEN";
- case ANOTEGRP:
- return "NOTATION";
- case ACHARS:
- return "CDATA";
- case AENTITY:
- case AENTITYS:
- return "ENTITY";
- }
-#if 0
- fatal("invalid attribute type %d", type);
-#endif
- return "INVALID";
-}
-
-static VOID output_begin_attribute(ent, aname, type)
-UNCH *ent, *aname;
-int type;
-{
- flush_data();
- if (ent)
- printf("%c%s %s %s", DATA_ATTRIBUTE_CODE, ent, aname,
- attribute_type_string(type));
- else
- printf("%c%s %s", ATTRIBUTE_CODE, aname,
- attribute_type_string(type));
-
-}
-
-static VOID output_attribute_token(vallen, val)
-UNS vallen;
-UNCH *val;
-{
- putchar(' ');
- for (; vallen > 0; --vallen, ++val)
- putchar(*val);
-}
-
-static VOID output_end_attribute()
-{
- putchar('\n');
-}
-
-static VOID print_data(n, s, is_sdata)
-UNS n;
-UNCH *s;
-int is_sdata;
-{
- if (n > 0 || is_sdata) {
- if (n == 1 && *s == RECHAR)
- current_lineno++;
- else
- output_location();
- if (!have_data)
- putchar(DATA_CODE);
- print_string(n, s, is_sdata);
- have_data = 1;
- }
-}
-
-static VOID flush_data()
-{
- if (have_data) {
- putchar('\n');
- have_data = 0;
- }
-}
-
-static VOID output_location()
-{
- char *filename;
- unsigned long lineno;
- int filename_changed = 0;
-
- if (!locsw)
- return;
- if (!sgmlloc(&lineno, &filename))
- return;
- if (!current_filename || strcmp(filename, current_filename) != 0)
- filename_changed = 1;
- else if (lineno == current_lineno)
- return;
- flush_data();
- printf("%c%lu", LOCATION_CODE, lineno);
- current_lineno = lineno;
- if (filename_changed) {
- putchar(' ');
- print_filename(filename);
- current_filename = filename;
- }
- putchar('\n');
-}
-
-static VOID print_string(slen, s, is_sdata)
-UNS slen;
-UNCH *s;
-int is_sdata;
-{
- if (is_sdata)
- fputs("\\|", stdout);
- while (slen > 0) {
- UNCH ch = *s++;
- slen--;
- if (ch == DELSDATA) {
- if (is_sdata)
- ; /* I don't think this should happen */
- else
- fputs("\\|", stdout);
- ;
- }
- else if (ch == DELCDATA)
- ;
- else {
- if (ch == DELNONCH) {
- if (!slen)
- break;
- ch = UNSHIFTNON(*s);
- s++;
- slen--;
- }
- switch (ch) {
- case RECHAR:
- fputs("\\n", stdout);
- break;
- case '\\':
- fputs("\\\\", stdout);
- break;
- default:
- if (ISASCII(ch) && isprint(ch))
- putchar(ch);
- else
- printf("\\%03o", ch);
- break;
- }
- }
- }
- if (is_sdata)
- fputs("\\|", stdout);
-}
-
-
-static VOID print_id(id, pubid, sysid)
-UNIV id;
-UNCH *pubid;
-UNCH *sysid;
-{
-
- if (pubid) {
- putchar(PUBID_CODE);
- print_string(ustrlen(pubid), pubid, 0);
- putchar('\n');
- }
-
- if (sysid) {
- putchar(SYSID_CODE);
- print_string(ustrlen(sysid), sysid, 0);
- putchar('\n');
- }
-
- if (id) {
- char *p;
-
- for (p = id; *p != '\0'; p++) {
- putchar(FILE_CODE);
- do {
- switch (*p) {
- case '\\':
- fputs("\\\\", stdout);
- break;
- case '\n':
- fputs("\\n", stdout);
- break;
- default:
- if (ISASCII(*p) && isprint((UNCH)*p))
- putchar(*p);
- else
- printf("\\%03o", (UNCH)*p);
- break;
- }
- } while (*++p);
- putchar('\n');
- }
- }
-}
-
-static VOID print_filename(s)
-char *s;
-{
- for (; *s; s++)
- switch (*s) {
- case '\\':
- fputs("\\\\", stdout);
- break;
- case '\n':
- fputs("\\n", stdout);
- break;
- default:
- if (ISASCII(*s) && isprint((UNCH)*s))
- putchar(*s);
- else
- printf("\\%03o", (UNCH)*s);
- break;
- }
-}
-
-/*
-Local Variables:
-c-indent-level: 5
-c-continued-statement-offset: 5
-c-brace-offset: -5
-c-argdecl-indent: 0
-c-label-offset: -5
-End:
-*/
diff --git a/usr.bin/sgmls/sgmls/lineout.h b/usr.bin/sgmls/sgmls/lineout.h
deleted file mode 100644
index f3c4231..0000000
--- a/usr.bin/sgmls/sgmls/lineout.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* lineout.h */
-
-/* Output codes used by sgmls. */
-
-#define DATA_CODE '-'
-#define START_CODE '('
-#define END_CODE ')'
-#define ATTRIBUTE_CODE 'A'
-#define DATA_ATTRIBUTE_CODE 'D'
-#define REFERENCE_ENTITY_CODE '&'
-#define DEFINE_NOTATION_CODE 'N'
-#define DEFINE_EXTERNAL_ENTITY_CODE 'E'
-#define DEFINE_INTERNAL_ENTITY_CODE 'I'
-#define PI_CODE '?'
-#define DEFINE_SUBDOC_ENTITY_CODE 'S'
-#define START_SUBDOC_CODE '{'
-#define END_SUBDOC_CODE '}'
-#define LOCATION_CODE 'L'
-#define APPINFO_CODE '#'
-#define PUBID_CODE 'p'
-#define SYSID_CODE 's'
-#define FILE_CODE 'f'
-#define CONFORMING_CODE 'C'
diff --git a/usr.bin/sgmls/sgmls/main.c b/usr.bin/sgmls/sgmls/main.c
deleted file mode 100644
index 25ead40..0000000
--- a/usr.bin/sgmls/sgmls/main.c
+++ /dev/null
@@ -1,650 +0,0 @@
-/* main.c -
- Main program for sgmls.
-
- Written by James Clark (jjc@jclark.com).
-*/
-
-#include "config.h"
-#include "std.h"
-#include "getopt.h"
-#include "entity.h" /* Templates for entity control blocks. */
-#include "adl.h" /* Definitions for attribute list processing. */
-#include "sgmlmain.h" /* Main interface to SGML services. */
-#include "appl.h"
-#include "alloc.h"
-
-#define READCNT 512
-
-/* Before using argv[0] in error messages, strip off everything up to and
-including the last character in prog that occurs in PROG_PREFIX. */
-
-#ifndef PROG_PREFIX
-#define PROG_PREFIX "/"
-#endif /* not PROG_PREFIX */
-
-/* Message catalogue name. */
-#define CAT_NAME "sgmls"
-/* Message set to use for application error messages. */
-#define APP_SET 4
-/* Message set to use for error messages from catalog.c. */
-#define CAT_SET 5
-#define CATALOG_ERROR_HEADER_MSGNO 20
-#define CATALOG_ERROR_HEADER_TEXT "Catalog error at %s, line %lu"
-
-#ifdef HAVE_EXTENDED_PRINTF
-#define xvfprintf vfprintf
-#else
-extern int xvfprintf P((FILE *, char *, va_list));
-#endif
-
-static VOID usage P((void));
-static VOID fatal VP((int, ...));
-static VOID do_error P((int, va_list));
-static VOID swinit P((struct switches *));
-static VOID write_caps P((char *, struct sgmlcap *));
-static VOID do_catalog_error();
-
-static UNIV make_docent P((int, char **));
-static char *munge_program_name P((char *, char *));
-static VOID die P((void));
-#ifdef SUPPORT_SUBDOC
-static VOID build_subargv P((struct switches *));
-static VOID cleanup P((void));
-static char *create_subcap_file P((void));
-#endif /* SUPPORT_SUBDOC */
-
-static char *errlist[] = {
- 0,
- "Out of memory",
- "Cannot open SGML document entity",
- "Cannot exec `%s': %s",
- "Cannot fork: %s",
- "Error waiting for process: %s",
- "Program %s got fatal signal %d",
- "Cannot open `%s': %s",
- "Subdocument capacity botch",
- "Non-existent subdocument entity `%s' not processed",
-};
-
-int suppsw = 0; /* Non-zero means suppress output. */
-int locsw = 0; /* Non-zero means generate location info. */
-static char *prog; /* Program name (for error messages). */
-static nl_catd catd; /* Message catalogue descriptor. */
-static char *capfile = 0; /* File for capacity report. */
-extern char *version_string;
-static CATALOG catalog; /* Entity catalog. */
-
-char options[] = {
- 'c', ':', 'd', 'e', 'g', 'i', ':', 'l', 'o', ':', 'p', 'r', 's', 'u', 'v',
- 'm', ':',
-#ifdef CANT_REDIRECT_STDERR
- 'f', ':',
-#endif /* CANT_REDIRECT_STDERR */
-#ifdef TRACE
- 'x', ':', 'y', ':',
-#endif /* TRACE */
- '\0'
-};
-
-#ifdef SUPPORT_SUBDOC
-int suberr = 0; /* Error in subdocument. */
-static char *subargv[sizeof(options)];
-static int subargc = 0;
-static char nopenbuf[sizeof(long)*3 + 1];
-static char sgmldecl_file[L_tmpnam];
-static char subcap_file[L_tmpnam];
-#endif
-
-int main(argc, argv)
-int argc;
-char **argv;
-{
- static char stderr_buf[BUFSIZ];
- int opt;
-#ifdef CANT_REDIRECT_STDERR
- char *errfile = 0;
-#endif
- struct sgmlcap cap;
- struct switches sw;
- int nincludes = 0; /* number of -i options */
- setbuf(stderr, stderr_buf);
-
- /* Define MAIN_HOOK in config.h if some function needs to be called here. */
-#ifdef MAIN_HOOK
- MAIN_HOOK(argc, argv);
-#endif
-#ifdef SUPPORT_SUBDOC
- subargv[subargc++] = argv[0];
-#endif
-
- prog = argv[0] = munge_program_name(argv[0], "sgmls");
-
- catd = catopen(CAT_NAME, 0);
- catalog = catalog_create(do_catalog_error);
- swinit(&sw);
-
- while ((opt = getopt(argc, argv, options)) != -1) {
- switch (opt) {
- case 'm':
- catalog_load_file(catalog, optarg);
- break;
- case 'l': /* Generate location information. */
- locsw = 1;
- break;
- case 'c': /* Print capacity usage. */
- sw.swcap = 1;
- capfile = optarg;
- break;
- case 's': /* Suppress output. */
- suppsw = 1;
- break;
- case 'd': /* Report duplicate entity declarations. */
- sw.swdupent = 1;
- break;
- case 'e': /* Provide entity stack trace in error msg. */
- sw.swenttr = 1;
- break;
-#ifdef CANT_REDIRECT_STDERR
- case 'f': /* Redirect errors. */
- errfile = optarg;
- break;
-#endif /* CANT_REDIRECT_STDERR */
- case 'g': /* Provide GI stack trace in error messages. */
- sw.sweltr = 1;
- break;
- case 'p': /* Parse only the prolog. */
- sw.onlypro = 1;
- suppsw = 1;
- break;
- case 'r': /* Give warning for defaulted references. */
- sw.swrefmsg = 1;
- break;
- case 'u':
- sw.swundef = 1;
- break;
-#ifdef TRACE
- case 'x': /* Trace options for the document body. */
- sw.trace = optarg;
- break;
- case 'y': /* Trace options for the prolog. */
- sw.ptrace = optarg;
- break;
-#endif /* TRACE */
- case 'v': /* Print the version number. */
- fprintf(stderr, "sgmls version %s\n", version_string);
- fflush(stderr);
- break;
- case 'o':
- sw.nopen = atol(optarg);
- if (sw.nopen <= 0)
- usage();
- break;
- case 'i': /* Define parameter entity as "INCLUDE". */
- sw.includes = (char **)xrealloc((UNIV)sw.includes,
- (nincludes + 2)*sizeof(char *));
- sw.includes[nincludes++] = optarg;
- sw.includes[nincludes] = 0;
- break;
- case '?':
- usage();
- default:
- abort();
- }
- }
-
-#ifdef CANT_REDIRECT_STDERR
- if (errfile) {
- FILE *fp;
- errno = 0;
- fp = fopen(errfile, "w");
- if (!fp)
- fatal(E_OPEN, errfile, strerror(errno));
- fclose(fp);
- errno = 0;
- if (!freopen(errfile, "w", stderr)) {
- /* Can't use fatal() since stderr is now closed */
- printf("%s: ", prog);
- printf(errlist[E_OPEN], errfile, strerror(errno));
- putchar('\n');
- exit(EXIT_FAILURE);
- }
- }
-#endif /* CANT_REDIRECT_STDERR */
-
- (void)sgmlset(&sw);
-
-#ifdef SUPPORT_SUBDOC
- build_subargv(&sw);
-#endif
- if (sgmlsdoc(make_docent(argc - optind, argv + optind)))
- fatal(E_DOC);
-
- process_document(sw.nopen > 0);
- sgmlend(&cap);
- if (capfile)
- write_caps(capfile, &cap);
-#ifdef SUPPORT_SUBDOC
- cleanup();
- if (suberr)
- exit(EXIT_FAILURE);
-#endif /* SUPPORT_SUBDOC */
- if (sgmlgcnterr() > 0)
- exit(EXIT_FAILURE);
- if (!sw.nopen)
- output_conforming();
- exit(EXIT_SUCCESS);
-}
-
-static char *munge_program_name(arg, dflt)
-char *arg, *dflt;
-{
- char *p;
-#ifdef PROG_STRIP_EXTENSION
- char *ext;
-#endif
- if (!arg || !*arg)
- return dflt;
- p = strchr(arg, '\0');
- for (;;) {
- if (p == arg)
- break;
- --p;
- if (strchr(PROG_PREFIX, *p)) {
- p++;
- break;
- }
- }
- arg = p;
-#ifdef PROG_STRIP_EXTENSION
- ext = strrchr(arg, '.');
- if (ext) {
- p = (char *)xmalloc(ext - arg + 1);
- memcpy(p, arg, ext - arg);
- p[ext - arg] = '\0';
- arg = p;
- }
-#endif /* PROG_STRIP_EXTENSION */
-#ifdef PROG_FOLD
-#ifdef PROG_STRIP_EXTENSION
- if (!ext) {
-#endif
- p = xmalloc(strlen(arg) + 1);
- strcpy(p, arg);
- arg = p;
-#ifdef PROG_STRIP_EXTENSION
- }
-#endif
- for (p = arg; *p; p++)
- if (ISASCII((unsigned char)*p) && isupper((unsigned char)*p))
- *p = tolower((unsigned char)*p);
-#endif /* PROG_FOLD */
- return arg;
-}
-
-static UNIV make_docent(argc, argv)
-int argc;
-char **argv;
-{
- UNS len = 1;
- int i;
- UNIV res;
- char *ptr;
- static char *stdinname = STDINNAME;
-
- if (argc == 0) {
- argv = &stdinname;
- argc = 1;
- }
-
- for (i = 0; i < argc; i++)
- len += strlen(argv[i]) + 1;
-
- res = xmalloc(len);
- ptr = (char *)res;
- for (i = 0; i < argc; i++) {
- strcpy(ptr, argv[i]);
- ptr = strchr(ptr, '\0') + 1;
- }
- *ptr = '\0';
- return res;
-}
-
-
-static VOID usage()
-{
- /* Don't mention -o since this are for internal use only. */
- fprintf(stderr, "Usage: %s [-deglprsuv]%s [-c file] [-i entity] [-m file]%s [filename ...]\n",
- prog,
-#ifdef CANT_REDIRECT_STDERR
- " [-f file]",
-#else /* not CANT_REDIRECT_STDERR */
- "",
-#endif /* not CANT_REDIRECT_STDERR */
-#ifdef TRACE
- " [-x flags] [-y flags]"
-#else /* not TRACE */
- ""
-#endif /* not TRACE */
- );
- exit(EXIT_FAILURE);
-}
-
-static VOID die()
-{
-#ifdef SUPPORT_SUBDOC
- cleanup();
-#endif /* SUPPORT_SUBDOC */
- exit(EXIT_FAILURE);
-}
-
-static VOID swinit(swp)
-struct switches *swp;
-{
- swp->swenttr = 0;
- swp->sweltr = 0;
- swp->swbufsz = READCNT+2;
- swp->prog = prog;
- swp->swdupent = 0;
- swp->swrefmsg = 0;
-#ifdef TRACE
- swp->trace = 0;
- swp->ptrace = 0;
-#endif /* TRACE */
- swp->catd = catd;
- swp->catalog = catalog;
- swp->swambig = 1; /* Always check for ambiguity. */
- swp->swundef = 0;
- swp->swcap = 0; /* Don't check capacities. */
- swp->nopen = 0;
- swp->onlypro = 0;
- swp->includes = 0;
- swp->die = die;
-}
-
-#ifdef SUPPORT_SUBDOC
-
-static VOID build_subargv(swp)
-struct switches *swp;
-{
- if (suppsw)
- subargv[subargc++] = "-s";
- if (locsw)
- subargv[subargc++] = "-l";
- if (swp->swdupent)
- subargv[subargc++] = "-d";
- if (swp->swenttr)
- subargv[subargc++] = "-e";
- if (swp->sweltr)
- subargv[subargc++] = "-g";
- if (swp->swrefmsg)
- subargv[subargc++] = "-r";
-#ifdef TRACE
- if (swp->trace) {
- subargv[subargc++] = "-x";
- subargv[subargc++] = swp->trace;
- }
- if (swp->ptrace) {
- subargv[subargc++] = "-y";
- subargv[subargc++] = swp->ptrace;
- }
-#endif /* TRACE */
- subargv[subargc++] = "-o";
- sprintf(nopenbuf, "%ld", swp->nopen + 1);
- subargv[subargc++] = nopenbuf;
-}
-
-
-static
-VOID handler(sig)
-int sig;
-{
- signal(sig, SIG_DFL);
- cleanup();
- raise(sig);
-}
-
-static
-VOID cleanup()
-{
- if (sgmldecl_file[0]) {
- (void)remove(sgmldecl_file);
- sgmldecl_file[0] = '\0';
- }
- if (subcap_file[0]) {
- (void)remove(subcap_file);
- subcap_file[0] = '\0';
- }
-}
-
-static
-char *store_sgmldecl()
-{
- if (!sgmldecl_file[0]) {
- FILE *fp;
- if (signal(SIGINT, SIG_IGN) != SIG_IGN)
- signal(SIGINT, handler);
-#ifdef SIGTERM
- if (signal(SIGTERM, SIG_IGN) != SIG_IGN)
- signal(SIGTERM, handler);
-#endif /* SIGTERM */
-#ifdef SIGPIPE
- if (signal(SIGPIPE, SIG_IGN) != SIG_IGN)
- signal(SIGPIPE, handler);
-#endif
-#ifdef SIGHUP
- if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
- signal(SIGHUP, handler);
-#endif
- tmpnam(sgmldecl_file);
- errno = 0;
- fp = fopen(sgmldecl_file, "w");
- if (!fp)
- fatal(E_OPEN, sgmldecl_file, strerror(errno));
- sgmlwrsd(fp);
- fclose(fp);
- }
- return sgmldecl_file;
-}
-
-static
-char *create_subcap_file()
-{
- if (subcap_file[0] == '\0') {
- FILE *fp;
- tmpnam(subcap_file);
- fp = fopen(subcap_file, "w");
- if (!fp)
- fatal(E_OPEN, subcap_file, strerror(errno));
- fclose(fp);
- }
- return subcap_file;
-}
-
-char **make_argv(id)
-UNIV id;
-{
- int nfiles;
- char *p;
- char **argv;
- int i;
-
- for (p = (char *)id, nfiles = 0; *p; p = strchr(p, '\0') + 1)
- nfiles++;
-
- argv = (char **)xmalloc((subargc + 2 + 1 + nfiles + 1)*sizeof(char *));
- memcpy((UNIV)argv, (UNIV)subargv, subargc*sizeof(char *));
-
- i = subargc;
-
- argv[i++] = "-c";
- argv[i++] = create_subcap_file();
-
- argv[i++] = store_sgmldecl();
-
- for (p = (char *)id; *p; p = strchr(p, '\0') + 1)
- argv[i++] = p;
- argv[i] = 0;
- return argv;
-}
-
-VOID get_subcaps()
-{
- long cap[NCAPACITY];
- FILE *fp;
- int i;
-
- if (!subcap_file[0])
- return;
- errno = 0;
- fp = fopen(subcap_file, "r");
- if (!fp)
- fatal(E_OPEN, subcap_file, strerror(errno));
- for (i = 0; i < NCAPACITY; i++)
- if (fscanf(fp, "%*s %ld", cap + i) != 1)
- fatal(E_CAPBOTCH);
- fclose(fp);
- sgmlsubcap(cap);
-}
-
-
-#endif /* SUPPORT_SUBDOC */
-
-/* Print capacity statistics.*/
-
-static VOID write_caps(name, p)
-char *name;
-struct sgmlcap *p;
-{
- FILE *fp;
- int i;
- fp = fopen(name, "w");
- if (!fp)
- fatal(E_OPEN, name, strerror(errno));
- /* This is in RACT format. */
- for (i = 0; i < NCAPACITY; i++)
- fprintf(fp, "%s %ld\n", p->name[i], p->number[i]*p->points[i]);
- fclose(fp);
-}
-
-UNIV xmalloc(n)
-UNS n;
-{
- UNIV p = malloc(n);
- if (!p)
- fatal(E_NOMEM);
- return p;
-}
-
-UNIV xrealloc(s, n)
-UNIV s;
-UNS n;
-{
- s = s ? realloc(s, n) : malloc(n);
- if (!s)
- fatal(E_NOMEM);
- return s;
-}
-
-static
-#ifdef VARARGS
-VOID fatal(va_alist) va_dcl
-#else
-VOID fatal(int errnum,...)
-#endif
-{
-#ifdef VARARGS
- int errnum;
-#endif
- va_list ap;
-
-#ifdef VARARGS
- va_start(ap);
- errnum = va_arg(ap, int);
-#else
- va_start(ap, errnum);
-#endif
- do_error(errnum, ap);
- va_end(ap);
- exit(EXIT_FAILURE);
-}
-
-#ifdef VARARGS
-VOID appl_error(va_alist) va_dcl
-#else
-VOID appl_error(int errnum,...)
-#endif
-{
-#ifdef VARARGS
- int errnum;
-#endif
- va_list ap;
-
-#ifdef VARARGS
- va_start(ap);
- errnum = va_arg(ap, int);
-#else
- va_start(ap, errnum);
-#endif
- do_error(errnum, ap);
- va_end(ap);
-}
-
-static
-VOID do_error(errnum, ap)
-int errnum;
-va_list ap;
-{
- char *text;
- fprintf(stderr, "%s: ", prog);
- assert(errnum > 0);
- assert(errnum < sizeof(errlist)/sizeof(errlist[0]));
- text = catgets(catd, APP_SET, errnum, errlist[errnum]);
- assert(text != 0);
- xvfprintf(stderr, text, ap);
- fputc('\n', stderr);
- fflush(stderr);
-}
-
-static
-VOID do_catalog_error(filename, lineno, error_number, flags, sys_errno)
-char *filename;
-unsigned long lineno;
-int error_number;
-unsigned flags;
-int sys_errno;
-{
- char *text;
- unsigned indent;
- text = catgets(catd, CAT_SET, error_number,
- (char *)catalog_error_text(error_number)); /* XXX */
- assert(text != 0);
- fprintf(stderr, "%s: ", prog);
- indent = strlen(prog) + 2;
- if (flags & CATALOG_SYSTEM_ERROR)
- fprintf(stderr, text, filename, strerror(sys_errno));
- else {
- unsigned i;
- fprintf(stderr,
- catgets(catd, APP_SET,
- CATALOG_ERROR_HEADER_MSGNO,
- CATALOG_ERROR_HEADER_TEXT),
- filename, lineno);
- fputs(":\n", stderr);
- for (i = 0; i < indent; i++)
- putc(' ', stderr);
- fputs(text, stderr);
- }
- putc('\n', stderr);
- fflush(stderr);
-}
-
-/*
-Local Variables:
-c-indent-level: 5
-c-continued-statement-offset: 5
-c-brace-offset: -5
-c-argdecl-indent: 0
-c-label-offset: -5
-comment-column: 30
-End:
-*/
diff --git a/usr.bin/sgmls/sgmls/md1.c b/usr.bin/sgmls/sgmls/md1.c
deleted file mode 100644
index 66c476d..0000000
--- a/usr.bin/sgmls/sgmls/md1.c
+++ /dev/null
@@ -1,866 +0,0 @@
-#include "sgmlincl.h" /* #INCLUDE statements for SGML parser. */
-/* MDADL: Process ATTLIST declaration.
-*/
-VOID mdadl(tbuf)
-UNCH *tbuf; /* Work area for tokenization (tbuf). */
-{
- int i; /* Loop counter; temporary variable. */
- int adlim; /* Number of unused ad slots in al. */
- struct ad *alperm = 0; /* Attribute definition list. */
- int stored = 0;
-
- mdname = key[KATTLIST]; /* Identify declaration for messages. */
- subdcl = 0; /* No subject as yet. */
- parmno = 0; /* No parameters as yet. */
- mdessv = es; /* Save es level for entity nesting check. */
- reqadn = noteadn = 0; /* No required attributes yet. */
- idadn = conradn = 0; /* No special atts yet.*/
- AN(al) = 0; /* Number of attributes defined. */
- ADN(al) = 0; /* Number of ad's in al (atts + name vals).*/
- /* PARAMETER 1: Element name or a group of them.
- */
- parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN);
- TRACEMD("1: element name or group");
- switch (pcbmd.action) {
- case NAS:
- nmgrp[0] = etddef(tbuf);
- nmgrp[1] = 0;
- break;
- case GRPS:
- parsegrp(nmgrp, &pcbgrnm, tbuf);
- break;
- case RNS: /* Reserved name started. */
- if (ustrcmp(tbuf+1, key[KNOTATION])) {
- mderr(118, tbuf+1, key[KNOTATION]);
- return;
- }
- mdnadl(tbuf);
- return;
- default:
- mderr(121, (UNCH *)0, (UNCH *)0);
- return;
- }
- /* Save first GI for error msgs. */
- if (nmgrp[0])
- subdcl = nmgrp[0]->etdgi+1;
- /* PARAMETER 2: Attribute definition list.
- */
- parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN);
- TRACEMD("2: attribute list");
- if (pcbmd.action!=NAS) {
- mderr(120, (UNCH *)0, (UNCH *)0);
- return;
- }
- while (pcbmd.action==NAS) {
- al[ADN(al)+1].adname = savenm(tbuf);
- if ((adlim = ATTCNT-((int)++ADN(al)))<0) {
- mderr(111, (UNCH *)0, (UNCH *)0);
- adlfree(al, 1);
- return;
- }
- ++AN(al);
- if (mdattdef(adlim, 0)) {
- adlfree(al, 1);
- return;
- }
- parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN);
- }
- if (AN(al)>0) { /* Save list only if 1 or more good atts. */
- if (reqadn) SET(ADLF(al), ADLREQ); /* Element must have start-tag. */
- if (noteadn) SET(ADLF(al), ADLNOTE); /* Element cannot be EMPTY. */
- if (conradn) SET(ADLF(al), ADLCONR); /* Element cannot be EMPTY. */
- alperm = (struct ad *)rmalloc((1+ADN(al))*ADSZ);
- memcpy((UNIV)alperm, (UNIV)al, (1+ADN(al))*ADSZ );
- ds.attcnt += AN(al); /* Number of attributes defined. */
- ds.attgcnt += ADN(al) - AN(al); /* Number of att grp members. */
- TRACEADL(alperm);
- }
- /* Clear attribute list for next declaration. */
- MEMZERO((UNIV)al, (1+ADN(al))*ADSZ);
-
- /* PARAMETER 3: End of declaration.
- */
- /* Next pcb.action was set during attribute definition loop. */
- TRACEMD(emd);
- if (pcbmd.action!=EMD) {mderr(126, (UNCH *)0, (UNCH *)0); return;}
- if (es!=mdessv) synerr(37, &pcbmd);
-
- /* EXECUTE: Store the definition for each element name specified.
- */
- TRACEGRP(nmgrp);
- for (i = 0; nmgrp[i]; i++) {
- if (nmgrp[i]->adl) { /* Error if an ADL exists. */
- mderr(112, (UNCH *)0, (UNCH *)0);
- continue;
- }
- nmgrp[i]->adl = alperm; /* If virgin, store the adl ptr. */
- stored = 1;
- if (alperm && nmgrp[i]->etdmod)
- etdadl(nmgrp[i]); /* Check for conflicts with ETD. */
- }
- if (!stored && alperm) {
- adlfree(alperm, 1);
- frem((UNIV)alperm);
- }
-}
-/* ETDADL: Check compatibility between ETD and ADL.
-*/
-VOID etdadl(p)
-struct etd *p; /* Pointer to element type definition. */
-{
- parmno = 0;
- /* Minimizable element cannot have required attribute. */
- if (GET(p->etdmin, SMO) && GET(p->adl[0].adflags, ADLREQ)) {
- mderr(40, (UNCH *)0, (UNCH *)0);
- RESET(p->etdmin, SMO);
- }
- /* Empty element cannot have NOTATION attribute.
- Attribute is not removed (too much trouble), but we trap
- attempts to specify it on the start-tag in adlval().
- */
- if (GET(p->etdmod->ttype, MNONE)) {
- if (GET(p->adl[0].adflags, ADLNOTE))
- mderr(83, (UNCH *)0, (UNCH *)0);
-
- /* Empty element cannot have CONREF attribute.
- Attribute is not removed because it just acts
- like IMPLIED anyway.
- */
- if (GET(p->adl[0].adflags, ADLCONR))
- mderr(85, (UNCH *)0, (UNCH *)0);
- }
-#if 0
- /* "-" should not be specified for the end-tag minimization if
- the element has a content reference attribute. */
- if (GET(p->adl[0].adflags, ADLCONR) && BITON(p->etdmin, EMM))
- mderr(153, (UNCH *)0, (UNCH *)0);
-#endif
-}
-/* MDNADL: Process ATTLIST declaration for notation.
- TO DO: Pass deftab and dvtab as parameters so
- that prohibited types can be handled by leaving
- them out of the tables.
-*/
-VOID mdnadl(tbuf)
-UNCH *tbuf; /* Work area for tokenization (tbuf). */
-{
- int i; /* Loop counter; temporary variable. */
- int adlim; /* Number of unused ad slots in al. */
- struct ad *alperm = 0; /* Attribute definition list. */
- int stored = 0;
-
- /* PARAMETER 1: Notation name or a group of them.
- */
- parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN);
- TRACEMD("1: notation name or group");
- switch (pcbmd.action) {
- case NAS:
- nnmgrp[0] = dcndef(tbuf);
- nnmgrp[1] = 0;
- break;
- case GRPS:
- parsngrp(nnmgrp, &pcbgrnm, tbuf);
- break;
- default:
- mderr(121, (UNCH *)0, (UNCH *)0);
- return;
- }
- subdcl = nnmgrp[0]->ename+1; /* Save first name for error msgs. */
- /* PARAMETER 2: Attribute definition list.
- */
- parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN);
- TRACEMD("2: attribute list");
- if (pcbmd.action!=NAS) {
- mderr(120, (UNCH *)0, (UNCH *)0);
- return;
- }
- while (pcbmd.action==NAS) {
- al[ADN(al)+1].adname = savenm(tbuf);
- if ((adlim = ATTCNT-((int)ADN(al)++))<0) {
- mderr(111, (UNCH *)0, (UNCH *)0);
- adlfree(al, 1);
- return;
- }
- ++AN(al);
- if (mdattdef(adlim, 1)) {
- adlfree(al, 1);
- return;
- }
- parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN);
- }
- if (AN(al)>0) { /* Save list only if 1 or more good atts. */
- alperm = (struct ad *)rmalloc((1+ADN(al))*ADSZ);
- memcpy((UNIV)alperm, (UNIV)al, (1+ADN(al))*ADSZ );
- ds.attcnt += AN(al); /* Number of attributes defined. */
- ds.attgcnt += ADN(al) - AN(al); /* Number of att grp members. */
- TRACEADL(alperm);
- }
- /* Clear attribute list for next declaration. */
- MEMZERO((UNIV)al, (1+ADN(al))*ADSZ);
-
- /* PARAMETER 3: End of declaration.
- */
- /* Next pcb.action was set during attribute definition loop. */
- TRACEMD(emd);
- if (pcbmd.action!=EMD) {mderr(126, (UNCH *)0, (UNCH *)0); return;}
- if (es!=mdessv) synerr(37, &pcbmd);
-
- /* EXECUTE: Store the definition for each notation name specified.
- */
- TRACENGR(nnmgrp);
- for (i = 0; nnmgrp[i]; i++) {
- if (nnmgrp[i]->adl) { /* Error if an ADL exists. */
- mderr(112, (UNCH *)0, (UNCH *)0);
- continue;
- }
- nnmgrp[i]->adl = alperm; /* If virgin, store the adl ptr. */
- if (nnmgrp[i]->entsw)
- fixdatt(nnmgrp[i]);
- stored = 1;
- TRACEDCN(nnmgrp[i]);
- }
- if (!stored && alperm) {
- adlfree(alperm, 1);
- frem((UNIV)alperm);
- }
-}
-
-/* Data attributes have been specified for notation p, but entities
-have already been declared with notation p. Fix up the definitions of
-all entities with notation p. Generate an error for any data
-attribute that was required. */
-
-VOID fixdatt(p)
-struct dcncb *p;
-{
- int i;
- for (i = 0; i < ENTHASH; i++) {
- struct entity *ep;
- for (ep = etab[i]; ep; ep = ep->enext)
- if (ep->estore == ESN && ep->etx.n && ep->etx.n->nedcn == p) {
- int adn;
- initatt(p->adl);
- /* Don't use adlval because if there were required
- attributes the error message wouldn't say what
- entity was involved. */
- for (adn = 1; adn <= ADN(al); adn++) {
- if (GET(ADFLAGS(al,adn), AREQ)) {
- sgmlerr(218, &pcbstag, ADNAME(al,adn),
- ep->ename + 1);
- SET(ADFLAGS(al,adn), AINVALID);
- }
- if (BITON(ADFLAGS(al, adn), AGROUP))
- adn += ADNUM(al, adn);
- }
- storedatt(ep->etx.n);
- }
- }
-}
-
-/* MDATTDEF: Process an individual attribute definition.
- The attribute name is parsed by the caller.
- Duplicate attributes are parsed, but removed from list.
- Returns 0 if successful, otherwise returns 1.
-*/
-int mdattdef(adlim, datt)
-int adlim; /* Remaining capacity of al (in tokens).*/
-int datt; /* Non-zero if a data attribute. */
-{
- int deftype; /* Default value type: 0=not keyword. */
- int errsw = 0; /* 1=semantic error; ignore att. */
- int novalsw = 0; /* 1=semantic error; treat as IMPLIED. */
- int attadn = (int)ADN(al); /* Save ad number of this attribute. */
- struct parse *grppcb = NULL; /* PCB for name/token grp parse. */
- int errcode; /* Error type returned by PARSEVAL, ANMTGRP. */
- UNCH *advalsv; /* Save area for permanent value ptr. */
-
- /* PARAMETER 1: Attribute name (parsed by caller).
- */
- TRACEMD("1: attribute name");
- if (anmget((int)ADN(al)-1, al[attadn].adname)) {
- errsw = 1;
- mderr(99, ADNAME(al,attadn), (UNCH *)0);
- }
- ADNUM(al,attadn) = ADFLAGS(al,attadn) = ADLEN(al,attadn) = 0;
- ADVAL(al,attadn) = 0; ADDATA(al,attadn).x = 0; ADTYPE(al,attadn) = ANMTGRP;
- /* PARAMETER 2: Declared value.
- */
- parsemd(lbuf, NAMECASE, &pcblitp, NAMELEN);
- TRACEMD("2: declared value");
- switch (pcbmd.action) {
- case NAS: /* Keyword for value type. */
- switch (ADTYPE(al,attadn) = (UNCH)mapsrch(dvtab, lbuf+1)) {
- case 0:
- mderr(100, ADNAME(al,attadn), lbuf+1);
- return 1;
- case ANOTEGRP:
- if (datt) {
- errsw = 1;
- mderr(156, (UNCH *)0, (UNCH *)0);
- }
- else if (!noteadn) noteadn = ADN(al);
- else {
- errsw = 1;
- mderr(101, ADNAME(al,attadn), (UNCH *)0);
- }
- grppcb = &pcbgrnm; /* NOTATION requires name grp. */
- parsemd(lbuf, NAMECASE, &pcblitp, NAMELEN);/* Get GRPO*/
- break;
- case AID:
- if (datt) {
- errsw = 1;
- mderr(144, (UNCH *)0, (UNCH *)0);
- }
- else if (!idadn)
- idadn = attadn;
- else {
- errsw = 1;
- mderr(102, ADNAME(al,attadn), (UNCH *)0);
- }
- break;
- case AIDREF:
- case AIDREFS:
- if (datt) {
- errsw = 1;
- mderr(155, (UNCH *)0, (UNCH *)0);
- }
- break;
- case AENTITY:
- case AENTITYS:
- if (datt) {
- errsw = 1;
- mderr(154, (UNCH *)0, (UNCH *)0);
- }
- break;
- }
- break;
- case GRPS:
- grppcb = &pcbgrnt; /* Normal grp is name token grp. */
- break;
- case EMD:
- mderr(103, ADNAME(al,attadn), (UNCH *)0);
- return 1;
- default:
- mderr(104, ADNAME(al,attadn), (UNCH *)0);
- return 1;
- }
- /* PARAMETER 2A: Name token group.
- */
- if (grppcb != NULL) {
- TRACEMD("2A: name group");
- switch (pcbmd.action) {
- case GRPS: /* Name token list. */
- SET(ADFLAGS(al,attadn), AGROUP);
- /* Call routine to parse group, create ad entries in adl. */
- errcode = anmtgrp(grppcb, al+attadn,
- (GRPCNT<adlim ? GRPCNT+1 : adlim+1),
- &al[attadn].adnum, ADN(al));
- if (errcode<=0) {
- if (adlim < GRPCNT)
- mderr(111, (UNCH *)0, (UNCH *)0);
- else
- mderr(105, ADNAME(al,attadn), (UNCH *)0);
- return 1;
- }
- ADN(al) += ADNUM(al,attadn); /* Add grp size to total ad cnt.*/
- break;
- default:
- mderr(106, ADNAME(al,attadn), (UNCH *)0);
- return 1;
- }
- }
- /* PARAMETER 3: Default value keyword.
- */
- parsemd(lbuf, AVALCASE,
- (ADTYPE(al,attadn)==ACHARS) ? &pcblitr : &pcblitt, LITLEN);
- TRACEMD("3: default keyword");
- switch (pcbmd.action) {
- case RNS: /* Keyword. */
- deftype = mapsrch(deftab, lbuf+1);
- switch (deftype) {
- case DFIXED: /* FIXED */
- SET(ADFLAGS(al,attadn), AFIXED);
- parsemd(lbuf, AVALCASE,
- (ADTYPE(al,attadn)==ACHARS) ? &pcblitr : &pcblitt,
- LITLEN); /* Real default. */
- goto parm3x; /* Go process specified value. */
- case DCURR: /* CURRENT: If ID, treat as IMPLIED. */
- if (ADTYPE(al,attadn)==AID) {
- mderr(80, ADNAME(al,attadn), (UNCH *)0);
- break;
- }
- if (datt) {
- mderr(157, (UNCH *)0, (UNCH *)0);
- break;
- }
- SET(ADFLAGS(al,attadn), ACURRENT);
- break;
- case DREQ: /* REQUIRED */
- SET(ADFLAGS(al,attadn), AREQ); ++reqadn;
- break;
- case DCONR: /* CONREF */
- if (ADTYPE(al,attadn)==AID) {
- mderr(107, ADNAME(al,attadn), (UNCH *)0);
- break;
- }
- if (datt) {
- mderr(158, (UNCH *)0, (UNCH *)0);
- break;
- }
- SET(ADFLAGS(al,attadn), ACONREF); conradn = 1;
- case DNULL: /* IMPLIED */
- break;
- default: /* Unknown keyword is an error. */
- mderr(108, ADNAME(al,attadn), lbuf+1);
- errsw = 1;
- }
- if (errsw) {
- /* Ignore erroneous att. */
- adlfree(al, attadn);
- --AN(al);
- ADN(al) = (UNCH)attadn-1;
- }
- return(0);
- default:
- break;
- }
- /* PARAMETER 3x: Default value (non-keyword).
- */
- parm3x:
- TRACEMD("3x: default (non-keyword)");
- if (ADTYPE(al,attadn)==AID) { /* If ID, treat as IMPLIED. */
- mderr(81, ADNAME(al,attadn), (UNCH *)0);
- novalsw = 1; /* Keep parsing to keep things straight. */
- }
- switch (pcbmd.action) {
- case LIT: /* Literal. */
- case LITE: /* Literal. */
- /* Null string (except CDATA) is error: msg and treat as IMPLIED. */
- if (*lbuf == '\0' && ADTYPE(al,attadn)!=ACHARS) {
- mderr(82, ADNAME(al,attadn), (UNCH *)0);
- novalsw = 1;
- }
- break;
- case NAS: /* Name character string. */
- case NMT: /* Name character string. */
- case NUM: /* Number or number token string. */
- /* The name won't have a length byte because AVALCASE was specified. */
- break;
- case CDR:
- parsetkn(lbuf, NMC, LITLEN);
- break;
- case EMD:
- mderr(109, ADNAME(al,attadn), (UNCH *)0);
- return 1;
- default:
- mderr(110, ADNAME(al,attadn), (UNCH *)0);
- return 1;
- }
- if (errsw) {
- /* Ignore erroneous att. */
- adlfree(al, attadn);
- --AN(al);
- ADN(al) = (UNCH)attadn-1;
- return(0);
- }
- if (novalsw) return(0);
-
- /* PARAMETER 3y: Validate and store default value.
- */
- if (ADTYPE(al,attadn)==ACHARS) {
- UNS len = vallen(ACHARS, 0, lbuf);
- if (len > LITLEN) {
- /* Treat as implied. */
- sgmlerr(224, &pcbmd, ADNAME(al,attadn), (UNCH *)0);
- return 0;
- }
- /* No more checking for CDATA value. */
- ADNUM(al,attadn) = 0; /* CDATA is 0 tokens. */
- ADVAL(al,attadn) = savestr(lbuf);/* Store default; save ptr. */
- ADLEN(al,attadn) = len;
- ds.attdef += len;
- return 0;
- }
- /* Parse value and save token count (GROUP implies 1 token). */
- advalsv = (UNCH *)rmalloc(ustrlen(lbuf)+2); /* Storage for tokenized value. */
- errcode = parseval(lbuf, (UNS)ADTYPE(al,attadn), advalsv);
- if (BITOFF(ADFLAGS(al,attadn), AGROUP)) ADNUM(al,attadn) = (UNCH)tokencnt;
-
- /* If value was invalid, or was a group member that was not in the group,
- issue an appropriate message and set the error switch. */
- if (errcode)
- {sgmlerr((UNS)errcode, &pcbmd, ADNAME(al,attadn), lbuf); errsw = 1;}
- else if ( BITON(ADFLAGS(al,attadn), AGROUP)
- && !amemget(&al[attadn], (int)ADNUM(al,attadn), advalsv) ) {
- sgmlerr(79, &pcbmd, ADNAME(al,attadn), advalsv+1);
- errsw = 1;
- }
- ADLEN(al,attadn) = vallen(ADTYPE(al,attadn), ADNUM(al,attadn), advalsv);
- if (ADLEN(al,attadn) > LITLEN) {
- sgmlerr(224, &pcbmd, ADNAME(al,attadn), (UNCH *)0);
- ADLEN(al,attadn) = 0;
- errsw = 1;
- }
- /* For valid tokenized value, save it and update statistics. */
- if (!errsw) {
- ADVAL(al,attadn) = advalsv;
- ds.attdef += ADLEN(al,attadn);
- return 0;
- }
- /* If value was bad, free the value's storage and treat as
- IMPLIED or REQUIRED. */
- frem((UNIV)advalsv); /* Release storage for value. */
- ADVAL(al,attadn) = NULL; /* And make value NULL. */
- return 0;
-}
-/* ANMTGRP: Parse a name or name token group, create attribute descriptors
- for its members, and add them to the attribute descriptor list.
- The parse either terminates or returns a good token, so no
- switch is needed.
-*/
-int anmtgrp(pcb, nt, grplim, adn, adsz)
-struct parse *pcb; /* PCB for name or name token grp. */
-struct ad nt[]; /* Buffer for creating name token list. */
-int grplim; /* Maximum size of list (plus 1). */
-UNS *adn; /* Ptr to number of names or tokens in grp. */
-int adsz; /* Size of att def list. */
-{
- UNCH adtype = (UNCH)(pcb==&pcbgrnt ? ANMTGRP:ANOTEGRP);/*Attribute type.*/
- int essv = es; /* Entity stack level when grp started. */
-
- *adn = 0; /* Group is empty to start. */
- while (parse(pcb)!=GRPE && *adn<grplim) {
- switch (pcb->action) {
- case NAS_: /* Name or name token (depending on pcb). */
- case NMT_:
- parsenm(lbuf, NAMECASE);
- nt[*adn+1].adname = savenm(lbuf);
- if (antvget((int)(adsz+*adn), nt[*adn+1].adname, (UNCH **)0))
- mderr(98, ntoa((int)*adn+1), nt[*adn+1].adname+1);
- nt[++*adn].adtype = adtype;
- nt[*adn].addef = NULL;
- continue;
-
- case EE_: /* Entity ended (correctly or incorrectly). */
- if (es<essv) {synerr(37, pcb); essv = es;}
- continue;
-
- case PIE_: /* PI entity reference (invalid). */
- entpisw = 0; /* Reset PI entity indicator. */
- synerr(59, pcb);
- continue;
-
- default:
- break;
- }
- break;
- }
- if (es!=essv) synerr(37, pcb);
- if (*adn==grplim) return -1;
- else return *adn; /* Return number of tokens. */
-}
-/* MDDTDS: Process start of DOCTYPE declaration (through MSO).
-*/
-VOID mddtds(tbuf)
-UNCH *tbuf; /* Work area for tokenization[LITLEN+2]. */
-{
- struct fpi fpicb; /* Formal public identifier structure. */
- union etext etx; /* Ptr to entity text. */
- UNCH estore = ESD; /* Entity storage class. */
- int emdsw = 0; /* 1=end of declaration found; 0=not yet. */
-
- mdname = key[KDOCTYPE]; /* Identify declaration for messages. */
- subdcl = NULL; /* No subject as yet. */
- parmno = 0; /* No parameters as yet. */
- mdessv = es; /* Save es for checking entity nesting. */
- dtdrefsw = 0; /* No external DTD entity as yet. */
- /* PARAMETER 1: Document type name.
- */
- pcbmd.newstate = 0;
- parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN);
- TRACEMD("1: doc type name");
- if (pcbmd.action!=NAS) {mderr(120, (UNCH *)0, (UNCH *)0); return;}
- dtype = savenm(tbuf);
- subdcl = dtype+1; /* Subject of declaration for error msgs. */
-
- /* PARAMETER 2: External identifier keyword or MDS.
- */
- parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN);
- TRACEMD("2: extid or MDS");
- switch (pcbmd.action) {
- case NAS:
- if (mdextid(tbuf, &fpicb, dtype+1, &estore, (PNE)0)==0) return;
- if ((etx.x = entgen(&fpicb))==0)
- mderr(146, dtype+1, (UNCH *)0);
- else
- dtdrefsw = 1; /* Signal external DTD entity. */
- break;
- case MDS:
- goto execute;
- default:
- mderr(128, (UNCH *)0, (UNCH *)0);
- return;
- }
- /* PARAMETER 3: MDS or end of declaration.
- */
- TRACEMD("3: MDS or EMD");
- switch (pcbmd.action) {
- default: /* Treat as end of declaration. */
- mderr(126, (UNCH *)0, (UNCH *)0);
- case EMD:
- emdsw = 1;
- case MDS:
- break;
- }
- /* EXECUTE: Store entity definition if an external ID was specified.
- */
- execute:
- if (es!=mdessv) synerr(37, &pcbmd);
- propcb = &pcbmds; /* Prepare to parse doc type definition (MDS). */
- if (dtdrefsw) {
- /* TO DO: If concurrent DTD's supported, free existing
- etext for all but first DTD (or reuse it). */
- entdef(indtdent, estore, &etx);
- ++ds.ecbcnt; ds.ecbtext += entlen;
- if (emdsw) {
- REPEATCC; /* Push back the MDC. */
- *FPOS = lex.d.msc; /* Simulate end of DTD subset. */
- REPEATCC; /* Back up to read MSC next. */
- delmscsw = 1; /* Insert MSC after referenced DTD. */
- }
- }
- indtdsw = 1; /* Allow "DTD only" parameters. */
- return;
-}
-/* MDDTDE: Process DOCTYPE declaration end.
-*/
-VOID mddtde(tbuf)
-UNCH *tbuf; /* Work area for tokenization. */
-{
- mdessv = es; /* Save es for checking entity nesting. */
- propcb = &pcbpro; /* Restore normal prolog parse. */
- indtdsw = 0; /* Prohibit "DTD only" parameters. */
-
- mdname = key[KDOCTYPE]; /* Identify declaration for messages. */
- subdcl = dtype+1; /* Subject of declaration for error msgs. */
- parmno = 0; /* No parameters as yet. */
- /* PARAMETER 4: End of declaration.
- */
- pcbmd.newstate = pcbmdtk;
- parsemd(tbuf, NAMECASE, &pcblitp, LITLEN);
- TRACEMD(emd);
- if (pcbmd.action!=EMD) mderr(126, (UNCH *)0, (UNCH *)0);
- if (es!=mdessv) synerr(37, &pcbmd);
-}
-/* MDELEM: Process ELEMENT declaration.
-*/
-VOID mdelem(tbuf)
-UNCH *tbuf; /* Work area for tokenization (tbuf). */
-{
- UNCH *ranksuff = lbuf; /* Rank suffix. */
- UNS dctype = 0; /* Declared content type (from dctab). */
- UNCH fmin = 0; /* Minimization bit flags. */
- int i; /* Loop counter. */
- UNS u; /* Temporary variable. */
- struct etd **mexgrp, **pexgrp; /* Ptr to model exceptions array. */
- struct thdr *cmod, *cmodsv; /* Ptr to content model. */
- UNCH *etdgi; /* GI of current etd (when going through group).*/
- int minomitted = 0; /* Tag minimization parameters omitted. */
-
- mdname = key[KELEMENT]; /* Identify declaration for messages. */
- subdcl = NULL; /* No subject as yet. */
- parmno = 0; /* No parameters as yet. */
- mdessv = es; /* Save es level for entity nesting check. */
- ranksuff[0] = 0;
- mexgrp = pexgrp = 0;
-
- /* PARAMETER 1: Element name or a group of them.
- */
- parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN);
- TRACEMD("1: element name or grp");
- switch (pcbmd.action) {
- case NAS:
- nmgrp[0] = etddef(tbuf);
- nmgrp[1] = 0;
- break;
- case GRPS:
- parsegrp(nmgrp, &pcbgrnm, tbuf);
- break;
- default:
- mderr(121, (UNCH *)0, (UNCH *)0);
- return;
- }
- /* Save first GI for trace and error messages. */
- if (nmgrp[0])
- subdcl = nmgrp[0]->etdgi+1;
-
- /* PARAMETER 1A: Rank suffix (optional).
- */
- parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN);
- TRACEMD("1A: rank suffix");
- switch (pcbmd.action) {
- case NUM:
- ustrcpy(ranksuff, tbuf);
- parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN);
- default:
- break;
- }
- /* PARAMETER 2A: Start-tag minimization.
- */
- TRACEMD("2A: start min");
- switch (pcbmd.action) {
- case CDR:
- break;
- case NAS:
- if (!ustrcmp(tbuf+1, key[KO])) {
- if (OMITTAG==YES) SET(fmin, SMO);
- break;
- }
- /* fall through */
- default:
- if (OMITTAG==NO) {minomitted=1; break;}
- mderr(129, tbuf+1, (UNCH *)0);
- return;
- }
- /* Must omit omitted end-tag minimization, if omitted
- start-tag minimization was omitted (because OMITTAG == NO). */
- if (!minomitted) {
- /* PARAMETER 2B: End-tag minimization.
- */
- parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN);
- TRACEMD("2B: end min");
- switch (pcbmd.action) {
- case NAS:
- if (ustrcmp(tbuf+1, key[KO])) {mderr(129, tbuf+1, (UNCH *)0); return;}
- if (OMITTAG==YES) SET(fmin, EMO);
- break;
- case MGRP:
- REPEATCC;
- /* fall through */
- case CDR:
- SET(fmin, EMM);
- break;
- default:
- mderr(129, tbuf+1, (UNCH *)0);
- return;
- }
- /* PARAMETER 3: Declared content.
- */
- parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN);
- }
- TRACEMD("3: declared content");
- switch (pcbmd.action) {
- case NAS:
- dctype = mapsrch(dctab, tbuf+1);
- if (!dctype) {mderr(24, tbuf+1, (UNCH *)0); return;}
- /* Eliminate incompatibilities among parameters. */
- if (GET(fmin, SMO) && GET(dctype, MNONE+MCDATA+MRCDATA)) {
- mderr(58, (UNCH *)0, (UNCH *)0);
- RESET(fmin, SMO);
- }
- if (GET(dctype, MNONE) && BITON(fmin, EMM)) {
- mderr(87, (UNCH *)0, (UNCH *)0);
- SET(fmin, EMO);
- }
- /* If valid, process like a content model. */
- case GRPS:
- cmodsv = parsemod((int)(pcbmd.action==GRPS ? 0 : dctype));
- if (cmodsv==0) return;
- u = (dctype ? 1 : cmodsv->tu.tnum+2) * THSZ;
- cmod = (struct thdr *)rmalloc(u);
- memcpy((UNIV)cmod , (UNIV)cmodsv, u );
- ds.modcnt += cmod->tu.tnum;
- TRACEMOD(cmod);
- break;
- default:
- mderr(130, (UNCH *)0, (UNCH *)0);
- return;
- }
- /* PARAMETERS 3A, 3B: Exceptions or end.
- */
- parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN);
- if (BITOFF(cmod->ttype, MCDATA+MRCDATA+MNONE)) {
- /* PARAMETER 3A: Minus exceptions.
- */
- TRACEMD("3A: -grp");
- switch (pcbmd.action) {
- case MGRP:
- /* We cheat and use nnmgrp for this. */
- mexgrp = copygrp((PETD *)nnmgrp,
- u = parsegrp((PETD *)nnmgrp, &pcbgrnm, tbuf));
- ++ds.pmexgcnt; ds.pmexcnt += u-1;
- TRACEGRP(mexgrp);
- parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN);
- default:
- break;
- }
- /* PARAMETER 3B: Plus exceptions.
- */
- TRACEMD("3B: +grp");
- switch (pcbmd.action) {
- case PGRP:
- pexgrp = copygrp((PETD *)nnmgrp,
- u = parsegrp((PETD *)nnmgrp, &pcbgrnm, tbuf));
- ++ds.pmexgcnt; ds.pmexcnt += u-1;
- TRACEGRP(pexgrp);
- parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN);
- default:
- break;
- }
- }
- /* PARAMETER 4: End of declaration.
- */
- TRACEMD(emd);
- if (pcbmd.action!=EMD) mderr(126, (UNCH *)0, (UNCH *)0);
- if (es!=mdessv) synerr(37, &pcbmd);
-
- /* EXECUTE: Store the definition for each element name specified.
- */
- TRACEGRP(nmgrp);
- for (i = -1; nmgrp[++i];) {
- etdgi = nmgrp[i]->etdgi;
- if (*ranksuff) {
- if ((tbuf[0] = *etdgi + ustrlen(ranksuff)) - 2 > NAMELEN) {
- mderr(131, etdgi+1, ranksuff);
- continue;
- }
- memcpy(tbuf+1, etdgi+1, *etdgi-1);
- ustrcpy(tbuf+*etdgi-1, ranksuff);
- etdcan(etdgi);
- nmgrp[i] = etddef(tbuf);
- }
- if (nmgrp[i]->etdmod) {mderr(56, etdgi+1, (UNCH *)0); continue;}
- etdset(nmgrp[i], fmin+ETDDCL, cmod, mexgrp, pexgrp, nmgrp[i]->etdsrm);
- ++ds.etdcnt;
- if (nmgrp[i]->adl) etdadl(nmgrp[i]); /* Check ETD conflicts. */
- TRACEETD(nmgrp[i]);
- }
-}
-
-VOID adlfree(al, aln)
-struct ad *al;
-int aln;
-{
- for (; aln <= ADN(al); aln++) {
- frem((UNIV)al[aln].adname);
- if (ADVAL(al, aln))
- frem((UNIV)ADVAL(al, aln));
- if (BITON(ADFLAGS(al, aln), AGROUP)) {
- int i;
- for (i = 0; i < ADNUM(al, aln); i++)
- frem((UNIV)al[aln + i + 1].adname);
- aln += ADNUM(al, aln);
- }
- }
-}
-
-/*
-Local Variables:
-c-indent-level: 5
-c-continued-statement-offset: 5
-c-brace-offset: -5
-c-argdecl-indent: 0
-c-label-offset: -5
-comment-column: 30
-End:
-*/
diff --git a/usr.bin/sgmls/sgmls/md2.c b/usr.bin/sgmls/sgmls/md2.c
deleted file mode 100644
index df7e57e..0000000
--- a/usr.bin/sgmls/sgmls/md2.c
+++ /dev/null
@@ -1,792 +0,0 @@
-#include "sgmlincl.h" /* #INCLUDE statements for SGML parser. */
-/* MDENTITY: Process ENTITY declaration.
-*/
-VOID mdentity(tbuf)
-UNCH *tbuf; /* Work area for tokenization[LITLEN+2]. */
-{
- struct fpi fpicb; /* Formal public identifier structure. */
- struct fpi *fpis = &fpicb; /* Ptr to current or #DEFAULT fpi. */
- union etext etx; /* Ptr to entity text. */
- UNCH estore = ESM; /* Entity storage class. */
- struct entity *ecb; /* Ptr to entity control block. */
- int parmsw = 0; /* 1=parameter entity declaration; 0 = not. */
- int defltsw = 0; /* 1=#DEFAULT declaration; 0=not. */
- PNE pne = 0; /* Ptr to N/C/SDATA entity control block. */
-
- mdname = key[KENTITY]; /* Declaration name for messages. */
- subdcl = NULL; /* No subject as yet. */
- parmno = 0; /* No parameters as yet. */
- mdessv = es; /* Save es for checking entity nesting. */
- /* PARAMETER 1: Entity name.
- */
- pcbmd.newstate = 0;
- parsemd(nmbuf, ENTCASE, &pcblitp, NAMELEN);
- TRACEMD("1: entity nm");
- switch (pcbmd.action) {
- case PEN:
- parsemd(nmbuf + 1, ENTCASE, &pcblitp, NAMELEN);
- if (pcbmd.action!=NAS) {mderr(120, (UNCH *)0, (UNCH *)0); return;}
- if (nmbuf[1] == NAMELEN + 2) {
- /* It was too long. */
- nmbuf[0] = NAMELEN + 2;
- nmbuf[NAMELEN + 1] = '\0';
- mderr(65, (UNCH *)0, (UNCH *)0);
- }
- else
- nmbuf[0] = nmbuf[1] + 1; /* Increment length for PERO. */
- nmbuf[1] = lex.d.pero; /* Prefix PERO to name. */
- parmsw = 1; /* Indicate parameter entity. */
- case NAS:
- break;
- case RNS: /* Reserved name started. */
- if (ustrcmp(nmbuf+1, key[KDEFAULT])) {
- mderr(118, nmbuf+1, key[KDEFAULT]);
- return;
- }
- memcpy(nmbuf, indefent, *indefent);/* Copy #DEFAULT to name buffer. */
- fpis = &fpidf; /* Use #DEFAULT fpi if external. */
- defltsw = 1; /* Indicate #DEFAULT is being defined.*/
- break;
- default:
- mderr(122, (UNCH *)0, (UNCH *)0);
- return;
- }
- subdcl = nmbuf+1; /* Subject name for error messages. */
- /* PARAMETER 2: Entity text keyword (optional).
- */
- parsemd(tbuf, NAMECASE, &pcblitp, LITLEN);
- TRACEMD("2: keyword");
- switch (pcbmd.action) {
- case NAS:
- if ((estore = (UNCH)mapsrch(enttab, tbuf+1))==0) {
- estore = parmsw ? ESP : ESF;
- pne = (PNE)rmalloc(NESZ);
- if (mdextid(tbuf, fpis, nmbuf+1+parmsw, &estore, pne)==0)
- return;
- if (defltsw) etx.x = NULL;
- else if ((etx.x = entgen(&fpicb))==0) {
- if (parmsw)
- mderr(148, nmbuf+2, (UNCH *)0);
- else
- mderr(147, nmbuf+1, (UNCH *)0);
- }
- goto parm4;
- }
- if (parmsw && (estore==ESX || estore==ESC)) {
- mderr(38, tbuf+1, (UNCH *)0);
- estore = ESM;
- }
- parsemd(tbuf, NAMECASE, &pcblitp, LITLEN);
- break;
- default:
- estore = ESM;
- break;
- }
- /* PARAMETER 3: Parameter literal.
- */
- TRACEMD("3: literal");
- switch (pcbmd.action) {
- case LITE:
- case LIT:
- switch (estore) {
- case ESM: /* LITERAL: parameter literal required. */
- case ESC: /* CDATA: parameter literal required. */
- case ESX: /* SDATA: parameter literal required. */
- case ESI: /* PI: parameter literal required. */
- etx.c = savestr(tbuf);
- break;
- case ESMD: /* MD: parameter literal required. */
- etx.c = sandwich(tbuf, lex.m.mdo, lex.m.mdc);
- goto bcheck;
- case ESMS: /* MS: parameter literal required. */
- etx.c = sandwich(tbuf, lex.m.mss, lex.m.mse);
- goto bcheck;
- case ESS: /* STARTTAG: parameter literal required. */
- etx.c = sandwich(tbuf, lex.m.stag, lex.m.tagc);
- goto bcheck;
- case ESE: /* ENDTAG: parameter literal required. */
- etx.c = sandwich(tbuf, lex.m.etag, lex.m.tagc);
- bcheck:
- if (etx.c == 0) {
- mderr(225, (UNCH *)0, (UNCH *)0);
- return;
- }
- break;
- }
- break;
- default:
- mderr(123, (UNCH *)0, (UNCH *)0);
- return;
- }
- /* PARAMETER 4: End of declaration.
- */
- parsemd(tbuf, NAMECASE, &pcblitp, LITLEN);
- parm4:
- TRACEMD(emd);
- if (pcbmd.action!=EMD) mderr(126, (UNCH *)0, (UNCH *)0);
- if (es!=mdessv) synerr(37, &pcbmd);
-
- /* EXECUTE: If the entity already exists, ignore the new definition.
- If it is a new entity, store the definition.
- */
- if ((ecb = entfind(nmbuf))!=0 && ecb->estore) {
- if (ecb->dflt) {
- mderr(228, nmbuf + 1, (UNCH *)0);
- hout((THASH)etab, nmbuf, hash(nmbuf, ENTHASH));
- if (ecb->estore == ESN) {
- frem((UNIV)NEID(ecb->etx.n));
- frem((UNIV)ecb->etx.n);
- }
- else if (ecb->estore >= ESFM)
- frem((UNIV)ecb->etx.x);
- frem((UNIV)ecb);
- }
- else {
- /* Duplicate definition: not an error. */
- if (sw.swdupent) mderr(68, nmbuf+1, (UNCH *)0);
- if (estore<ESFM) frem((UNIV)etx.c);
- return;
- }
- }
- ++ds.ecbcnt; /* Do capacity before NOTATION. */
- ds.ecbtext += estore<ESFM ? ustrlen(etx.c) : entlen;
- ecb = entdef(nmbuf, estore, &etx); /* Define the entity. */
- if (estore==ESN) { /* If entity is external: */
- NEENAME(pne) = ecb->ename; /* Store entity name in ne. */
- NEID(pne) = etx.x; /* Store system fileid in ne. */
- NESYSID(pne) = fpis->fpisysis ? savestr(fpis->fpisysis) : 0;
- NEPUBID(pne) = fpis->fpipubis ? savestr(fpis->fpipubis) : 0;
- ecb->etx.n = pne; /* Store ne control block in etx. */
- TRACEESN(pne);
- }
- else if (pne)
- frem((UNIV)pne);
- if (defltsw) {
- ecbdeflt = ecb; /* If #DEFAULT save ecb. */
- if (fpidf.fpipubis)
- fpidf.fpipubis = savestr(fpidf.fpipubis);
- if (fpidf.fpisysis)
- fpidf.fpisysis = savestr(fpidf.fpisysis);
- }
-}
-/* SANDWICH: Catenate a prefix and suffix to a string.
- The result has an EOS but no length.
- Return 0 if the result if longer than LITLEN.
-*/
-UNCH *sandwich(s, pref, suff)
-UNCH *s; /* String, with EOS. */
-UNCH *pref; /* Prefix, with length and EOS. */
-UNCH *suff; /* Suffix, with length and EOS. */
-{
- UNCH *pt;
- UNS slen, tlen;
-
- slen = ustrlen(s);
- tlen = slen + (*pref - 2) + (*suff - 2);
- if (tlen > LITLEN)
- return 0;
- pt = (UNCH *)rmalloc(tlen + 1);
- memcpy(pt, pref + 1, *pref - 2);
- memcpy(pt + (*pref - 2), s, slen);
- memcpy(pt + (*pref - 2) + slen, suff + 1, *suff - 1);
- return pt;
-}
-/* MDEXTID: Process external identifier parameter of a markup declaration.
- On entry, tbuf contains SYSTEM or PUBLIC if all is well.
- NULL is returned if an error, otherwise fpis. If it is a
- valid external data entity, the caller's estore is set to ESN
- and its nxetype is set to the code for the external entity type.
- The event that terminated the parse is preserved in pcb.action,
- so the caller should process it before further parsing.
-*/
-struct fpi *mdextid(tbuf, fpis, ename, estore, pne)
-UNCH *tbuf; /* Work area for tokenization[2*(LITLEN+2)]. */
-struct fpi *fpis; /* FPI structure. */
-UNCH *ename; /* Entity or notation name, with EOS, no length.*/
- /* NOTE: No PERO on parameter entity name. */
-UNCH *estore; /* DTD, general or parameter entity, DCN. */
-PNE pne; /* Caller's external entity ptr. */
-{
- PDCB dcb; /* Ptr to DCN control block. */
- int exidtype; /* External ID type: 0=none 1=system 2=public. */
- int exetype; /* External entity type. */
-
- MEMZERO((UNIV)fpis, (UNS)FPISZ); /* Initialize fpi structure. */
- /* Move entity name into fpi (any PERO was stripped by caller). */
- fpis->fpinm = ename;
- entlen = 0; /* Initialize external ID length. */
-
- /* PARAMETER 1: External identifier keyword or error.
- */
- TRACEMD("1: extid keyword");
- if ((exidtype = mapsrch(exttab, tbuf+1))==0) {
- mderr(29, (UNCH *)0, (UNCH *)0);
- return (struct fpi *)0;
- }
- if (exidtype==EDSYSTEM) goto parm3;
-
- /* PARAMETER 2: Public ID literal.
- */
- /* The length of a minimum literal cannot exceed the value of LITLEN
- in the reference quantity set. */
- parsemd(pubibuf, NAMECASE, &pcblitv, REFLITLEN);
- TRACEMD("2: pub ID literal");
- switch (pcbmd.action) {
- case LITE: /* Use alternative literal delimiter. */
- case LIT: /* Save literal as public ID string. */
- entlen = ustrlen(pubibuf);
- fpis->fpipubis = pubibuf;
- break;
- default:
- mderr(117, (UNCH *)0, (UNCH *)0);
- return (struct fpi *)0; /* Signal error to caller. */
- }
- /* PARAMETER 3: System ID literal.
- */
- parm3:
- parsemd(sysibuf, NAMECASE, &pcblitc, LITLEN);
- TRACEMD("3: sys ID literal");
- if (pcbmd.action==LIT || pcbmd.action==LITE) {
- entlen += ustrlen(sysibuf);
- fpis->fpisysis = sysibuf;
- parsemd(tbuf, NAMECASE, &pcblitp, LITLEN);
- }
- else memcpy(tbuf, sysibuf, *sysibuf);
- if (*estore!=ESF || pcbmd.action!=NAS) goto genfpi;
-
- /* PARAMETER 4: Entity type keyword.
- */
- TRACEMD("4: Entity type");
- if ((exetype = mapsrch(extettab, tbuf+1))==0) {
- mderr(24, tbuf+1, (UNCH *)0);
- return (struct fpi *)0;
- }
- if (exetype==ESNSUB && SUBDOC == NO) {
- mderr(90, tbuf+1, (UNCH *)0);
- return (struct fpi *)0;
- }
-
- NEXTYPE(pne) = (UNCH)exetype; /* Save entity type in caller's ne. */
- *estore = ESN; /* Signal that entity is a data entity. */
-
- if (exetype==ESNSUB) {
- pne->nedcn = 0;
- parsemd(tbuf, NAMECASE, &pcblitp, LITLEN);
- goto genfpi;
- }
- /* PARAMETER 5: Notation name.
- */
- parsemd(lbuf, NAMECASE, &pcblitp, NAMELEN);
- TRACEMD("5: notation");
- if (pcbmd.action!=NAS) {mderr(119, tbuf+1, (UNCH *)0); return (struct fpi *)0;}
- /* Locate the data content notation. */
- pne->nedcn = dcb = dcndef(lbuf);
- /* Note that we have defined an entity with this notation.
- If attributes are later defined for this notation, we'll
- have to fix up this entity. */
- dcb->entsw = 1;
-
- /* PARAMETER 6: Data attribute specification.
- */
- parsemd(lbuf, NAMECASE, &pcblitp, NAMELEN);
- TRACEMD("6: [att list]");
- if (pcbmd.action!=MDS) { /* No attributes specified. */
- if (dcb->adl == 0)
- NEAL(pne) = 0;
- else {
- initatt(dcb->adl);
- adlval((int)ADN(al), (struct etd *)0);
- storedatt(pne);
- }
- goto genfpi;
- }
- if (dcb->adl==0) { /* Atts specified, but none defined. */
- mderr(22, (UNCH *)0, (UNCH *)0);
- return (struct fpi *)0;
- }
- pcbstag.newstate = pcbstan; /* First separator is optional. */
- if ((parseatt(dcb->adl, tbuf))==0)/* Empty list. */
- mderr(91, (UNCH *)0, (UNCH *)0);
- else {
- adlval((int)ADN(al), (struct etd *)0);
- storedatt(pne);
- }
- parse(&pcbeal); /* Parse the list ending. */
- parsemd(tbuf, NAMECASE, &pcblitp, LITLEN);
-
- /* GENFPI: Builds a formal public identifier structure, including the
- entity name, offsets of the components of the public ID, and
- other data a system might use to identify the actual file.
- */
- genfpi:
- TRACEMD("7: generate fpi");
- fpis->fpistore = *estore - ESFM + 1; /* External entity type: 1-6. */
- if (*estore == ESN) {
- if (NEXTYPE(pne) == ESNSUB)
- fpis->fpinedcn = 0;
- else
- fpis->fpinedcn = NEDCN(pne) + 1;
- }
- /* Analyze public ID and make structure entries. */
- if (exidtype==EDPUBLIC) {
- if (parsefpi(fpis)>0) {
- if (FORMAL==YES)
- mderr(88, fpis->fpipubis, (UNCH *)0);
- fpis->fpiversw = -1; /* Signal bad formal public ID. */
- }
- }
- return fpis;
-}
-
-/* Store a data attribute. */
-
-VOID storedatt(pne)
-PNE pne;
-{
- int i;
-
- NEAL(pne) = (struct ad *)rmalloc((1+ADN(al))*ADSZ);
- memcpy((UNIV)NEAL(pne), (UNIV)al, (1+ADN(al))*ADSZ);
- for (i = 1; i <= (int)ADN(al); i++) {
- if (GET(ADFLAGS(al, i), ASPEC))
- ds.attdef += ADLEN(al, i);
- if (NEAL(pne)[i].addef != 0)
- NEAL(pne)[i].addef = savestr(NEAL(pne)[i].addef);
- }
- ds.attcnt += AN(al); /* Number of attributes defined. */
-#if 0
- /* I can't see any reason to increase AVGRPCNT here. */
- ds.attgcnt += ADN(al) - AN(al); /* Number of att grp members. */
-#endif
-}
-
-/* PARSEFPI: Parses a formal public identifier and builds a control block.
- PARSEFPI returns a positive error code (1-10), or 0 if no errors.
- It set fpiversw if no version was specified in the ID and the
- public text is in a class that permits display versions.
- Note: An empty version ("//") can be specified (usually it is
- the non-device-specific form, such as a definitional entity set).
-*/
-int parsefpi(f)
-PFPI f; /* Ptr to formal public identifier structure. */
-{
- UNCH *l; /* Pointer to EOS of public identifier. */
- UNCH *p, *q; /* Ptrs to current field in public identifier. */
- UNS len; /* Field length */
-
- p = f->fpipubis; /* Point to start of identifier. */
- l = p + ustrlen(p); /* Point to EOS of identifier. */
- if ((*p=='+' || *p=='-')
- && p[1] == '/' && p[2] == '/') { /* If owner registered,
- unregistered. */
- f->fpiot = *p; /* Save owner type. */
- p += 3;
- }
- else f->fpiot = '!'; /* Indicate ISO owner identifier. */
- if ((q = pubfield(p, l, '/', &len))==0) /* Find end of owner ID field. */
- return 2;
- f->fpiol = len; /* Save owner ID length. */
- f->fpio = p - f->fpipubis; /* Save offset in pubis to owner ID. */
-
- if ((p = pubfield(q, l, ' ', &len))==0) /* Find end of text class field. */
- return 3;
- *(--p) = EOS; /* Temporarily make class a string. */
- f->fpic = mapsrch(pubcltab, q); /* Check for valid uc class name.*/
- *p++ = ' '; /* Restore the SPACE delimiter. */
- if (f->fpic==0) return 4; /* Error if not valid uc class name.*/
-
- /* The public text class in a notation identifier must be NOTATION. */
- if (f->fpistore == ESK - ESFM + 1 && f->fpic != FPINOT) return 10;
-
- if (*p=='-' && p[1] == '/' && p[2] == '/') { /* If text is unavailable
- public text.*/
- f->fpitt = *p; /* Save text type. */
- p += 3;
- }
- else f->fpitt = '+'; /* Indicate available public text. */
- if ((q = pubfield(p, l, '/', &len))==0) /* Find end of text description. */
- return 6;
- f->fpitl = len; /* Save text description length. */
- f->fpit = p - f->fpipubis; /* Save ptr to description.*/
-
- p = pubfield(q, l, '/', &len); /* Bound language field. */
- if (f->fpic != FPICHARS) {
- int i;
- /* Language must be all upper-case letters. */
- /* The standard only says that it *should* be two letters, so
- don't enforce that. */
- /* Language must be a name, which means it can't be empty. */
- if (len == 0)
- return 7;
- for (i = 0; i < len; i++) {
- /* Don't assume ASCII. */
- if (!strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZ", q[i]))
- return 7;
- }
- }
- f->fpill = len;
- f->fpil = q - f->fpipubis;
- if (p!=0) { /* If there is a version field: */
- if (f->fpic<FPICMINV) /* Error if class prohibits versions. */
- return 8;
- if ((pubfield(p, l, '/', &len))!=0) /* Bound version field. */
- return 9; /* Error if yet another field. */
- f->fpivl = len; /* Save version length. */
- f->fpiv = p - f->fpipubis; /* Save ptr (in pubis) to version. */
- }
- else if (f->fpic>=FPICMINV) f->fpiversw = 1;/* No version: get the best. */
- return(0);
-}
-/* PUBFIELD: Returns ptr to next field, or NULL if ID has ended.
-*/
-#ifdef USE_PROTOTYPES
-UNCH *pubfield(UNCH *p, UNCH *l, UNCH d, UNS *lenp)
-#else
-UNCH *pubfield(p, l, d, lenp)
-UNCH *p; /* Public identifier field (no length or EOS). */
-UNCH *l; /* Pointer to EOS of public identifier. */
-UNCH d; /* Field delimiter: ' ' or '/'. */
-UNS *lenp; /* Gets field length */
-#endif
-{
- UNCH *psv = p+1; /* Save starting value of p. */
-
- while (p<l) {
- if (*p++==d) { /* Test for delimiter character. */
- *lenp = p - psv; /* Save field length (no len or EOS). */
- if (d=='/' && *p++!=d) /* Solidus requires a second one. */
- continue;
- return(p); /* Return ptr to next field. */
- }
- }
- *lenp = p - --psv; /* Save field length (no len or EOS). */
- return NULL;
-}
-/* MDMS: Process marked section start.
- If already in special parse, bump the level counters and return
- without parsing the declaration.
-*/
-struct parse *mdms(tbuf, pcb)
-UNCH *tbuf; /* Work area for tokenization [NAMELEN+2]. */
-struct parse *pcb; /* Parse control block for this parse. */
-{
- int key; /* Index of keyword in mslist. */
- int ptype; /* Parameter token type. */
- int pcbcode = 0; /* Parse code: 0=same; 2-4 per defines. */
-
- if (++mslevel>TAGLVL) {
- --mslevel;
- sgmlerr(27, (struct parse *)0, ntoa(TAGLVL), (UNCH *)0);
- }
-
- /* If already in IGNORE mode, return without parsing parameters. */
- if (msplevel) {++msplevel; return(pcb);}
-
- parmno = 0; /* No parameters as yet. */
- mdessv = es; /* Save es for checking entity nesting. */
- pcbmd.newstate = pcbmdtk; /* First separator is optional. */
-
- /* PARAMETERS: TEMP, RCDATA, CDATA, IGNORE, INCLUDE, or MDS. */
- while ((ptype = parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN))==NAS){
- if ((key = mapsrch(mstab, tbuf+1))==0) {
- sgmlerr(64, (struct parse *)0, ntoa(parmno), tbuf+1);
- continue;
- }
- if (key==MSTEMP) continue; /* TEMP: for documentation. */
- msplevel = 1; /* Special parse required. */
- if (key>pcbcode) pcbcode = key; /* Update if higher priority. */
- }
- if (ptype!=MDS) {
- NEWCC; /* Syntax error did REPEATCC. */
- sgmlerr(97, (struct parse *)0, lex.m.dso, (UNCH *)0);
- REPEATCC; /* 1st char of marked section. */
- }
- if (es!=mdessv) synerr(37, pcb);
- TRACEMS(1, pcbcode, mslevel, msplevel);
- if (pcbcode==MSIGNORE) pcb = &pcbmsi;
- else if (pcbcode) {
- pcb = pcbcode==MSCDATA ? &pcbmsc : (rcessv = es, &pcbmsrc);
- }
- return(pcb); /* Tell caller whether to change the parse. */
-}
-/* MDMSE: Process marked section end.
- Issue an error if no marked section had started.
-*/
-int mdmse()
-{
- int retcode = 0; /* Return code: 0=same parse; 1=cancel special. */
-
- if (mslevel) --mslevel;
- else sgmlerr(26, (struct parse *)0, (UNCH *)0, (UNCH *)0);
-
- if (msplevel) if (--msplevel==0) retcode = 1;
- TRACEMS(0, retcode, mslevel, msplevel);
- return retcode;
-}
-/* MDNOT: Process NOTATION declaration.
-*/
-VOID mdnot(tbuf)
-UNCH *tbuf; /* Work area for tokenization[LITLEN+2]. */
-{
- struct fpi fpicb; /* Formal public identifier structure. */
- PDCB dcb; /* Ptr to notation entity in dcntab. */
- UNCH estore = ESK; /* Entity storage class. */
-
- mdname = key[KNOTATION]; /* Identify declaration for messages. */
- subdcl = NULL; /* No subject as yet. */
- parmno = 0; /* No parameters as yet. */
- mdessv = es; /* Save es for checking entity nesting. */
-
- /* PARAMETER 1: Notation name.
- */
- pcbmd.newstate = 0;
- parsemd(lbuf, NAMECASE, &pcblitp, NAMELEN);
- TRACEMD("1: name");
- if (pcbmd.action!=NAS) {mderr(120, (UNCH *)0, (UNCH *)0); return;}
- subdcl = lbuf+1; /* Save notation name for error msgs. */
-
- /* PARAMETER 2: External identifier keyword.
- */
- parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN);
- TRACEMD("2: extid");
- if (pcbmd.action!=NAS) {mderr(29, (UNCH *)0, (UNCH *)0); return;}
- if (mdextid(tbuf, &fpicb, lbuf+1, &estore, (PNE)0)==0) return;
-
- /* PARAMETER 3: End of declaration.
- Token was parsed by MDEXTID.
- */
- TRACEMD(emd);
- if (pcbmd.action!=EMD) mderr(126, (UNCH *)0, (UNCH *)0);
- if (es!=mdessv) synerr(37, &pcbmd);
-
- /* EXECUTE: Store notation name.
- */
- if ((dcb = dcnfind(lbuf)) != 0 && dcb->defined) {
- mderr(56, lbuf+1, (UNCH *)0);
- return;
- }
- /* else */
- dcb = dcndef(lbuf);
- dcb->defined = 1;
- dcb->sysid = fpicb.fpisysis ? savestr(fpicb.fpisysis) : 0;
- dcb->pubid = fpicb.fpipubis ? savestr(fpicb.fpipubis) : 0;
- ++ds.dcncnt;
- ds.dcntext += entlen;
- TRACEDCN(dcb);
- return;
-}
-/* DCNDEF: Define a notation and return its DCNCB.
- If caller does not care if it already exists,
- he should specify NULL for the notation text
- so we don't clobber the existing text (if any).
-*/
-struct dcncb *dcndef(nname)
-UNCH *nname; /* Notation name (with length and EOS). */
-{
- return((PDCB)hin((THASH)dcntab, nname, 0, DCBSZ));
-}
-/* DCNFIND: If a notation was declared, return its DCNCB.
- Return NULL if it is not defined.
-*/
-struct dcncb *dcnfind(nname)
-UNCH *nname; /* Notation name (with length and EOS). */
-{
- return((PDCB)hfind((THASH)dcntab, nname, 0));
-}
-#define SRM(i) (srhptr->srhsrm[i]) /* Current entry in SHORTREF map. */
-/* MDSRMDEF: Process short reference mapping declaration.
-*/
-VOID mdsrmdef(tbuf)
-UNCH *tbuf; /* Work area for tokenization[LITLEN+2]. */
-{
- struct entity *entcb; /* Ptr to defined entity. */
- PSRH srhptr; /* Ptr to short reference map hdr (in srhtab).*/
- int srn; /* Short reference delimiter number in srdeltab.*/
- int mapused = 0; /* Has map already been used? */
-
- mdname = key[KSHORTREF]; /* Identify declaration for messages. */
- subdcl = NULL; /* No subject as yet. */
- parmno = 0; /* No parameters as yet. */
- if (!sd.shortref) {mderr(198, (UNCH *)0, (UNCH *)0); return;}
- mdessv = es; /* Save es for checking entity nesting. */
- /* PARAMETER 1: SHORTREF map name.
- */
- pcbmd.newstate = 0;
- parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN);
- TRACEMD("1: map nm");
- if (pcbmd.action!=NAS) {mderr(120, (UNCH *)0, (UNCH *)0); return;}
- if ((srhptr = srhfind(tbuf))!=0) {
- mapused = 1;
- /* Error if map was declared (not just used). */
- if (SRM(0)) {mderr(56, tbuf+1, (UNCH *)0); return;}
- }
- else srhptr = srhdef(tbuf); /* Create map with SRs mapped to NULL.*/
- SRM(0) = (PECB)srhptr; /* Indicate map was actually declared.*/
- subdcl = srhptr->ename+1; /* Save map name for error msgs. */
-
- while (parsemd(tbuf, NAMECASE, &pcblitp, SRMAXLEN) == LIT
- || pcbmd.action==LITE ) {
- /* PARAMETER 2: Delimiter string.
- */
- TRACEMD("2: SR string");
- if ((srn = mapsrch(lex.s.dtb, tbuf))==0) {
- mderr(124, tbuf, (UNCH *)0);
- goto cleanup;
- }
- /* PARAMETER 3: Entity name.
- */
- parsemd(tbuf, ENTCASE, &pcblitp, NAMELEN);
- TRACEMD("3: entity");
- if (pcbmd.action!=NAS) {mderr(120, (UNCH *)0, (UNCH *)0); goto cleanup;}
- if ((entcb = entfind(tbuf))==0) {
- union etext etx;
- etx.x = 0;
- entcb = entdef(tbuf, '\0', &etx);
- }
- if (SRM(srn)) {
- mderr(56, (srn<lex.s.prtmin ? (UNCH *)lex.s.pdtb[srn]
- : lex.s.dtb[srn].mapnm), (UNCH *)0);
- continue;
- }
- SRM(srn) = entcb;
- if (srn>=lex.s.fce && srn!=lex.s.hyp && srn!=lex.s.hyp2
- && srn!=lex.s.lbr && srn!=lex.s.rbr)
- lexcnm[*lex.s.dtb[srn].mapnm] = lex.l.fce;
- else if (srn==lex.s.spc) lexcnm[' '] = lex.l.spcr;
- }
- /* PARAMETER 4: End of declaration.
- */
- TRACEMD(emd);
- if (parmno==2)
- {mderr((UNS)(pcbmd.action==EMD ? 28:123), (UNCH *)0, (UNCH *)0); goto cleanup;}
- if (pcbmd.action!=EMD) mderr(126, (UNCH *)0, (UNCH *)0);
- if (es!=mdessv) synerr(37, &pcbmd);
- ++ds.srcnt;
- TRACESRM("SHORTREF", srhptr->srhsrm, (UNCH *)0);
- return;
-
- cleanup:
- /* Don't free the map if the map was in use (because of a USEMAP
- declaration) before this declaration. */
- if (mapused)
- MEMZERO((UNIV)srhptr->srhsrm, sizeof(PECB)*(lex.s.dtb[0].mapdata+1));
- else {
- frem((UNIV)srhptr->srhsrm);
- hout((THASH)srhtab, srhptr->ename, 0);
- frem((UNIV)srhptr);
- }
-}
-/* MDSRMUSE: Activate a short reference map.
-*/
-VOID mdsrmuse(tbuf)
-UNCH *tbuf; /* Work area for tokenization[LITLEN+2]. */
-{
- PSRH srhptr; /* Ptr to short reference map hdr (in srhtab).*/
- TECB srmptr; /* Ptr to short reference map (in header). */
- int i; /* Loop counter; temporary variable. */
-
- mdname = key[KUSEMAP]; /* Identify declaration for messages. */
- subdcl = NULL; /* No subject as yet. */
- parmno = 0; /* No parameters as yet. */
- mdessv = es; /* Save es for checking entity nesting. */
- /* PARAMETER 1: SHORTREF map name or "#EMPTY".
- */
- pcbmd.newstate = 0;
- parsemd(lbuf, NAMECASE, &pcblitp, NAMELEN);
- TRACEMD("1: map nm");
- subdcl = lbuf+1; /* Subject name for error messages. */
- switch (pcbmd.action) {
- case RNS: /* Empty SHORTREF map requested. */
- if (ustrcmp(lbuf+1, key[KEMPTY])) {
- mderr(118, lbuf+1, key[KEMPTY]);
- return;
- }
- srmptr = SRMNULL;
- break;
- case NAS: /* Map name specified; save if undefined. */
- if ((srhptr = srhfind(lbuf))==0) {
- if (!indtdsw) {mderr(125, (UNCH *)0, (UNCH *)0); return;}
- srmptr = NULL;
- }
- else
- srmptr = srhptr->srhsrm;
- break;
- default:
- mderr(120, (UNCH *)0, (UNCH *)0);
- return;
- }
- /* PARAMETER 2: Element name or a group of them. (In DTD only.)
- */
- parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN);
- TRACEMD("2: GI or grp");
- switch (pcbmd.action) {
- case NAS:
- if (!indtdsw) {mderr(142, (UNCH *)0, (UNCH *)0); return;}
- nmgrp[0] = etddef(tbuf);
- nmgrp[1] = (PETD)NULL;
- break;
- case GRPS:
- if (!indtdsw) {mderr(142, (UNCH *)0, (UNCH *)0); return;}
- parsegrp(nmgrp, &pcbgrnm, tbuf);
- break;
- case EMD:
- if (indtdsw) {mderr(28, (UNCH *)0, (UNCH *)0); return;}
- if (docelsw) {mderr(233, (UNCH *)0, (UNCH *)0); return;}
- tags[ts].tsrm = srmptr;
- TRACESRM("USEMAP", tags[ts].tsrm, tags[ts].tetd->etdgi+1);
- goto realemd;
- default:
- mderr(indtdsw ? 121 : 126, (UNCH *)0, (UNCH *)0);
- return;
- }
- /* PARAMETER 3: End of declaration.
- */
- parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN);
- TRACEMD(emd);
- if (pcbmd.action!=EMD) mderr(126, (UNCH *)0, (UNCH *)0);
- /* If map has not yet been defined, do it and get map pointer. */
- if (!srmptr) srmptr = (srhdef(lbuf))->srhsrm;
-
- /* Store the map pointer for each element name specified.
- */
- TRACEGRP(nmgrp);
- for (i = -1; nmgrp[++i];) {
- if (!nmgrp[i]->etdsrm) nmgrp[i]->etdsrm = srmptr;
- else if (sw.swdupent) mderr(68, nmgrp[i]->etdgi+1, (UNCH *)0);
- }
- realemd:
- if (es!=mdessv) synerr(37, &pcbmd);
-}
-/* SRHDEF: Define a SHORTREF map and return ptr to its header.
- All entries in map are mapped to NULL.
- Caller must determine whether it already exists.
-*/
-PSRH srhdef(sname)
-UNCH *sname; /* SHORTREF map name (with length and EOS). */
-{
- PSRH srh; /* Ptr to SHORTREF map hdr in srhtab. */
-
- (srh = (PSRH)hin((THASH)srhtab, sname, 0, SRHSZ))->srhsrm =
- (TECB)rmalloc((UNS)(lex.s.dtb[0].mapdata+1)*sizeof(PECB));
- return(srh);
-}
-/* SRHFIND: If a SHORTREF map was declared, return the ptr to its header.
- Return NULL if it is not defined.
-*/
-PSRH srhfind(sname)
-UNCH *sname; /* SHORTREF map name (with length and EOS). */
-{
- return((PSRH)hfind((THASH)srhtab, sname, 0));
-}
-#undef SRM
-
-/*
-Local Variables:
-c-indent-level: 5
-c-continued-statement-offset: 5
-c-brace-offset: -5
-c-argdecl-indent: 0
-c-label-offset: -5
-comment-column: 30
-End:
-*/
diff --git a/usr.bin/sgmls/sgmls/msg.h b/usr.bin/sgmls/sgmls/msg.h
deleted file mode 100644
index 5526337..0000000
--- a/usr.bin/sgmls/sgmls/msg.h
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
-Severity codes:
-I information (not an SGML error at all)
-W warning (an SGML markup error but it knows what you mean)
-E error
-C critical (fatal)
-
-Type codes:
-R resource
-C ?context/content
-M minimization
-Q quantity
-S syntax
-D declaration
-U unsupported feature
-*/
-struct {
- char *text;
- char severity;
- char type;
-} messages[] = {
-/* 0 */ {0},
-/* 1 */ {"%s element not allowed at this point in %s element", 'E', 'C'},
-/* 2 */ {"%s markup declaration not permitted here; declaration ended", 'E', 'D'},
-/* 3 */ {"Length of name, number, or token exceeded NAMELEN or LITLEN limit", 'E', 'Q'},
-/* 4 */ {"Non-SGML character ignored", 'E', 'S'},
-/* 5 */ {"%s end-tag ignored: doesn't end any open element (current is %s)", 'E', 'C'},
-/* 6 */ {"%s start-tag exceeds open element limit; possible lies from %s on", 'E', 'Q'},
-/* 7 */ {"Start-tag omitted from %s with empty content", 'E', 'M'},
-/* 8 */ {"Illegal entity end in markup or delimited text", 'E', 'S'},
-/* 9 */ {"Incorrect character in markup; markup terminated", 'E', 'S'},
-/* 10 */ {"Data not allowed at this point in %s element", 'E', 'C'},
-/* 11 */ {"No element declaration for %s end-tag GI; end-tag ignored", 'E', 'C'},
-/* 12 */ {"%s name ignored: not a syntactically valid SGML name", 'E', 'S'},
-/* 13 */ {"%s = \"%s\" attribute ignored: not defined for this element", 'E', 'C'},
-/* 14 */ {"%s = \"%s\" attribute value defaulted: invalid character", 'E', 'S'},
-/* 15 */ {"%s = \"%s\" attribute value defaulted: token too long", 'E', 'Q'},
-/* 16 */ {"%s = \"%s\" attribute value defaulted: too many tokens", 'E', 'C'},
-/* 17 */ {"%s = \"%s\" attribute value defaulted: wrong token type", 'E', 'C'},
-/* 18 */ {"%s = \"%s\" attribute value defaulted: token not in group", 'E', 'C'},
-/* 19 */ {"Required %s attribute was not specified; may affect processing", 'E', 'C'},
-/* 20 */ {"%s end-tag implied by %s end-tag; not minimizable", 'E', 'M'},
-/* 21 */ {"%s start-tag implied by %s start-tag; not minimizable", 'W', 'M'},
-/* 22 */ {"Possible attributes treated as data because none were defined", 'E', 'C'},
-/* 23 */ {"Duplicate specification occurred for \"%s\"; may affect processing", 'E', 'D'},
-/* 24 */ {"\"%s\" keyword invalid; declaration terminated", 'E', 'D'},
-/* 25 */ {"%s = \"%s\" attribute defaulted: empty string not allowed for token", 'E', 'C'},
-/* 26 */ {"Marked section end ignored; not in a marked section", 'E', 'S'},
-/* 27 */ {"Marked section start ignored; %s marked sections open already", 'E', 'Q'},
-/* 28 */ {"One or more parameters missing; declaration ignored", 'E', 'D'},
-/* 29 */ {"\"PUBLIC\" or \"SYSTEM\" required; declaration terminated", 'E', 'D'},
-/* 30 */ {"%s element ended prematurely; required %s omitted", 'E', 'C'},
-/* 31 */ {"Entity \"%s\" terminated: could not read file", 'E', 'R'},
-/* 32 */ {"Could not open file for entity \"%s\"; entity reference ignored", 'E', 'R'},
-/* 33 */ {"Insufficient main memory; unable to continue parsing", 'C', 'R'},
-/* 34 */ {"%s entity reference ignored; exceeded open entity limit (%s)", 'E', 'Q'},
-/* 35 */ {"No declaration for entity \"%s\"; reference ignored", 'E', 'C'},
-/* 36 */ {"%s entity reference occurred within own text; reference ignored", 'E', 'C'},
-/* 37 */ {"Entity nesting level out of sync", 'E', 'S'},
-/* 38 */ {"Parameter entity text cannot have %s keyword; keyword ignored", 'E', 'D'},
-/* 39 */ {"%s end-tag implied by %s start-tag; not minimizable", 'W', 'M'},
-/* 40 */ {"Start-tag minimization ignored; element has required attribute", 'E', 'D'},
-/* 41 */ {"Required %s element cannot be excluded from %s element", 'E', 'C'},
-/* 42 */ {"No DOCTYPE declaration; document type is unknown", 'E', 'C'},
-/* 43 */ {"Undefined %1$s start-tag GI was used in DTD; \"%1$s O O ANY\" assumed", 'E', 'C'},
-/* 44 */ {"Invalid character(s) ignored; attempting to resume DOCTYPE subset", 'E', 'S'},
-/* 45 */ {"No declaration for entity \"%s\"; default definition used", 'I', 'C'},
-/* 46 */ {"%s end-tag implied by NET delimiter; not minimizable", 'W', 'M'},
-/* 47 */ {"%s end-tag implied by data; not minimizable", 'W', 'M'},
-/* 48 */ {"%s end-tag implied by short start-tag (no GI); not minimizable", 'W', 'M'},
-/* 49 */ {"%s start-tag implied by data; not minimizable", 'W', 'M'},
-/* 50 */ {"%s start-tag implied by short start-tag (no GI); not minimizable", 'W', 'M'},
-/* 51 */ {"Short end-tag (no GI) ignored: no open elements", 'E', 'C'},
-/* 52 */ {"No definition for %1$s document type; \"%1$s O O ANY\" assumed", 'E', 'C'},
-/* 53 */ {"No definition for %1$s implied start-tag; \"%1$s O O ANY\" assumed", 'E', 'C'},
-/* 54 */ {"%s element ended prematurely; required subelement omitted", 'E', 'C'},
-/* 55 */ {"Content model token %s: connectors conflict; first was used", 'E', 'D'},
-/* 56 */ {"Duplicate specification occurred for \"%s\"; duplicate ignored", 'E', 'D'},
-/* 57 */ {"Bad end-tag in R/CDATA element; treated as short (no GI) end-tag", 'E', 'S'},
-/* 58 */ {"Start-tag minimization should be \"-\" for element with declared content", 'I', 'D'},
-/* 59 */ {"Reference to PI entity not permitted here; reference ignored", 'E', 'S'},
-/* 60 */ {"Non-SGML character found; should have been character reference", 'W', 'S'},
-/* 61 */ {"Numeric character reference exceeds 255; reference ignored", 'E', 'S'},
-/* 62 */ {"Invalid alphabetic character reference ignored", 'E', 'S'},
-/* 63 */ {"Invalid character in minimum literal; character ignored", 'E', 'S'},
-/* 64 */ {"Keyword %s ignored; \"%s\" is not a valid marked section keyword", 'E', 'D'},
-/* 65 */ {"Parameter entity name longer than (NAMELEN-1); truncated", 'E', 'Q'},
-/* 66 */ {"Start-tag length exceeds TAGLEN limit; parsed correctly", 'W', 'Q'},
-/* 67 */ {"%s attribute defaulted: FIXED attribute must equal default", 'W', 'C'},
-/* 68 */ {"Duplicate specification occurred for \"%s\"; duplicate ignored", 'I', 'D'},
-/* 69 */ {"%s = \"%s\" IDREF attribute ignored: referenced ID does not exist", 'E', 'C'},
-/* 70 */ {"%s = \"%s\" IDREF attribute ignored: number of IDs in list exceeds GRPCNT limit", 'E', 'Q'},
-/* 71 */ {"%s = \"%s\" ID attribute ignored: ID in use for another element", 'E', 'C'},
-/* 72 */ {"%s = \"%s\" ENTITY attribute not general entity; may affect processing", 'E', 'C'},
-/* 73 */ {"%s = \"%s\" attribute ignored: previously specified in same list", 'W', 'C'},
-/* 74 */ {"\"?\" = \"%s\" name token ignored: not in any group in this list", 'E', 'C'},
-/* 75 */ {"Normalized attribute specification length over ATTSPLEN limit", 'E', 'Q'},
-/* 76 */ {"%s = \"%s\" NOTATION ignored: element content is empty", 'E', 'C'},
-/* 77 */ {"%s = \"%s\" NOTATION undefined: may affect processing", 'E', 'C'},
-/* 78 */ {"Entity \"%2$s\" has undefined notation \"%1$s\"", 'E', 'C'},
-/* 79 */ {"%s = \"%s\" default attribute value not in group; #IMPLIED used", 'E', 'C'},
-/* 80 */ {"#CURRENT default value treated as #IMPLIED for %s ID attribute", 'E', 'D'},
-/* 81 */ {"ID attribute %s cannot have a default value; treated as #IMPLIED", 'E', 'D'},
-/* 82 */ {"%s attribute must be token, not empty string; treated as #IMPLIED", 'E', 'D'},
-/* 83 */ {"NOTATION attribute ignored for EMPTY element", 'E', 'D'},
-/* 84 */ {"%s = \"%s\" NOTATION ignored: content reference specified", 'E', 'C'},
-/* 85 */ {"#CONREF default value treated as #IMPLIED for EMPTY element", 'W', 'D'},
-/* 86 */ {"%s = \"%s\" entity not data entity; may affect processing", 'E', 'C'},
-/* 87 */ {"End-tag minimization should be \"O\" for EMPTY element", 'I', 'D'},
-/* 88 */ {"Formal public identifier \"%s\" invalid; treated as informal", 'E', 'S'},
-/* 89 */ {"Out-of-context %2$s start-tag ended %1$s document element (and parse)", 'E', 'C'},
-/* 90 */ {"\"%s\" keyword is for unsupported feature; declaration terminated", 'E', 'D'},
-/* 91 */ {"Attribute specification list in prolog cannot be empty", 'E', 'D'},
-/* 92 */ {"Document ended invalidly within a literal; parsing ended", 'C', 'S'},
-/* 93 */ {"General entity \"%s\" in short reference map \"%s\" undeclared", 'E', 'D'},
-/* 94 */ {"Could not reopen file to continue entity \"%s\"; entity terminated", 'E', 'R'},
-/* 95 */ {"Out-of-context data ended %s document element (and parse)", 'E', 'C'},
-/* 96 */ {"Short start-tag (no GI) ended %s document element (and parse)", 'E', 'C'},
-/* 97 */ {"DSO delimiter (%s) omitted from marked section declaration", 'E', 'D'},
-/* 98 */ {"Group token %s: duplicate name or name token \"%s\" ignored", 'E', 'D'},
-/* 99 */ {"Attempt to redefine %s attribute ignored", 'E', 'D'},
-/* 100 */ {"%s definition ignored: %s is not a valid declared value keyword", 'E', 'D'},
-/* 101 */ {"%s definition ignored: NOTATION attribute already defined", 'E', 'D'},
-/* 102 */ {"%s definition ignored: ID attribute already defined", 'E', 'D'},
-/* 103 */ {"%s definition ignored: no declared value specified", 'E', 'D'},
-/* 104 */ {"%s definition ignored: invalid declared value specified", 'E', 'D'},
-/* 105 */ {"%s definition ignored: number of names or name tokens in group exceeded GRPCNT limit", 'E', 'D'},
-/* 106 */ {"%s definition ignored: name group omitted for NOTATION attribute", 'E', 'D'},
-/* 107 */ {"#CONREF default value treated as #IMPLIED for %s ID attribute", 'E', 'D'},
-/* 108 */ {"%s definition ignored: %s is not a valid default value keyword", 'E', 'D'},
-/* 109 */ {"%s definition ignored: no default value specified", 'E', 'D'},
-/* 110 */ {"%s definition ignored: invalid default value specified", 'E', 'D'},
-/* 111 */ {"More than ATTCNT attribute names and/or name (token) values; terminated", 'E', 'D'},
-/* 112 */ {"Attempted redefinition of attribute definition list ignored", 'E', 'D'},
-/* 113 */ {"Content model token %s: more than GRPCNT model group tokens; terminated", 'E', 'Q'},
-/* 114 */ {"Content model token %s: more than GRPGTCNT content model tokens; terminated", 'E', 'Q'},
-/* 115 */ {"Content model token %s: more than GRPLVL nested model groups; terminated", 'E', 'Q'},
-/* 116 */ {"Content model token %s: %s invalid; declaration terminated", 'E', 'D'},
-/* 117 */ {"\"PUBLIC\" specified without public ID; declaration terminated", 'E', 'D'},
-/* 118 */ {"\"%s\" keyword invalid (only %s permitted); declaration terminated", 'E', 'D'},
-/* 119 */ {"\"%s\" specified without notation name; declaration terminated", 'E', 'D'},
-/* 120 */ {"Parameter must be a name; declaration terminated", 'E', 'D'},
-/* 121 */ {"Parameter must be a GI or a group of them; declaration terminated", 'E', 'D'},
-/* 122 */ {"Parameter must be a name or PERO (%%); declaration terminated", 'E', 'D'},
-/* 123 */ {"Parameter must be a literal; declaration terminated", 'E', 'D'},
-/* 124 */ {"\"%s\" not valid short reference delimiter; declaration terminated", 'E', 'D'},
-/* 125 */ {"Map does not exist; declaration ignored", 'E', 'C'},
-/* 126 */ {"MDC delimiter (>) expected; following text may be misinterpreted", 'E', 'D'},
-/* 127 */ {"Document ended invalidly within prolog; parsing ended", 'C', 'S'},
-/* 128 */ {"\"PUBLIC\" or \"SYSTEM\" or DSO ([) required; declaration terminated", 'E', 'D'},
-/* 129 */ {"Minimization must be \"-\" or \"O\" (not \"%s\"); declaration terminated", 'E', 'D'},
-/* 130 */ {"Content model or keyword expected; declaration terminated", 'E', 'D'},
-/* 131 */ {"Rank stem \"%s\" + suffix \"%s\" more than NAMELEN characters; not defined", 'E', 'D'},
-/* 132 */ {"Undefined %s start-tag GI ignored; not used in DTD", 'E', 'C'},
-/* 133 */ {"Document ended invalidly within a markup declaration; parsing ended", 'C', 'S'},
-/* 134 */ {"Normalized length of literal exceeded %s; markup terminated", 'E', 'Q'},
-/* 135 */ {"R/CDATA marked section in declaration subset; prolog terminated", 'E', 'D'},
-/* 136 */ {"%s = \"%s\" ENTITIES attribute ignored: more than GRPCNT in list", 'E', 'Q'},
-/* 137 */ {"Content model is ambiguous", 'W', 'D'},
-/* 138 */ {"Invalid parameter entity name \"%s\"", 'E', 'S'},
-/* 139 */ {"Document ended invalidly within a marked section; parsing ended", 'C', 'S'},
-/* 140 */ {"Element \"%s\" used in DTD but not defined", 'I', 'D'},
-/* 141 */ {"Invalid NDATA or SUBDOC entity reference occurred; ignored", 'E', 'S'},
-/* 142 */ {"Associated element type not allowed in document instance", 'E', 'C'},
-/* 143 */ {"Illegal DSC character; in different entity from DSO", 'E', 'C'},
-/* 144 */ {"Declared value of data attribute cannot be ID", 'E', 'D' },
-/* 145 */ {"Invalid reference to external CDATA or SDATA entity; ignored", 'E', 'S'},
-/* 146 */ {"Could not find external document type \"%s\"", 'E', 'R'},
-/* 147 */ {"Could not find external general entity \"%s\"", 'I', 'R'},
-/* 148 */ {"Could not find external parameter entity \"%s\"", 'I', 'R'},
-/* 149 */ {"Reference to non-existent general entity \"%s\" ignored", 'E', 'R'},
-/* 150 */ {"Could not find entity \"%s\" using default declaration", 'I', 'R'},
-/* 151 */ {"Could not find entity \"%2$s\" in attribute %1$s using default declaration", 'E', 'R'},
-/* 152 */ {"Short reference map \"%s\" used in USEMAP declaration but not defined; declaration will be ignored", 'E', 'D'},
-/* 153 */ {"End-tag minimization should be \"O\" for element with CONREF attribute", 'I', 'D'},
-/* 154 */ {"Declared value of data attribute cannot be ENTITY or ENTITIES", 'E', 'D' },
-/* 155 */ {"Declared value of data attribute cannot be IDREF or IDREFS", 'E', 'D' },
-/* 156 */ {"Declared value of data attribute cannot be NOTATION", 'E', 'D' },
-/* 157 */ {"CURRENT cannot be specified for a data attribute", 'E', 'D' },
-/* 158 */ {"CONREF cannot be specified for a data attribute", 'E', 'D' },
-/* 159 */ {"Parameter must be a number or CONTROLS or NONE", 'E', 'D'},
-/* 160 */ {"Cannot create temporary file", 'C', 'R'},
-/* 161 */ {"Document ended invalidly within SGML declaration", 'C', 'D'},
-/* 162 */ {"Capacity limit %s exceeded by %s points", 'W', 'Q'},
-/* 163 */ {"Amendment 1 requires \"ISO 8879:1986\" instead of \"ISO 8879-1986\"", 'W', 'D'},
-/* 164 */ {"Non-markup, non-minimum data character in SGML declaration", 'E', 'D'},
-/* 165 */ {"Parameter cannot be a literal", 'E', 'D'},
-/* 166 */ {"Invalid concrete syntax scope \"%s\"", 'E', 'D'},
-/* 167 */ {"Parameter must be a number", 'E', 'D'},
-/* 168 */ {"\"%s\" should have been \"%s\"", 'E', 'D'},
-/* 169 */ {"Character number %s is not supported as an additional name character", 'E', 'U'},
-/* 170 */ {"Parameter must be a literal or \"%s\"", 'E', 'D'},
-/* 171 */ {"Bad character description for character %s", 'E', 'D'},
-/* 172 */ {"Character number %s is described more than once", 'W', 'D'},
-/* 173 */ {"Character number plus number of characters exceeds 256", 'E', 'D'},
-/* 174 */ {"No description for upper half of character set: assuming \"128 128 UNUSED\"", 'W', 'D'},
-/* 175 */ {"Character number %s was not described; assuming UNUSED", 'E', 'D'},
-/* 176 */ {"Non-significant shunned character number %s not declared UNUSED", 'E', 'D'},
-/* 177 */ {"Significant character \"%s\" cannot be non-SGML", 'E', 'D'},
-/* 178 */ {"Unknown capacity set \"%s\"", 'E', 'U'},
-/* 179 */ {"No capacities specified." , 'E', 'D'},
-/* 180 */ {"Unknown concrete syntax \"%s\"", 'E', 'U'},
-/* 181 */ {"Character number exceeds 255", 'E', 'D'},
-/* 182 */ {"Concrete syntax SWITCHES not supported", 'E', 'U'},
-/* 183 */ {"\"INSTANCE\" scope not supported", 'E', 'U'},
-/* 184 */ {"Value of \"%s\" feature must be one or more", 'E', 'D'},
-/* 185 */ {"\"%s\" invalid; must be \"YES\" or \"NO\"", 'E', 'D'},
-/* 186 */ {"\"%s\" invalid; must be \"PUBLIC\" or \"SGMLREF\"", 'E', 'D'},
-/* 187 */ {"Feature \"%s\" is not supported", 'E', 'U'},
-/* 188 */ {"Too many open subdocument entities", 'E', 'Q'},
-/* 189 */ {"Invalid formal public identifier", 'W', 'D'},
-/* 190 */ {"Public text class must be \"%s\"", 'W', 'D'},
-/* 191 */ {"Use of character number %s as an SGML character is not supported", 'W', 'U'},
-/* 192 */ {"Notation \"%s\" not defined in DTD", 'W', 'D'},
-/* 193 */ {"Unclosed start or end tag requires \"SHORTTAG YES\"", 'W', 'M'},
-/* 194 */ {"Net-enabling start tag requires \"SHORTTAG YES\"", 'W', 'M'},
-/* 195 */ {"Attribute name omission requires \"SHORTTAG YES\"", 'W', 'M'},
-/* 196 */ {"Undelimited attribute value requires \"SHORTTAG YES\"", 'W', 'M'},
-/* 197 */ {"Attribute specification omitted for \"%s\": requires markup minimization", 'W', 'M'},
-/* 198 */ {"Concrete syntax does not have any short reference delimiters", 'E', 'D'},
-/* 199 */ {"Character number %s not in the base character set; assuming UNUSED", 'E', 'D'},
-/* 200 */ {"Character number %s is UNUSED in the syntax reference character set", 'E', 'D'},
-/* 201 */ {"Character number %s was not described in the syntax reference character set", 'E', 'D'},
-/* 202 */ {"Character number %s in the syntax reference character set has no corresponding character in the system character set", 'E', 'D'},
-/* 203 */ {"Character number %s was described using an unknown base set", 'E', 'D'},
-/* 204 */ {"Duplication specification for added function \"%s\"", 'E', 'D'},
-/* 205 */ {"Added function character cannot be \"%s\"", 'E', 'D'},
-/* 206 */ {"Only reference concrete syntax function characters supported", 'E', 'U'},
-/* 207 */ {"Only reference concrete syntax general delimiters supported", 'E', 'U'},
-/* 208 */ {"Only reference concrete syntax short reference delimiters supported", 'E', 'U'},
-/* 209 */ {"Unrecognized keyword \"%s\"", 'E', 'D'},
-/* 210 */ {"Unrecognized quantity name \"%s\"", 'E', 'D'},
-/* 211 */ {"Interpretation of \"%s\" is not a valid name in the declared concrete syntax", 'E', 'D'},
-/* 212 */ {"Replacement reserved name \"%s\" cannot be reference reserved name", 'E', 'D'},
-/* 213 */ {"Duplicate replacement reserved name \"%s\"", 'E', 'D'},
-/* 214 */ {"Quantity \"%s\" must not be less than %s", 'E', 'D'},
-/* 215 */ {"Only values up to %2$s are supported for quantity \"%1$s\"", 'E', 'U'},
-/* 216 */ {"%s element cannot be excluded from %s element because it is neither inherently optional nor a member of an or group", 'E', 'C'},
-/* 217 */ {"Marked section not allowed in other prolog", 'E', 'C'},
-/* 218 */ {"Required %s attribute was not specified for entity %s", 'E', 'C'},
-/* 219 */ {"UCNMSTRT must have the same number of characters as LCNMSTRT", 'E', 'D'},
-/* 220 */ {"UCNMCHAR must have the same number of characters as LCNMCHAR", 'E', 'D'},
-/* 221 */ {"Character number %s assigned to both LCNMSTRT or UCNMSTRT and LCNMCHAR or UCNMCHAR", 'E', 'D'},
-/* 222 */ {"Character number %s cannot be an additional name character", 'E', 'D'},
-/* 223 */ {"It is unsupported for \"-\" not to be assigned to UCNMCHAR or LCNMCHAR", 'E', 'U'},
-/* 224 */ {"Normalized length of value of attribute \"%s\" exceeded LITLEN", 'E', 'Q'},
-/* 225 */ {"Length of interpreted parameter literal exceeds LITLEN less the length of the bracketing delimiters", 'E', 'Q'},
-/* 226 */ {"Start tag of document element omitted; not minimizable", 'W', 'M'},
-/* 227 */ {"Unrecognized designating escape sequence \"%s\"", 'I', 'U'},
-/* 228 */ {"Earlier reference to entity \"%s\" used default entity", 'I', 'D'},
-/* 229 */ {"Reference to non-existent parameter entity \"%s\" ignored", 'E', 'R'},
-/* 230 */ {"DSC within marked section; marked section terminated", 'E', 'C'},
-/* 231 */ {"Document element end tag can only occur in document element because entity end not allowed in other prolog", 'E', 'C'},
-/* 232 */ {"Character reference not allowed in other prolog", 'E', 'C'},
-/* 233 */ {"USEMAP declaration not allowed in other prolog", 'E', 'D'},
-/* 234 */ {"Entity reference not allowed in other prolog", 'E', 'C'},
-/* 235 */ {"Value assigned to capacity %s exceeds value assigned to TOTALCAP", 'W', 'D'},
-};
diff --git a/usr.bin/sgmls/sgmls/msgcat.c b/usr.bin/sgmls/sgmls/msgcat.c
deleted file mode 100644
index 5c7ee9f..0000000
--- a/usr.bin/sgmls/sgmls/msgcat.c
+++ /dev/null
@@ -1,840 +0,0 @@
-/* msgcat.c -
- X/Open message catalogue functions and gencat utility.
-
- Written by James Clark (jjc@jclark.com).
-*/
-
-#include "config.h"
-
-#ifndef HAVE_CAT
-
-/* In this implementation the message catalogue format is the same as the
-message text source file format (see pp 42-43 of the X/Open
-Portability Guide, Issue 3, Volume 3.) This means that you don't have
-to use the gencat utility, but it is still useful for checking and
-merging catalogues. */
-
-/* Compile this with -DGENCAT to get the gencat utility. */
-
-#include "std.h"
-#include "msgcat.h"
-
-#ifdef USE_PROTOTYPES
-#define P(parms) parms
-#else
-#define P(parms) ()
-#endif
-
-#ifdef USE_ISASCII
-#define ISASCII(c) isascii(c)
-#else
-#define ISASCII(c) (1)
-#endif
-
-/* Default message set. */
-#define NL_SETD 1
-
-#ifndef PATH_FILE_SEP
-#define PATH_FILE_SEP ':'
-#endif
-
-#ifndef DEFAULT_NLSPATH
-#define DEFAULT_NLSPATH ""
-#endif
-
-#ifndef DEFAULT_LANG
-#define DEFAULT_LANG "default"
-#endif
-
-#define HASH_TAB_SIZE 251
-
-struct message {
- struct message *next;
- unsigned msgnum;
- unsigned setnum;
- char *text;
-};
-
-struct cat {
- char *name;
- int loaded;
- int bad;
- struct message *table[HASH_TAB_SIZE];
-};
-
-static char *read_buf = 0;
-static unsigned read_buf_len = 0;
-
-/* Errors that can be generated by read_catalog. */
-
-enum cat_err {
- E_ZERO, /* not an error */
- E_BADARG,
- E_NOMEM,
- E_NOSUCHCOMMAND,
- E_INPUT,
- E_EOF,
- E_BADSEP,
- E_BADLINE
-};
-
-#ifdef GENCAT
-/* These must match enum cat_err. */
-static char *cat_errlist[] = {
- "Error 0",
- "Invalid argument to command",
- "Out of memory",
- "Unrecognized command",
- "Input error",
- "Unexpected end of file",
- "Space or tab expected after message number",
- "Invalid line",
-};
-#endif /* GENCAT */
-
-#ifndef GENCAT
-/* The value of NLSPATH. */
-static char *nlspath = 0;
-/* The value of LANG. */
-static char *lang = 0;
-#endif /* not GENCAT */
-
-static int current_lineno = -1;
-static enum cat_err cat_errno = E_ZERO;
-
-#ifndef GENCAT
-static void load_catalog P((struct cat *));
-static FILE *find_catalog P((char *, char **));
-#endif
-static int read_catalog P((FILE *, struct message **));
-static void delete_set P((struct message **, unsigned));
-static void delete_message P((struct message **, unsigned, unsigned));
-static int hash P((unsigned setnum, unsigned msgnum));
-static char *parse_text P((FILE *, int));
-
-#ifndef GENCAT
-
-nl_catd catopen(name, oflag)
-char *name;
-int oflag;
-{
- struct cat *catp;
- int i;
-
- if (!name)
- return 0;
-
- catp = (struct cat *)malloc(sizeof *catp);
- if (!catp)
- return 0;
- for (i = 0; i < HASH_TAB_SIZE; i++)
- catp->table[i] = 0;
- catp->name = malloc(strlen(name) + 1);
- catp->loaded = 0;
- catp->bad = 0;
- strcpy(catp->name, name);
- return (nl_catd)catp;
-}
-
-int catclose(catd)
-nl_catd catd;
-{
- int i;
- struct cat *catp = (struct cat *)catd;
-
- if (!catp)
- return 0;
-
- for (i = 0; i < HASH_TAB_SIZE; i++) {
- struct message *p, *nextp;
- for (p = catp->table[i]; p; p = nextp) {
- nextp = p->next;
- free(p->text);
- free((char *)p);
- }
- }
- if (catp->name)
- free(catp->name);
- free((char *)catp);
- return 0;
-}
-
-char *catgets(catd, setnum, msgnum, dflt)
-nl_catd catd;
-int setnum, msgnum;
-char *dflt;
-{
- struct message *p;
- struct cat *catp;
-
- /* setnum and msgnum are required to be >= 1. */
- if (!catd || setnum <= 0 || msgnum <= 0)
- return dflt;
- catp = (struct cat *)catd;
- if (!catp->loaded)
- load_catalog(catp);
- if (catp->bad)
- return dflt;
- for (p = catp->table[hash(setnum, msgnum)]; p; p = p->next)
- if (p->msgnum == msgnum && p->setnum == setnum)
- break;
- if (!p)
- return dflt;
- return p->text;
-}
-
-static
-VOID load_catalog(catp)
-struct cat *catp;
-{
- FILE *fp;
- char *path;
-
- catp->loaded = 1;
- fp = find_catalog(catp->name, &path);
- if (!fp) {
- catp->bad = 1;
- return;
- }
- current_lineno = 0;
- if (read_catalog(fp, catp->table) < 0)
- catp->bad = 1;
- fclose(fp);
- if (read_buf) {
- free(read_buf);
- read_buf = 0;
- }
- read_buf_len = 0;
- free(path);
-}
-
-static
-FILE *find_catalog(name, pathp)
-char *name;
-char **pathp;
-{
- char *path;
-
- if (!name)
- return 0;
- if (!nlspath) {
- nlspath = getenv("NLSPATH");
- if (!nlspath)
- nlspath = DEFAULT_NLSPATH;
- }
- if (!lang) {
- lang = getenv("LANG");
- if (!lang)
- lang = DEFAULT_LANG;
- }
- path = nlspath;
- for (;;) {
- char *p;
- unsigned len = 0;
-
- for (p = path; *p != '\0' && *p != PATH_FILE_SEP; p++) {
- if (*p == '%') {
- if (p[1] == 'N') {
- p++;
- len += strlen(name);
- }
- else if (p[1] == 'L') {
- p++;
- len += strlen(lang);
- }
- else if (p[1] == '%') {
- p++;
- len++;
- }
- else
- len++;
-
- }
- else
- len++;
- }
- if (len > 0) {
- char *s, *try;
- FILE *fp;
- s = try = malloc(len + 1);
- if (!s)
- return 0;
- for (p = path; *p != '\0' && *p != PATH_FILE_SEP; p++) {
- if (*p == '%') {
- if (p[1] == 'N') {
- p++;
- strcpy(s, name);
- s += strlen(name);
- }
- else if (p[1] == 'L') {
- p++;
- strcpy(s, lang);
- s += strlen(lang);
- }
- else if (p[1] == '%') {
- p++;
- *s++ = '%';
- }
- else
- *s++ = *p;
- }
- else
- *s++ = *p;
- }
- *s++ = '\0';
- fp = fopen(try, "r");
- if (fp) {
- *pathp = try;
- return fp;
- }
- free(try);
- }
- if (*p == '\0')
- break;
- path = ++p;
- }
- return 0;
-}
-
-#endif /* not GENCAT */
-
-/* 0 success, -1 error */
-
-static
-int parse_message(c, fp, table, setnum, quote)
-int c;
-FILE *fp;
-struct message **table;
-unsigned setnum;
-int quote;
-{
- unsigned msgnum;
- struct message *msgp;
- char *text;
- int hc;
-
- msgnum = c - '0';
- for (;;) {
- c = getc(fp);
- if (!isdigit(c))
- break;
- msgnum = msgnum*10 + (c - '0');
- }
- if (c == '\n') {
- delete_message(table, setnum, msgnum);
- return 0;
- }
- if (c != ' ' && c != '\t') {
- cat_errno = E_BADSEP;
- return -1;
- }
- text = parse_text(fp, quote);
- if (!text)
- return -1;
- hc = hash(setnum, msgnum);
- for (msgp = table[hc]; msgp; msgp = msgp->next)
- if (msgp->setnum == setnum && msgp->msgnum == msgnum)
- break;
- if (msgp)
- free(msgp->text);
- else {
- msgp = (struct message *)malloc(sizeof *msgp);
- if (!msgp) {
- cat_errno = E_NOMEM;
- return -1;
- }
- msgp->next = table[hc];
- table[hc] = msgp;
- msgp->msgnum = msgnum;
- msgp->setnum = setnum;
- }
- msgp->text = text;
- return 0;
-}
-
-static
-char *parse_text(fp, quote)
-FILE *fp;
-int quote;
-{
- unsigned i = 0;
- char *p;
- int c;
- int quoted;
-
- c = getc(fp);
- if (c == quote) {
- quoted = 1;
- c = getc(fp);
- }
- else
- quoted = 0;
- for (;; c = getc(fp)) {
- if (c == EOF) {
- if (ferror(fp)) {
- cat_errno = E_INPUT;
- return 0;
- }
- break;
- }
- if (c == '\n')
- break;
- /* XXX
-
- Can quotes be used in quoted message text if protected by \ ?
-
- Is it illegal to omit the closing quote if there's an opening
- quote?
-
- Is it illegal to have anything after a closing quote?
-
- */
-
- if (quoted && c == quote) {
- /* Skip the rest of the line. */
- while ((c = getc(fp)) != '\n')
- if (c == EOF) {
- if (ferror(fp)) {
- cat_errno = E_INPUT;
- return 0;
- }
- break;
- }
- break;
- }
- if (c == '\\') {
- int d;
-
- c = getc(fp);
- if (c == EOF)
- break;
- switch (c) {
- case '\n':
- current_lineno++;
- continue;
- case 'n':
- c = '\n';
- break;
- case 'b':
- c = '\b';
- break;
- case 'f':
- c = '\f';
- break;
- case 't':
- c = '\t';
- break;
- case 'v':
- c = '\v';
- break;
- case 'r':
- c = '\r';
- break;
- case '\\':
- c = '\\';
- break;
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- c -= '0';
- d = getc(fp);
- if (d >= '0' && d <= '7') {
- c = c*8 + d - '0';
- d = getc(fp);
- if (d >= '0' && d <= '7')
- c = c*8 + d - '0';
- else if (d != EOF)
- ungetc(d,fp);
- }
- else if (d != EOF)
- ungetc(d, fp);
- if (c == '\0')
- continue; /* XXX */
- break;
- default:
- /* Ignore the quote. */
- break;
- }
- }
- if (i >= read_buf_len) {
- if (!read_buf)
- read_buf = malloc(read_buf_len = 40);
- else
- read_buf = realloc(read_buf, read_buf_len *= 2);
- if (!read_buf) {
- cat_errno = E_NOMEM;
- return 0;
- }
- }
- read_buf[i++] = c;
- }
- p = malloc(i + 1);
- if (!p) {
- cat_errno = E_NOMEM;
- return 0;
- }
- memcpy(p, read_buf, i);
- p[i] = '\0';
- return p;
-}
-
-/* 0 success, -1 error */
-
-static
-int parse_command(fp, table, setnump, quotep)
-FILE *fp;
-struct message **table;
-unsigned *setnump;
-int *quotep;
-{
- char buf[128];
- if (fgets(buf, 128, fp) == NULL) {
- cat_errno = ferror(fp) ? E_INPUT : E_EOF;
- return -1;
- }
- if (buf[0] == ' ' || buf[0] == '\t' || buf[0] == '\n')
- /* a comment */;
- else if (strncmp(buf, "set", 3) == 0) {
- if (sscanf(buf + 3, "%u", setnump) != 1) {
- cat_errno = E_BADARG;
- return -1;
- }
-
- }
- else if (strncmp(buf, "delset", 6) == 0) {
- unsigned num;
- if (sscanf(buf + 6, "%u", &num) != 1) {
- cat_errno = E_BADARG;
- return -1;
- }
- delete_set(table, num);
- *setnump = NL_SETD;
- }
- else if (strncmp(buf, "quote", 5) == 0) {
- char *p = buf + 5;
- while (*p == ' ' || *p == '\t')
- p++;
- /* XXX should \ be allowed as the quote character? */
- if (*p == '\0' || *p == '\n')
- *quotep = -1;
- else
- *quotep = *p;
- }
- else {
- cat_errno = E_NOSUCHCOMMAND;
- return -1;
- }
- if (strchr(buf, '\n') == 0) {
- int c;
- while ((c = getc(fp)) != '\n' && c != EOF)
- ;
- }
- return 0;
-}
-
-
-static
-VOID delete_set(table, setnum)
-struct message **table;
-unsigned setnum;
-{
- int i;
-
- for (i = 0; i < HASH_TAB_SIZE; i++) {
- struct message *p, *nextp;
- for (p = table[i], table[i] = 0; p; p = nextp) {
- nextp = p->next;
- if (p->setnum == setnum)
- free((char *)p);
- else {
- p->next = table[i];
- table[i] = p;
- }
- }
- }
-}
-
-static
-VOID delete_message(table, setnum, msgnum)
-struct message **table;
-unsigned setnum, msgnum;
-{
- struct message **pp;
-
- for (pp = &table[hash(setnum, msgnum)]; *pp; pp = &(*pp)->next)
- if ((*pp)->setnum == setnum && (*pp)->msgnum == msgnum) {
- struct message *p = *pp;
- *pp = p->next;
- free(p->text);
- free((char *)p);
- break;
- }
-}
-
-/* 0 success, -1 error. On error cat_errno is set to the error number. */
-
-static
-int read_catalog(fp, table)
-FILE *fp;
-struct message **table;
-{
- int c;
- unsigned setnum = NL_SETD;
- int quote_char = -1;
-
- for (;;) {
- /* start of line */
- c = getc(fp);
- if (c == EOF)
- break;
- ++current_lineno;
- if (isdigit(c)) {
- if (parse_message(c, fp, table, setnum, quote_char) < 0)
- return -1;
- }
- else if (c == '$') {
- if (parse_command(fp, table, &setnum, &quote_char) < 0)
- return -1;
- }
- else if (c != '\n') {
- while ((c = getc(fp)) != '\n' && c != EOF)
- if (c != ' ' && c != '\t') {
- cat_errno = E_BADLINE;
- return -1;
- }
- if (c == EOF)
- break;
- }
- }
- return 0;
-}
-
-static
-int hash(setnum, msgnum)
-unsigned setnum, msgnum;
-{
- return ((setnum << 8) + msgnum) % HASH_TAB_SIZE;
-}
-
-#ifdef GENCAT
-
-static char *program_name;
-
-static int message_compare P((UNIV, UNIV));
-static void print_text P((char *, FILE *));
-static void usage P((void));
-
-#ifdef VARARGS
-static void fatal();
-#else
-static void fatal P((char *,...));
-#endif
-
-int main(argc, argv)
-int argc;
-char **argv;
-{
- FILE *fp;
- int i, j, nmessages;
- struct message **list;
- unsigned setnum;
- struct message *table[HASH_TAB_SIZE];
-
- program_name = argv[0];
-
- if (argc < 3)
- usage();
-
- for (i = 0; i < HASH_TAB_SIZE; i++)
- table[i] = 0;
- for (i = 1; i < argc; i++) {
- errno = 0;
- fp = fopen(argv[i], "r");
- if (!fp) {
- if (i > 1)
- fatal("can't open `%s': %s", argv[i], strerror(errno));
- }
- else {
- current_lineno = 0;
- cat_errno = E_ZERO;
- if (read_catalog(fp, table) < 0) {
- assert(cat_errno != E_ZERO);
- assert(cat_errno
- < sizeof(cat_errlist)/sizeof(cat_errlist[0]));
- fatal("%s:%d: %s", argv[i], current_lineno,
- cat_errlist[cat_errno]);
- }
- fclose(fp);
- }
- }
-
- errno = 0;
- fp = fopen(argv[1], "w");
- if (!fp)
- fatal("can't open `%s' for output: %s", argv[1], strerror(errno));
- nmessages = 0;
- for (i = 0; i < HASH_TAB_SIZE; i++) {
- struct message *p;
- for (p = table[i]; p; p = p->next)
- nmessages++;
- }
- list = (struct message **)malloc(nmessages*sizeof(struct message *));
- if (!list)
- fatal("out of memory");
- j = 0;
- for (i = 0; i < HASH_TAB_SIZE; i++) {
- struct message *p;
- for (p = table[i]; p; p = p->next)
- list[j++] = p;
- }
- assert(j == nmessages);
-
- qsort((UNIV)list, nmessages, sizeof(struct message *), message_compare);
-
- setnum = NL_SETD;
- for (i = 0; i < nmessages; i++) {
- struct message *p = list[i];
- if (p->setnum != setnum) {
- setnum = p->setnum;
- fprintf(fp, "$set %u\n", setnum);
- }
- fprintf(fp, "%u ", p->msgnum);
- print_text(p->text, fp);
- putc('\n', fp);
- }
- if (fclose(fp) == EOF)
- fatal("error closing `%s'", argv[1]);
- return 0;
-}
-
-static
-VOID usage()
-{
- fprintf(stderr, "usage: %s catfile msgfile...\n", program_name);
- exit(1);
-}
-
-static
-#ifdef VARARGS
-VOID fatal(va_alist) va_dcl
-#else /* not VARARGS */
-VOID fatal(char *message,...)
-#endif /* not VARARGS */
-{
- va_list ap;
-
-#ifdef VARARGS
- char *message;
- va_start(ap);
- message = va_arg(ap, char *);
-#else /* not VARARGS */
- va_start(ap, message);
-#endif /* not VARARGS */
-
- fprintf(stderr, "%s: ", program_name);
- vfprintf(stderr, message, ap);
- putc('\n', stderr);
- va_end(ap);
- exit(1);
-}
-
-static
-int message_compare(p1, p2)
-UNIV p1;
-UNIV p2;
-{
- struct message *m1 = *(struct message **)p1;
- struct message *m2 = *(struct message **)p2;
-
- if (m1->setnum < m2->setnum)
- return -1;
- if (m1->setnum > m2->setnum)
- return 1;
- if (m1->msgnum < m2->msgnum)
- return -1;
- if (m1->msgnum > m2->msgnum)
- return 1;
- return 0;
-}
-
-static
-VOID print_text(s, fp)
-char *s;
-FILE *fp;
-{
- for (; *s; s++) {
- if (*s == '\\')
- fputs("\\\\", fp);
- else if (ISASCII(*s) && isprint((unsigned char)*s))
- putc(*s, fp);
- else {
- switch (*s) {
- case '\n':
- fputs("\\n", fp);
- break;
- case '\b':
- fputs("\\b", fp);
- break;
- case '\f':
- fputs("\\f", fp);
- break;
- case '\t':
- fputs("\\t", fp);
- break;
- case '\v':
- fputs("\\v", fp);
- break;
- case '\r':
- fputs("\\r", fp);
- break;
- default:
- fprintf(fp, "\\%03o", (unsigned char)*s);
- break;
- }
- }
- }
-}
-
-#endif /* GENCAT */
-
-#ifdef TEST
-
-int main(argc, argv)
-int argc;
-char **argv;
-{
- nl_catd catd;
- int msgnum, setnum;
-
- if (argc != 2) {
- fprintf(stderr, "usage: %s catalogue\n", argv[0]);
- exit(1);
- }
- catd = catopen(argv[1], 0);
- fprintf(stderr, "Enter set number, message number pairs:\n");
- fflush(stderr);
- while (scanf("%d %d", &setnum, &msgnum) == 2) {
- char *msg = catgets(catd, setnum, msgnum, "<default>");
- fprintf(stderr, "Returned \"%s\"\n", msg);
- fflush(stderr);
- }
- return 0;
-}
-
-#endif /* TEST */
-
-#endif /* not HAVE_CAT */
-/*
-Local Variables:
-c-indent-level: 5
-c-continued-statement-offset: 5
-c-brace-offset: -5
-c-argdecl-indent: 0
-c-label-offset: -5
-End:
-*/
diff --git a/usr.bin/sgmls/sgmls/msgcat.h b/usr.bin/sgmls/sgmls/msgcat.h
deleted file mode 100644
index 83e998a..0000000
--- a/usr.bin/sgmls/sgmls/msgcat.h
+++ /dev/null
@@ -1,13 +0,0 @@
-
-#ifdef HAVE_CAT
-#include <nl_types.h>
-#else
-typedef UNIV nl_catd;
-#endif
-
-/* Don't use prototypes here in case nl_types.h declares a conflicting
-prototype. */
-
-nl_catd catopen();
-int catclose();
-char *catgets();
diff --git a/usr.bin/sgmls/sgmls/pars1.c b/usr.bin/sgmls/sgmls/pars1.c
deleted file mode 100644
index 0a67cbc..0000000
--- a/usr.bin/sgmls/sgmls/pars1.c
+++ /dev/null
@@ -1,984 +0,0 @@
-#include "sgmlincl.h" /* #INCLUDE statements for SGML parser. */
-#define GI (tags[ts].tetd->etdgi+1) /* GI of current element. */
-#define NEWGI (newetd->etdgi+1) /* GI of new tag. */
-
-static VOID doincludes P((void));
-static int pentname P((char *));
-static struct mpos *newmpos P((void));
-static VOID commbufs P((void));
-static VOID checkdtd P((void));
-
-/* PARSECON: Parse content of an element.
-*/
-int parsecon(tbuf, pcb)
-UNCH *tbuf; /* Work area for tokenization. */
-struct parse *pcb; /* Parse control block for this parse. */
-{
- int srn; /* SHORTREF delimiter number (1-32). */
- int refrc; /* Return code from sentref, stagetd, etc. */
-
- TRACECON(etagimct, dostag, datarc, pcb, conrefsw, didreq);
- if (eodsw) return(EOD_);
- if (didreq && (conrefsw & TAGREF)) {didreq = 0; goto conr;}
- if (etagimct>0) {etagimsw = --etagimct ? 1 : 0; destack(); return(ETG_);}
- if (dostag) {
- conrefsw = conrefsv;
- etisw = etiswsv;
- if (charmode) {dostag = 0; return datarc;}
- return stag(datarc);
- }
- if (conrefsw) {
- conr:
- destack();
- conrefsw = 0;
- return ETG_;
- }
- else if (eofsw) return(EOD_);
-
- datarc = 0;
- while (1) {
- parse(pcb);
- srn = (int)pcb->action - SRMIN; /* Just in case it's a SHORTREF. */
- switch (pcb->action) {
- case DCE_: /* Data character in element content. */
- /* The data character might be a non-SGML character so
- reprocess it using pcbconm. */
- REPEATCC;
- pcb = conpcb = &pcbconm;
- pcb->newstate = pcbcnet;
- continue;
- case DAS_: /* Current character begins data. */
- data = FPOS;
- continue;
-
- case NLF_: /* NET or SR returns data in lookahead buffer. */
- datalen = (UNS)(ptcon - data); REPEATCC;
- goto rcc;
-
- case LAF_: /* Return data in lookahead buffer: mixed. */
- datalen = (UNS)(ptcon+1 - data);
- goto rcc;
-
- case NON_: /* Single nonchar in nonchbuf. */
- datalen = 2; data = nonchbuf;
- goto nrcc;
-
- case DAR_: /* Return data except for last char. */
- REPEATCC;
- case DAF_: /* Return data in source entity buffer. */
- datalen = (UNS)(FPOS - data);
- rcc:
- REPEATCC;
- case DEF_: /* Return data in data entity. */
- nrcc:
- datarc = DAF_;
- if (pcb==&pcbcone) {
- pcbconm.newstate = pcbcnet;
- conpcb = &pcbconm;
- }
- if (charmode) return(datarc);
- stagmin = MINNONE; stagreal = newetd = ETDCDATA;
- return(stag(datarc));
-
- case LAS_: /* Start lookahead buffer with current char. */
- *(ptcon = data = tbuf+1) = *FPOS;
- continue;
-
- case LAM_: /* Move character to lookahead buffer. */
- *++ptcon = *FPOS;
- continue;
-
- case STG_: /* Process non-null start-tag. */
- CTRSET(tagctr); /* Start counting tag length. */
- tages = es;
- parsenm(tbuf, NAMECASE); /* Get the GI. */
- newetd = etdref(tbuf);
- if (newetd && newetd->adl) {
- parseatt(newetd->adl, tbuf);
- adlval((int)ADN(al), newetd);
- }
- parsetag(&pcbstag); /* Parse the tag ending. */
- if ((CTRGET(tagctr)-tagdelsw)>=TAGLEN)
- sgmlerr(66, &pcbstag, (UNCH *)0, (UNCH *)0);
- if (!newetd) {
- sgmlerr(132, pcb, tbuf+1, (UNCH *)0);
- continue;
- }
- return(stagetd(&pcbstag));
-
- case NST_: /* Process null start-tag. */
- return nstetd();
-
- case ETC_: /* End-tag in CDATA or RCDATA. */
- case ETG_: /* Process non-null end-tag. */
- newetd = etdref(parsenm(tbuf, NAMECASE)); /* Get the GI. */
- parsetag(&pcbetag); /* Parse tag end. */
- if (!newetd) /* Error: undefined.*/
- sgmlerr(11, &pcbetag, tbuf+1, (UNCH *)0);
- else if (etagetd(&pcbetag)>=0) return ETG_;/* Open element. */
- if (pcb->action!=ETC_) continue;
- /* Tag is undefined or not for an open element and we are in
- a CDATA or RCDATA element; issue message and treat as
- null end-tag (</>).
- */
- sgmlerr(57, &pcbetag, (UNCH *)0, (UNCH *)0);
- case NET_: /* Process null end-tag. */
- if ((refrc = netetd(conpcb))!=0) return ETG_;
- continue;
-
- case NED_: /* Process null end-tag delimiter. */
- etagmin = MINNET;
- newetd = etagreal = ETDNET;
- etagimct = etag();
- etagimsw = etagimct ? 1 : 0; destack();
- return ETG_;
- case GTR_:
- if (entget()!=-1) {
- data = FPOS;
- continue;
- }
- /* fall through */
- case EOD_: /* End of primary file. */
- if (ts<1) return(EOD_); /* Normal end: stack is empty. */
- etagimct = ts-1; /* Treat as end-tag for top tag on stack. */
- etagmin = MINETAG; etagreal = tags[0].tetd;
- destack();
- eofsw = 1; /* Return EOD_ after destacking all. */
- return ETG_;
-
- /* Short references ending with blanks:
- If the blank sequence is followed by RE, go do SR7 or SR6.
- If the entity is undefined and we are in mixed content,
- the blanks must be returned as data. If not, they
- can be ignored.
- */
- case SR9_: /* Process SR9 (two or more blanks). */
- REPEATCC; /* Make first blank the CC. */
- case SR4_: /* Process SR4 (RS, blanks). */
- parseseq(tbuf, BSEQLEN); /* Squeeze out all blanks. */
- if (*FPOS=='\r') {srn = (srn==9) ? 7 : 6; data = tbuf; goto sr6;}
- else REPEATCC;
- if ((refrc = shortref(srn, pcb))==DEF_) goto nrcc;
- if (refrc>0) return refrc;
- if (refrc==ENTUNDEF && pcb==&pcbconm)
- {data = tbuf; goto nrcc;}
- continue;
-
- /* Short references ending with RE:
- If the reference is defined, the RE is ignored.
- For RE and RS RE,
- no special action is needed if the reference is undefined,
- as the RE will be processed immediately as the current character.
- For B RE and RS B RE,
- the input is primed with a special character that will
- be treated as an RE that cannot be a short reference.
- */
- case SR7_: /* Process SR7 (blanks, RE). */
- datalen = (UNS)(FPOS - data);
- case SR2_: /* Process SR2 (RE). */
- case SR5_: /* Process SR5 (RS, RE). */
- sr6: /* Process SR6 (RS, blanks, RE). */
- if ((refrc = shortref(srn, pcb))!=ENTUNDEF) {
- if (refrc==DEF_) goto nrcc; /* Defined: data entity. */
- if (refrc>0) return refrc; /* Defined: tag entity. */
- continue; /* Defined: not tag. */
- }
- if (pcb!=&pcbconm) continue; /* Not mixed; ignore chars. */
- if (srn>=6) /* Return blanks as data. */
- {*FPOS = lex.d.genre; REPEATCC; goto nrcc;}
- case REF_: /* Undefined SR with RE; return record end. */
- datarc = REF_;
- if (charmode) return(datarc);
-#if 0
- /* The standard says this situation can force a tag.
- See 323:3-6, 412:1-7. */
- /* If RE would be ignored, don't treat it as start-tag
- because it could force a required tag; but do change
- state to show that an RE was ignored.
- */
- if (scbsgml[pss].snext==scbsgmst) {
- scbsgml[pss].snext = scbsgmnr;
- TRACEGML(scbsgml, pss, conactsw, conact);
- continue;
- }
-#endif
- stagmin = MINNONE; stagreal = newetd = ETDCDATA;
- return(stag(datarc));
-
- case SR3_: /* Process SR3 (RS). */
- REPEATCC;
- if ((refrc = shortref(srn, pcb))==DEF_) goto nrcc;
- if (refrc>0) return refrc;
- continue;
-
- case RBR_: /* Two right brackets */
- srn = 26;
- REPEATCC;
- /* fall through */
- case SR1_: /* Process SR1 (TAB). */
- case SR8_: /* Process SR8 (space). */
- case SR19: /* Process SR19 (-). */
- case SR26: /* Process SR26 (]). */
- REPEATCC;
- goto srproc;
-
- case FCE_: /* Process free character (SR11-18, SR21-32). */
- fce[0] = *FPOS;
- srn = mapsrch(&lex.s.dtb[lex.s.fce], fce);
- case SR10: /* Process SR10 ("). */
- case SR11: /* Process SR11 (#). */
- case SR20: /* Process SR20 (-). */
- case SR25: /* Process SR25 ([). */
- srproc:
- if ((refrc = shortref(srn, pcb))==DEF_) goto nrcc;
- if (refrc>0) return refrc;
- if (refrc==ENTUNDEF) { /* Treat the SR as data. */
- data = FPOS - (srn==lex.s.hyp2);/* Two data chars if SR20.*/
- if (pcb!=&pcbconm) { /* If not in mixed content: */
- if (srn>=lex.s.data) { /* Change PCB. */
- pcb = conpcb = &pcbconm;
- pcb->newstate = pcbcnda;
- }
- }
- else pcb->newstate = pcbcnda;/* Now in data found state. */
- }
- continue;
-
- case ERX_: /* Entity ref in RCDATA: cancel ending delims.*/
- lexcon[lex.d.tago] = lex.l.fre;
- lexcon[lex.d.net] = lex.l.nonet;
- lexlms[lex.d.msc] = lex.l.fre;
- continue;
-
- case EE_: /* Entity end in RCDATA: check nesting. */
- if (es<rcessv) {synerr(37, pcb); rcessv = es;}
- /* If back at top level, re-enable the ending delimiters. */
- if (es==rcessv) {
- lexcon[lex.d.tago] = lex.l.tago;
- lexcon[lex.d.net] = etictr ? lex.l.net : lex.l.nonet;
- lexlms[lex.d.msc] = lex.l.msc;
- }
- continue;
-
- case PIE_: /* PI entity: same as PIS_. */
- return PIS_;
-
- case RSR_: /* Record start: ccnt=0; ++rcnt.*/
- ++RCNT; CTRSET(RSCC);
- return RSR_;
- case MSS_:
- if (ts == 0) synerr(217, pcb);
- return MSS_;
- default:
- return (int)pcb->action; /* Default (MD_ MDC_ MSS_ MSE_ PIS_). */
- }
- }
-}
-/* STAGETD: Process start-tag etd.
-*/
-int stagetd(pcb)
-struct parse *pcb; /* Parse control block for this parse. */
-{
- if (!newetd->etdmod) {
- sgmlerr(43, pcb, newetd->etdgi+1, (UNCH *)0);
- ++ds.etdercnt;
- etdset(newetd, (UNCH)SMO+EMO+ETDOCC, &undechdr,
- (PETD *)0, (PETD *)0, (PECB *)0);
- TRACEETD(newetd);
- }
- stagmin = MINNONE; stagreal = newetd;
- return stag(0);
-}
-/* NSTETD: Process null start-tag etd.
-*/
-int nstetd()
-{
- if (sd.omittag && ts > 0)
- newetd = tags[ts].tetd;
- else if (!sd.omittag && lastetd != 0)
- newetd = lastetd;
- else
- newetd = tags[0].tetd->etdmod[2].tu.thetd;
- stagmin = MINNULL; stagreal = ETDNULL;
- etisw = 0;
- return stag(0);
-}
-/* ETAGETD: Process end-tag etd.
-*/
-int etagetd(pcb)
-struct parse *pcb; /* Parse control block for this parse. */
-{
- etagmin = MINNONE; etagreal = newetd;
- if ((etagimct = etag())<0) {
- sgmlerr(E_ETAG, pcb, NEWGI, tags[ts].tetd->etdgi+1);
- return etagimct;
- }
- etagimsw = etagimct ? 1 : 0; destack();
- return ETG_;
-}
-/* NETETD: Process null end-tag etd.
-*/
-int netetd(pcb)
-struct parse *pcb; /* Parse control block for this parse. */
-{
- if (ts<1) {
- sgmlerr(51, pcb, (UNCH *)0, (UNCH *)0);
- return 0;
- }
- etagmin = MINNULL; etagreal = ETDNULL;
- etagimsw = 0; destack();
- return ETG_;
-}
-/* SHORTREF: Process a short (alternative) reference to an entity.
- Returns ENTUNDEF if entity is not defined, otherwise returns
- the return code from stagetd or etagetd if the entity was
- a tag, or zero if an error occurred somewhere.
-*/
-int shortref(srn, pcb)
-int srn; /* Short reference number. */
-struct parse *pcb; /* Parse control block for this parse. */
-{
- int rc; /* Return code from entopen. */
-
- if (tags[ts].tsrm==SRMNULL || !tags[ts].tsrm[srn]) return ENTUNDEF;
- rc = entopen(tags[ts].tsrm[srn]);
- if (rc==ENTDATA) return DEF_;
- if (rc==ENTPI) return PIS_;
- return(0);
-}
-/* PARSEPRO: Parse prolog.
- Note: ptpro cannot overrun tbuf (and therefore needn't be
- tested), as long as the buffer exceeds the longest
- lookahead sequence in the content parse tables.
-*/
-int parsepro()
-{
- struct parse *oldpcb;
-
- while (1) {
- int rc; /* Return code: DAF MSS DCE */
- switch (parse(propcb)) {
-
- case LAS_: /* Start lookahead buffer with current char. */
- *(ptpro = data = tbuf+1) = *FPOS;
- continue;
- case LAM_: /* Move character to lookahead buffer. */
- *++ptpro = *FPOS;
- continue;
- case LAF_: /* Return data in lookahead buffer. */
- datalen = (UNS)(ptpro+1 - data);
- REPEATCC;
- rc = DAF_;
- break; /* Prolog ended; data pending. */
-
- case DTD_: /* Process document type declaration. */
- parsenm(tbuf, NAMECASE); /* Get declaration name. */
- if (!ustrcmp(tbuf+1, sgmlkey)
- && !dtdsw && !sgmlsw++) {
-#if 0
- parse(&pcbmdi);
-#endif
- /* If we got some appinfo, return. */
- if (sgmldecl())
- return APP_;
- continue;
- }
- if (!ustrcmp(tbuf+1, key[KDOCTYPE]) && !dtdsw++) {
- startdtd();
- mddtds(tbuf);
- continue;
- }
- sgmlerr(E_MDNAME, propcb, tbuf+1, (UNCH *)0);
- continue;
- case DTE_: /* DOCTYPE declaration (and prolog) ended. */
- REPEATCC; /* Put back char that followed MSC. */
- if (es != 0)
- sgmlerr(143, propcb, (UNCH *)0, (UNCH *)0);
- else if (dtdrefsw) {/* Process referenced DTD before real DTE. */
- dtdrefsw = 0; /* Keep us from coming through here again. */
- REPEATCC; /* Put back MSC so it follows referenced DTD. */
- entref(indtdent);
- }
- else {
- if (mslevel > 0) {
- sgmlerr(230, propcb, (UNCH *)0, (UNCH *)0);
- mslevel = 0;
- msplevel = 0;
- }
- mddtde(tbuf);
- }
- continue;
-
- case MD_:
- /* Process markup declaration within DTD or LPD. */
- parsenm(tbuf, NAMECASE); /* Get declaration name. */
- if (!ustrcmp(tbuf+1, key[KENTITY]))
- mdentity(tbuf);
- else if (!ustrcmp(tbuf+1, key[KUSEMAP]))
- mdsrmuse(tbuf);
- else if (!ustrcmp(tbuf+1, key[KATTLIST]))
- mdadl(tbuf);
- else if (!ustrcmp(tbuf+1, key[KSHORTREF]))
- mdsrmdef(tbuf);
- else if (!ustrcmp(tbuf+1, key[KELEMENT]))
- mdelem(tbuf);
- else if (!ustrcmp(tbuf+1, key[KNOTATION]))
- mdnot(tbuf);
- else
- sgmlerr(E_MDNAME, propcb, tbuf+1, (UNCH *)0);
- continue;
- case MDC_: /* Process markup declaration comment. */
- sgmlsw++; /* SGML declaration not allowed after comment */
- parsemd(tbuf, NAMECASE, (struct parse *)0, NAMELEN);
- continue;
-
- case MSS_: /* Process marked section start. */
- oldpcb = propcb;
- propcb = mdms(tbuf, propcb);
- if (propcb==&pcbmsc || propcb==&pcbmsrc) {
- if (oldpcb == &pcbmds)
- sgmlerr(135, oldpcb, (UNCH *)0, (UNCH *)0);
- conpcb = propcb;
- rc = DCE_;
- break;
- }
- continue;
- case MSE_: /* Process marked section end. */
- if (mdmse()) propcb = &pcbmds;
- continue;
- case MSP_: /* Marked section start in prolog outside DTD */
- rc = MSS_;
- break;
- case PIE_: /* PI entity: same as PIS_. */
- return(PIS_);
-
- case EOD_: /* Return end of primary entity. */
- if (dtdsw && propcb == &pcbpro) {
- /* We've had a DTD, so check it. */
- setdtype();
- checkdtd();
- }
- if (!sw.onlypro || propcb != &pcbpro || !dtdsw)
- sgmlerr(127, propcb, (UNCH *)0, (UNCH *)0);
- return propcb->action;
- case PIS_: /* Return processing instruction (string). */
- sgmlsw++; /* SGML declaration not allowed after PI */
- return((int)propcb->action); /* Prolog will continue later. */
-
- case CIR_: /* Chars ignored; trying to resume parse. */
- synerr(E_RESTART, propcb);
- REPEATCC;
- continue;
- case ETE_: /* End tag ended prolog */
- REPEATCC;
- /* fall through */
- case STE_: /* Start tag ended prolog */
- REPEATCC;
- REPEATCC;
- rc = STE_;
- break;
- case PEP_: /* Previous character ended prolog. */
- REPEATCC;
- case DCE_: /* Data character ended prolog. */
- REPEATCC;
- rc = DCE_;
- break;
- case EE_: /* Illegal entity end in ignored marked section. */
- /* An error message has already been given. */
- continue;
- default:
- abort();
- } /* switch */
- setdtype(); /* First pass only: set document type. */
- checkdtd();
- if (sw.onlypro)
- return EOD_;
- TRACESET(); /* Set trace switches. */
- endprolog();
- /* *DOC is first element; stack it at level 0. */
- stack(newetd = nextetd = stagreal = etagreal = docetd);
- return(rc);
- } /* while */
-}
-
-/* Allocate buffers that are used in the DTD. */
-
-VOID startdtd()
-{
- nmgrp = (struct etd **)rmalloc((GRPCNT+1)*sizeof(struct etd *));
- nnmgrp = (PDCB *)rmalloc((GRPCNT+1)*sizeof(PDCB));
- gbuf = (struct thdr *)rmalloc((GRPGTCNT+3)*sizeof(struct thdr));
- /* The extra 1 is for parsing the name of a parameter entity in
- mdentity(). */
- nmbuf = (UNCH *)rmalloc(NAMELEN+3);
- pubibuf = (UNCH *)rmalloc(LITLEN+1);
- sysibuf = (UNCH *)rmalloc(LITLEN+1);
- commbufs();
- doincludes();
-}
-
-static
-VOID checkdtd()
-{
- struct dcncb *np;
- struct srh *sp;
-
- if (sw.swundef) {
- int i;
- struct etd *ep;
-
- for (i = 0; i < ETDHASH; i++)
- for (ep = etdtab[i]; ep; ep = ep->etdnext)
- if (!ep->etdmod)
- sgmlerr(140, (struct parse *)0, ep->etdgi + 1,
- (UNCH *)0);
- }
- for (sp = srhtab[0]; sp; sp = sp->enext)
- if (sp->srhsrm[0] == 0)
- sgmlerr(152, (struct parse *)0, sp->ename + 1, (UNCH *)0);
- else {
- int i;
- for (i = 1; i < lex.s.dtb[0].mapdata + 1; i++) {
- struct entity *ecb = sp->srhsrm[i];
- if (ecb && !ecb->estore) {
- sgmlerr(93, (struct parse *)0,
- ecb->ename + 1,
- sp->srhsrm[0]->ename + 1);
- sp->srhsrm[i] = 0;
- }
- }
- }
- for (np = dcntab[0]; np; np = np->enext)
- if (!np->defined)
- sgmlerr(192, (struct parse *)0, np->ename + 1, (UNCH *)0);
-}
-
-/* Return non-zero if s is a valid parameter entity name.
-If so put a transformed name in entbuf. */
-
-static
-int pentname(s)
-char *s;
-{
- int i;
- if (lextoke[(UNCH)*s] != NMS)
- return 0;
- entbuf[2] = ENTCASE ? lextran[(UNCH)*s] : (UNCH)*s;
- for (i = 1; s[i]; i++) {
- if (i > NAMELEN - 1)
- return 0;
- if (lextoke[(UNCH)s[i]] < NMC || s[i] == EOBCHAR)
- return 0;
- entbuf[i + 2] = ENTCASE ? lextran[(UNCH)s[i]] : (UNCH)s[i];
- }
- entbuf[1] = lex.d.pero;
- entbuf[i + 2] = '\0';
- entbuf[0] = (UNCH)(i + 3); /* length byte, PERO and '\0' */
- return 1;
-}
-
-/* Handle sw.includes. */
-
-static
-VOID doincludes()
-{
- char **p;
- if (!sw.includes)
- return;
- for (p = sw.includes; *p; p++) {
- if (pentname(*p)) {
- if (!entfind(entbuf)) {
- union etext etx;
- etx.c = savestr(key[KINCLUDE]);
- entdef(entbuf, ESM, &etx);
- ++ds.ecbcnt;
- ds.ecbtext += ustrlen(key[KINCLUDE]);
- }
- }
- else
- sgmlerr(138, (struct parse *)0, (UNCH *)*p, (UNCH *)0);
- }
-}
-
-/* Allocate buffers that are use both in the DTD and the instance. */
-
-static
-VOID commbufs()
-{
- al = (struct ad *)rmalloc((ATTCNT+2)*sizeof(struct ad));
- lbuf = (UNCH *)rmalloc(LITLEN + 1);
-}
-
-static
-struct mpos *newmpos()
-{
- int j;
- unsigned long *h;
- struct mpos *p = (struct mpos *)rmalloc((GRPLVL+2)*sizeof(struct mpos));
-
- assert(grplongs > 0);
- h = (unsigned long *)rmalloc((GRPLVL+2)*grplongs*sizeof(unsigned long));
- for (j = 0; j < GRPLVL+2; j++) {
- p[j].h = h;
- h += grplongs;
- }
- return p;
-}
-
-/* Perform end of prolog buffer allocation. */
-
-VOID endprolog()
-{
- int i;
-
- ambigfree();
- if (dtdsw) {
- frem((UNIV)nmgrp);
- frem((UNIV)nnmgrp);
- frem((UNIV)gbuf);
- frem((UNIV)nmbuf);
- frem((UNIV)sysibuf);
- frem((UNIV)pubibuf);
- }
- else {
- commbufs();
- doincludes();
- }
- scbsgml = (struct restate *)rmalloc((TAGLVL+1)*sizeof(struct restate));
- tags = (struct tag *)rmalloc((TAGLVL+1)*sizeof(struct tag));
- grplongs = (GRPCNT + LONGBITS - 1)/LONGBITS;
- for (i = 0; i < TAGLVL+1; i++)
- tags[i].tpos = newmpos();
- savedpos = newmpos();
-}
-
-/* SETDTYPE: Establish specified or default document type.
-*/
-VOID setdtype()
-{
- /* Initialize default model hdr for declared content. */
- undechdr.ttype = MANY+MCHARS+MGI; /* Declared content is ANY. */
- undechdr.tu.tnum = 0; /* No content model. */
-
- /* Initialize content model and etd for *DOC. */
- prcon[0].ttype = MGI; /* Model is an element model. */
- prcon[0].tu.tnum = 2; /* A single group with a single GI in it. */
- prcon[1].ttype = TTSEQ; /* Non-repeatable SEQ group. */
- prcon[1].tu.tnum = 1; /* Only one token in group. */
- prcon[2].ttype = TTETD; /* Token is an etd. */
- docetd = etddef(indocetd); /* etd for document as a whole. */
- etdset(docetd, ETDOCC, prcon, (PETD *)0, (PETD *)0, SRMNULL);
-
- /* Put specified or default document type etd in *DOC model. */
- if (!dtype) {
- sgmlerr(E_DOCTYPE, propcb, (UNCH *)0, (UNCH *)0);
- dtype = indefetd;
- }
- prcon[2].tu.thetd = etddef(dtype);
- if (!prcon[2].tu.thetd->etdmod) {
- if (dtype != indefetd)
- sgmlerr(52, propcb, dtype+1, (UNCH *)0);
- ++ds.etdercnt;
- etdset(prcon[2].tu.thetd, (UNCH)SMO+EMO+ETDUSED+ETDOCC, &undechdr,
- (PETD *)0, (PETD *)0, (PECB *)0);
- }
- TRACEETD(docetd);
- TRACEMOD(prcon);
- TRACEETD(prcon[2].tu.thetd);
- return;
-}
-/* PARSETAG: Tag end parser for SGML documents.
- For start-tags, it
- sets etisw to TAGNET if tag ended with ETI; otherwise to 0.
-*/
-VOID parsetag(pcb)
-struct parse *pcb; /* Parse control block: pcbstag or pcbetag. */
-{
- tagdelsw = 1; /* Assume tag had an ETI or TAGC. */
- switch (parse(pcb)) {
- case ETIC: /* Tag closed with ETI. */
- if (!sd.shorttag) synerr(194, pcb);
- etisw = TAGNET; /* Set switch for stack entry flag. */
- return;
- case DSC:
- synerr(9, pcb);
- REPEATCC;
- etisw = 0;
- return;
- case NVS: /* Att name or value token found. */
- case NTV: /* Name token value found. */
- synerr(E_POSSATT, pcb);
- pcb->newstate = 0; /* Reset parse state. */
- REPEATCC; /* Put it back for next read. */
- tagdelsw = 0; /* Tag had no closing delimiter. */
- etisw = 0; /* Don't flag stack entry. */
- return;
- case TAGO: /* Tag closing implied by TAGO. */
- if (!sd.shorttag) synerr(193, pcb);
- REPEATCC; /* Put it back for next read. */
- tagdelsw = 0; /* Tag had no closing delimiter. */
- case TAGC: /* Normal close. */
- default: /* Invalid character (msg was sent). */
- etisw = 0; /* Don't flag stack entry. */
- return;
- }
-}
-/* STAG: Check whether a start-tag is valid at this point in the document
- structure, or whether other tags must precede it.
- Special case processing is done for the fake tag, #CDATA, as
- it is never stacked.
-*/
-int stag(dataret)
-int dataret; /* Data pending: DAF_ REF_ 0=not #PCDATA. */
-{
- int rc, realrc; /* Return code from context or other test. */
- int mexts = 0; /* >0=stack level of minus grp; -1=plus; 0=none.*/
-
- badresw = pexsw = 0;
- /* If real element (i.e., not #PCDATA) set mexts and test if empty. */
- if (dataret==0) {
- mexts = pexmex(newetd);
- /* If element is declared empty, it is same as a conref. */
- if (GET(newetd->etdmod->ttype, MNONE)) conrefsw = TAGREF;
- }
- if (GET(tags[ts].tetd->etdmod->ttype, MANY))
- rc = mexts>0 ? RCMEX : RCHIT;
- else rc = context(newetd, tags[ts].tetd->etdmod, tags[ts].tpos,
- &tags[ts].status, mexts);
- TRACESTG(newetd, dataret, rc, nextetd, mexts);
-
- switch (rc) {
- case RCEND: /* End current element, then retry start-tag. */
- if (ts<1) realrc = RCMISS;
- else realrc = RCEND;
- break;
- case RCREQ: /* Stack compulsory GI, then retry start-tag. */
- realrc = RCREQ;
- break;
- case RCMISS: /* Start-tag invalid (#PCDATA or real). */
- if (ts>0 && GET(tags[ts].tetd->etdmod->ttype, MANY))
- realrc = RCEND;
- else realrc = RCMISS;
- break;
- case RCMEX: /* Start-tag invalid (minus exception). */
- etagimct = ts - mexts;
- realrc = RCEND;
- break;
- case RCHITMEX: /* Invalid minus exclusion for required element. */
- sgmlerr(216, &pcbstag, NEWGI, tags[mexts].tetd->etdgi+1);
- /* fall through */
- case RCHIT: /* Start-tag was valid. */
- realrc = RCHIT;
- break;
- case RCPEX: /* Start-tag valid only because of plus exception. */
- pexsw = TAGPEX;
- realrc = RCHIT;
- break;
- default:
- abort();
- }
-
- switch (realrc) {
- case RCEND: /* End current element, then retry start-tag. */
- if (didreq) sgmlerr(07, &pcbstag, nextetd->etdgi+1, (UNCH *)0);
- didreq = 0; /* No required start-tag done. */
- dostag = 1; etiswsv = etisw; /* Save real start-tag status. */
- conrefsv = conrefsw; /* Save real start-tag conref. */
- conrefsw = 0; /* Current element is not empty. */
- etagmin = MINSTAG; destack(); /* Process omitted end-tag. */
- return ETG_;
- case RCREQ: /* Stack compulsory GI, then retry start-tag. */
- if (!BADPTR(nextetd)) {
- if ((mexts = pexmex(nextetd))>0)
- sgmlerr(E_MEXERR, &pcbstag, nextetd->etdgi+1,
- tags[mexts].tetd->etdgi+1);
- if (!nextetd->etdmod) {
- sgmlerr(53, &pcbstag, nextetd->etdgi+1, (UNCH *)0);
- etdset(nextetd, (UNCH)SMO+EMO+ETDOCC, &undechdr,
- (PETD *)0, (PETD *)0, (PECB *)0);
- ++ds.etdercnt;
- TRACEETD(nextetd);
- }
- }
- if (BITOFF(nextetd->etdmin, SMO)) {
- if (!BADPTR(stagreal))
- sgmlerr(21, &pcbstag, nextetd->etdgi+1, stagreal->etdgi+1);
- else if (stagreal==ETDCDATA)
- sgmlerr(49, &pcbstag, nextetd->etdgi+1, (UNCH *)0);
- else sgmlerr(50, &pcbstag, nextetd->etdgi+1, (UNCH *)0);
- }
- didreq = 1; /* Required start-tag done. */
- dostag = 1; etiswsv = etisw; /* Save real start-tag status. */
- etisw = 0; conrefsv = conrefsw; /* Save real start-tag conref. */
- /* If element is declared empty, it is same as a conref. */
- conrefsw = (GET(nextetd->etdmod->ttype, MNONE)) ? TAGREF : 0;
- stack(nextetd); /* Process omitted start-tag. */
- return STG_;
- case RCMISS: /* Start-tag invalid (#PCDATA or actual). */
- dostag = 0; contersw |= 1; didreq = 0;
- if (dataret) {
- if (dataret==REF_) badresw = 1;
- else sgmlerr(E_CHARS, conpcb, tags[ts].tetd->etdgi+1, (UNCH *)0);
- return dataret;
- }
- sgmlerr(E_CONTEXT, &pcbstag, NEWGI, tags[ts].tetd->etdgi+1);
- if (stagmin!=MINNULL) stagmin = MINNONE; stack(newetd);
- return STG_;
- case RCHIT: /* Start-tag was valid. */
- dostag = 0; didreq = 0;
- if (dataret) return dataret;
- stack(newetd);
- return STG_;
- }
- return NOP_; /* To avoid Borland C++ warning */
-}
-/* PEXMEX: See if a GI is in a plus or minus exception group on the stack.
- If in a minus, returns stack level of minus group; otherwise,
- returns -1 if in a plus and not a minus, and zero if in neither.
-*/
-int pexmex(curetd)
-struct etd *curetd; /* The etd for this GI. */
-{
- int tsl; /* Temporary stack level for looping. */
- int pex = 0; /* 1=found in plus grp; 0=not. */
-
- for (tsl = ts; tsl>0; --tsl) {
- if (tags[tsl].tetd->etdmex && ingrp(tags[tsl].tetd->etdmex, curetd))
- return(tsl);
- if (tags[tsl].tetd->etdpex && ingrp(tags[tsl].tetd->etdpex, curetd))
- pex = -1;
- }
- return(pex);
-}
-/* STACK: Add a new entry to the tag stack.
- If there is no room, issue a message and reuse last position.
-*/
-VOID stack(curetd)
-struct etd *curetd; /* The etd for this entry. */
-{
- /* Stack the new element type definition (error if no room). */
- if (++ts>TAGLVL)
- sgmlerr(E_STAGMAX, conpcb, curetd->etdgi+1, tags[--ts].tetd->etdgi+1);
- tags[ts].tetd = curetd;
-
- /* Set flags: plus exception + tag had ETI + context error + empty. */
- tags[ts].tflags = (UNCH)pexsw + etisw + contersw + conrefsw; contersw = 0;
-
- /* If tag had ETI, update ETI counter and enable NET if first ETI. */
- if (etisw && ++etictr==1) lexcon[lex.d.net] = lexcnm[lex.d.net] = lex.l.net;
-
- /* If etd has ALT table, use it; otherwise, use last element's ALT. */
- if (curetd->etdsrm) {
- if (curetd->etdsrm != SRMNULL && curetd->etdsrm[0] == NULL) {
- /* Map hasn't been defined. Ignore it.
- We already gave an error. */
- curetd->etdsrm = 0;
- tags[ts].tsrm = tags[ts-1].tsrm;
- }
- else
- tags[ts].tsrm = curetd->etdsrm;
- }
- else
- tags[ts].tsrm = tags[ts-1].tsrm;
-
- /* Initialize rest of stack entry. */
- tags[ts].status = 0;
- tags[ts].tpos[0].g = 1; /* M: Index in model of next token to test.*/
- tags[ts].tpos[0].t = 1; /* P: Index in tpos of current group. */
- HITCLEAR(tags[ts].tpos[0].h);
- tags[ts].tpos[1].g = 1; /* Index of group in model (dummy grp). */
- tags[ts].tpos[1].t = 1; /* 1st token is next in grp to be tested. */
- HITCLEAR(tags[ts].tpos[1].h); /* No hits yet as yet. */
- TRACESTK(&tags[ts], ts, etictr);
- return;
-}
-/* ETAG: Check validity of an end-tag by seeing if it matches any tag
- on the stack. If so, return the offset of the match from the
- current entry (0=current). If there is no match, issue a message
- and return an error code (-1).
- If the newetd is ETDNET, a NET delimiter was found, so check for
- a tag that ended with ETI instead of a matching GI.
-*/
-int etag()
-{
- int tsl = ts+1; /* Temporary stack level for looping. */
-
- /* See if end-tag is anywhere on stack, starting at current entry. */
- while (--tsl) {
- if (newetd!=ETDNET ? newetd==tags[tsl].tetd : tags[tsl].tflags) {
- TRACEETG(&tags[ts], newetd, tsl, ts-tsl);
- return(ts-tsl);
- }
- }
- return (-1); /* End-tag didn't match any start-tag. */
-}
-/* DESTACK:
- Call ECONTEXT to see if element can be ended at this point.
- and issue message if there are required tags left.
- Remove the current entry from the tag stack.
- Issue an error if the destacked element was not minimizable
- and its end-tag was omitted.
-*/
-VOID destack()
-{
- register int ecode = 0; /* Error code (0=o.k.). */
- UNCH *eparm2 = NULL; /* Second parameter of error message. */
- register int minmsgsw; /* 1=message if tag omitted; 0=no message. */
-
- /* If element has a content model (i.e., not a keyword) and there
- are required tags left, and no CONREF attribute was specified,
- issue an error message.
- */
- lastetd = tags[ts].tetd;
- if (!GET(tags[ts].tetd->etdmod->ttype, MKEYWORD)
- && !conrefsw
- && !econtext(tags[ts].tetd->etdmod, tags[ts].tpos, &tags[ts].status)) {
- if (BADPTR(nextetd))
- sgmlerr(54, conpcb, tags[ts].tetd->etdgi+1, (UNCH *)0);
- else
- sgmlerr(30, conpcb, tags[ts].tetd->etdgi+1, nextetd->etdgi+1);
- }
- /* If the current tag ended with ETI, decrement the etictr.
- If etictr is now zero, disable the NET delimiter.
- */
- if (GET(tags[ts--].tflags, TAGNET) && --etictr==0)
- lexcon[lex.d.net] = lexcnm[lex.d.net] = lex.l.nonet;
-
- minmsgsw = BITOFF(tags[ts+1].tetd->etdmin, EMO);
- if (!conrefsw && minmsgsw && (etagimsw || etagmin==MINETAG)) {
- /* Minimization caused by NET delimiter. */
- if (BADPTR(etagreal)) ecode = 46;
- /* Minimization caused by a containing end-tag. */
- else {ecode = 20; eparm2 = etagreal->etdgi+1;}
- }
- else if (!conrefsw && etagmin==MINSTAG && (minmsgsw || ts<=0)) {
- /* Minimization caused by out-of-context start-tag. */
- if (!BADPTR(stagreal)) {
- ecode = ts>0 ? 39 : 89;
- eparm2 = stagreal->etdgi+1;
- }
- /* Minimization caused by out-of-context data. */
- else if (stagreal==ETDCDATA) ecode = ts>0 ? 47 : 95;
- /* Minimization caused by out-of-context short start-tag. */
- else ecode = ts>0 ? 48 : 96;
- if (ts<=0 && ecode) eodsw = 1;
- }
- if (ecode) sgmlerr((UNS)ecode, conpcb, tags[ts+1].tetd->etdgi+1, eparm2);
- /* TEMP: See if parser bug caused stack to go below zero. */
- else if (ts<0) {sgmlerr(64, conpcb, (UNCH *)0, (UNCH *)0); ts = 0;}
- TRACEDSK(&tags[ts], &tags[ts+1], ts, etictr);
- if (ts == 0) {
- docelsw = 1; /* Finished document element. */
- if (es > 0) sgmlerr(231, conpcb, (UNCH *)0, (UNCH *)0);
- }
-}
-/*
-Local Variables:
-c-indent-level: 5
-c-continued-statement-offset: 5
-c-brace-offset: -5
-c-argdecl-indent: 0
-c-label-offset: -5
-comment-column: 30
-End:
-*/
diff --git a/usr.bin/sgmls/sgmls/pars2.c b/usr.bin/sgmls/sgmls/pars2.c
deleted file mode 100644
index 4249797..0000000
--- a/usr.bin/sgmls/sgmls/pars2.c
+++ /dev/null
@@ -1,1333 +0,0 @@
-#include "sgmlincl.h" /* #INCLUDE statements for SGML parser. */
-/* PARSE: Parse a source input stream with specified lexical and state tables.
- Return to caller with action code.
-*/
-int parse(pcb)
-struct parse *pcb; /* Current parse control block. */
-{
- int rc; /* Return code from ENTREF. */
-
- while (1) {
- NEWCC;
- pcb->input = pcb->plex[*FPOS];
- pcb->state = pcb->newstate;
- pcb->newstate = (*(pcb->ptab + pcb->state)) [pcb->input];
- pcb->action = (*(pcb->ptab + pcb->state + 1)) [pcb->input];
- TRACEPCB(pcb);
- switch (pcb->action) {
- case RC2_: /* Back up two characters. */
- REPEATCC;
- case RCC_: /* Repeat current character. */
- REPEATCC;
- case NOP_: /* No action necessary.*/
- continue;
-
- case RS_: /* Record start: ccnt=0; ++rcnt.*/
- ++RCNT; CTRSET(RSCC);
- continue;
-
- case GET_: /* EOB or dull EOS or EE found: keep going.*/
- if (entget()==-1) {pcb->action = EOD_; break;}/* Signal if EOD.*/
- continue;
-
- case EOF_: /* Illegal entity end; return EE_. */
- synerr(E_EOF, pcb);
- pcb->action = EE_;
- case EE_: /* Important EOS or EE found: return to caller.*/
- if (entget()==-1) pcb->action = EOD_; /* Signal if EOD. */
- break;
-
- case PER_: /* Parameter entity reference. */
- REPEATCC; /* Use PERO as 1st char of entity name. */
- parsenm(entbuf, ENTCASE);
- parse(&pcbref); /* Handle REFC or other terminator. */
- rc = entref(entbuf);
- if (rc==ENTPI) {pcb->action = PIE_; break;}
- continue;
-
- case ER_: /* General entity reference; continue. */
- parsenm(entbuf, ENTCASE);
- parse(&pcbref); /* Handle REFC or other terminator. */
- rc = entref(entbuf);
- if (rc==ENTDATA) {pcb->action = DEF_; break;}
- if (rc==ENTPI) {pcb->action = PIE_; break;}
- continue;
-
-
- case PEX_: /* Parameter entity reference; return. */
- REPEATCC; /* Use PERO as 1st char of entity name. */
- case ERX_: /* General entity reference; return. */
- parsenm(entbuf, ENTCASE);
- parse(&pcbref); /* Handle REFC or other terminator. */
- rc = entref(entbuf);
- if (rc == ENTDATA){
- /* Reference to external data/subdoc entity in replaceable
- character data. */
- if (BITON(entdatsw, NDECONT)) {
- switch (((PNE)data)->nextype) {
- case ESNCDATA:
- case ESNSDATA:
- /* The standard says `non-SGML data entity'
- but the amendment should have changed it
- to `external data entity'. */
- synerr(145, pcb);
- break;
- case ESNNDATA:
- case ESNSUB:
- /* This is definitely illegal. */
- synerr(141, pcb);
- break;
- }
- entdatsw = 0;
- continue;
- }
- pcb->action = DEF_;
- }
- else if (rc == ENTPI) {
- /* Reference to PI entity not allowed in replaceable
- character data. */
- synerr(59, pcb);
- entpisw = 0;
- continue;
- }
- else if (rc) pcb->action = EE_;
- break;
-
- case CRN_: /* Character reference: numeric. */
- parsetkn(entbuf, NU, NAMELEN);
- parse(&pcbref); /* Handle reference terminator. */
- pcb->action = charrefn(entbuf, pcb);
- if (pcb->action==CRN_) continue; /* Invalid reference */
- break;
-
- case CRA_: /* Character reference: alphabetic. */
- parsenm(entbuf, NAMECASE);
- parse(&pcbref); /* Handle reference terminator. */
- charrefa(entbuf);
- if (docelsw) synerr(232, pcb);
- continue;
-
- case SYS_: /* Invalid NONCHAR: send msg and ignore. */
- synerr(E_SYS, pcb);
- if (*FPOS == DELNONCH) NEWCC;
- continue;
-
- case NON_: /* Valid NONCHAR: prefix and shift encoding. */
- synerr(60, pcb);
- pcb->action = datachar(*FPOS, pcb);
- break;
- case NSC_:
- synerr(60, pcb);
- NEWCC;
- nonchbuf[1] = *FPOS;
- pcb->action = NON_;
- break;
- case PCI_: /* Previous character was invalid (INV_). */
- REPEATCC;
- case INV_: /* Markup ended by invalid char; repeat char. */
- synerr(9, pcb);
- REPEATCC;
- break;
-
- case LNR_: /* Previous char exceeded len; back up to it. */
- REPEATCC;
- case LEN_: /* Token too long; ignore excess character. */
- synerr(3, pcb);
- continue;
-
- case RCR_: /* Repeat current char and return to caller. */
- REPEATCC;
- default: /* Actions for specific parse. */
- break;
- }
- return (int)pcb->action;
- }
-}
-/* CHARREFA: Resolve an alphabetical reference to a function character
- and put the character in the read buffer.
- If reference is bad, issue an error message.
-*/
-VOID charrefa(r)
-UNCH *r; /* Undelimited char ref (with length and EOS). */
-{
- UNCH thechar;
-
- thechar = mapsrch(funtab, r+1);
- if (thechar == 0)
- synerr(62, &pcbref);
- else {
- /* This isn't ideal, because the character position will still
- be wrong for one line. */
- if (thechar == RSCHAR) RCNT--;
- setcurchar(thechar);
- REPEATCC;
- }
-}
-
-/* Make the current character ch. */
-
-VOID setcurchar(ch)
-int ch;
-{
- /* If we're reading directly from an internal entity, we can't
- change the entity, since the entity might be referenced again.
- So in this case we copy the entity. This is inefficient, but
- it will only happen in a case like this:
-
- <!entity % amp "&">
- <!entity e "x%amp;#SPACE;">
-
- Usually character references will have been processed while the
- entity was being defined. */
- if (*FPOS != ch) {
- if (!FILESW && !COPIEDSW) {
- UNCH *s = savestr(FBUF + 1);
- FPOS = s + (FPOS - FBUF - 1);
- FBUF = s - 1;
- COPIEDSW = 1;
- }
- *FPOS = ch;
- }
-}
-
-/* CHARREFN: Resolve a numeric character reference.
- If reference is bad, issue an error message.
-*/
-
-int charrefn(r, pcb)
-UNCH *r; /* Undelimited character reference. */
-struct parse *pcb; /* Current parse control block. */
-{
- int thechar;
-
- thechar = atoi((char *)r);
- if (thechar<0 || thechar>255) {
- synerr(61, &pcbref);
- return((int)pcb->action);
- }
- return datachar(thechar, pcb);
-}
-
-/* Return ch as a datachar. If this a non-SGML character which might
-confuse the parser, shift it to a code that won't and place it in a
-special buffer which has DELNONCH in the preceding byte. Otherwise
-put it the read buffer. */
-
-int datachar(ch, pcb)
-int ch;
-struct parse *pcb;
-{
- switch (ch) {
- case EOS:
- case EOFCHAR:
- case EOBCHAR:
- case GENRECHAR:
- case DELCDATA:
- case DELSDATA:
- case DELNONCH:
- /* A potentially confusing character which must be prefixed
- with DELNONCH. */
- nonchbuf[1] = SHIFTNON((UNCH)ch);
- return NON_;
- }
- setcurchar(ch);
- /* If in content, return DCE_ for element content, DAF_ for mixed. */
- /* If not content, it must be a literal parse, so return MLA_. */
- if (pcb == conpcb) {
- if (pcb == &pcbcone)
- return DCE_;
- else {
- data = FPOS;
- /* Action for DAF_ will do REPEATCC. */
- NEWCC;
- return DAF_;
- }
- }
- else
- return MLA_;
-}
-/* INITATT: Initialize al with adl. */
-
-VOID initatt(adl)
-struct ad *adl;
-{
- notadn = 0; /* No NOTATION attribute yet. */
- conrefsw = 0; /* Assume no content reference att. */
- /* Copy attribute definition list as a template. */
- memcpy((UNIV)al, (UNIV)adl, (1+ADN(adl))*ADSZ);
-}
-
-/* PARSEATT: Parse attribute specification list.
- Make a current copy of the attribute definition list
- and update it with the user's specifications.
- Indicate each attribute that was specified in the
- list (as opposed to defaulted) by setting the ASPEC flag.
- If no attributes were specified, return NULL. Otherwise,
- if in the prolog, make a permanent copy of the list and
- return its pointer. If not in the prolog, return al.
-*/
-struct ad *parseatt(adl, pt)
-struct ad *adl; /* Attribute definition list. */
-UNCH *pt; /* Tokenization area: tbuf[TAGLEN+ATTSPLEN]. */
-{
- UNCH *antvptr;
- UNCH *nm = 0; /* Pointer to saved name in tbuf (with length). */
- int adn = -1; /* Position of attribute in list (-1=empty). */
- UNCH *tbuflim = pt + ATTSPLEN;
- mdessv = es; /* Save es for checking entity nesting. */
- initatt(adl);
- while (pt<=tbuflim) {
- parse(&pcbstag);
- switch (pcbstag.action) {
- case NVS: /* Att name or value token found. */
- parsenm(pt, NAMECASE); /* Case translation wanted on name. */
- pt += *(nm = pt); /* Save name while pointing past it. */
- continue;
-
- case AVD: /* Delimited value found. */
- case AVDA: /* Delimited value found (alternate delimiter). */
- /* Find position (adn) of saved attribute name in list. */
- adn = anmget((int)ADN(al), nm);
- parselit(pt,
- (adn == 0 || ADTYPE(al, adn) == ACHARS)
- ? &pcblitr
- : &pcblitt,
- LITLEN,
- (pcbstag.action==AVD) ? lex.d.lit : lex.d.lita);
- if (adn == 0) {
- /* Error: unrecognized attribute name. */
- sgmlerr(13, &pcbstag, nm+1, pt);
- continue;
- }
- /* Tokenize and validate value; let it default if an error. */
- /* Put value in list and bump ptr by the normalized length
- (which is always >= the actual length). */
- if (!attval(1, pt, adn, adl)) pt += ADLEN(al,adn);
- continue;
- case AVU: /* Attribute value found: undelimited. */
- if (!sd.shorttag) sgmlerr(196, &pcbstag, (UNCH *)0, (UNCH *)0);
- parsetkn(pt, NMC, LITLEN);
- /* Find position (adn) of saved attribute name in list. */
- if ((adn = anmget((int)ADN(al), nm))==0) {
- /* Error: unrecognized attribute name. */
- sgmlerr(13, &pcbstag, nm+1, pt);
- continue;
- }
- /* Tokenize and validate value; let it default if an error. */
- /* Put value in list and bump ptr by the normalized length
- (which is always >= the actual length). */
- if (!attval(1, pt, adn, adl)) pt += ADLEN(al,adn);
- continue;
-
- case NASV: /* Saved NVS was really an NTV. */
- REPEATCC; /* Put back next token starter. */
- pt = nm; /* Back up to NVS. */
- case NTV: /* Name token value found. */
- if (!sd.shorttag) sgmlerr(195, &pcbstag, (UNCH *)0, (UNCH *)0);
- if (pcbstag.action==NTV) parsenm(pt, NAMECASE);
- if ((adn = antvget((int)ADN(al), pt, &antvptr))==0) {
- /* Error: unrecognized name token value. */
- sgmlerr(74, &pcbstag, pt+1, (UNCH *)0);
- continue;
- }
- /* Validate value; let it default if an error. */
- /* Put value in list and bump ptr by the normalized length
- (which is always >= the actual length). */
- if (!attval(0, antvptr+1, adn, adl)) pt += ADLEN(al,adn);
- continue;
-
- default: /* All attributes have been parsed. */
- REPEATCC; /* Put next char back for tag close parse. */
- break;
- }
- break;
- }
- if (pt>tbuflim) synerr(75, &pcbstag);
- if (es!=mdessv) synerr(37, &pcbstag);
- if (adn<0) return((struct ad *)0); /* List was empty. */
- TRACEADL(al);
- return al;
-}
-/* ATTVAL: Validate a specified attribute value. Issue a message if it is
- the wrong type (or otherwise is not up to spec), and use the default.
- Call PARSEVAL to tokenize the value, unless it is a CDATA string.
- If the attribute is a group, the value is a string.
- For other types, the token count is set by PARSEVAL if the value
- is syntactically correct. If incorrect (or if CDATA) the token
- count is zero (i.e., the value is a string).
- The length of a token does not include the length byte, and
- there is no EOS. A string length (as always) includes both
- the length byte and the EOS.
- If it is a CONREF attribute, set a switch for STAG().
- If it is a CURRENT attribute, store the value as the new default.
-*/
-#define DEFVAL adl[adn].addef /* Default value of current attribute. */
-#define DEFNUM adl[adn].adnum /* Default group size of current attribute. */
-#define DEFLEN adl[adn].adlen /* Length of default value of current attribute.*/
-int attval(mtvsw, adval, adn, adl)
-int mtvsw; /* Must tokenize value: 1=yes; 0=no. */
-UNCH *adval; /* Untokenized attribute value. */
-int adn; /* Attribute's position in list. */
-struct ad *adl; /* Element's master att def list. */
-{
- int errcode; /* Value/declaration conflict error code. */
-
- if (GET(ADFLAGS(al,adn), ASPEC)) /* Can't respecify same attribute. */
- {sgmlerr(73, &pcbstag, ADNAME(al,adn), adval); return(1);}
- SET(ADFLAGS(al,adn), ASPEC); /* Indicate att was specified. */
- if (GET(ADFLAGS(al,adn), ACONREF)) /* If attribute is content reference: */
- conrefsw = TAGREF; /* Set switch for STAG(). */
- if (mtvsw && ADTYPE(al,adn)!=ACHARS) {
- /* If no syntax errors, check for proper group membership. */
- if ( ((errcode = parseval(adval, ADTYPE(al,adn), lbuf))==0)
- && GET(ADFLAGS(al,adn), AGROUP)
- && !amemget(&al[adn], ADNUM(al,adn), lbuf) ) errcode = 18;
- /* If syntax or group membership error, send message and exit. */
- if (errcode) {
- sgmlerr(errcode, &pcbstag, ADNAME(al,adn), adval);
- SET(ADFLAGS(al,adn), AERROR);
- return(1);
- }
- /* Replace specified value in adval with tokenized in lbuf. */
- ustrcpy(adval, lbuf);
- if (BITOFF(ADFLAGS(al,adn), AGROUP)) ADNUM(al,adn) = (UNCH)tokencnt;
- }
- if (!mtvsw)
- adval--;
- /* If attribute is FIXED, specified value must equal default. */
- if (BITON(ADFLAGS(al,adn), AFIXED) && ustrcmp(adval, DEFVAL)) {
- /* Since the value has been tokenized, don't use it in the
- error message. */
- sgmlerr(67, &pcbstag, ADNAME(al,adn), (UNCH *)0);
- SET(ADFLAGS(al,adn), AERROR);
- return(1);
- }
- ADLEN(al,adn) = vallen(ADTYPE(al,adn), ADNUM(al,adn), adval);
- if (ADLEN(al,adn) > LITLEN) {
- sgmlerr(224, &pcbstag, ADNAME(al,adn), (UNCH *)0);
- SET(ADFLAGS(al,adn), AERROR);
- return 1;
- }
- ADVAL(al,adn) = adval;
- /* If attribute is CURRENT, value is new default.*/
- if (GET(ADFLAGS(al,adn), ACURRENT)) {
- if (ADLEN(al,adn)>DEFLEN) {
- ds.attdef += (ADLEN(al,adn) - DEFLEN);
- DEFLEN = ADLEN(al,adn);
- }
- DEFVAL = replace(DEFVAL, ADVAL(al,adn));
- DEFNUM = ADNUM(al,adn);
- }
- return(0); /* Indicate value was valid. */
-}
-/* ADLVAL: Validate the completed attribute definition list (defaults plus
- specified values). Issue a message if an
- attribute is required or current and its value is NULL.
-*/
-VOID adlval(adsz, newetd)
-int adsz; /* Size of list. */
-struct etd *newetd; /* Element type definition for this element. */
-{
- int adn = 1; /* Position in list. */
- UNCH *npt, *pt; /* Ptr save areas. */
- UNCH nptsv; /* Save area for ptr value (length?). */
- struct dcncb *dpt; /* Save area for dcncb ptr. */
-
- aentctr = 0; /* Number of AENTITY tokens in this att list. */
- idrctr = 0; /* Number of IDREF tokens in this att list. */
- do {
- if (ADVAL(al,adn)==NULL) { /* NULL value */
- if (GET(ADFLAGS(al,adn), AREQ+ACURRENT)) { /*Error if REQ, CURRENT*/
- sgmlerr(19, &pcbstag, ADNAME(al,adn), (UNCH *)0);
- SET(ADFLAGS(al,adn), AINVALID);
- }
- }
- else switch (ADTYPE(al,adn)) {
- case AENTITY: /* Return data ecb pointer if valid entity. */
- aenttst(adn, ADVAL(al,adn));
- break;
- case AENTITYS: /* Return data ecb pointers if valid entities. */
- pt = ADVAL(al,adn);
- tokencnt = (int)ADNUM(al,adn);
- while (tokencnt--) {
- nptsv = *(npt = pt + *pt+1);
- *pt += 2; *npt = EOS;
- aenttst(adn, pt);
- *pt -= 2; *(pt = npt) = nptsv;
- }
- break;
- case AID:
- /* Define ID; msg if it already exists. */
- if (iddef(ADVAL(al,adn))) {
- sgmlerr(71, &pcbstag, ADNAME(al,adn), ADVAL(al,adn)+1);
- SET(ADFLAGS(al,adn), AINVALID);
- continue;
- }
- ++ds.idcnt;
- break;
- case AIDREF:
- idreftst(adn, ADVAL(al,adn));
- break;
- case AIDREFS:
- pt = ADVAL(al,adn);
- tokencnt = (int)ADNUM(al,adn);
- while (tokencnt--) {
- nptsv = *(npt = pt + *pt+1);
- *pt += 2; *npt = EOS;
- idreftst(adn, pt);
- *pt -= 2; *(pt = npt) = nptsv;
- }
- break;
- case ANOTEGRP: /* Return notation identifier. */
- if (GET(ADFLAGS(al,adn), ASPEC)) notadn = adn;/*NOTATION specified*/
- if ((dpt = dcnfind(ADVAL(al,adn)))==0) {
- sgmlerr(77, &pcbstag, ADNAME(al,adn), ADVAL(al,adn)+1);
- SET(ADFLAGS(al,adn), AINVALID);
- }
- else ADDATA(al,adn).x = dpt;
- break;
- }
- if (!sd.shorttag && !sd.omittag && ADVAL(al,adn)!=NULL
- && !GET(ADFLAGS(al,adn), ASPEC+AINVALID))
- sgmlerr(197, &pcbstag, ADNAME(al,adn), (UNCH *)0);
- } while ((adn+=BITON(ADFLAGS(al,adn),AGROUP) ? (int)ADNUM(al,adn)+1 : 1)<=adsz);
-
- /* Error if NOTATION specified with CONREF attribute or EMPTY element. */
- if (notadn && (conrefsw
- || (newetd && GET(newetd->etdmod->ttype, MNONE)))) {
- sgmlerr((UNS)(conrefsw ? 84 : 76), &pcbstag,
- ADNAME(al,notadn), ADVAL(al,notadn)+1);
- SET(ADFLAGS(al,notadn), AINVALID);
- }
-}
-/* AENTTST: Validate an individual ENTITY token in AENTITY or AENTITYS value.
-*/
-VOID aenttst(adn, pt)
-int adn; /* Position in list. */
-UNCH *pt; /* Ptr to current ENTITY token in value. */
-{
- struct entity *ept; /* Save area for ecb ptr. */
-
- if (++aentctr>GRPCNT) {
- sgmlerr(136, &pcbstag, ADNAME(al,adn), pt+1);
- SET(ADFLAGS(al,adn), AINVALID);
- return;
- }
- if ( (ept = entfind(pt))==0
- && (ecbdeflt==0 || (ept = usedef(pt))==0) ) {
- sgmlerr(ecbdeflt ? 151 : 72, &pcbstag, ADNAME(al,adn), pt+1);
- SET(ADFLAGS(al,adn), AINVALID);
- return;
- }
- if (ept->estore==ESX || ept->estore==ESC || ept->estore==ESN) {
- /* Error if DCN has no notation identifier. */
- if (ept->estore==ESN && NEXTYPE(ept->etx.n)!=ESNSUB
- && !NEDCNDEFINED(ept->etx.n)) {
- sgmlerr(78, &pcbstag, NEDCN(ept->etx.n)+1,
- pt+1);
- SET(ADFLAGS(al,adn), AINVALID);
- }
- }
- else {
- sgmlerr(86, &pcbstag, ADNAME(al,adn), pt+1);
- SET(ADFLAGS(al,adn), AINVALID);
- }
-}
-/* IDREFTST: Validate an individual IDREF token in an IDREF or IDREFS value.
-*/
-VOID idreftst(adn, pt)
-int adn; /* Position in list. */
-UNCH *pt; /* Ptr to current IDREF token in value. */
-{
- struct fwdref *rp;
- if (++idrctr>GRPCNT) {
- sgmlerr(70, &pcbstag, ADNAME(al,adn), pt+1);
- SET(ADFLAGS(al,adn), AINVALID);
- return;
- }
- /* Note IDREF; indicate if ID exists. */
- if ((rp = idref(pt)) != 0)
- rp->msg = saverr(69, &pcbstag, ADNAME(al,adn), pt+1);
- ++ds.idrcnt;
-}
-/* ANMGET: Locate an attribute name in an attribute definition list.
-*/
-int anmget(adsz, nm)
-int adsz; /* Size of list. */
-UNCH *nm; /* Value to be found (with length byte). */
-{
- int adn = 0; /* Position in list. */
-
- while (++adn <= adsz && ustrcmp(nm+1, ADNAME(al,adn))) {
- if (BITON(ADFLAGS(al,adn), AGROUP)) adn += (int)ADNUM(al,adn);
- }
- return (adn > adsz) ? 0 : adn;
-}
-/* ANTVGET: Find the position of a name token value in an attribute list.
- Return the position of the attribute definition, or zero
- if none was found. Set pp to the value, if non-NULL.
-*/
-int antvget(adsz, nm, pp)
-int adsz; /* Size of list. */
-UNCH *nm; /* Value to be found (with length byte). */
-UNCH **pp; /* Store value here */
-{
- int adn = 0; /* Position in list. */
-
- while (++adn<=adsz) {
- /* Test only name group members. */
- if (BITON(ADFLAGS(al,adn), AGROUP)) {
- int advn; /* Position of value in sub-list. */
- if ((advn = amemget(&al[adn], (int)ADNUM(al,adn), nm))!=0) {
- if (pp)
- *pp = al[adn+advn].adname;
- return adn;
- }
- adn += (int)ADNUM(al,adn);
- }
- }
- return 0;
-}
-/* AMEMGET: Get the position of a member in an attribute name token group.
- Returns the position, or zero if not found.
- The length byte is ignored in the comparison so that final
- form tokens from ATTVAL can be compared to group members.
-*/
-int amemget(anmtgrp, adsz, nm)
-struct ad anmtgrp[]; /* Name token group. */
-int adsz; /* Size of group. */
-UNCH *nm; /* Name to be found (with length byte). */
-{
- int adn = 0; /* Position in group. */
-
- while ( ++adn<=adsz && ustrncmp(nm+1, anmtgrp[adn].adname+1, (UNS)*nm-1)) ;
- return (adn>adsz) ? 0 : adn;
-}
-/* VALLEN: Returns the length of an attribute value for capacity
- calculations. Normally, the length is NORMSEP plus the number
- of characters. For tokenized lists, it is NORMSEP,
- plus the number of characters in the tokens, plus
- NORMSEP for each token.
- ACHARS and tokenized lists don't have a length byte.
-
-*/
-UNS vallen(type, num, def)
-int type; /* ADTYPE(al,adn) */
-int num; /* ADNUM(al,adn) */
-UNCH *def; /* ADVAL(al,adn) */
-{
- if (type == ACHARS)
- return ustrlen(def) + NORMSEP;
- if (type < ATKNLIST)
- return *def - 2 + NORMSEP;
- return ustrlen(def) + num * (NORMSEP - 1) + NORMSEP;
-}
-/* PARSEGRP: Parse GI names, get their etds, and form an array of pointers
- to them. The array is terminated by a NULL pointer.
- The number of pointers (including the NULL) is returned.
- The grp buffer must have room for GRPCNT+1 etds.
-*/
-UNS parsegrp(grp, pcb, tbuf)
-struct etd *grp[]; /* Buffer for building the group. */
-struct parse *pcb; /* Current parse control block. */
-UNCH *tbuf;
-{
- int grpcnt = 0; /* Number of etds in the group. */
- int i;
- int essv = es; /* Entity stack level when grp started. */
-
- while (parse(pcb)!=GRPE && grpcnt<GRPCNT) {
- switch (pcb->action) {
- case NAS_: /* GI name: get its etd for the group. */
- grp[grpcnt] = etddef(parsenm(tbuf, NAMECASE));
- for (i = 0; i < grpcnt; i++)
- if (grp[i] == grp[grpcnt]) {
- mderr(98, ntoa(grpcnt + 1), grp[grpcnt]->etdgi + 1);
- break;
- }
- if (i == grpcnt)
- grpcnt++;
- continue;
-
- case EE_: /* Entity ended (correctly or incorrectly). */
- if (es<essv) {synerr(37, pcb); essv = es;}
- continue;
-
- case PIE_: /* PI entity reference (invalid). */
- entpisw = 0; /* Reset PI entity indicator. */
- synerr(59, pcb);
- continue;
-
- default:
- break;
- }
- break;
- }
- grp[grpcnt++] = 0; /* NULL pointer indicates end of group. */
- if (es!=essv) synerr(37, pcb);
- return grpcnt; /* Return number of ptrs in group. */
-}
-/* PARSNGRP: Parse notation names, get their dcncbs, and form an array of
- pointers to them. The array is terminated by a NULL pointer.
- The number of pointers (including the NULL) is returned.
- The grp buffer must have room for GRPCNT+1 members.
-*/
-UNS parsngrp(grp, pcb, tbuf)
-struct dcncb *grp[]; /* Buffer for building the group. */
-struct parse *pcb; /* Current parse control block. */
-UNCH *tbuf;
-{
- int grpcnt = 0; /* Number of members in the group. */
- int i;
- int essv = es; /* Entity stack level when grp started. */
-
- while (parse(pcb)!=GRPE && grpcnt<GRPCNT) {
- switch (pcb->action) {
- case NAS_: /* Member name: get its control block. */
- grp[grpcnt] = dcndef(parsenm(tbuf, NAMECASE));
- for (i = 0; i < grpcnt; i++)
- if (grp[i] == grp[grpcnt]) {
- mderr(98, ntoa(grpcnt + 1), grp[grpcnt]->ename + 1);
- break;
- }
- if (i == grpcnt)
- grpcnt++;
- continue;
-
- case EE_: /* Entity ended (correctly or incorrectly). */
- if (es<essv) {synerr(37, pcb); essv = es;}
- continue;
-
- case PIE_: /* PI entity reference (invalid). */
- entpisw = 0; /* Reset PI entity indicator. */
- synerr(59, pcb);
- continue;
-
- default:
- break;
- }
- break;
- }
- grp[grpcnt++] = 0; /* NULL pointer indicates end of group. */
- if (es!=essv) synerr(37, pcb);
- return grpcnt; /* Return number of ptrs in group. */
-}
-/* COPYGRP: Allocate storage for a group and copy the group into it.
-*/
-PETD *copygrp(pg, grpsz)
-PETD pg[]; /* Pointer to a group (array of etd ptrs). */
-UNS grpsz; /* Number of ptrs in grp, including final NULL. */
-{
- UNS glen; /* Group length in characters. */
- PETD *gnm; /* Ptr to permanent name group. */
-
- if (pg==0) return (PETD *)0;
- glen = grpsz * sizeof(struct etd *);
- memcpy( (UNIV)(gnm = (struct etd **)rmalloc(glen)) , (UNIV)pg, glen );
- return gnm;
-}
-/* INGRP: Locate an etd in a name group and return its index+1 (or zero
- if not found).
-*/
-int ingrp(pg, ketd)
-PETD pg[]; /* Array of pointers to etds. */
-PETD ketd; /* Pointer to etd to be found in group. */
-{
- int i = 0; /* Array index. */
-
- while (pg[i]) if (pg[i++]==ketd) return i;
- return 0;
-}
-/* PARSELIT: Parse a delimited string and collect it into a token.
- Caller supplies buffer, which must be 1 longer than
- maximum string allowed.
- Caller also supplies character that delimits the string.
- TODO: Return 1 if CDATA, SDATA or NONSGML occurred.
-*/
-#ifdef USE_PROTOTYPES
-VOID parselit(UNCH *tbuf, struct parse *pcb, UNS maxlen, UNCH del)
-#else
-VOID parselit(tbuf, pcb, maxlen, del)
-UNCH *tbuf; /* Work area for tokenization (parmlen+1). */
-struct parse *pcb; /* Current parse control block. */
-UNS maxlen; /* Maximum length of token. */
-UNCH del; /* Literal delimiter: LIT LITA PIC EOS */
-#endif
-{
- UNCH *pt = tbuf; /* Current pointer into tbuf. */
- UNCH lexsv = pcb->plex[del];/* Saved value of delimiter in lexical table. */
- int essv = es; /* Entity stack level when literal started. */
- UNCH datadel; /* Delimiter for CDATA/SDATA entity. */
- int parmlen = (int)maxlen + 1; /* Working limit (to be decremented). */
- int overflow = 0; /* Did the buffer overflow? */
-
- pcb->plex[del] = pcb->plex == lexlms ? lex.l.litc : lex.l.minlitc;
-
- /* The RPR_ action may cause the length of the literal to decrease by
- 1 (this discards a final space in a minimum literal); so while
- building the literal, the length must be allowed to grow to
- maxlen + 1. */
-
- do {
- switch (parse(pcb)) {
- case LP2_: /* Move 2nd char back to buffer; redo prev.*/
- REPEATCC;
- case LPR_: /* Move previous char to buffer; REPEATCC; */
- REPEATCC;
- case MLA_: /* Move character to buffer. */
- if (parmlen <= 0) { overflow = 1; break; }
- *pt++ = *FPOS; --parmlen;
- continue;
-
- case FUN_: /* Function char found; replace with space.*/
- if (parmlen <= 0) { overflow = 1; break; }
- *pt++ = ' '; --parmlen;
- continue;
-
- case RSM_: /* Record start: ccnt=0; ++rcnt.*/
- ++RCNT; CTRSET(RSCC);
- if (parmlen <= 0) { overflow = 1; break; }
- *pt++ = *FPOS; --parmlen;
- continue;
-
- case ERX_: /* Entity reference: cancel LITC delim. */
- case PEX_: /* Parameter entity ref: cancel LITC delim.*/
- lexlms[del] = lexsv;
- continue;
-
- case EE_:
- if (es<essv) {
- synerr(37, pcb);
- essv = es;
- }
- /* If back at top level, re-enable the LITC delimiter. */
- if (es==essv) lexlms[del] = lex.l.litc;
- continue;
-
- case MLE_: /* Char not allowed in minimum literal. */
- synerr(63, pcb);
- continue;
-
- case DEF_: /* Data entity: add it to buffer. */
- if (pcb == &pcblitt) {
- int parmlensv = parmlen;
- entdatsw = 0;
- parmlen = tokdata(pt, parmlen);
- if (parmlen < 0)
- break;
- pt += parmlensv - parmlen;
- continue;
- }
- if (parmlen < datalen + 2) {
- entdatsw = 0;
- overflow = 1;
- break;
- }
- parmlen -= datalen + 2;
- *pt++ = datadel =
- BITON(entdatsw, CDECONT) ? DELCDATA : DELSDATA;
- entdatsw = 0;
- memcpy( pt , data, datalen );
- pt += datalen;
- *pt++ = datadel;
- continue;
-
- case NON_: /* Non-SGML char (delimited and shifted). */
- if (parmlen < 2) { overflow = 1; break; }
- parmlen -= 2;
- memcpy( pt , nonchbuf, 2 );
- pt += 2;
- continue;
-
- case RPR_: /* Remove character from buffer. */
- --pt; ++parmlen;
- break;
-
- case EOD_:
- exiterr(92, pcb);
-
- default:
- break;
- }
- break;
- } while (!overflow && pcb->action!=TER_);
-
- if (parmlen <= 0) {
- --pt;
- overflow = 1;
- }
- if (overflow)
- sgmlerr(134, pcb, ntoa((int)maxlen),(UNCH *)0);
-
- datalen = (UNS)(pt-tbuf);/* To return PI string to text processor. */
- *pt++ = EOS;
- pcb->plex[del] = lexsv; /* Restore normal delimiter handling. */
- if (es!=essv) synerr(37, pcb);
-}
-
-/* Handle a data entity in a tokenized attribute value literal.
-Parmlen is amount of space left. Return new parmlen. If there's not
-enough space return -1, and copy up to parmlen + 1 characters. Only
-tokenization should be done, not attribute value interpretation. */
-
-int tokdata(pt, parmlen)
-UNCH *pt;
-int parmlen;
-{
- int skip = (pcblitt.newstate == 0);
- int i;
-
- for (i = 0; parmlen >= 0 && i < datalen; i++) {
- switch (data[i]) {
- case SPCCHAR:
- if (!skip) {
- *pt++ = data[i];
- parmlen--;
- skip = 1;
- }
- break;
- default:
- if (data[i] == DELNONCH) {
- assert(i + 1 < datalen);
- if ((parmlen -= 2) < 0)
- break;
- *pt++ = DELNONCH;
- *pt++ = data[++i];
- skip = 0;
- }
- else {
- *pt++ = data[i];
- parmlen--;
- skip = 0;
- }
- break;
- }
- }
- pcblitt.newstate = skip ? 0 : pcblittda;
- return parmlen;
-}
-
-
-/* PARSEMD: Parser for markup declarations.
- It returns a token each time it is called.
-
-*/
-int parsemd(pt, namecase, lpcb, tokenlen)
-UNCH *pt; /* Token buffer: >=tokenlen+2. */
-int namecase; /* Case translation: ENTCASE NAMECASE AVALCASE. */
-struct parse *lpcb; /* Parse control block for literal parse. */
-UNS tokenlen; /* Max length of expected token: NAMELEN LITLEN */
-{
- struct parse *pcb; /* Current parse control block. */
-
- pcb = (lpcb) ? &pcbmd : &pcbmdc; /* If no literal pcb, dcl is comment. */
-
- doparse: while (parse(pcb)==EE_)
- if (es<mdessv) {synerr(37, pcb); mdessv = es;}
- if (pcb->action==PIE_) { /* PI entity reference not allowed. */
- entpisw = 0; /* Reset PI entity indicator. */
- synerr(59, pcb);
- goto doparse;
- }
- ++parmno; /* Increment parameter counter. */
- switch (pcb->action) {
- case CDR: /* COM[1] (MINUS) occurred previously. */
- REPEATCC;
- return (int)pcb->action;
- case LIT: /* Literal: CDATA with LIT delimiter. */
- parselit(pt, lpcb, tokenlen, lex.d.lit);
- return (int)pcb->action;
- case LITE: /* Literal: CDATA with LITA delimiter. */
- parselit(pt, lpcb, tokenlen, lex.d.lita);
- return((int)(pcb->action = LIT));
- case RNS: /* Reserved name started (after RNI). */
- parsenm(pt, NAMECASE);
- return (int)pcb->action;
- case NAS: /* Name started. */
- if (namecase!=AVALCASE) {
- parsenm(pt, namecase);
- return (int)pcb->action;
- }
- /* Treat attribute value as name character string. */
- case NMT: /* Name token string. */
- parsetkn(pt, NMC, (int)tokenlen); /* Get undelimited value. */
- return (int)pcb->action;
- case NUM: /* Number or number token string. */
- parsetkn(pt, (UNCH)((int)tokenlen<=NAMELEN ? NU:NMC), (int)tokenlen);
- if (tokenlen > NAMELEN) pcb->newstate = 0;
- return (int)pcb->action;
- case PENR:
- REPEATCC;
- return (pcb->action = PEN);
- case EOD_:
- exiterr(133, pcb);
- /* EXIT */
- default: /* End of declaration. */
- return (int)pcb->action; /* EMD GRPS MGRP PEN PGRP */
- }
-}
-/* PARSEMOD: If the declared content was a keyword, the token count is zero
- and it is only necessary to save the type. Otherwise,
- collect the outermost token count and model type bytes for a model.
- The count includes tokens found in nested groups also.
- After building the model, parse for its occurrence indicator.
-*/
-struct thdr *parsemod(dctype)
-int dctype; /* Content type (0=model). */
-{
- gbuf[0].ttype = (UNCH)dctype; /* Initialize content flags byte. */
- if (dctype) {gbuf[0].tu.tnum = 0; return gbuf;} /* Return if not model. */
-
- gbuf[0].tu.tnum = 0; /* Don't count 1st group or model header. */
- gbuf[1].ttype = 0; /* Initialize 1st group type ... */
- gbuf[1].tu.tnum = 0; /* and count. */
- grplvl = 1; /* Content model is 1st level group. */
- pcbgrcm.newstate = 0; /* Go parse the model group. */
- /* Empty group is trapped during syntax parse; other errors return NULL. */
- if (!parsegcm(&pcbgrcm, &gbuf[1], &gbuf[0])) return (struct thdr *)0;
- parse(&pcbgrcs); /* Get the model suffix, if there is one. */
- switch(pcbgrcs.action) {
- case OPT: /* OPT occurrence indicator for model. */
- SET(gbuf[1].ttype, TOPT|TXOPT);
- break;
- case REP: /* REP occurrence indicator for model. */
- SET(gbuf[1].ttype, TREP|TXREP);
- break;
- case OREP: /* OREP occurrence indicator for model. */
- SET(gbuf[1].ttype, TOREP|TXOREP);
- break;
- case EE_:
- if (es < mdessv) {
- synerr(37, &pcbmd);
- mdessv = es;
- }
- default: /* RCR_: Repeat char and return. */
- break;
- }
- if (sw.swambig) ambig(); /* Check content model for ambiguity. */
- return gbuf;
-}
-/* PARSEGCM: Collect token headers (struct thdr) into a group (array).
- An etd is defined for each GI (if none exists) and its pointer is
- stored in the header. The function is called recursively.
-*/
-struct thdr *parsegcm(pcb, pgh, gbuf)
-struct parse *pcb; /* Current parse control block. */
-struct thdr *pgh; /* Current group header in group buffer. */
-struct thdr *gbuf; /* Header for outermost group (model). */
-{
-#define MCON gbuf->ttype /* Model type (content attributes). */
- struct thdr *pg=pgh; /* Current group token. */
- struct thdr *pgsv=pgh; /* Saved current token for occ indicator. */
- int optcnt = 0; /* Count of optional tokens in group. */
- int essv = es; /* Entity stack level when grp started. */
-
- while (gbuf->tu.tnum<=GRPGTCNT && pgh->tu.tnum<=GRPCNT && parse(pcb)!=GRPE)
- switch (pcb->action) {
-
- case NAS_: /* GI name: get its etd and store it. */
- ++gbuf->tu.tnum; ++pgh->tu.tnum;
- (pgsv = ++pg)->ttype = TTETD;
- pg->tu.thetd = etddef(parsenm(tbuf, NAMECASE));
- SET(MCON, MGI);
- continue;
-
- case RNS_: /* Reserved name started (#PCDATA). */
- parsenm(tbuf, NAMECASE);
- if (ustrcmp(tbuf+1, key[KPCDATA])) {
- mderr(116, ntoa(gbuf->tu.tnum), tbuf+1);
- return (struct thdr *)0;
- }
- /* If #PCDATA is the first non-group token, model is a phrase. */
- if (!MCON) SET(MCON, MPHRASE);
- case DTAG: /* Data tag template ignored; treat as #PCDATA. */
- if (pcb->action==DTAG) SET(pgh->ttype, TTSEQ); /* DTAG is SEQ grp. */
- ++gbuf->tu.tnum; ++pgh->tu.tnum;
- (++pg)->ttype = TTCHARS+TOREP;/* #PCDATA is OPT and REP. */
- pg->tu.thetd = ETDCDATA;
- ++optcnt; /* Ct opt tokens to see if grp is opt.*/
- SET(MCON, MCHARS);
- continue;
-
- case GRP_: /* Group started. */
- ++gbuf->tu.tnum; ++pgh->tu.tnum;
- (pgsv = ++pg)->ttype = 0; /* Type will be set by connector. */
- pg->tu.tnum = 0; /* Group has number instead of etd. */
- if (++grplvl>GRPLVL) {
- mderr(115, ntoa(gbuf->tu.tnum), (UNCH *)0);
- return (struct thdr *)0;
- }
- pg = parsegcm(pcb, pg, gbuf);
- if (!pg) return (struct thdr *)0;
- if (GET(pgsv->ttype, TOPT)) ++optcnt; /* Indicate nested opt grp. */
- --grplvl;
- continue;
-
- case OREP: /* OREP occurrence indicator for current token.*/
- SET(pgsv->ttype, TREP|TXREP);
- /* Now treat like OPT. */
- case OPT: /* OPT occurrence indicator for current token. */
- SET(pgsv->ttype, TXOPT);
- if (GET(pgsv->ttype, TOPT)) continue; /* Exit if nested opt grp. */
- SET(pgsv->ttype, TOPT);
- ++optcnt; /* Count opt tokens to see if grp is optional. */
- continue;
- case REP: /* REP occurrence indicator for current token. */
- SET(pgsv->ttype, TREP|TXREP);
- continue;
-
- case OR: /* OR connector found. */
- if BITOFF(pgh->ttype, TTAND) SET(pgh->ttype, TTOR);
- else if (GET(pgh->ttype, TTAND)!=TTOR)
- mderr(55, ntoa(gbuf->tu.tnum), (UNCH *)0);
- continue;
- case AND: /* AND connector found. */
- if BITOFF(pgh->ttype, TTAND) SET(pgh->ttype, TTAND);
- else if (GET(pgh->ttype, TTAND)!=TTAND)
- mderr(55, ntoa(gbuf->tu.tnum), (UNCH *)0);
- continue;
- case SEQ: /* SEQ connector found. */
- if BITOFF(pgh->ttype, TTAND) SET(pgh->ttype, TTSEQ);
- else if (GET(pgh->ttype, TTAND)!=TTSEQ)
- mderr(55, ntoa(gbuf->tu.tnum), (UNCH *)0);
- continue;
-
- case EE_: /* Entity ended (correctly or incorrectly). */
- if (es<essv) {synerr(37, pcb); essv = es;}
- continue;
-
- case PIE_: /* PI entity reference (not permitted). */
- entpisw = 0; /* Reset PI entity indicator. */
- synerr(59, pcb);
- continue;
-
- default: /* Syntax errors return in disgrace. */
- synerr(37, pcb);
- return (struct thdr *)0;
- }
- if (pgh->tu.tnum>GRPCNT) {
- mderr(113, ntoa(gbuf->tu.tnum), (UNCH *)0);
- return (struct thdr *)0;
- }
- if (gbuf->tu.tnum>GRPGTCNT) {
- mderr(114, ntoa(gbuf->tu.tnum), (UNCH *)0);
- return (struct thdr *)0;
- }
- if (pgh->tu.tnum==1) SET(pgh->ttype, TTSEQ); /* Unit grp is SEQ. */
- /* An optional token in an OR group makes the group optional. */
- if (GET(pgh->ttype, TTMASK)==TTOR && optcnt) SET(pgh->ttype, TOPT);
- /* If all tokens in any group are optional, so is the group. */
- if (pgh->tu.tnum<=optcnt) SET(pgh->ttype, TOPT);
-
- if (es!=essv) synerr(37, pcb);
- return pg; /* Return pointer to GRPS token. */
-}
-/* PARSENM: Parser for SGML names, which can be translated with LEXTRAN.
- The input is read from the entity stack. CC is 1st char of name.
- Returns a pointer to the parsed name.
-*/
-UNCH *parsenm(tbuf, nc)
-UNCH *tbuf; /* Buffer for name: >=NAMELEN+2. */
-int nc; /* Namecase translation: 1=yes; 0=no. */
-{
- UNCH len; /* Length of name (incl EOS & length byte). */
-
- *(tbuf + (len = 1) ) = nc ? lextran[*FPOS] : *FPOS;
- while ((NEWCC, (int)lextoke[*FPOS]>=NMC) && (len<NAMELEN)) {
- TRACETKN(NMC, lextoke);
- if (lextoke[*(tbuf + ++len) = (nc ? lextran[*FPOS] : *FPOS)]==EOB) {
- --len;
- entget();
- }
- }
- REPEATCC; /* Put back the non-token character. */
- *(tbuf + ++len) = EOS; /* Terminate name with standard EOS. */
- *tbuf = ++len; /* Store length ahead of name. */
- return tbuf;
-}
-/* PARSETKN: Parser for start-tag attribute value tokens.
- First character of token is already in *FPOS.
- Returns a pointer to the parsed token.
- Parsed token has EOS but no length byte.
-*/
-#ifdef USE_PROTOTYPES
-UNCH *parsetkn(UNCH *tbuf, UNCH scope, int maxlen)
-#else
-UNCH *parsetkn(tbuf, scope, maxlen)
-UNCH *tbuf; /* Buffer for token: >=maxlen+1. */
-UNCH scope; /* Minimum lexical class allowed. */
-int maxlen; /* Maximum length of a token. */
-#endif
-{
- int i = 1;
- tbuf[0] = *FPOS;
- while (i < maxlen) {
- NEWCC;
- if (lextoke[*FPOS] < scope) {
- REPEATCC;
- break;
- }
- TRACETKN(scope, lextoke);
- if (*FPOS == EOBCHAR)
- entget();
- else
- tbuf[i++] = *FPOS;
- }
- tbuf[i] = EOS;
- return tbuf;
-}
-/* PARSESEQ: Parser for blank sequences (i.e., space and TAB characters ).
- First character of sequence is already in *FPOS.
-*/
-VOID parseseq(tbuf, maxlen)
-UNCH *tbuf; /* Buffer for storing found sequence. */
-int maxlen; /* Maximum length of a blank sequence. */
-{
- tbuf[0] = *FPOS;
- datalen = 1;
- for (;;) {
- NEWCC;
- if (*FPOS == EOBCHAR) {
- entget();
- continue;
- }
- if ((lextoke[*FPOS] != SEP && *FPOS != SPCCHAR)
- || datalen >= maxlen)
- break;
- tbuf[datalen++] = *FPOS;
- TRACETKN(SEP, lextoke);
- }
-}
-/* S2VALNM: Parser for attribute values that are tokenized like names.
- The input is read from a string (hence S ("string") 2 ("to") VALNM).
- It stops at the first bad character.
- Returns a pointer to the created name.
-*/
-#ifdef USE_PROTOTYPES
-UNCH *s2valnm(UNCH *nm, UNCH *s, UNCH scope, int translate)
-#else
-UNCH *s2valnm(nm, s, scope, translate)
-UNCH *nm; /* Name to be created. */
-UNCH *s; /* Source string to be parsed as name. */
-UNCH scope; /* Minimum lexical class allowed. */
-int translate; /* Namecase translation: 1=yes; 0=no. */
-#endif
-{
- UNCH len = 0; /* Length of name (incl EOS and length). */
-
- for (; (int)lextoke[*s] >= scope && len < NAMELEN; s++)
- nm[++len] = translate ? lextran[*s] : *s;
- nm[++len] = EOS; /* Terminate name with standard EOS. */
- *nm = ++len; /* Store length ahead of name. */
- return nm;
-}
-/* PARSEVAL: Parser for attribute values.
- The input is read from a string and tokenized in a buffer.
- The input is terminated by EOS.
- Each token is preceded by its actual length; there is no EOS.
- If an error occurs while parsing, or
- if a token doesn't conform, set the token count to 0 to show that
- value was not tokenized and return the error code.
- After successful parse, return buffer length and 0 error code.
- The number of tokens found is set in external variable tokencnt.
-*/
-int parseval(s, atype, tbuf)
-UNCH *s; /* Source string to be parsed as token list. */
-UNS atype; /* Type of token list expected. */
-UNCH *tbuf; /* Work area for tokenization. */
-{
- int t;
- UNCH *pt = tbuf;
-
- pcbval.newstate = 0; tokencnt = 0;
- while (1) {
- for (;;) {
- pcbval.input = lextoke[*s];
- pcbval.state = pcbval.newstate;
- pcbval.newstate = (*(pcbval.ptab + pcbval.state)) [pcbval.input];
- pcbval.action = (*(pcbval.ptab + pcbval.state+1)) [pcbval.input];
- TRACEVAL(&pcbval, atype, s, tokencnt);
- if (pcbval.action != NOPA)
- break;
- s++;
- }
-
-
- switch (pcbval.action) {
- case INVA: /* Invalid character; terminate parse. */
- if (*s == '\0') goto alldone; /* Normal termination. */
- tokencnt = 0; /* Value was not tokenized. */
- return(14);
- case LENA: /* Length limit of token exceeded; end parse. */
- tokencnt = 0; /* Value was not tokenized. */
- return(15);
- default: /* Token begun: NUMA, NASA, or NMTA. */
- break;
- }
-
- ++tokencnt; /* One token per iteration. */
- switch (atype) {
- case AENTITY:
- if (tokencnt>1) {tokencnt = 0; return(16);}
- case AENTITYS:
- if (pcbval.action!=NASA) {tokencnt = 0; return(17);}
- s2valnm(pt, s, NMC, ENTCASE);
- break;
-
- case AID:
- case AIDREF:
- case ANAME:
- case ANOTEGRP:
- if (tokencnt>1) {tokencnt = 0; return(16);}
- case AIDREFS:
- case ANAMES:
- if (pcbval.action!=NASA) {tokencnt = 0; return(17);}
- s2valnm(pt, s, NMC, NAMECASE);
- break;
-
- case ANMTGRP:
- case ANMTOKE:
- if (tokencnt>1) {tokencnt = 0; return(16);}
- case ANMTOKES:
- /* No test needed because NMTA, NUMA and NASA are all valid. */
- s2valnm(pt, s, NMC, NAMECASE);
- break;
-
- case ANUMBER:
- if (tokencnt>1) {tokencnt = 0; return(16);}
- case ANUMBERS:
- if (pcbval.action!=NUMA) {tokencnt = 0; return(17);}
- s2valnm(pt, s, NU, NAMECASE);
- t = lextoke[s[*pt - 2]];
- if (t == NMS || t == NMC) {tokencnt = 0; return(17);}
- break;
-
- case ANUTOKE:
- if (tokencnt>1) {tokencnt = 0; return(16);}
- case ANUTOKES:
- if (pcbval.action!=NUMA) {tokencnt = 0; return(17);}
- s2valnm(pt, s, NMC, NAMECASE);
- break;
- }
- *pt -= 2;
- s += *pt;
- pt += *pt + 1;
- }
- alldone:
- *pt++ = EOS;
- if (*tbuf == '\0')
- return 25;
- if (atype < ATKNLIST)
- *tbuf += 2; /* include length and EOS */
- return 0;
-}
-/*
-Local Variables:
-c-indent-level: 5
-c-continued-statement-offset: 5
-c-brace-offset: -5
-c-argdecl-indent: 0
-c-label-offset: -5
-comment-column: 30
-End:
-*/
diff --git a/usr.bin/sgmls/sgmls/pcbrf.c b/usr.bin/sgmls/sgmls/pcbrf.c
deleted file mode 100644
index 554fdfb..0000000
--- a/usr.bin/sgmls/sgmls/pcbrf.c
+++ /dev/null
@@ -1,1351 +0,0 @@
-/* PCBRF: Parse tables for reference concrete syntax.
-*/
-#include "config.h"
-#include "entity.h" /* Templates for entity control blocks. */
-#include "action.h" /* Action names for all parsing. */
-#include "synxtrn.h" /* Declarations for concrete syntax constants. */
-#include "adl.h" /* Definitions for attribute list processing. */
-/* PCBCONM: State and action table for content parse of mixed content.
- Initial state assumes a start-tag was just processed.
-*/
-/* Symbols for state names (end with a number). */
-#define ET0 0 /* Markup found or buffer flushed; no data. */
-#define DA0 2 /* Data in buffer. */
-#define DA1 4 /* Data and space in buffer. */
-#define ER0 6 /* ERO found; start lookahead buffer. */
-#define CR0 8 /* CRO found (ERO, RNI). */
-#define RS0 10 /* RS found; possible SR 3-6. */
-#define ME0 12 /* MSC found; possible SR26. */
-#define ME1 14 /* MSC, MSC found. */
-#define ES0 16 /* TAGO found; start lookahead buffer. */
-#define EE0 18 /* End-tag start (TAGO,ETI); move to lookahead buffer. */
-#define NE0 20 /* End-tag start (TAGO,NET); process NET if not end-tag. */
-#define MD0 22 /* MDO found (TAGO, MDO[2]). */
-#define MC0 24 /* MDO, COM found. */
-#define SC0 26 /* COM found; possible SR19-20. */
-#define SP0 28 /* Space found; data pending; possible SR7 or SR9. */
-#define SR0 30 /* SPCR found; possible SR7 or SR9. */
-#define TB0 32 /* TAB found; possible SR7 or SR9. */
-
-int pcbcnet = ET0; /* PCBCONM: markup found or data buffer flushed.*/
-int pcbcnda = DA0; /* PCBCONM: data in buffer. */
-
-static UNCH
-/* free nu nmc nms spc non ee eob rs re sep cde nsc ero
- nmre com eti net lit spcr mdo msc mso pio rni tagc tago fce */
-et0 []={DA0 ,DA0 ,DA0 ,DA0 ,SP0 ,ET0 ,ET0 ,ET0 ,RS0 ,ET0 ,TB0 ,DA0 ,ET0 ,ER0 ,
- ET0 ,SC0 ,DA0 ,ET0 ,ET0 ,SR0 ,DA0 ,ME0 ,ET0 ,DA0 ,ET0 ,DA0 ,ES0 ,ET0 },/*et0*/
-et0a[]={DAS_,DAS_,DAS_,DAS_,DAS_,NON_,GET_,GET_,RSR_,SR2_,DAS_,DAS_,NSC_,LAS_,
- REF_,NOP_,DAS_,NED_,SR10,DAS_,DAS_,NOP_,SR25,DAS_,SR11,DAS_,LAS_,FCE_},
-
-da0 []={DA0 ,DA0 ,DA0 ,DA0 ,DA1 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,DA0 ,ET0 ,ET0 ,
- ET0 ,ET0 ,DA0 ,ET0 ,ET0 ,ET0 ,DA0 ,ET0 ,ET0 ,DA0 ,ET0 ,DA0 ,ET0 ,ET0 },/*da0*/
-da0a[]={NOP_,NOP_,NOP_,NOP_,NOP_,DAF_,DAF_,DAF_,DAF_,DAF_,DAF_,NOP_,DAF_,DAF_,
- DAF_,DAF_,NOP_,DAF_,DAF_,DAF_,NOP_,DAF_,DAF_,NOP_,DAF_,NOP_,DAF_,DAF_},
-
-da1 []={DA0 ,DA0 ,DA0 ,DA0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,DA0 ,ET0 ,ET0 ,
- ET0 ,ET0 ,DA0 ,ET0 ,ET0 ,ET0 ,DA0 ,ET0 ,ET0 ,DA0 ,ET0 ,DA0 ,ET0 ,ET0 },/*da1*/
-da1a[]={NOP_,NOP_,NOP_,NOP_,DAR_,DAF_,DAF_,DAR_,DAF_,DAR_,DAR_,NOP_,DAF_,DAF_,
- DAF_,DAF_,NOP_,DAF_,DAF_,DAR_,NOP_,DAF_,DAF_,NOP_,DAF_,NOP_,DAF_,DAF_},
-
-er0 []={ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ER0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,
- ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,CR0 ,ET0 ,ET0 ,ET0 },/*er0*/
-er0a[]={LAF_,LAF_,LAF_,ER_ ,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,
- LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAM_,LAF_,LAF_,LAF_},
-
-/* free nu nmc nms spc non ee eob rs re sep cde nsc ero
- nmre com eti net lit spcr mdo msc mso pio rni tagc tago fce */
-cr0 []={ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,CR0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,
- ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 },/*cr0*/
-cr0a[]={NLF_,CRN_,NLF_,CRA_,NLF_,NLF_,NLF_,GET_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,
- NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_},
-
-rs0 []={ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,RS0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,
- ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 },/*rs0*/
-rs0a[]={SR3_,SR3_,SR3_,SR3_,SR4_,SR3_,SR3_,GET_,SR3_,SR5_,SR4_,SR3_,SR3_,SR3_,
- SR3_,SR3_,SR3_,NED_,SR3_,SR4_,SR3_,SR3_,SR3_,SR3_,SR3_,SR3_,SR3_,SR3_},
-
-me0 []={ET0, ET0, ET0, ET0, ET0 ,ET0, ET0, ME0, ET0 ,ET0 ,ET0 ,ET0, ET0, ET0,
- ET0 ,ET0 ,ET0 ,ET0, ET0, ET0, ET0, ME1 ,ET0, ET0, ET0 ,ET0, ET0, ET0 },/*me0*/
-me0a[]={SR26,SR26,SR26,SR26,SR26,SR26,SR26,GET_,SR26,SR26,SR26,SR26,SR26,SR26,
- SR26,SR26,SR26,SR26,SR26,SR26,SR26,NOP_,SR26,SR26,SR26,SR26,SR26,SR26},
-
-me1 []={ET0, ET0, ET0, ET0, ET0 ,ET0, ET0, ME1, ET0 ,ET0 ,ET0 ,ET0, ET0, ET0,
- ET0 ,ET0 ,ET0 ,ET0, ET0, ET0, ET0, ET0 ,ET0, ET0, ET0 ,ET0, ET0, ET0 },/*me1*/
-me1a[]={RBR_,RBR_,RBR_,RBR_,RBR_,RBR_,RBR_,GET_,RBR_,RBR_,RBR_,RBR_,RBR_,RBR_,
- RBR_,RBR_,RBR_,RBR_,RBR_,RBR_,RBR_,RBR_,RBR_,RBR_,RBR_,MSE_,RBR_,RBR_},
-
-/* free nu nmc nms spc non ee eob rs re sep cde nsc ero
- nmre com eti net lit spcr mdo msc mso pio rni tagc tago fce */
-es0 []={ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ES0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,
- ET0 ,ET0 ,EE0 ,NE0 ,ET0 ,ET0 ,MD0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 },/*es0*/
-es0a[]={LAF_,LAF_,LAF_,STG_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,
- LAF_,LAF_,LAM_,LAM_,LAF_,LAF_,LAM_,LAF_,LAF_,PIS_,LAF_,NST_,LAF_,LAF_},
-
-ee0 []={ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,EE0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,
- ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 },/*ee0*/
-ee0a[]={LAF_,LAF_,LAF_,ETG_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,
- LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,NET_,LAF_,LAF_},
-
-ne0 []={ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,NE0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,
- ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 },/*ne0*/
-ne0a[]={NLF_,NLF_,NLF_,ETG_,NLF_,NLF_,NLF_,GET_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,
- NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NET_,NLF_,NLF_},
-
-/* free nu nmc nms spc non ee eob rs re sep cde nsc ero
- nmre com eti net lit spcr mdo msc mso pio rni tagc tago fce */
-md0 []={ET0, ET0, ET0, ET0, ET0 ,ET0, ET0, MD0, ET0 ,ET0 ,ET0 ,ET0, ET0, ET0,
- ET0 ,MC0 ,ET0 ,ET0, ET0, ET0, ET0, ET0 ,ET0, ET0, ET0 ,ET0, ET0, ET0 },/*md0*/
-md0a[]={LAF_,LAF_,LAF_,MD_ ,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,
- LAF_,LAM_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,MSS_,LAF_,LAF_,MDC_,LAF_,LAF_},
-
-mc0 []={ET0, ET0, ET0, ET0, ET0, ET0 ,ET0, MC0, ET0 ,ET0, ET0 ,ET0, ET0, ET0,
- ET0 ,ET0 ,ET0 ,ET0, ET0, ET0, ET0, ET0 ,ET0 ,ET0 ,ET0 ,ET0, ET0, ET0 },/*mc0*/
-mc0a[]={NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,GET_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,
- NLF_,MDC_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_},
-
-sc0 []={ET0, ET0, ET0, ET0, ET0, ET0 ,ET0, SC0, ET0 ,ET0, ET0 ,ET0, ET0, ET0,
- ET0 ,ET0 ,ET0 ,ET0, ET0, ET0, ET0, ET0 ,ET0 ,ET0 ,ET0 ,ET0, ET0, ET0 },/*sc0*/
-sc0a[]={SR19,SR19,SR19,SR19,SR19,SR19,SR19,GET_,SR19,SR19,SR19,SR19,SR19,SR19,
- SR19,SR20,SR19,SR19,SR19,SR19,SR19,SR19,SR19,SR19,SR19,SR19,SR19,SR19},
-
-/* free nu nmc nms spc non ee eob rs re sep cde nsc ero
- nmre com eti net lit spcr mdo msc mso pio rni tagc tago fce */
-sp0 []={DA0 ,DA0 ,DA0 ,DA0 ,ET0 ,ET0 ,ET0 ,SP0 ,ET0 ,ET0 ,ET0 ,DA0 ,DA0 ,ET0 ,
- ET0 ,ET0 ,DA0 ,ET0 ,ET0 ,ET0 ,DA0 ,ET0 ,ET0 ,DA0 ,DA0 ,DA0 ,ET0 ,ET0 },/*sp0*/
-sp0a[]={NOP_,NOP_,NOP_,NOP_,SR9_,DAF_,DAF_,GTR_,DAF_,SR7_,SR9_,NOP_,NOP_,DAF_,
- DAF_,DAF_,NOP_,DAF_,DAF_,SR9_,NOP_,DAF_,DAF_,NOP_,NOP_,NOP_,DAF_,DAF_},
-
-sr0 []={ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,SR0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,
- ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 },/*sr0*/
-sr0a[]={SR8_,SR8_,SR8_,SR8_,SR9_,SR8_,SR8_,GET_,SR8_,SR7_,SR9_,SR8_,SR8_,SR8_,
- SR8_,SR8_,SR8_,SR8_,SR8_,SR9_,SR8_,SR8_,SR8_,SR8_,SR8_,SR8_,SR8_,SR8_},
-
-tb0 []={ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,TB0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,
- ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 },/*tb0*/
-tb0a[]={SR1_,SR1_,SR1_,SR1_,SR9_,SR1_,SR1_,GET_,SR1_,SR7_,SR9_,SR1_,SR1_,SR1_,
- SR1_,SR1_,SR1_,SR1_,SR1_,SR9_,SR1_,SR1_,SR1_,SR1_,SR1_,SR1_,SR1_,SR1_},
-
-/* free nu nmc nms spc non ee eob rs re sep cde nsc ero
- nmre com eti net lit spcr mdo msc mso pio rni tagc tago fce */
-
-*conmtab[] = {et0, et0a, da0, da0a, da1, da1a, er0, er0a, cr0, cr0a, rs0, rs0a,
- me0, me0a, me1, me1a, es0, es0a, ee0, ee0a, ne0, ne0a, md0, md0a,
- mc0, mc0a, sc0, sc0a, sp0, sp0a, sr0, sr0a, tb0, tb0a };
-struct parse pcbconm = {"CONM", lexcnm, conmtab, 0, 0, 0, 0};
-#undef ET0
-#undef DA0
-#undef DA1
-#undef ER0
-#undef CR0
-#undef RS0
-#undef ME0
-#undef ME1
-#undef ES0
-#undef EE0
-#undef NE0
-#undef MD0
-#undef MC0
-#undef SC0
-#undef SP0
-#undef SR0
-#undef TB0
-/* PCBCONE: State and action table for content parse of element content.
- Initial state assumes a start-tag was just processed.
-*/
-/* Symbols for state names (end with a number). */
-#define ET2 0 /* Markup found. */
-#define ER2 2 /* ERO found; start lookahead buffer. */
-#define CR2 4 /* CRO found (ERO, RNI). */
-#define RS2 6 /* RS found; possible SR 3-6 if they were declared. */
-#define ME2 8 /* MSC found. */
-#define ME3 10 /* MSC, MSC found. */
-#define ES2 12 /* TAGO found; start lookahead buffer. */
-#define EE2 14 /* End-tag start (TAGO,ETI); move to lookahead buffer. */
-#define NE2 16 /* End-tag start (TAGO,NET); process NET if not end-tag. */
-#define MD2 18 /* MDO found (TAGO, MDO[2]). */
-#define MC2 20 /* MDO, COM found. */
-#define SC2 22 /* COM found; possible SR19-20 if they were mapped. */
-#define SP2 24 /* Space found; possible SR7 or SR9. */
-#define SR2 26 /* SPCR found; possible SR7 or SR9. */
-#define TB2 28 /* TAB found; possible SR7 or SR9. */
-
-static UNCH
-/* free nu nmc nms spc non ee eob rs re sep cde nsc ero
- nmre com eti net lit spcr mdo msc mso pio rni tagc tago fce */
-et2 []={ET2 ,ET2 ,ET2 ,ET2 ,SP2 ,ET2 ,ET2 ,ET2 ,RS2 ,ET2 ,TB2 ,ET2 ,ET2 ,ER2 ,
- ET2 ,SC2 ,ET2 ,ET2 ,ET2 ,SR2 ,ET2 ,ME2 ,ET2 ,ET2 ,ET2 ,ET2 ,ES2 ,ET2 },/*et2*/
-et2a[]={DCE_,DCE_,DCE_,DCE_,NOP_,DCE_,GET_,GET_,RS_ ,SR2_,NOP_,DCE_,DCE_,LAS_,
- NOP_,NOP_,DCE_,NED_,SR10,NOP_,DCE_,NOP_,SR25,DCE_,SR11,DCE_,LAS_,FCE_},
-
-er2 []={ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ER2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,
- ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,CR2 ,ET2 ,ET2 ,ET2 },/*er2*/
-er2a[]={LAF_,LAF_,LAF_,ER_ ,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,
- LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAM_,LAF_,LAF_,LAF_},
-
-cr2 []={ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,CR2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,
- ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 },/*cr2*/
-cr2a[]={NLF_,CRN_,NLF_,CRA_,NLF_,NLF_,NLF_,GET_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,
- NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_},
-
-rs2 []={ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,RS2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,
- ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 },/*rs2*/
-rs2a[]={SR3_,SR3_,SR3_,SR3_,SR4_,SR3_,SR3_,GET_,SR3_,SR5_,SR4_,SR3_,SR3_,SR3_,
- SR3_,SR3_,SR3_,NED_,SR3_,SR4_,SR3_,SR3_,SR3_,SR3_,SR3_,SR3_,SR3_,SR3_},
-
-/* free nu nmc nms spc non ee eob rs re sep cde nsc ero
- nmre com eti net lit spcr mdo msc mso pio rni tagc tago fce */
-me2 []={ET2, ET2, ET2, ET2, ET2 ,ET2, ET2, ME2, ET2 ,ET2 ,ET2 ,ET2, ET2, ET2,
- ET2 ,ET2, ET2 ,ET2, ET2, ET2, ET2, ME3 ,ET2, ET2, ET2 ,ET2, ET2, ET2 },/*me2*/
-me2a[]={SR26,SR26,SR26,SR26,SR26,SR26,SR26,GET_,SR26,SR26,SR26,SR26,SR26,SR26,
- SR26,SR26,SR26,SR26,SR26,SR26,SR26,NOP_,SR26,SR26,SR26,SR26,SR26,SR26},
-
-me3 []={ET2, ET2, ET2, ET2, ET2 ,ET2, ET2, ME3, ET2 ,ET2 ,ET2 ,ET2, ET2, ET2,
- ET2 ,ET2, ET2 ,ET2, ET2, ET2, ET2, ET2 ,ET2, ET2, ET2 ,ET2, ET2, ET2 },/*me3*/
-me3a[]={RBR_,RBR_,RBR_,RBR_,RBR_,RBR_,RBR_,GET_,RBR_,RBR_,RBR_,RBR_,RBR_,RBR_,
- RBR_,RBR_,RBR_,RBR_,RBR_,RBR_,RBR_,RBR_,RBR_,RBR_,RBR_,MSE_,RBR_,RBR_},
-
-es2 []={ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ES2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,
- ET2 ,ET2 ,EE2 ,NE2 ,ET2 ,ET2 ,MD2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 },/*es2*/
-es2a[]={LAF_,LAF_,LAF_,STG_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,
- LAF_,LAF_,LAM_,LAM_,LAF_,LAF_,LAM_,LAF_,LAF_,PIS_,LAF_,NST_,LAF_,LAF_},
-
-ee2 []={ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,EE2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,
- ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 },/*ee2*/
-ee2a[]={LAF_,LAF_,LAF_,ETG_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,
- LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,NET_,LAF_,LAF_},
-
-/* free nu nmc nms spc non ee eob rs re sep cde nsc ero
- nmre com eti net lit spc mdo msc mso pio rni tagc tago fce */
-ne2 []={ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,NE2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,
- ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 },/*ne2*/
-ne2a[]={NLF_,NLF_,NLF_,ETG_,NLF_,NLF_,NLF_,GET_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,
- NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NET_,NLF_,NLF_},
-
-md2 []={ET2, ET2, ET2, ET2, ET2 ,ET2, ET2, MD2, ET2 ,ET2 ,ET2 ,ET2, ET2, ET2,
- ET2 ,MC2, ET2 ,ET2, ET2, ET2, ET2, ET2 ,ET2, ET2, ET2 ,ET2, ET2, ET2 },/*md2*/
-md2a[]={LAF_,LAF_,LAF_,MD_ ,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,
- LAF_,LAM_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,MSS_,LAF_,LAF_,MDC_,LAF_,LAF_},
-
-mc2 []={ET2, ET2, ET2, ET2, ET2, ET2 ,ET2, MC2, ET2 ,ET2, ET2 ,ET2, ET2, ET2,
- ET2 ,ET2, ET2 ,ET2, ET2, ET2, ET2, ET2 ,ET2 ,ET2 ,ET2 ,ET2, ET2, ET2 },/*mc2*/
-mc2a[]={NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,GET_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,
- NLF_,MDC_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_},
-
-sc2 []={ET2, ET2, ET2, ET2, ET2, ET2 ,ET2, SC2, ET2 ,ET2, ET2 ,ET2, ET2, ET2,
- ET2 ,ET2 ,ET2 ,ET2, ET2, ET2, ET2, ET2 ,ET2 ,ET2 ,ET2 ,ET2, ET2, ET2 },/*sc2*/
-sc2a[]={SR19,SR19,SR19,SR19,SR19,SR19,SR19,GET_,SR19,SR19,SR19,SR19,SR19,SR19,
- SR19,SR20,SR19,SR19,SR19,SR19,SR19,SR19,SR19,SR19,SR19,SR19,SR19,SR19},
-
-/* free nu nmc nms spc non ee eob rs re sep cde nsc ero
- nmre com eti net lit spc mdo msc mso pio rni tagc tago fce */
-sp2 []={ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,SP2 ,RS2 ,ET2 ,ET2 ,ET2 ,ET2 ,ER2 ,
- ET2 ,SC2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ME2 ,ET2 ,ET2 ,ET2 ,ET2 ,ES2 ,ET2 },/*sp2*/
-sp2a[]={DCE_,DCE_,DCE_,DCE_,SR9_,DCE_,GET_,GET_,RS_ ,SR7_,SR9_,DCE_,DCE_,LAS_,
- NOP_,NOP_,DCE_,NED_,SR10,SR9_,DCE_,LAS_,DCE_,DCE_,SR11,DCE_,LAS_,DCE_},
-
-sr2 []={ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,SR2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,
- ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 },/*sr2*/
-sr2a[]={SR8_,SR8_,SR8_,SR8_,SR9_,SR8_,SR8_,GET_,SR8_,SR7_,SR9_,SR8_,SR8_,SR8_,
- SR8_,SR8_,SR8_,SR8_,SR8_,SR9_,SR8_,SR8_,SR8_,SR8_,SR8_,SR8_,SR8_,SR8_},
-
-tb2 []={ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,TB2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,
- ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 },/*tb2*/
-tb2a[]={SR1_,SR1_,SR1_,SR1_,SR9_,SR1_,SR1_,GET_,SR1_,SR7_,SR9_,SR1_,SR1_,SR1_,
- SR1_,SR1_,SR1_,SR1_,SR1_,SR9_,SR1_,SR1_,SR1_,SR1_,SR1_,SR1_,SR1_,SR1_},
-
-*conetab[] = {et2, et2a, er2, er2a, cr2, cr2a, rs2, rs2a, me2, me2a, me3, me3a,
- es2, es2a, ee2, ee2a, ne2, ne2a, md2, md2a, mc2, mc2a, sc2, sc2a,
- sp2, sp2a, sr2, sr2a, tb2, tb2a };
-struct parse pcbcone = {"CONE", lexcnm, conetab, 0, 0, 0, 0};
-#undef ET2
-#undef ER2
-#undef CR2
-#undef RS2
-#undef ME2
-#undef ME3
-#undef ES2
-#undef EE2
-#undef NE2
-#undef MD2
-#undef MC2
-#undef SC2
-#undef SP2
-#undef SR2
-#undef TB2
-/* PCBCONR: State and action table for content parse of replaceable character
- data. Initial state assumes a start-tag was just processed.
- Only entity references and character references are recognized.
-*/
-/* Symbols for state names (end with a number). */
-#define ET4 0 /* Markup found or buffer flushed; no data. */
-#define DA4 2 /* Data in buffer. */
-#define ER4 4 /* ERO found; start lookahead buffer. */
-#define CR4 6 /* CRO found (ER2, RNI). */
-#define ES4 8 /* TAGO found; start lookahead buffer. */
-#define EE4 10 /* End-tag start (TAGO,ETI); move to lookahead buffer. */
-#define NE4 12 /* End-tag start (TAGO,NET); process NET if not end-tag. */
-
-static UNCH
-/* free nu nmc nms spc non ee eob rs re sep cde nsc ero
- nmre com eti net mdo msc mso pero pio rni tagc tago */
-et4 []={DA4 ,DA4 ,DA4 ,DA4 ,DA4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,DA4 ,DA4 ,ET4 ,ER4 ,
- ET4 ,DA4 ,DA4 ,ET4 ,DA4 ,DA4 ,DA4 ,DA4 ,DA4 ,DA4 ,DA4 ,ES4 },/*et4*/
-et4a[]={DAS_,DAS_,DAS_,DAS_,DAS_,NON_,EE_ ,GET_,RS_ ,REF_,DAS_,DAS_,NSC_,LAS_,
- REF_,DAS_,DAS_,NED_,DAS_,DAS_,DAS_,DAS_,DAS_,DAS_,DAS_,LAS_},
-
-da4 []={DA4 ,DA4 ,DA4 ,DA4 ,DA4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,DA4 ,DA4 ,ET4 ,ET4 ,
- ET4 ,DA4 ,DA4 ,ET4 ,DA4 ,DA4 ,DA4 ,DA4 ,DA4 ,DA4 ,DA4 ,ET4 },/*da4*/
-da4a[]={NOP_,NOP_,NOP_,NOP_,NOP_,DAF_,DAF_,DAF_,DAF_,DAF_,NOP_,NOP_,DAF_,DAF_,
- DAF_,NOP_,NOP_,DAF_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,DAF_},
-
-er4 []={ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ER4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,
- ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,CR4 ,ET4 ,ET4 },/*er4*/
-er4a[]={LAF_,LAF_,LAF_,ERX_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,
- LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAM_,LAF_,LAF_},
-
-cr4 []={ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,CR4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,
- ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 },/*cr4*/
-cr4a[]={LAF_,CRN_,LAF_,CRA_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,
- LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_},
-
-/* free nu nmc nms spc non ee eob rs re sep cde nsc ero
- nmre com eti net mdo msc mso pero pio rni tagc tago */
-es4 []={ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ES4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,
- ET4 ,ET4 ,EE4 ,NE4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 },/*es4*/
-es4a[]={LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,
- LAF_,LAF_,LAM_,LAM_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_},
-
-ee4 []={ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,EE4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,
- ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 },/*ee4*/
-ee4a[]={LAF_,LAF_,LAF_,ETC_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,
- LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,NET_,LAF_},
-
-ne4 []={EE4 ,EE4 ,EE4 ,ET4 ,EE4 ,EE4 ,EE4 ,NE4 ,EE4 ,EE4 ,EE4 ,EE4 ,EE4 ,EE4 ,
- EE4 ,EE4 ,EE4 ,EE4 ,EE4 ,EE4 ,EE4 ,EE4 ,EE4 ,EE4 ,ET4 ,EE4 },/*ne4*/
-ne4a[]={RC2_,RC2_,RC2_,ETC_,RC2_,RC2_,RC2_,GET_,RC2_,RC2_,RC2_,RC2_,RC2_,RC2_,
- RC2_,RC2_,RC2_,RC2_,RC2_,RC2_,RC2_,RC2_,RC2_,RC2_,NET_,RC2_},
-
-*conrtab[] = {et4, et4a, da4, da4a, er4, er4a, cr4, cr4a,
- es4, es4a, ee4, ee4a, ne4, ne4a};
-struct parse pcbconr = {"CONR", lexcon, conrtab, 0, 0, 0, 0};
-#undef ET4
-#undef DA4
-#undef ER4
-#undef CR4
-#undef ES4
-#undef EE4
-#undef NE4
-/* PCBCONC: State and action table for content parse of character data.
- Initial state assumes a start-tag was just processed.
-*/
-/* Symbols for state names (end with a number). */
-#define ET6 0 /* Markup found or buffer flushed; no data. */
-#define DA6 2 /* Data in buffer. */
-#define ES6 4 /* TAGO found; start lookahead buffer. */
-#define EE6 6 /* End-tag start (TAGO,ETI); move to lookahead buffer. */
-#define NE6 8 /* End-tag start (TAGO,NET); process NET if not end-tag. */
-
-static UNCH
-/* free nu nmc nms spc non ee eob rs re sep cde nsc ero
- nmre com eti net mdo msc mso pero pio rni tagc tago */
-et6 []={DA6 ,DA6 ,DA6 ,DA6 ,DA6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,DA6 ,DA6 ,ET6 ,DA6 ,
- ET6 ,DA6 ,DA6 ,ET6 ,DA6 ,DA6 ,DA6 ,DA6 ,DA6 ,DA6 ,DA6 ,ES6 },/*et6*/
-et6a[]={DAS_,DAS_,DAS_,DAS_,DAS_,NON_,EOF_,GET_,RS_ ,REF_,DAS_,DAS_,NSC_,DAS_,
- REF_,DAS_,DAS_,NED_,DAS_,DAS_,DAS_,DAS_,DAS_,DAS_,DAS_,LAS_},
-
-da6 []={DA6 ,DA6 ,DA6 ,DA6 ,DA6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,DA6 ,DA6 ,ET6 ,ET6 ,
- ET6 ,DA6 ,DA6 ,ET6 ,DA6 ,DA6 ,DA6 ,DA6 ,DA6 ,DA6 ,DA6 ,ET6 },/*da6*/
-da6a[]={NOP_,NOP_,NOP_,NOP_,NOP_,DAF_,DAF_,DAF_,DAF_,DAF_,NOP_,NOP_,DAF_,DAF_,
- DAF_,NOP_,NOP_,DAF_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,DAF_},
-
-/* free nu nmc nms spc non ee eob rs re sep cde nsc ero
- nmre com eti net mdo msc mso pero pio rni tagc tago */
-es6 []={ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,ES6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,
- ET6 ,ET6 ,EE6 ,NE6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 },/*es6*/
-es6a[]={LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,
- LAF_,LAF_,LAM_,LAM_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_},
-
-ee6 []={ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,EE6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,
- ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 },/*ee6*/
-ee6a[]={LAF_,LAF_,LAF_,ETC_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,
- LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,NET_,LAF_},
-
-ne6 []={EE6 ,EE6 ,EE6 ,ET6 ,EE6 ,EE6 ,EE6 ,NE6 ,EE6 ,EE6 ,EE6 ,EE6 ,EE6 ,EE6 ,
- EE6 ,EE6 ,EE6 ,EE6 ,EE6 ,EE6 ,EE6 ,EE6 ,EE6 ,EE6 ,ET6 ,EE6 },/*ne6*/
-ne6a[]={RC2_,RC2_,RC2_,ETC_,RC2_,RC2_,RC2_,GET_,RC2_,RC2_,RC2_,RC2_,RC2_,RC2_,
- RC2_,RC2_,RC2_,RC2_,RC2_,RC2_,RC2_,RC2_,RC2_,RC2_,NET_,RC2_},
-
-*conctab[] = {et6, et6a, da6, da6a, es6, es6a, ee6, ee6a, ne6, ne6a};
-struct parse pcbconc = {"CONC", lexcon, conctab, 0, 0, 0, 0};
-#undef ET6
-#undef DA6
-#undef ES6
-#undef EE6
-#undef NE6
-/* PCBPRO: State and action table for prolog parse.
- Initial state assumes document just began.
-*/
-/* Symbols for state names (end with a number). */
-#define ET7 0 /* Markup found. */
-#define ES7 2 /* TAGO found; start lookahead buffer. */
-#define MD7 4 /* MDO found (TAGO, MDO[2]). */
-#define MC7 6 /* MDO, COM found. */
-#define EE7 8 /* TAGO, ETI found */
-
-static UNCH
-/* free nu nmc nms spc non ee eob rs re sep cde nsc ero
- nmre com eti net mdo msc mso pero pio rni tagc tago */
-et7 []={ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,
- ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ES7 },/*et7*/
-et7a[]={DCE_,DCE_,DCE_,DCE_,NOP_,DCE_,EE_ ,GET_,RS_ ,NOP_,NOP_,DCE_,DCE_,DCE_,
- DCE_,DCE_,DCE_,DCE_,DCE_,DCE_,DCE_,DCE_,DCE_,DCE_,DCE_,LAS_},
-
-es7 []={ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ES7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,
- ET7 ,ET7 ,EE7 ,ET7 ,MD7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 },/*es7*/
-es7a[]={PEP_,PEP_,PEP_,STE_,PEP_,PEP_,PEP_,GET_,PEP_,PEP_,PEP_,PEP_,PEP_,PEP_,
- PEP_,PEP_,LAM_,PEP_,LAM_,PEP_,PEP_,PEP_,PIS_,PEP_,STE_,PEP_},
-
-md7 []={ET7, ET7, ET7, ET7, ET7 ,ET7, ET7, MD7, ET7 ,ET7 ,ET7 ,ET7, ET7, ET7,
- ET7, MC7, ET7, ET7, ET7, ET7 ,ET7, ET7, ET7, ET7 ,ET7, ET7 },/*md7*/
-md7a[]={LAF_,LAF_,LAF_,DTD_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,
- LAF_,LAM_,LAF_,LAF_,LAF_,LAF_,MSP_,LAF_,LAF_,LAF_,NOP_,LAF_},
-
-mc7 []={ET7, ET7, ET7, ET7, ET7, ET7 ,ET7, MC7, ET7 ,ET7, ET7 ,ET7, ET7, ET7,
- ET7, ET7, ET7, ET7, ET7, ET7 ,ET7 ,ET7, ET7 ,ET7 ,ET7, ET7 },/*mc7*/
-mc7a[]={LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,
- LAF_,MDC_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_},
-
-ee7 []={ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,EE7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,
- ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 },/*ee7*/
-ee7a[]={LAF_,LAF_,LAF_,ETE_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,
- LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,ETE_,LAF_},
-
-*protab[] = {et7, et7a, es7, es7a, md7, md7a, mc7, mc7a, ee7, ee7a};
-struct parse pcbpro = {"PRO", lexcon, protab, 0, 0, 0, 0};
-#undef ET7
-#undef ES7
-#undef MD7
-#undef MC7
-#undef EE7
-/* PCBMDS: State and action table for parse of markup declaration subset.
- Initial state assumes subset just began (MSO found).
-*/
-/* Symbols for state names (end with a number). */
-#define ET8 0 /* Markup found. */
-#define ER8 2 /* PERO found; start lookahead buffer. */
-#define ME8 4 /* MSC found. */
-#define ME9 6 /* MSC, MSC found. */
-#define ES8 8 /* TAGO found; start lookahead buffer. */
-#define MD8 10 /* MDO found (TAGO, MDO[2]). */
-#define MC8 12 /* MDO, CD found. */
-#define DC8 14 /* Data characters found (erroneously). */
-
-static UNCH
-/* free nu nmc nms spc non ee eob rs re sep cde nsc ero
- nmre com eti net mdo msc mso pero pio rni tagc tago */
-et8 []={DC8 ,DC8 ,DC8 ,DC8 ,ET8 ,DC8 ,ET8 ,ET8 ,ET8 ,ET8 ,ET8 ,DC8 ,DC8 ,DC8 ,
- DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,ME8 ,DC8 ,ER8 ,DC8 ,DC8 ,DC8 ,ES8 },/*et8*/
-et8a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,GET_,GET_,RS_ ,NOP_,NOP_,NOP_,SYS_,NOP_,
- NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_},
-
-er8 []={DC8 ,DC8 ,DC8 ,ET8 ,DC8 ,DC8 ,DC8 ,ER8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,
- DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 },/*er8*/
-er8a[]={NOP_,NOP_,NOP_,PER_,NOP_,SYS_,NOP_,GET_,NOP_,NOP_,NOP_,NOP_,SYS_,NOP_,
- NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_},
-
-me8 []={ET8, ET8, ET8, ET8, ET8 ,ET8, ET8, ME8, ET8 ,ET8 ,ET8 ,ET8, ET8, ET8,
- ET8 ,ET8, ET8 ,ET8, ET8, ME9 ,ET8, ET8, ET8, ET8 ,ET8, ET8 },/*me8*/
-me8a[]={DTE_,DTE_,DTE_,DTE_,DTE_,DTE_,DTE_,GET_,DTE_,DTE_,DTE_,DTE_,DTE_,DTE_,
- DTE_,DTE_,DTE_,DTE_,DTE_,NOP_,DTE_,DTE_,DTE_,DTE_,DTE_,DTE_},
-
-me9 []={DC8, DC8, DC8, DC8, DC8 ,DC8, DC8, ME9, DC8 ,DC8 ,DC8 ,DC8, DC8, DC8,
- DC8 ,DC8, DC8 ,DC8, DC8, DC8 ,DC8, DC8, DC8, DC8 ,ET8, DC8 },/*me9*/
-me9a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,NOP_,GET_,NOP_,NOP_,NOP_,NOP_,SYS_,NOP_,
- NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,MSE_,NOP_},
-
-/* free nu nmc nms spc non ee eob rs re sep cde nsc ero
- nmre com eti net mdo msc mso pero pio rni tagc tago */
-es8 []={DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,ES8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,
- DC8 ,DC8 ,DC8 ,DC8 ,MD8 ,DC8 ,DC8 ,DC8 ,ET8 ,DC8 ,DC8 ,DC8 },/*es8*/
-es8a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,NOP_,GET_,NOP_,NOP_,NOP_,NOP_,SYS_,NOP_,
- NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,PIS_,NOP_,NOP_,NOP_},
-
-md8 []={DC8, DC8, DC8, ET8, DC8 ,DC8, DC8, MD8, DC8 ,DC8 ,DC8 ,DC8, DC8, DC8,
- DC8 ,MC8, DC8 ,DC8, DC8, DC8 ,ET8, DC8, DC8, DC8 ,ET8, DC8 },/*md8*/
-md8a[]={NOP_,NOP_,NOP_,MD_ ,NOP_,SYS_,NOP_,GET_,NOP_,NOP_,NOP_,NOP_,SYS_,NOP_,
- NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,MSS_,NOP_,NOP_,NOP_,NOP_,NOP_},
-
-mc8 []={DC8, DC8, DC8, DC8, DC8, DC8 ,DC8, MC8, DC8 ,DC8, DC8 ,DC8, DC8, DC8,
- DC8 ,ET8, DC8 ,DC8, DC8, DC8 ,DC8 ,DC8, DC8 ,DC8 ,DC8, DC8 },/*mc8*/
-mc8a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,NOP_,GET_,NOP_,NOP_,NOP_,NOP_,SYS_,NOP_,
- NOP_,MDC_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_},
-
-dc8 []={DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,
- DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,ET8 ,DC8 ,ET8 ,DC8 ,DC8 ,DC8 ,ET8 },/*dc8*/
-dc8a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,GET_,GET_,RS_ ,NOP_,NOP_,NOP_,SYS_,NOP_,
- NOP_,NOP_,NOP_,NOP_,NOP_,CIR_,NOP_,CIR_,NOP_,NOP_,NOP_,CIR_},
-
-*mdstab[] = {et8, et8a, er8, er8a, me8, me8a, me9, me9a,
- es8, es8a, md8, md8a, mc8, mc8a, dc8, dc8a};
-struct parse pcbmds = {"MDS", lexcon, mdstab, 0, 0, 0, 0};
-#undef ET8
-#undef ER8
-#undef ME8
-#undef ME9
-#undef ES8
-#undef MD8
-#undef MC8
-#undef DC8
-/* PCBGRCM: State and action table for content model group.
- Groups can nest. Reserved names are allowed.
- Data tag token groups are allowed.
- A non-reserved name or model group can have a suffix.
- Columns are based on LEXGRP.C.
-*/
-/* Symbols for state names (end with a number). */
-#define TK1 0 /* Token expected: name, #CHARS, data tag grp, model. */
-#define CO1 2 /* Connector between tokens expected. */
-#define ER1 4 /* PERO found when token was expected. */
-#define SP1 6 /* Name or model: suffix or connector expected. */
-#define RN1 8 /* RNI found; possible #PCDATA. */
-#define DG1 10 /* Data tag: group begun; name expected. */
-#define DN1 12 /* Data tag: name found; SEQ connector expected. */
-#define DT1 14 /* Data tag: ignore template and pattern; MSC expected. */
-#define DR1 16 /* PERO found when data tag name was expected. */
-#define LI1 18 /* Literal in data tag group; search for LIT. */
-#define LA1 20 /* Literal in data tag group; search for LITA. */
-
-static UNCH
-/* bit nmc nms re spc non ee eob rs and grpc grpo lit lita
- dtgc dtgo opt or pero plus rep rni seq refc */
-tk01 []={TK1 ,TK1 ,SP1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,
- TK1 ,DG1 ,TK1 ,TK1 ,ER1 ,TK1 ,TK1 ,RN1 ,TK1 ,TK1 },/*tk1*/
-tk01a[]={INV_,INV_,NAS_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,INV_,INV_,GRP_,INV_,INV_,
- INV_,GRP_,INV_,INV_,NOP_,INV_,INV_,NOP_,INV_,INV_},
-
-co01 []={TK1 ,TK1 ,TK1 ,CO1 ,CO1 ,CO1 ,CO1 ,CO1 ,CO1 ,TK1 ,SP1 ,TK1 ,TK1 ,TK1 ,
- TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 },/*co1*/
-co01a[]={INV_,INV_,INV_,NOP_,NOP_,SYS_,EE_ ,GET_,RS_ ,AND ,GRPE,INV_,INV_,INV_,
- INV_,INV_,INV_,OR ,INV_,INV_,INV_,INV_,SEQ ,INV_},
-
-er01 []={TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,ER1 ,TK1 ,ER1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,
- TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 },/*er1*/
-er01a[]={PCI_,PCI_,PER_,PCI_,PCI_,SYS_,PCI_,GET_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,
- PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_},
-
-sp01 []={TK1 ,TK1 ,TK1 ,CO1 ,CO1 ,SP1 ,CO1 ,SP1 ,CO1 ,TK1 ,SP1 ,TK1 ,TK1 ,TK1 ,
- TK1 ,TK1 ,CO1 ,TK1 ,TK1 ,CO1 ,CO1 ,TK1 ,TK1 ,TK1 },/*sp1*/
-sp01a[]={INV_,LEN_,LEN_,NOP_,NOP_,SYS_,EE_ ,GET_,RS_ ,AND ,GRPE,INV_,INV_,INV_,
- INV_,INV_,OPT ,OR ,INV_,REP ,OREP,INV_,SEQ ,LEN_},
-
-/* bit nmc nms spc spc non ee eob rs and grpc grpo lit lita
- dtgc dtgo opt or pero plus rep rni seq refc */
-rn01 []={TK1 ,TK1 ,CO1 ,TK1 ,TK1 ,RN1 ,TK1 ,RN1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,
- TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 },/*rn1*/
-rn01a[]={PCI_,PCI_,RNS_,PCI_,PCI_,SYS_,PCI_,GET_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,
- PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_},
-
-dg01 []={TK1 ,TK1 ,DN1 ,DG1 ,DG1 ,DG1 ,DG1 ,DG1 ,DG1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,
- TK1 ,TK1 ,TK1 ,TK1 ,DR1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 },/*dg1*/
-dg01a[]={INV_,INV_,NAS_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,INV_,INV_,INV_,INV_,INV_,
- INV_,INV_,INV_,INV_,NOP_,INV_,INV_,INV_,INV_,INV_},
-
-dn01 []={TK1 ,TK1 ,TK1 ,DN1 ,DN1 ,DN1 ,DN1 ,DN1 ,DN1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,
- TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,DT1 ,TK1 },/*dn1*/
-dn01a[]={INV_,INV_,INV_,NOP_,NOP_,SYS_,EE_ ,GET_,RS_ ,INV_,INV_,INV_,INV_,INV_,
- INV_,INV_,INV_,INV_,INV_,INV_,INV_,INV_,DTAG,INV_},
-
-dt01 []={TK1 ,TK1 ,TK1 ,DT1 ,DT1 ,DT1 ,DT1 ,DT1 ,DT1 ,TK1 ,DT1 ,DT1 ,LI1 ,LA1 ,
- SP1 ,TK1 ,TK1 ,DT1 ,DT1 ,TK1 ,TK1 ,TK1 ,DT1 ,TK1 },/*dt1*/
-dt01a[]={INV_,INV_,INV_,NOP_,NOP_,SYS_,EE_ ,GET_,RS_ ,INV_,NOP_,NOP_,NOP_,NOP_,
- GRPE,INV_,INV_,NOP_,NOP_,INV_,INV_,INV_,NOP_,INV_},
-
-/* bit nmc nms spc spc non ee eob rs and grpc grpo lit lita
- dtgc dtgo opt or pero plus rep rni seq refc */
-dr01 []={TK1 ,TK1 ,DG1 ,TK1 ,TK1 ,DR1 ,TK1 ,DR1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,
- TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 },/*dr1*/
-dr01a[]={PCI_,PCI_,PER_,PCI_,PCI_,SYS_,PCI_,GET_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,
- PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_},
-
-li01 []={LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,DT1 ,LI1 ,
- LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 },/*li1*/
-li01a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,NOP_,NOP_,
- NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_},
-
-la01 []={LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,DT1 ,
- LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 },/*la1*/
-la01a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,NOP_,NOP_,
- NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_},
-
-*grcmtab[] = {tk01, tk01a, co01, co01a, er01, er01a, sp01, sp01a,
- rn01, rn01a, dg01, dg01a, dn01, dn01a, dt01, dt01a,
- dr01, dr01a, li01, li01a, la01, la01a};
-struct parse pcbgrcm = {"GRCM", lexgrp, grcmtab, 0, 0, 0, 0};
-#undef TK1
-#undef CO1
-#undef ER1
-#undef SP1
-#undef RN1
-#undef DG1
-#undef DN1
-#undef DT1
-#undef DR1
-#undef LI1
-#undef LA1
-/* PCBGRCS: State and action table for content model suffix.
- If suffix occurs, process it. Otherwise, put character
- back for the next parse.
-*/
-/* Symbols for state names (end with a number). */
-#define SP4 0 /* Suffix expected. */
-
-static UNCH
-/* bit nmc nms re spc non ee eob rs and grpc grpo lit lita
- dtgc dtgo opt or pero plus rep rni seq refc */
-sp04 []={SP4 ,SP4 ,SP4 ,SP4 ,SP4 ,SP4 ,SP4 ,SP4 ,SP4 ,SP4 ,SP4 ,SP4 ,SP4 ,SP4 ,
- SP4 ,SP4 ,SP4 ,SP4 ,SP4 ,SP4 ,SP4 ,SP4 ,SP4 ,SP4 },/*sp4*/
-sp04a[]={RCR_,RCR_,RCR_,RCR_,RCR_,SYS_,EE_ ,GET_,RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,
- RCR_,RCR_,OPT ,RCR_,RCR_,REP ,OREP,RCR_,RCR_,RCR_},
-
-*grcstab[] = {sp04, sp04a};
-struct parse pcbgrcs = {"GRCS", lexgrp, grcstab, 0, 0, 0, 0};
-#undef SP4
-/* PCBGRNT: State and action table for name token group parse.
- Groups cannot nest. Reserved names are not allowed.
- No suffixes or data tag pattern groups.
-*/
-/* Symbols for state names (end with a number). */
-#define TK1 0 /* Token expected: name, #CHARS, data tag grp, model. */
-#define CO1 2 /* Connector between tokens expected. */
-#define ER1 4 /* PERO found when token was expected. */
-
-static UNCH
-/* bit nmc nms re spc non ee eob rs and grpc grpo lit lita
- dtgc dtgo opt or pero plus rep rni seq refc */
-tk02 []={TK1 ,CO1 ,CO1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,
- TK1 ,TK1 ,TK1 ,TK1 ,ER1 ,TK1 ,TK1 ,TK1 ,TK1 ,CO1 },/*tk1*/
-tk02a[]={INV_,NMT_,NMT_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,INV_,INV_,INV_,INV_,INV_,
- INV_,INV_,INV_,INV_,NOP_,INV_,INV_,INV_,INV_,NMT_},
-
-co02 []={TK1 ,TK1 ,TK1 ,CO1 ,CO1 ,CO1 ,CO1 ,CO1 ,CO1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,
- TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 },/*co1*/
-co02a[]={INV_,INV_,INV_,NOP_,NOP_,SYS_,EE_ ,GET_,RS_ ,NOP_,GRPE,INV_,INV_,INV_,
- INV_,INV_,INV_,NOP_,INV_,INV_,INV_,INV_,NOP_,INV_},
-
-er02 []={TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,ER1 ,TK1 ,ER1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,
- TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 },/*er1*/
-er02a[]={PCI_,PCI_,PER_,PCI_,PCI_,SYS_,PCI_,GET_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,
- PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_},
-
-*grnttab[] = {tk02, tk02a, co02, co02a, er02, er02a};
-struct parse pcbgrnt = {"GRNT", lexgrp, grnttab, 0, 0, 0, 0};
-#undef TK1
-#undef CO1
-#undef ER1
-/* PCBGRNM: State and action table for name group parse.
- Groups cannot nest. Reserved names are not allowed.
- No suffixes or data tag pattern groups.
-*/
-/* Symbols for state names (end with a number). */
-#define TK1 0 /* Token expected: name, #CHARS, data tag grp, model. */
-#define CO1 2 /* Connector between tokens expected. */
-#define ER1 4 /* PERO found when token was expected. */
-
-static UNCH
-/* bit nmc nms re spc non ee eob rs and grpc grpo lit lita
- dtgc dtgo opt or pero plus rep rni seq refc */
-tk03 []={TK1 ,TK1 ,CO1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,
- TK1 ,TK1 ,TK1 ,TK1 ,ER1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 },/*tk1*/
-tk03a[]={INV_,INV_,NAS_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,INV_,INV_,INV_,INV_,INV_,
- INV_,INV_,INV_,INV_,NOP_,INV_,INV_,INV_,INV_,INV_},
-
-co03 []={TK1 ,TK1 ,TK1 ,CO1 ,CO1 ,CO1 ,CO1 ,CO1 ,CO1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,
- TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 },/*co1*/
-co03a[]={INV_,INV_,INV_,NOP_,NOP_,SYS_,EE_ ,GET_,RS_ ,NOP_,GRPE,INV_,INV_,INV_,
- INV_,INV_,INV_,NOP_,INV_,INV_,INV_,INV_,NOP_,INV_},
-
-er03 []={TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,ER1 ,TK1 ,ER1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,
- TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 },/*er1*/
-er03a[]={PCI_,PCI_,PER_,PCI_,PCI_,SYS_,PCI_,GET_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,
- PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_},
-
-*grnmtab[] = {tk03, tk03a, co03, co03a, er03, er03a};
-struct parse pcbgrnm = {"GRNM", lexgrp, grnmtab, 0, 0, 0, 0};
-#undef TK1
-#undef CO1
-#undef ER1
-/* PCBREF: State and action table to find the end of entity, parameter entity,
- and character references. The opening delimiter and name
- have already been found; the parse determines whether the
- tokenization of the name ended normally and processes the REFC.
-*/
-/* Symbols for state names (end with a number). */
-#define ER5 0 /* Handle REFC or other entity reference termination. */
-#define ER6 2 /* Return to caller and reset state for next call. */
-
-static UNCH
-/* bit nmc nms re spc non ee eob rs and grpc grpo lit lita
- dtgc dtgo opt or pero plus rep rni seq refc */
-er05 []={ER5 ,ER6 ,ER6 ,ER6 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,
- ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER6 },/*er5*/
-er05a[]={RCR_,LEN_,LEN_,NOP_,RCR_,SYS_,RCR_,GET_,RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,
- RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,NOP_},
-
-er06 []={ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,
- ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 },/*er6*/
-er06a[]={RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,
- RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,RCR_},
-
-*reftab[]={er05, er05a, er06, er06a};
-struct parse pcbref = {"ENTREF", lexgrp, reftab, 0, 0, 0, 0};
-#undef ER5
-#undef ER6
-/*
-Use (typical) Name Ending Chsw References RS RE SEP
-Parameter literal LITPC LIT/A OK Parm,Char RSM_ LAM_ LAM_
- Data tag template NO
-System ID LITC LIT/A n/a none RSM_ LAM_ LAM_
- Processing instruction PIC
-Attribute value LITRV LIT/A NO Gen,Char RS_ FUN_ FUN_
-Minimum literal LITV LIT/A n/a none RS_ FUN_ MLE_
-*/
-/* PCBLITP: Literal parse with parameter and character references;
- no function character translation.
-*/
-/* Symbols for state names (end with a number). */
-#define DA0 0 /* Data in buffer. */
-#define ER0 2 /* ERO found. */
-#define CR0 4 /* CRO found (ER0, RNI). */
-#define PR0 6 /* PRO found (for PCBLITP). */
-
-static UNCH
-/* free num min nms spc non ee eob rs re sep cde nsc ero
- mdo msc mso pero rni tagc tago litc */
-da13 []={DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,ER0 ,
- DA0 ,DA0 ,DA0 ,PR0 ,DA0 ,DA0 ,DA0 ,DA0 },/*da3*/
-da13a[]={MLA_,MLA_,MLA_,MLA_,MLA_,NON_,EE_ ,GET_,RSM_,MLA_,MLA_,MLA_,NSC_,NOP_,
- MLA_,MLA_,MLA_,NOP_,MLA_,MLA_,MLA_,TER_},
-
-er13 []={DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,ER0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,
- DA0 ,DA0 ,DA0 ,DA0 ,CR0 ,DA0 ,DA0 ,DA0 },/*er3*/
-er13a[]={LPR_,LPR_,LPR_,LPR_,LPR_,LPR_,LPR_,GET_,LPR_,LPR_,LPR_,LPR_,LPR_,LPR_,
- LPR_,LPR_,LPR_,LPR_,NOP_,LPR_,LPR_,LPR_},
-
-cr13 []={DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,CR0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,
- DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 },/*cr3*/
-cr13a[]={LP2_,CRN_,LP2_,CRA_,LP2_,LP2_,LP2_,GET_,LP2_,LP2_,LP2_,LP2_,LP2_,LP2_,
- LP2_,LP2_,LP2_,LP2_,LP2_,LP2_,LP2_,LP2_},
-
-pr13 []={DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,PR0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,
- DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 },/*pr3*/
-pr13a[]={LPR_,LPR_,LPR_,PEX_,LPR_,LPR_,LPR_,GET_,LPR_,LPR_,LPR_,LPR_,LPR_,LPR_,
- LPR_,LPR_,LPR_,LPR_,LPR_,LPR_,LPR_,LPR_},
-
-*litptab[] = {da13, da13a, er13, er13a, cr13, cr13a, pr13, pr13a};
-struct parse pcblitp = {"LITP", lexlms, litptab, 0, 0, 0, 0};
-#undef DA0
-#undef ER0
-#undef CR0
-#undef PR0
-/* PCBLITC: Literal parse; no references; no function char translation.
- Used for character data (system data).
-*/
-/* Symbols for state names (end with a number). */
-#define DA0 0 /* Data in buffer. */
-
-static UNCH
-/* free num min nms spc non ee eob rs re sep cde nsc ero
- mdo msc mso pero rni tagc tago litc */
-da2 []={DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,
- DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 },/*da2*/
-da2a[]={MLA_,MLA_,MLA_,MLA_,MLA_,SYS_,EOF_,GET_,RSM_,MLA_,MLA_,MLA_,SYS_,MLA_,
- MLA_,MLA_,MLA_,MLA_,MLA_,MLA_,MLA_,TER_},
-
-*litctab[] = {da2, da2a};
-struct parse pcblitc = {"LITC", lexlms, litctab, 0, 0, 0, 0};
-#undef DA0
-/* PCBLITR: Attribute value parse; general and character references;
- function chars are translated.
-*/
-/* Symbols for state names (end with a number). */
-#define DA0 0 /* Data in buffer. */
-#define ER0 2 /* ERO found. */
-#define CR0 4 /* CRO found (ER0, RNI). */
-
-static UNCH
-/* free num min nms spc non ee eob rs re sep cde nsc ero
- mdo msc mso pero rni tagc tago litc */
-da11 []={DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,ER0 ,
- DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 },/*da1*/
-da11a[]={MLA_,MLA_,MLA_,MLA_,MLA_,NON_,EE_ ,GET_,RS_ ,FUN_,FUN_,MLA_,NSC_,NOP_,
- MLA_,MLA_,MLA_,MLA_,MLA_,MLA_,MLA_,TER_},
-
-er11 []={DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,ER0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,
- DA0 ,DA0 ,DA0 ,DA0 ,CR0 ,DA0 ,DA0 ,DA0 },/*er1*/
-er11a[]={LPR_,LPR_,LPR_,ERX_,LPR_,LPR_,LPR_,GET_,LPR_,LPR_,LPR_,LPR_,LPR_,LPR_,
- LPR_,LPR_,LPR_,LPR_,NOP_,LPR_,LPR_,LPR_},
-
-cr11 []={DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,CR0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,
- DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 },/*cr1*/
-cr11a[]={LP2_,CRN_,LP2_,CRA_,LP2_,LP2_,LP2_,GET_,LP2_,LP2_,LP2_,LP2_,LP2_,LP2_,
- LP2_,LP2_,LP2_,LP2_,LP2_,LP2_,LP2_,LP2_},
-
-*litrtab[] = {da11, da11a, er11, er11a, cr11, cr11a};
-struct parse pcblitr = {"LITR", lexlms, litrtab, 0, 0, 0, 0};
-#undef DA0
-#undef ER0
-#undef CR0
-/* PCBLITV: Literal parse; no references; RS ignored; RE/SPACE sequences
- become single SPACE. Only minimum data characters allowed.
-*/
-/* Symbols for state names (end with a number). */
-#define LS0 0 /* Leading SPACE or RE found. */
-#define VA0 2 /* Valid character found. */
-#define SP0 4 /* SPACE/RE sequence begun. */
-
-static UNCH
-/* free num min nms spc non ee eob rs re sep cde nsc
- litc */
-ls10 []={VA0 ,VA0 ,VA0 ,VA0 ,LS0 ,VA0 ,LS0 ,LS0 ,LS0 ,LS0 ,LS0 ,VA0 ,VA0 ,
- LS0 },/*ls0*/
-ls10a[]={MLE_,MLA_,MLA_,MLA_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,MLE_,SYS_,SYS_,
- TER_},
-va10 []={VA0 ,VA0 ,VA0 ,VA0 ,SP0 ,VA0 ,VA0 ,VA0 ,VA0 ,SP0 ,SP0 ,VA0 ,VA0 ,
- LS0 },/*va0*/
-da10a[]={MLE_,MLA_,MLA_,MLA_,MLA_,SYS_,EOF_,GET_,RS_ ,FUN_,MLE_,SYS_,SYS_,
- TER_},
-sp10 []={VA0 ,VA0 ,VA0 ,VA0 ,SP0 ,VA0 ,VA0 ,SP0 ,SP0 ,SP0 ,SP0 ,VA0 ,VA0 ,
- LS0 },/*sp0*/
-sp10a[]={MLE_,MLA_,MLA_,MLA_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,MLE_,SYS_,SYS_,
- RPR_},
-
-*litvtab[] = {ls10, ls10a, va10, da10a, sp10, sp10a};
-struct parse pcblitv = {"LITV", lexmin, litvtab, 0, 0, 0, 0};
-#undef LS0
-#undef VA0
-#undef SP0
-/* PCBLITT: Tokenized attribute value parse.
-*/
-
-/* PCBLITT: Attribute value parse; general and character references;
- function chars are translated.
-*/
-/* Symbols for state names (end with a number). */
-#define SP0 0 /* Ignore spaces */
-#define DA0 2 /* Data character */
-#define ER0 4 /* ERO found; ignore space */
-#define ER1 6 /* ERO found; don't ignore space */
-#define CR0 8 /* CRO found (ER0, RNI); ignore space */
-#define CR1 10 /* CR0 found; don't ignore space */
-
-int pcblittda = DA0;
-
-static UNCH
-/* free num min nms spc non ee eob rs re sep cde nsc ero
- mdo msc mso pero rni tagc tago litc */
-
-sp14 []={DA0 ,DA0 ,DA0 ,DA0 ,SP0 ,DA0 ,DA0 ,SP0 ,SP0 ,SP0 ,SP0 ,DA0 ,DA0 ,ER0 ,
- DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 },/*sp0*/
-sp14a[]={MLA_,MLA_,MLA_,MLA_,NOP_,NON_,EE_ ,GET_,RS_ ,NOP_,NOP_,MLA_,NSC_,NOP_,
- MLA_,MLA_,MLA_,MLA_,MLA_,MLA_,MLA_,TER_},
-
-da14 []={DA0 ,DA0 ,DA0 ,DA0 ,SP0 ,DA0 ,DA0 ,DA0 ,DA0 ,SP0 ,SP0 ,DA0 ,DA0 ,ER1 ,
- DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,SP0 },/*da0*/
-da14a[]={MLA_,MLA_,MLA_,MLA_,MLA_,NON_,EE_ ,GET_,RS_ ,FUN_,FUN_,MLA_,NSC_,NOP_,
- MLA_,MLA_,MLA_,MLA_,MLA_,MLA_,MLA_,TER_},
-
-er14 []={DA0 ,DA0 ,DA0 ,SP0 ,DA0 ,DA0 ,DA0 ,ER0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,
- DA0 ,DA0 ,DA0 ,DA0 ,CR0 ,DA0 ,DA0 ,DA0 },/*er0*/
-er14a[]={LPR_,LPR_,LPR_,ERX_,LPR_,LPR_,LPR_,GET_,LPR_,LPR_,LPR_,LPR_,LPR_,LPR_,
- LPR_,LPR_,LPR_,LPR_,NOP_,LPR_,LPR_,LPR_},
-
-er15 []={DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,ER1 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,
- DA0 ,DA0 ,DA0 ,DA0 ,CR1 ,DA0 ,DA0 ,DA0 },/*er1*/
-er15a[]={LPR_,LPR_,LPR_,ERX_,LPR_,LPR_,LPR_,GET_,LPR_,LPR_,LPR_,LPR_,LPR_,LPR_,
- LPR_,LPR_,LPR_,LPR_,NOP_,LPR_,LPR_,LPR_},
-
-cr14 []={DA0 ,DA0 ,DA0 ,SP0 ,DA0 ,DA0 ,DA0 ,CR0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,
- DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 },/*cr0*/
-cr14a[]={LP2_,CRN_,LP2_,CRA_,LP2_,LP2_,LP2_,GET_,LP2_,LP2_,LP2_,LP2_,LP2_,LP2_,
- LP2_,LP2_,LP2_,LP2_,LP2_,LP2_,LP2_,LP2_},
-
-cr15 []={DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,CR1 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,
- DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 },/*cr1*/
-cr15a[]={LP2_,CRN_,LP2_,CRA_,LP2_,LP2_,LP2_,GET_,LP2_,LP2_,LP2_,LP2_,LP2_,LP2_,
- LP2_,LP2_,LP2_,LP2_,LP2_,LP2_,LP2_,LP2_},
-
-*litttab[] = {sp14, sp14a, da14, da14a, er14, er14a, er15, er15a, cr14, cr14a,
- cr15, cr15a};
-struct parse pcblitt = {"LITT", lexlms, litttab, 0, 0, 0, 0};
-#undef SP0
-#undef DA0
-#undef ER0
-#undef ER1
-#undef CR0
-#undef CR1
-/* PCBMD: State and action table for markup declaration tokenization.
- Columns are based on LEXMARK.C.
-*/
-/* Symbols for state names (end with a number). */
-#define SP1 0 /* Separator before token expected (but not -). */
-#define SP2 2 /* Separator before token expected. */
-#define TK1 4 /* Token expected. */
-#define CM1 6 /* COM[1] found: possible comment, MGRP, or minus.*/
-#define CM2 8 /* COM[2] found; in comment. */
-#define CM3 10 /* Ending COM[1] found; end comment or continue it. */
-#define PR1 12 /* PERO found when token was expected. */
-#define PX1 14 /* PLUS found: PGRP or error. */
-#define RN1 16 /* RNI found; possible reserved name start. */
-
-int pcbmdtk = TK1; /* PCBMD: token expected. */
-
-static UNCH
-/* bit nmc num nms spc non ee eob rs com eti grpo lit lita
- dso dsc pero plus refc rni tagc tago vi */
-sp21 []={SP1 ,SP1 ,SP1 ,SP1 ,TK1 ,SP1 ,TK1 ,SP1 ,TK1 ,SP1 ,SP1 ,TK1 ,TK1 ,TK1 ,
- TK1 ,SP1 ,PR1 ,PX1 ,SP1 ,RN1 ,SP1 ,SP1 ,SP1 },
-sp21a[]={INV_,LEN_,LEN_,LEN_,NOP_,SYS_,EE_ ,GET_,RS_ ,LEN_,INV_,GRPS,LIT ,LITE,
- MDS ,INV_,NOP_,NOP_,INV_,NOP_,EMD ,INV_,INV_},
-
-sp22 []={SP2 ,SP2 ,SP2 ,SP2 ,TK1 ,SP2 ,TK1 ,SP2 ,TK1 ,CM1 ,SP2 ,TK1 ,TK1 ,TK1 ,
- TK1 ,SP2 ,PR1 ,PX1 ,SP2 ,RN1 ,SP2 ,SP2 ,SP2 },
-sp22a[]={INV_,LEN_,LEN_,LEN_,NOP_,SYS_,EE_ ,GET_,RS_ ,NOP_,INV_,GRPS,LIT ,LITE,
- MDS ,INV_,NOP_,NOP_,INV_,NOP_,EMD ,INV_,INV_},
-
-tk21 []={SP1 ,SP1 ,SP2 ,SP1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,CM1 ,SP1 ,TK1 ,TK1 ,TK1 ,
- TK1 ,SP1 ,PR1 ,PX1 ,SP1 ,RN1 ,SP1 ,SP1 ,SP1 },
-tk21a[]={INV_,NMT ,NUM ,NAS ,NOP_,SYS_,EE_ ,GET_,RS_ ,NOP_,INV_,GRPS,LIT ,LITE,
- MDS ,INV_,NOP_,NOP_,INV_,NOP_,EMD ,INV_,INV_},
-
-/* bit nmc num nms spc non ee eob rs com eti grpo lit lita
- dso dsc pero plus refc rni tagc tago vi */
-
-cm21 []={TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,CM1 ,TK1 ,CM1 ,TK1 ,CM2 ,TK1 ,TK1 ,TK1 ,TK1 ,
- TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 },
-cm21a[]={CDR ,CDR ,CDR ,CDR ,CDR ,SYS_,CDR ,GET_,CDR ,NOP_,CDR ,MGRP,CDR ,CDR ,
- CDR ,CDR ,CDR ,CDR ,CDR ,CDR ,CDR ,CDR ,CDR },
-
-cm22 []={CM2 ,CM2 ,CM2 ,CM2 ,CM2 ,CM2 ,TK1 ,CM2 ,CM2 ,CM3 ,CM2 ,CM2 ,CM2 ,CM2 ,
- CM2 ,CM2 ,CM2 ,CM2 ,CM2 ,CM2 ,CM2 ,CM2 ,CM2 },
-cm22a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,NOP_,NOP_,
- NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_},
-
-/* bit nmc num nms spc non ee eob rs com eti grpo lit lita
- dso dsc pero plus refc rni tagc tago vi */
-cm23 []={CM2 ,CM2 ,CM2 ,CM2 ,CM2 ,CM3 ,TK1 ,CM3 ,CM2 ,TK1 ,CM2 ,CM2 ,CM2 ,CM2 ,
- CM2 ,CM2 ,CM2 ,CM2 ,CM2 ,CM2 ,CM2 ,CM2 ,CM2 },
-cm23a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,NOP_,NOP_,
- NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_},
-
-pr21 []={SP1 ,SP1 ,SP1 ,TK1 ,TK1 ,PR1 ,SP2 ,PR1 ,TK1 ,SP2 ,SP1 ,SP1 ,SP1 ,SP1 ,
- SP1 ,SP1 ,SP2 ,SP1 ,SP1 ,TK1 ,SP1 ,SP1 ,SP1 },
-pr21a[]={PCI_,PCI_,PCI_,PER_,PEN ,SYS_,PENR,GET_,PEN ,PENR,PCI_,PCI_,PCI_,PCI_,
- PCI_,PCI_,PENR,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_},
-
-px21 []={SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,PX1 ,SP1 ,PX1 ,SP1 ,SP1 ,SP1 ,TK1 ,SP1 ,SP1 ,
- SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 },
-px21a[]={PCI_,PCI_,PCI_,PCI_,PCI_,SYS_,PCI_,GET_,PCI_,PCI_,PCI_,PGRP,PCI_,PCI_,
- PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_},
-
-rn21 []={TK1 ,TK1 ,TK1 ,SP1 ,TK1 ,RN1 ,TK1 ,RN1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,
- TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 },
-rn21a[]={PCI_,PCI_,PCI_,RNS ,PCI_,SYS_,PCI_,GET_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,
- PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_},
-
-*mdtab[] = {sp21, sp21a, sp22, sp22a, tk21, tk21a, cm21, cm21a, cm22, cm22a,
- cm23, cm23a, pr21, pr21a, px21, px21a, rn21, rn21a};
-struct parse pcbmd = {"MD", lexmark, mdtab, 0, 0, 0, 0};
-#undef SP1
-#undef SP2
-#undef TK1
-#undef CM1
-#undef CM2
-#undef CM3
-#undef PR1
-#undef PX1
-#undef RN1
-/* PCBMDC: State and action table for comment declaration.
-*/
-/* Symbols for state names (end with a number). */
-#define CD2 0 /* COM[2] found; in comment. */
-#define CD3 2 /* Ending COM[1] found; end comment or continue it. */
-#define EM1 4 /* Ending COM[2] found; start new comment or end. */
-#define CD1 6 /* COM[1] found; new comment or error. */
-
-static UNCH
-/* bit nmc num nms spc non ee eob rs com eti grpo lit lita
- dso dsc pero plus refc rni tagc tago vi */
-cd22 []={CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD3 ,CD2 ,CD2 ,CD2 ,CD2 ,
- CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 },
-cd22a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,NOP_,NOP_,
- NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_},
-
-cd23 []={CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD3 ,CD2 ,CD3 ,CD2 ,EM1 ,CD2 ,CD2 ,CD2 ,CD2 ,
- CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 },
-cd23a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,NOP_,NOP_,
- NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_},
-
-em21 []={CD2 ,CD2 ,CD2 ,CD2 ,EM1 ,EM1 ,CD2 ,EM1 ,EM1 ,CD1 ,CD2 ,CD2 ,CD2 ,CD2 ,
- CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 },
-em21a[]={INV_,INV_,INV_,INV_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,INV_,INV_,INV_,INV_,
- INV_,INV_,INV_,INV_,INV_,INV_,EMD ,INV_,INV_},
-
-cd21 []={CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD1 ,CD2 ,CD1 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,
- CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 },
-cd21a[]={PCI_,PCI_,PCI_,PCI_,PCI_,SYS_,EOF_,GET_,PCI_,NOP_,PCI_,PCI_,PCI_,PCI_,
- PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_},
-
-*mdctab[] = {cd22, cd22a, cd23, cd23a, em21, em21a, cd21, cd21a};
-struct parse pcbmdc = {"MDC", lexmark, mdctab, 0, 0, 0, 0};
-#undef CD2
-#undef CD3
-#undef EM1
-#undef CD1
-/* PCBMDI: State and action table for ignoring markup declarations.
- Literals are handled properly so a TAGC won't end the declaration.
- An error is noted if the entity ends within a declaration that
- is being ignored.
- TO DO: Handle nested declaration sets.
-*/
-/* Symbols for state names (end with a number). */
-#define NC1 0 /* Not in a comment; TAGC ends declaration. */
-#define IC1 2 /* COM[1] found; possible comment. */
-#define IC2 4 /* COM[2] found; in comment. */
-#define IC3 6 /* Ending COM[1] found; end comment or continue it. */
-#define LI1 8 /* Literal parameter; search for LIT. */
-#define LA1 10 /* Literal parameter; search for LITA. */
-
-static UNCH
-/* bit nmc num nms spc non ee eob rs com eti grpo lit lita
- dso dsc pero plus refc rni tagc tago vi */
-nc21 []={NC1 ,NC1 ,NC1 ,NC1 ,NC1 ,NC1 ,NC1 ,NC1 ,NC1 ,IC1 ,NC1 ,NC1 ,LI1 ,LA1 ,
- NC1 ,NC1 ,NC1 ,NC1 ,NC1 ,NC1 ,NC1 ,NC1 ,NC1 },
-nc21a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,NOP_,NOP_,
- NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,EMD ,NOP_,NOP_},
-
-ic21 []={NC1 ,NC1 ,NC1 ,NC1 ,NC1 ,IC1 ,NC1 ,IC1 ,NC1 ,IC2 ,NC1 ,NC1 ,LI1 ,LA1 ,
- NC1 ,NC1 ,NC1 ,NC1 ,NC1 ,NC1 ,NC1 ,NC1 ,NC1 },
-ic21a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,NOP_,NOP_,
- NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,EMD ,NOP_,NOP_},
-
-ic22 []={IC2 ,IC2 ,IC2 ,IC2 ,IC2 ,IC2 ,NC1 ,IC2 ,IC2 ,IC3 ,IC2 ,IC2 ,IC2 ,IC2 ,
- IC2 ,IC2 ,IC2 ,IC2 ,IC2 ,IC2 ,IC2 ,IC2 ,IC2 },
-ic22a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,NOP_,NOP_,
- NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_},
-
-ic23 []={IC2 ,IC2 ,IC2 ,IC2 ,IC2 ,IC3 ,NC1 ,IC3 ,IC2 ,NC1 ,IC2 ,IC2 ,IC2 ,IC2 ,
- IC2 ,IC2 ,IC2 ,IC2 ,IC2 ,IC2 ,IC2 ,IC2 ,IC2 },/*ic3*/
-ic23a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,NOP_,NOP_,
- NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_},
-
-/* bit nmc num nms spc non ee eob rs com eti grpo lit lita
- dso dsc pero plus refc rni tagc tago vi */
-li21 []={LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,NC1 ,LI1 ,
- LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 },/*li1*/
-li21a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,NOP_,NOP_,
- NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_},
-
-la21 []={LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,NC1 ,
- LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 },/*la1*/
-la21a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,NOP_,NOP_,
- NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_},
-
-*mditab[] = {nc21, nc21a, ic21, ic21a, ic22, ic22a,
- ic23, ic23a, li21, li21a, la21, la21a};
-struct parse pcbmdi = {"MDI", lexmark, mditab, 0, 0, 0, 0};
-#undef NC1
-#undef IC1
-#undef IC2
-#undef IC3
-#undef LI1
-#undef LA1
-/* PCBMSRC: State and action table for marked section in RCDATA mode.
- Nested marked sections are not recognized; the first MSE ends it.
- Initial state assumes an MS declaration was processed.
- Columns are based on LEXLMS.C but LITC column needn't exist.
-*/
-/* Symbols for state names (end with a number). */
-#define ET0 0 /* MSS processed or buffer flushed; no data. */
-#define DA0 2 /* Data in buffer. */
-#define ER0 4 /* ERO found; start lookahead buffer. */
-#define CR0 6 /* CRO found (ER0, RNI). */
-#define ME0 8 /* MSC found. */
-#define ME1 10 /* MSC, MSC found. */
-
-static UNCH
-/* free nu min nms spc non ee eob rs re sep cde nsc ero
- mdo msc mso pero rni tagc tago litc */
-et30 []={DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,DA0 ,DA0 ,ET0 ,ER0 ,
- DA0 ,ME0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 },/*et0*/
-et30a[]={DAS_,DAS_,DAS_,DAS_,DAS_,NON_,EE_ ,GET_,RS_ ,REF_,DAS_,DAS_,NSC_,LAS_,
- DAS_,LAS_,DAS_,DAS_,DAS_,DAS_,DAS_,DAS_},
-
-da30 []={DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,DA0 ,DA0 ,ET0 ,ET0 ,
- DA0 ,ET0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 },/*da0*/
-da30a[]={NOP_,NOP_,NOP_,NOP_,NOP_,DAF_,DAF_,DAF_,DAF_,DAF_,NOP_,NOP_,DAF_,DAF_,
- NOP_,DAF_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_},
-
-er30 []={ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ER0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,
- ET0 ,ET0 ,ET0 ,ET0 ,CR0 ,ET0 ,ET0 ,ET0 },/*er0*/
-er30a[]={LAF_,LAF_,LAF_,ERX_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,
- LAF_,LAF_,LAF_,LAF_,LAM_,LAF_,LAF_,LAF_},
-
-/* free nu min nms spc non ee eob rs re sep cde nsc ero
- mdo msc mso pero rni tagc tago litc */
-cr30 []={ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,CR0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,
- ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 },/*cr0*/
-cr30a[]={LAF_,CRN_,LAF_,CRA_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,
- LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_},
-
-me30 []={ET0, ET0, ET0, ET0, ET0 ,ET0, ET0, ME0, ET0 ,ET0 ,ET0 ,ET0, ET0 ,ET0 ,
- ET0, ME1, ET0 ,ET0, ET0 ,ET0, ET0 ,ET0 },/*me0*/
-me30a[]={LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,
- LAF_,LAM_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_},
-
-me31 []={ET0, ET0, ET0, ET0, ET0 ,ET0, ET0, ME1, ET0 ,ET0 ,ET0 ,ET0, ET0 ,ET0 ,
- ET0, ET0, ET0 ,ET0, ET0 ,ET0, ET0 ,ET0,},/*me1*/
-me31a[]={LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,
- LAF_,LAF_,LAF_,LAF_,LAF_,MSE_,LAF_,LAF_},
-
-*msrctab[]={et30, et30a, da30, da30a, er30, er30a, cr30, cr30a,
- me30, me30a, me31, me31a};
-struct parse pcbmsrc = {"MSRCDATA", lexlms, msrctab, 0, 0, 0, 0};
-#undef ET0
-#undef DA0
-#undef ER0
-#undef CR0
-#undef ME0
-#undef ME1
-/* PCBMSC: State and action table for marked section in CDATA mode.
- Nested marked sections are not recognized; the first MSE ends it.
- Initial state assumes an MS declaration was processed.
-*/
-/* Symbols for state names (end with a number). */
-#define ET2 0 /* MSS processed or buffer flushed; no data. */
-#define DA2 2 /* Data in buffer. */
-#define ME2 4 /* MSC found. */
-#define ME3 6 /* MSC, MSC found. */
-
-static UNCH
-/* free nu min nms spc non ee eob rs re sep cde nsc ero
- mdo msc mso pero rni tagc tago litc */
-et32 []={DA2 ,DA2 ,DA2 ,DA2 ,DA2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,DA2 ,DA2 ,ET2 ,DA2 ,
- DA2 ,ME2 ,DA2 ,DA2 ,DA2 ,DA2 ,DA2 ,DA2 },/*et2*/
-et32a[]={DAS_,DAS_,DAS_,DAS_,DAS_,NON_,EOF_,GET_,RS_ ,REF_,DAS_,DAS_,NSC_,DAS_,
- DAS_,LAS_,DAS_,DAS_,DAS_,DAS_,DAS_,DAS_},
-
-da32 []={DA2 ,DA2 ,DA2 ,DA2 ,DA2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,DA2 ,DA2 ,ET2 ,DA2 ,
- DA2 ,ET2 ,DA2 ,DA2 ,DA2 ,DA2 ,DA2 ,DA2 },/*da2*/
-da32a[]={NOP_,NOP_,NOP_,NOP_,NOP_,DAF_,DAF_,DAF_,DAF_,DAF_,NOP_,NOP_,DAF_,NOP_,
- NOP_,DAF_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_},
-
-me32 []={ET2, ET2, ET2, ET2, ET2 ,ET2, ET2, ME2, ET2 ,ET2 ,ET2 ,ET2, ET2 ,ET2 ,
- ET2, ME3, ET2 ,ET2, ET2 ,ET2, ET2, ET2,},/*me2*/
-me32a[]={LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,
- LAF_,LAM_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_},
-
-me33 []={ET2, ET2, ET2, ET2, ET2 ,ET2, ET2, ME3, ET2 ,ET2 ,ET2 ,ET2, ET2 ,ET2 ,
- ET2, ET2, ET2 ,ET2, ET2 ,ET2, ET2, ET2,},/*me3*/
-me33a[]={LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,
- LAF_,LAF_,LAF_,LAF_,LAF_,MSE_,LAF_,LAF_},
-
-*msctab[]={et32, et32a, da32, da32a, me32, me32a, me33, me33a};
-struct parse pcbmsc = {"MSCDATA", lexlms, msctab, 0, 0, 0, 0};
-#undef ET2
-#undef DA2
-#undef ME2
-#undef ME3
-/* PCBMSI: State and action table for marked section in IGNORE mode.
- Nested marked sections are recognized; the matching MSE ends it.
- Initial state assumes an MS declaration, MSS, or MSE was processed.
-*/
-/* Symbols for state names (end with a number). */
-#define ET4 0 /* Markup found or buffer flushed; no data. */
-#define ME4 2 /* MSC found. */
-#define ME5 4 /* MSC, MSC found. */
-#define ES4 6 /* TAGO found. */
-#define MD4 8 /* MDO found (TAGO, MDO[2]). */
-
-static UNCH
-/* free nu min nms spc non ee eob rs re sep cde nsc ero
- mdo msc mso pero rni tagc tago litc refc */
-et34 []={ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,
- ET4 ,ME4 ,ET4 ,ET4 ,ET4 ,ET4 ,ES4 ,ET4 ,ET4 },/*et4*/
-et34a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,SYS_,NOP_,
- NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_},
-
-me34 []={ET4, ET4, ET4, ET4, ET4 ,ET4, ET4, ME4, ET4 ,ET4 ,ET4 ,ET4, ET4, ET4 ,
- ET4, ME5 ,ET4, ET4, ET4 ,ET4, ET4, ET4, ET4,},/*me4*/
-me34a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,SYS_,NOP_,
- NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_},
-
-me35 []={ET4, ET4, ET4, ET4, ET4 ,ET4, ET4, ME5, ET4 ,ET4 ,ET4 ,ET4, ET4, ET4 ,
- ET4, ET4 ,ET4, ET4, ET4 ,ET4, ET4, ET4, ET4,},/*me5*/
-me35a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,SYS_,NOP_,
- NOP_,NOP_,NOP_,NOP_,NOP_,MSE_,NOP_,NOP_,NOP_},
-
-/* free nu min nms spc non ee eob rs re sep cde nsc ero
- mdo msc mso pero rni tagc tago litc */
-es34 []={ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ES4 ,ET4 ,ES4 ,ET4 ,ET4 ,ET4 ,ET4 ,ES4 ,ET4 ,
- MD4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 },/*es4*/
-es34a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,SYS_,NOP_,
- NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_},
-
-md34 []={ET4, ET4, ET4, ET4, ET4 ,MD4, ET4, MD4, ET4 ,ET4 ,ET4 ,ET4, ET4, ET4 ,
- ET4, ET4 ,ET4, ET4, ET4 ,ET4, ET4, ET4,},/*md4*/
-md34a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,SYS_,NOP_,
- NOP_,NOP_,MSS_,NOP_,NOP_,NOP_,NOP_,NOP_},
-
-*msitab[]={et34, et34a, me34, me34a, me35, me35a, es34, es34a, md34, md34a};
-struct parse pcbmsi = {"MSIGNORE", lexlms, msitab, 0, 0, 0, 0};
-#undef ET4
-#undef ME4
-#undef ME5
-#undef ES4
-#undef MD4
-#undef NS4
-/* PCBSTAG: State and action table for start-tag parse.
- Columns are based on LEXMARK.C.
-*/
-/* Symbols for state names (end with a number). */
-#define SP1 0 /* Separator before name expected. */
-#define AN1 2 /* Attribute name expected. */
-#define SP2 4 /* Separator or value indicator expected. */
-#define VI1 6 /* Value indicator expected. */
-#define AV1 8 /* Attribute value expected. */
-
-int pcbstan = AN1; /* PCBSTAG: attribute name expected. */
-
-static UNCH
-/* bit nmc num nms spc non ee eob rs com eti grpo lit lita
- dso dsc pero plus refc rni tagc tago vi */
-sp41 []={SP1 ,SP1 ,SP1 ,SP1 ,AN1 ,SP1 ,SP1 ,SP1 ,AN1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,
- SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 },
-sp41a[]={INV_,LEN_,LEN_,LEN_,NOP_,SYS_,EOF_,GET_,RS_ ,LEN_,ETIC,INV_,INV_,INV_,
- INV_,DSC ,INV_,INV_,INV_,INV_,TAGC,TAGO,INV_},
-
-an41 []={SP1 ,SP1 ,SP1 ,SP2 ,AN1 ,AN1 ,AN1 ,AN1 ,AN1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,
- SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 },
-an41a[]={INV_,NTV ,NTV ,NVS ,NOP_,SYS_,EOF_,GET_,RS_ ,NTV ,ETIC,INV_,INV_,INV_,
- INV_,DSC ,INV_,INV_,INV_,INV_,TAGC,TAGO,INV_},
-
-sp42 []={SP1 ,SP1 ,SP1 ,SP1 ,VI1 ,SP2 ,SP2 ,SP2 ,VI1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,
- SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,AV1 },
-sp42a[]={INV_,LEN_,LEN_,LEN_,NOP_,SYS_,EOF_,GET_,RS_ ,LEN_,NASV,INV_,INV_,INV_,
- INV_,NASV,INV_,INV_,INV_,INV_,NASV,NASV,NOP_},
-
-/* bit nmc num nms spc non ee eob rs com eti grpo lit lita
- dso dsc pero plus refc rni tagc tago vi */
-vi41 []={SP1 ,AN1 ,AN1 ,AN1 ,VI1 ,VI1 ,VI1 ,VI1 ,VI1 ,AN1 ,SP1 ,SP1 ,SP1 ,SP1 ,
- SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,AV1 },
-vi41a[]={INV_,NASV,NASV,NASV,NOP_,SYS_,EOF_,GET_,RS_ ,NASV,NASV,INV_,INV_,INV_,
- INV_,NASV,INV_,INV_,INV_,INV_,NASV,NASV,NOP_},
-
-av41 []={SP1 ,SP1 ,SP1 ,SP1 ,AV1 ,AV1 ,AV1 ,AV1 ,AV1 ,SP1 ,SP1 ,SP1 ,AN1 ,AN1 ,
- SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 },
-av41a[]={INV_,AVU ,AVU ,AVU ,NOP_,SYS_,EOF_,GET_,RS_ ,AVU ,INV_,INV_,AVD ,AVDA,
- INV_,INV_,INV_,INV_,INV_,INV_,INV_,INV_,INV_},
-
-*stagtab[] = {sp41, sp41a, an41, an41a, sp42, sp42a, vi41, vi41a, av41, av41a};
-struct parse pcbstag = {"STAG", lexmark, stagtab, 0, 0, 0, 0};
-#undef SP1
-#undef AN1
-#undef SP2
-#undef VI1
-#undef AV1
-/* PCBETAG: State and action table for end-tag parse.
-*/
-#define TC1 0 /* Tag close expected (no attributes allowed). */
-
-static UNCH
-/* bit nmc nu nms spc non ee eob rs com eti grpo lit lita
- dso dsc pero plus refc rni tagc tago vi */
-tc41 []={TC1 ,TC1 ,TC1 ,TC1 ,TC1 ,TC1 ,TC1 ,TC1 ,TC1 ,TC1 ,TC1 ,TC1 ,TC1 ,TC1 ,
- TC1 ,TC1 ,TC1 ,TC1 ,TC1 ,TC1 ,TC1 ,TC1 ,TC1 },/*tc1*/
-tc41a[]={INV_,INV_,INV_,INV_,NOP_,SYS_,EOF_,GET_,RS_ ,INV_,INV_,INV_,INV_,INV_,
- INV_,INV_,INV_,INV_,INV_,INV_,TAGC,TAGO,INV_},
-
-*etagtab[] = {tc41, tc41a};
-struct parse pcbetag = {"ETAG", lexmark, etagtab, 0, 0, 0, 0};
-#undef TC1
-/* PCBVAL: State and action table for tokenizing attribute values.
- Columns are based on lextoke (but EOB cannot occur).
-*/
-/* Symbols for state names (end with a number). */
-#define TK1 0 /* Token expected. */
-#define SP1 2 /* Separator before token expected. */
-
-static UNCH
-/* inv rec sep sp nmc nms nu eob */
-tk51 []={TK1 ,TK1 ,TK1 ,TK1 ,SP1 ,SP1 ,SP1 },/*tk1*/
-tk51a[]={INVA,INVA,INVA,NOPA,NMTA,NASA,NUMA},
-
-sp51 []={TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 },/*sp1*/
-sp51a[]={INVA,INVA,INVA,NOPA,LENA,LENA,LENA},
-
-*valtab[] = {tk51, tk51a, sp51, sp51a};
-struct parse pcbval = {"VAL", lextoke, valtab, 0, 0, 0, 0};
-#undef TK1
-#undef SP1
-/* PCBEAL: State and action table for end of attribute specification list.
- If delimiter occurs, process it. Otherwise, put invalid character
- back for the next parse.
-*/
-/* Symbols for state names (end with a number). */
-#define AL0 0 /* Delimiter expected. */
-
-static UNCH
-/* bit nmc nms re spc non ee eob rs and grpc grpo lit lita
- dtgc dtgo opt or pero plus rep rni seq refc */
-al00 []={AL0 ,AL0 ,AL0 ,AL0 ,AL0 ,AL0 ,AL0 ,AL0 ,AL0 ,AL0 ,AL0 ,AL0 ,AL0 ,AL0 ,
- AL0 ,AL0 ,AL0 ,AL0 ,AL0 ,AL0 ,AL0 ,AL0 ,AL0 ,AL0 },/*al0*/
-al00a[]={INV_,INV_,INV_,INV_,INV_,SYS_,EE_ ,GET_,INV_,INV_,INV_,INV_,INV_,INV_,
- GRPE,INV_,INV_,INV_,INV_,INV_,INV_,INV_,INV_,INV_},
-
-*ealtab[] = {al00, al00a};
-struct parse pcbeal = {"EAL", lexgrp, ealtab, 0, 0, 0, 0};
-#undef AL0
-
-/* PCBSD: State and action tables for SGML declaration parsing. */
-
-/* Symbols for state names. */
-
-#define SP1 0 /* Separator before token expected (but not -) */
-#define SP2 2 /* Separator before token expected. */
-#define TK1 4 /* Token expected. */
-#define CM1 6 /* COM[1] found: possible comment.*/
-#define CM2 8 /* COM[2] found; in comment. */
-#define CM3 10 /* Ending COM[1] found; end comment or continue it. */
-static UNCH
-/* sig dat num nms spc non ee eob rs com lit lita tagc */
-
-sp31 []={SP1 ,SP1 ,SP1 ,SP1 ,TK1 ,SP1 ,SP1 ,SP1 ,TK1 ,SP1 ,TK1 ,TK1 ,SP1 },
-sp31a[]={INV_,ISIG,LEN_,LEN_,NOP_,SYS_,EOF_,GET_,RS_ ,LEN_,LIT1,LIT2,ESGD},
-
-sp32 []={SP2 ,SP2 ,SP2 ,SP2 ,TK1 ,SP2 ,SP2 ,SP2 ,TK1 ,CM1 ,TK1 ,TK1 ,SP2 },
-sp32a[]={INV_,ISIG,LEN_,LEN_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,LIT1,LIT2,ESGD},
-
-tk31 []={TK1 ,TK1 ,SP2 ,SP1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,CM1 ,TK1 ,TK1 ,SP1 },
-tk31a[]={INV_,ISIG,NUM1,NAS1,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,LIT1,LIT2,ESGD},
-
-cm31 []={TK1 ,CM1 ,TK1 ,TK1 ,TK1 ,CM1 ,TK1 ,CM1 ,TK1 ,CM2 ,TK1 ,TK1 ,TK1 },
-cm31a[]={PCI_,ISIG,PCI_,PCI_,PCI_,SYS_,PCI_,GET_,PCI_,NOP_,PCI_,PCI_,PCI_},
-
-cm32 []={CM2 ,CM2 ,CM2 ,CM2 ,CM2 ,CM2 ,TK1 ,CM2 ,CM2 ,CM3 ,CM2 ,CM2 ,CM2 },
-cm32a[]={NOP_,ISIG,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,NOP_},
-
-cm33 []={CM2 ,CM3 ,CM2 ,CM2 ,CM2 ,CM3 ,TK1 ,CM3 ,CM2 ,TK1 ,CM2 ,CM2 ,CM2 },
-cm33a[]={NOP_,ISIG,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,NOP_},
-
-*sdtab[]={sp31, sp31a, sp32, sp32a, tk31, tk31a, cm31, cm31a, cm32, cm32a,
- cm33, cm33a};
-
-struct parse pcbsd = {"SD", lexsd, sdtab, 0, 0, 0, 0};
-
-#undef SP1
-#undef SP2
-#undef TK1
-#undef CM1
-#undef CM2
-#undef CM3
diff --git a/usr.bin/sgmls/sgmls/portproc.c b/usr.bin/sgmls/sgmls/portproc.c
deleted file mode 100644
index a057d24..0000000
--- a/usr.bin/sgmls/sgmls/portproc.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/* portproc.c -
-
- Semi-portable implementation of run_process().
-
- Written by James Clark (jjc@jclark.com).
-*/
-
-#include "config.h"
-
-#ifdef SUPPORT_SUBDOC
-
-#include "std.h"
-#include "entity.h"
-#include "appl.h"
-#include "alloc.h"
-
-/* This code shows how you might use system() to implement run_process().
-ANSI C says very little about the behaviour of system(), and so this
-is necessarily system dependent. */
-
-/* Characters that are significant to the shell and so need quoting. */
-#define SHELL_MAGIC "$\\\"';&()|<>^ \t\n"
-/* Character with which to quote shell arguments. */
-#define SHELL_QUOTE_CHAR '\''
-/* String that can be used to get SHELL_QUOTE_CHAR into a quoted argument. */
-#define SHELL_ESCAPE_QUOTE "'\\''"
-/* Character that can be used to separate arguments to the shell. */
-#define SHELL_ARG_SEP ' '
-
-static UNS shell_quote P((char *, char *));
-
-int run_process(argv)
-char **argv;
-{
- char **p;
- char *s, *command;
- int ret;
- UNS len = 0;
-
- for (p = argv; *p; p++)
- len += shell_quote(*p, (char *)0);
- len += p - argv;
- s = command = xmalloc(len);
- for (p = argv; *p; ++p) {
- if (s > command)
- *s++ = SHELL_ARG_SEP;
- s += shell_quote(*p, s);
- }
- *s++ = '\0';
- errno = 0;
- ret = system(command);
- if (ret < 0)
- appl_error(E_EXEC, argv[0], strerror(errno));
- free(command);
- return ret;
-}
-
-/* Quote a string so that it appears as a single argument to the
-shell (as used for system()). Store the quoted argument in result, if
-result is not NULL. Return the length. */
-
-static
-UNS shell_quote(s, result)
-char *s, *result;
-{
- UNS len = 0;
- int quoted = 0;
-
- if (strpbrk(s, SHELL_MAGIC)) {
- quoted = 1;
- len++;
- if (result)
- result[0] = SHELL_QUOTE_CHAR;
- }
- for (; *s; s++) {
- if (*s == SHELL_QUOTE_CHAR) {
- if (result)
- strcpy(result + len, SHELL_ESCAPE_QUOTE);
- len += strlen(SHELL_ESCAPE_QUOTE);
- }
- else {
- if (result)
- result[len] = *s;
- len++;
- }
- }
- if (quoted) {
- if (result)
- result[len] = SHELL_QUOTE_CHAR;
- len++;
- }
- return len;
-}
-
-#endif /* SUPPORT_SUBDOC */
-
-/*
-Local Variables:
-c-indent-level: 5
-c-continued-statement-offset: 5
-c-brace-offset: -5
-c-argdecl-indent: 0
-c-label-offset: -5
-End:
-*/
diff --git a/usr.bin/sgmls/sgmls/serv.c b/usr.bin/sgmls/sgmls/serv.c
deleted file mode 100644
index b9699d2..0000000
--- a/usr.bin/sgmls/sgmls/serv.c
+++ /dev/null
@@ -1,299 +0,0 @@
-#include "sgmlincl.h" /* #INCLUDE statements for SGML parser. */
-/* ETDDEF: Define an element type definition.
- Use an existing one if there is one; otherwise create one, which
- rmalloc initializes to zero which shows it is a virgin etd.
-*/
-PETD etddef(ename)
-UNCH *ename; /* Element name (GI) with length byte. */
-{
- PETD p; /* Pointer to an etd. */
- int hnum; /* Hash number for ename. */
-
- if ((p = (PETD)hfind((THASH)etdtab,ename,hnum = hash(ename, ETDHASH)))==0){
- p = (PETD)hin((THASH)etdtab, ename, hnum, ETDSZ);
- }
- return p;
-}
-/* ETDSET: Store data in an element type definition.
- The etd must be valid and virgin (except for adl and etdmin).
- As an etd cannot be modified, there is no checking for existing
- pointers and no freeing of their storage.
-*/
-#ifdef USE_PROTOTYPES
-PETD etdset(PETD p, UNCH fmin, struct thdr *cmod, PETD *mexgrp, PETD *pexgrp,
- struct entity **srm)
-#else
-PETD etdset(p, fmin, cmod, mexgrp, pexgrp, srm)
-PETD p; /* Pointer to an etd. */
-UNCH fmin; /* Minimization bit flags. */
-struct thdr *cmod; /* Pointer to content model. */
-PETD *mexgrp; /* Pointers to minus and plus exception lists. */
-PETD *pexgrp; /* Pointers to minus and plus exception lists. */
-struct entity **srm; /* Short reference map. */
-#endif
-{
- p->etdmin |= fmin;
- p->etdmod = cmod;
- p->etdmex = mexgrp;
- p->etdpex = pexgrp;
- p->etdsrm = srm;
- return p;
-}
-/* ETDREF: Retrieve the pointer to an element type definition.
-*/
-PETD etdref(ename)
-UNCH *ename; /* Element name (GI) with length byte.. */
-{
-
- return (PETD)hfind((THASH)etdtab, ename, hash(ename, ETDHASH));
-}
-/* ETDCAN: Cancel an element definition. The etd is freed and is removed
- from the hash table, but its model and other pointers are not freed.
-*/
-VOID etdcan(ename)
-UNCH *ename; /* GI name (with length and EOS). */
-{
- PETD p;
-
- if ((p = (PETD)hout((THASH)etdtab, ename, hash(ename, ETDHASH)))!=0)
- frem((UNIV)p);
-}
-/* SYMBOL TABLE FUNCTIONS: These functions manage hash tables that are used
- for entities, element type definitions, IDs, and other purposes. The
- interface will be expanded in the future to include multiple environments,
- probably by creating arrays of the present hash tables with each table
- in the array corresponding to an environment level.
-*/
-/* HASH: Form hash value for a string.
- From the Dragon Book, p436.
-*/
-int hash(s, hashsize)
-UNCH *s; /* String to be hashed. */
-int hashsize; /* Size of hash table array. */
-{
- unsigned long h = 0, g;
-
- while (*s != 0) {
- h <<= 4;
- h += *s++;
- if ((g = h & 0xf0000000) != 0) {
- h ^= g >> 24;
- h ^= g;
- }
- }
- return (int)(h % hashsize);
-}
-/* HFIND: Look for a name in a hash table.
-*/
-struct hash *hfind(htab, s, h)
-struct hash *htab[]; /* Hash table. */
-UNCH *s; /* Entity name. */
-int h; /* Hash value for entity name. */
-{
- struct hash *np;
-
- for (np = htab[h]; np != 0; np = np->enext)
- if (ustrcmp(s, np->ename) == 0) return np; /* Found it. */
- return (struct hash *)0; /* Not found. */
-}
-/* HIN: Locates an entry in a hash table, or allocates a new one.
- Returns a pointer to a structure containing a name
- and a pointer to the next entry. Other data in the
- structure must be maintained by the caller.
-*/
-struct hash *hin(htab, name, h, size)
-struct hash *htab[]; /* Hash table. */
-UNCH *name; /* Entity name. */
-int h; /* Hash value for entity name. */
-UNS size; /* Size of structures pointed to by table. */
-{
- struct hash *np;
-
- if ((np = hfind(htab, name, h))!=0) return np; /* Return if name found. */
- /* Allocate space for structure and name. */
- np = (struct hash *)rmalloc(size + name[0]);
- np->ename = (UNCH *)np + size;
- memcpy(np->ename, name, name[0]); /* Store name in it. */
- np->enext = htab[h]; /* 1st entry is now 2nd.*/
- htab[h] = np; /* New entry is now 1st.*/
- return np; /* Return new entry ptr. */
-}
-/* HOUT: Remove an entry from a hash table and return its pointer.
- The caller must free any pointers in the entry and then
- free the entry itself if that is what is desired; this
- routine does not free any storage.
-*/
-struct hash *hout(htab, s, h)
-struct hash *htab[]; /* Hash table. */
-UNCH *s; /* Search argument entry name. */
-int h; /* Hash value for search entry name. */
-{
- struct hash **pp;
-
- for (pp = &htab[h]; *pp != 0; pp = &(*pp)->enext)
- if (ustrcmp(s, (*pp)->ename) == 0) { /* Found it. */
- struct hash *tem = *pp;
- *pp = (*pp)->enext;
- return tem;
- }
- return 0; /* NULL if not found; else ptr. */
-}
-/* SAVESTR: Save a null-terminated string
-*/
-UNCH *savestr(s)
-UNCH *s;
-{
- UNCH *rp;
-
- rp = (UNCH *)rmalloc(ustrlen(s) + 1);
- ustrcpy(rp, s);
- return rp;
-}
-/* SAVENM: Save a name (with length and EOS)
-*/
-UNCH *savenm(s)
-UNCH *s;
-{
- UNCH *p;
- p = (UNCH *)rmalloc(*s);
- memcpy(p, s, *s);
- return p;
-}
-/* REPLACE: Free the storage for the old string (p) and store the new (s).
- If the specified ptr is NULL, don't free it.
-*/
-UNCH *replace(p, s)
-UNCH *p;
-UNCH *s;
-{
- if (p) frem((UNIV)p); /* Free old storage (if any). */
- if (!s) return(s); /* Return NULL if new string is NULL. */
- return savestr(s);
-}
-/* RMALLOC: Interface to memory allocation with error handling.
- If storage is not available, fatal error message is issued.
- Storage is initialized to zeros.
-*/
-UNIV rmalloc(size)
-unsigned size; /* Number of bytes of initialized storage. */
-{
- UNIV p = (UNIV)calloc(size, 1);
- if (!p) exiterr(33, (struct parse *)0);
- return p;
-}
-UNIV rrealloc(p, n)
-UNIV p;
-UNS n;
-{
- UNIV r = realloc(p, n);
- if (!r)
- exiterr(33, (struct parse *)0);
- return r;
-}
-
-UNCH *pt;
-/* FREM: Free specified memory area gotten with rmalloc().
-*/
-VOID frem(ptr)
-UNIV ptr; /* Memory area to be freed. */
-{
- free(ptr);
-}
-/* MAPSRCH: Find a string in a table and return its associated value.
- The last entry must be a dummy consisting of a NULL pointer for
- the string and whatever return code is desired if the
- string is not found in the table.
-*/
-int mapsrch(maptab, name)
-struct map maptab[];
-UNCH *name;
-{
- int i = 0;
-
- do {
- UNCH *mapnm, *nm;
- for (mapnm = maptab[i].mapnm, nm=name; *nm==*mapnm; mapnm++) {
- if (!*nm++) return maptab[i].mapdata;
- }
- } while (maptab[++i].mapnm);
- return maptab[i].mapdata;
-}
-/* IDDEF: Define an ID control block; return -1 if it already exists.
-*/
-int iddef(iname)
-UNCH *iname; /* ID name (with length and EOS). */
-{
- PID p;
- struct fwdref *r;
-
- p = (PID)hin((THASH)itab, iname, hash(iname, IDHASH), IDSZ);
- if (p->iddefed) return(-1);
- p->iddefed = 1;
- TRACEID("IDDEF", p);
- /* Delete any forward references. */
- r = p->idrl;
- p->idrl = 0;
- while (r) {
- struct fwdref *tem = r->next;
- if (r->msg)
- msgsfree(r->msg);
- frem((UNIV)r);
- r = tem;
- }
- return(0);
-}
-/* IDREF: Store a reference to an ID and define the ID if it doesn't yet exist.
- Return 0 if already defined, otherwise pointer to a fwdref.
-*/
-struct fwdref *idref(iname)
-UNCH *iname; /* ID name (with length and EOS). */
-{
- PID p;
- int hnum;
- struct fwdref *rp;
-
- if ((p = (PID)hfind((THASH)itab, iname, (hnum = hash(iname, IDHASH))))==0)
- p = (PID)hin((THASH)itab, iname, hnum, IDSZ);
- if (p->iddefed)
- return 0;
- rp = (struct fwdref *)rmalloc(FWDREFSZ);
- rp->next = p->idrl;
- p->idrl = rp;
- rp->msg = 0;
- TRACEID("IDREF", p);
- return rp;
-}
-/* IDRCK: Check idrefs.
-*/
-VOID idrck()
-{
- int i;
- PID p;
- struct fwdref *r;
-
- for (i = 0; i < IDHASH; i++)
- for (p = itab[i]; p; p = p->idnext)
- if (!p->iddefed)
- for (r = p->idrl; r; r = r->next)
- svderr(r->msg);
-}
-/* NTOA: Converts a positive integer to an ASCII string (abuf)
- No leading zeros are generated.
-*/
-UNCH *ntoa(i)
-int i;
-{
- static UNCH buf[1 + 3*sizeof(int) + 1];
- sprintf((char *)buf, "%d", i);
- return buf;
-}
-/*
-Local Variables:
-c-indent-level: 5
-c-continued-statement-offset: 5
-c-brace-offset: -5
-c-argdecl-indent: 0
-c-label-offset: -5
-comment-column: 30
-End:
-*/
diff --git a/usr.bin/sgmls/sgmls/sgml1.c b/usr.bin/sgmls/sgmls/sgml1.c
deleted file mode 100644
index c138c9f..0000000
--- a/usr.bin/sgmls/sgmls/sgml1.c
+++ /dev/null
@@ -1,485 +0,0 @@
-#include "sgmlincl.h" /* #INCLUDE statements for SGML parser. */
-
-#define ETDCON (tags[ts].tetd->etdmod->ttype) /* ETD content flags. */
-
-/* SGML: Main SGML driver routine.
-*/
-enum sgmlevent sgmlnext(rcbdafp, rcbtagp)
-struct rcbdata *rcbdafp;
-struct rcbtag *rcbtagp;
-{
- while (prologsw && !conactsw) {
- int oconact;
- conact = parsepro();
- conactsw = 0; /* Assume sgmlact() will not be skipped. */
- switch(conact) {
-
- case PIS_:
- case EOD_:
- case APP_: /* APPINFO */
- conactsw = 1; /* We can skip sgmlact() in opening state. */
- break;
-
- case DAF_:
- newetd = stagreal = ETDCDATA;
- conact = stag(datarc = DAF_);
- conactsw = 1; /* We can skip sgmlact() in opening state. */
- prologsw = 0; /* End the prolog. */
- break;
- case DCE_:
- case MSS_:
- /* prcon[2].tu.thetd holds the etd for the document element. */
- newetd = stagreal = prcon[2].tu.thetd;
- stagmin = MINSTAG; /* This tag was minimized. */
- /* It's an error if the start tag of the document element
- is not minimizable. */
- if (BITOFF(newetd->etdmin, SMO))
- sgmlerr(226, conpcb, (UNCH *)0, (UNCH *)0);
- oconact = conact; /* Save conact. */
- conact = stag(0); /* Start the document element. */
- conactsw = 1; /* conact needs processing. */
- prologsw = 0; /* The prolog is finished. */
- if (oconact == MSS_) {
- if (msplevel==0) conpcb = getpcb((int)ETDCON);
- conpcb = mdms(tbuf, conpcb); /* Parse the marked section
- start. */
- }
- break;
- default: /* STE_: not defined in SGMLACT.H. */
- if (msplevel==0) conpcb = getpcb((int)ETDCON);
- prologsw = 0; /* End the prolog. */
- break;
- }
- }
- for (;;) {
- unsigned swact; /* Switch action: saved conact, new, or sgmlact.*/
-
- if (conactsw) {
- conactsw = 0;
- swact = conact;
- contersw = contersv;
- }
- else {
- conact = parsecon(tbuf, conpcb);
- swact = sgmlact((UNCH)(conact != EOD_ ? conact : LOP_));
- }
-
- switch (swact) {
-
- case MD_: /* Process markup declaration. */
- parsenm(tbuf, NAMECASE); /* Get declaration name. */
- if (!ustrcmp(tbuf+1, key[KUSEMAP])) mdsrmuse(tbuf);
- else sgmlerr(E_MDNAME, conpcb, tbuf+1, (UNCH *)0);
- continue;
- case MDC_: /* Process markup declaration comment. */
- if (*FPOS!=lex.d.mdc)
- parsemd(tbuf, NAMECASE, (struct parse *)0, NAMELEN);
- continue;
-
- case MSS_: /* Process marked section start. */
- conpcb = mdms(tbuf, conpcb);
- continue;
- case MSE_: /* Process marked section end (drop to LOP_). */
- if (mdmse()) conpcb = getpcb((int)ETDCON);
- continue;
-
- case PIS_: /* Return processing instruction (string). */
- if (entpisw) rcbdafp->data = data;
- else {
- parselit(tbuf, &pcblitc, PILEN, lex.d.pic);
- rcbdafp->data = tbuf;
- }
- rcbdafp->datalen = datalen;
- rcbdafp->contersw = entpisw;
- entpisw = 0; /* Reset for next time.*/
- scbset(); /* Update location in current scb. */
- return SGMLPIS;
-
- case APP_:
- rcbdafp->data = tbuf;
- rcbdafp->datalen = ustrlen(tbuf);
- rcbdafp->contersw = 0;
- scbset();
- return SGMLAPP;
- case ETG_: /* Return end-tag. */
- charmode = 0; /* Not in char mode unless CDATA or RCDATA.*/
- if (msplevel==0) conpcb = getpcb((int)ETDCON);
- rcbtagp->contersw = tags[ts+1].tflags;
- rcbtagp->tagmin = etagimsw ? MINETAG : etagmin;
- rcbtagp->curgi = tags[ts+1].tetd->etdgi;
- rcbtagp->ru.oldgi = tags[ts].tetd->etdgi;
- if (etagmin==MINSTAG) rcbtagp->tagreal =
- BADPTR(stagreal) ? stagreal : (PETD)stagreal->etdgi;
- else rcbtagp->tagreal =
- BADPTR(etagreal) ? etagreal : (PETD)etagreal->etdgi;
- rcbtagp->etictr = etictr;
- rcbtagp->srmnm = tags[ts].tsrm!=SRMNULL ? tags[ts].tsrm[0]->ename
- : 0;
- scbset(); /* Update location in current scb. */
- return SGMLETG;
-
- case STG_: /* Return start-tag. */
- charmode = 0; /* Not in char mode unless CDATA or RCDATA.*/
- if (!conrefsw && msplevel==0) conpcb = getpcb((int)ETDCON);
- rcbtagp->contersw = tags[ts].tflags;
- rcbtagp->tagmin = dostag ? MINSTAG : stagmin;
- rcbtagp->curgi = tags[ts].tetd->etdgi;
- /* Get attribute list if one was defined for this element. */
- rcbtagp->ru.al = !tags[ts].tetd->adl ? 0 :
- rcbtagp->tagmin==MINNONE ? al : tags[ts].tetd->adl;
- rcbtagp->tagreal = BADPTR(stagreal)?stagreal:(PETD)stagreal->etdgi;
- rcbtagp->etictr = etictr;
- rcbtagp->srmnm = tags[ts].tsrm!=SRMNULL ? tags[ts].tsrm[0]->ename
- : 0;
- scbset(); /* Update location in current scb. */
- return SGMLSTG;
-
- case DAF_: /* Return data in source entity buffer. */
- charmode = 1;
- rcbdafp->datalen = datalen;
- rcbdafp->data = data;
- rcbdafp->contersw = contersw | entdatsw;
- contersw = entdatsw = 0;/* Reset for next time.*/
- scbset(); /* Update location in current scb. */
- return SGMLDAF;
-
- case CON_: /* Process conact after returning REF_. */
- conactsw = 1;
- contersv = contersw;
- case REF_: /* Return RE found. */
- if (badresw) {
- badresw = 0;
- sgmlerr(E_CHARS, &pcbconm, tags[ts].tetd->etdgi+1, (UNCH *)0);
- continue;
- }
- charmode = 1;
- rcbdafp->contersw = contersw;
- contersw = 0; /* Reset for next time.*/
- scbset(); /* Update location in current scb. */
- return SGMLREF;
-
- case EOD_: /* End of source document entity. */
- if (mslevel != 0) sgmlerr(139, conpcb, (UNCH *)0, (UNCH *)0);
- idrck(); /* Check idrefs. */
- scbset(); /* Update location in current scb. */
- return SGMLEOD;
-
- default: /* LOP_: Loop again with no action. */
- continue;
- }
- }
-}
-/* PCBSGML: State and action table for action codes returned to text processor
- by SGML.C.
- Columns are based on SGMLACT.H values minus DAF_, except that end
- of document has input code LOP_, regardless of its action code.
-*/
-/* Symbols for state names (end with a number). */
-#define ST1 0 /* Just had a start tag. */
-#define NR1 2 /* Just had an RS or RE. */
-#define DA1 4 /* Just had some data. */
-#define NR2 6 /* Just had an RE; RE pending. */
-#define ST2 8 /* Had only markup since last RE/RS; RE pending. */
-
-static UNCH sgmltab[][11] = {
-/*daf_ etg_ md_ mdc_ mss_ mse_ pis_ ref_ stg_ rsr_ eod */
- {DA1 ,DA1 ,ST1 ,ST1 ,ST1 ,ST1 ,ST1 ,NR1 ,ST1 ,NR1 ,ST1 },/*st1*/
- {DAF_,ETG_,MD_ ,MDC_,MSS_,MSE_,PIS_,LOP_,STG_,LOP_,EOD_},
-
- {DA1 ,DA1 ,ST1 ,ST1 ,ST1 ,ST1 ,ST1 ,NR2 ,ST1 ,NR1 ,ST1 },/*nr1*/
- {DAF_,ETG_,MD_ ,MDC_,MSS_,MSE_,PIS_,LOP_,STG_,LOP_,EOD_},
-
- {DA1 ,DA1 ,DA1 ,DA1 ,DA1 ,DA1 ,DA1 ,NR2 ,ST1 ,NR1 ,ST1 },/*da1*/
- {DAF_,ETG_,MD_ ,MDC_,MSS_,MSE_,PIS_,LOP_,STG_,LOP_,EOD_},
-
- {DA1 ,DA1 ,ST2 ,ST2 ,ST2 ,ST2 ,ST2 ,NR2 ,ST1 ,NR2 ,ST1 },/*nr2*/
- {CON_,ETG_,MD_ ,MDC_,MSS_,MSE_,PIS_,REF_,CON_,LOP_,EOD_},
-
- {DA1 ,DA1 ,ST2 ,ST2 ,ST2 ,ST2 ,ST2 ,NR2 ,ST1 ,NR2 ,ST1 },/*st2*/
- {CON_,ETG_,MD_ ,MDC_,MSS_,MSE_,PIS_,LOP_,CON_,LOP_,EOD_},
-};
-int scbsgmst = ST1; /* SCBSGML: trailing stag or markup; ignore RE. */
-int scbsgmnr = NR1; /* SCBSGML: new record; do not ignore RE. */
-/* SGMLACT: Determine action to be taken by SGML.C based on current state and
- specified input.
- For start or end of a plus exception element, push or pop the
- pcbsgml stack.
- Return to caller with action code.
-*/
-#ifdef USE_PROTOTYPES
-int sgmlact(UNCH conret)
-#else
-int sgmlact(conret)
-UNCH conret; /* Action returned to SGML.C by content parse. */
-#endif
-{
- int action;
-
- if (conret==STG_ && GET(tags[ts].tflags, TAGPEX))
- {++pss; scbsgml[pss].snext = ST1;}
- scbsgml[pss].sstate = scbsgml[pss].snext;
- scbsgml[pss].snext = sgmltab[scbsgml[pss].sstate]
- [scbsgml[pss].sinput = conret-DAF_];
- scbsgml[pss].saction = sgmltab[scbsgml[pss].sstate+1][scbsgml[pss].sinput];
- TRACEGML(scbsgml, pss, conactsw, conact);
- action = scbsgml[pss].saction;
- if (conret==ETG_ && GET(tags[ts+1].tflags, TAGPEX)) {
- pss--;
- /* An included subelement affects the enclosing state like a
- processing instruction (or MDC_ or MD_),
- that is to say NR1 is changed to ST1 and NR2 to ST2. */
- scbsgml[pss].sstate = scbsgml[pss].snext;
- scbsgml[pss].snext = sgmltab[scbsgml[pss].sstate][PIS_ - DAF_];
- }
- return action;
-}
-/* GETPCB: Choose pcb for new or resumed element.
-*/
-struct parse *getpcb(etdcon)
-int etdcon; /* Content type of new or resumed element. */
-{
- if (BITON(etdcon, MGI)) {
- return(BITON(etdcon, MCHARS) ? &pcbconm : &pcbcone);
- }
- if (BITON(etdcon, MCDATA) || BITON(etdcon, MRCDATA)) {
- charmode = 1;
- return(BITON(etdcon, MCDATA) ? &pcbconc : (rcessv = es, &pcbconr));
- }
- return(&pcbconm);
-}
-
-struct markup *sgmlset(swp)
-struct switches *swp;
-{
- /* Initialize variables based on switches structure members. */
- sw = *swp;
- rbufs = (UNCH *)rmalloc((UNS)3+sw.swbufsz) + 3; /* DOS file read area. */
- TRACEPRO(); /* Set trace switches for prolog. */
- msginit(swp);
- ioinit(swp);
- entginit(swp);
- sdinit();
- return &lex.m;
-}
-
-/* Points for each capacity, indexed by *CAP in sgmldecl.h. We'll replace
-2 with the real NAMELEN at run time. */
-
-static UNCH cappoints[] = {
- 1,
- 2,
- 1,
- 2,
- 2,
- 2,
- 2,
- 2,
- 1,
- 2,
- 2,
- 1,
- 2,
- 2,
- 2,
- 2,
- 2
-};
-
-static long capnumber[NCAPACITY];
-static long maxsubcap[NCAPACITY];
-
-VOID sgmlend(p)
-struct sgmlcap *p;
-{
- int i;
- for (; es >= 0; --es)
- if (FILESW)
- fileclos();
-
- capnumber[NOTCAP] = ds.dcncnt;
- capnumber[EXGRPCAP] = ds.pmexgcnt;
- capnumber[ELEMCAP] = ds.etdcnt+ds.etdercnt;
- capnumber[EXNMCAP] = ds.pmexcnt;
- capnumber[GRPCAP] = ds.modcnt;
- capnumber[ATTCAP] = ds.attcnt;
- capnumber[ATTCHCAP] = ds.attdef;
- capnumber[AVGRPCAP] = ds.attgcnt;
- capnumber[IDCAP] = ds.idcnt;
- capnumber[IDREFCAP] = ds.idrcnt;
- capnumber[ENTCAP] = ds.ecbcnt;
- capnumber[ENTCHCAP] = ds.ecbtext;
- capnumber[MAPCAP] = ds.srcnt + ds.srcnt*lex.s.dtb[0].mapdata;
- capnumber[NOTCHCAP] = ds.dcntext;
-
- capnumber[TOTALCAP] = 0;
-
- for (i = 1; i < NCAPACITY; i++) {
- if (cappoints[i] > 1)
- cappoints[i] = NAMELEN;
- capnumber[i] += maxsubcap[i]/cappoints[i];
- capnumber[TOTALCAP] += (long)capnumber[i] * cappoints[i];
- }
- p->number = capnumber;
- p->points = cappoints;
- p->limit = sd.capacity;
- p->name = captab;
-
- if (sw.swcap) {
- for (i = 0; i < NCAPACITY; i++) {
- long excess = capnumber[i]*cappoints[i] - sd.capacity[i];
- if (excess > 0) {
- char buf[sizeof(long)*3 + 1];
- sprintf(buf, "%ld", excess);
- sgmlerr(162, (struct parse *)0,
- (UNCH *)captab[i], (UNCH *)buf);
- }
- }
- }
-}
-
-VOID sgmlsubcap(v)
-long *v;
-{
- int i;
- for (i = 0; i < NCAPACITY; i++)
- if (v[i] > maxsubcap[i])
- maxsubcap[i] = v[i];
-}
-
-int sgmlsdoc(ptr)
-UNIV ptr;
-{
- struct entity *e;
- union etext etx;
- etx.x = ptr;
-
- e = entdef(indocent, ESF, &etx);
- if (!e)
- return -1;
- return entopen(e);
-}
-
-/* SGMLGENT: Get a data entity.
- Returns:
- -1 if the entity does not exist
- -2 if it is not a data entity
- 1 if it is an external entity
- 2 if it is an internal cdata entity
- 3 if it is an internal sdata entity
-*/
-int sgmlgent(iname, np, tp)
-UNCH *iname;
-PNE *np;
-UNCH **tp;
-{
- PECB ep; /* Pointer to an entity control block. */
-
- ep = entfind(iname);
- if (!ep)
- return -1;
- switch (ep->estore) {
- case ESN:
- if (np)
- *np = ep->etx.n;
- return 1;
- case ESC:
- if (tp)
- *tp = ep->etx.c;
- return 2;
- case ESX:
- if (tp)
- *tp = ep->etx.c;
- return 3;
- }
- return -2;
-}
-
-/* Mark an entity. */
-
-int sgmlment(iname)
-UNCH *iname;
-{
- PECB ep;
- int rc;
-
- ep = entfind(iname);
- if (!ep)
- return -1;
- rc = ep->mark;
- ep->mark = 1;
- return rc;
-}
-
-int sgmlgcnterr()
-{
- return msgcnterr();
-}
-
-char *getsubst()
-{
- return (char *)lextran;
-}
-
-/* This is for error handling functions that want to print a gi backtrace. */
-
-UNCH *getgi(i)
-int i;
-{
- return i >= 0 && i <= ts ? tags[i].tetd->etdgi + 1 : NULL;
-}
-
-/* Returns the value of prologsw for the use by error handling functions. */
-
-int inprolog()
-{
- return prologsw;
-}
-
-/* Used by the error handling functions to access scbs. */
-
-int getlocation(level, locp)
-int level;
-struct location *locp;
-{
- if (level < 0 || level > es)
- return 0;
- if (locp) {
- int es = level;
- /* source macros access a variable called `es' */
-
- locp->filesw = FILESW;
- locp->rcnt = RCNT;
- locp->ccnt = CCNT;
- locp->ename = ENTITY + 1;
- locp->fcb = SCBFCB;
- locp->curchar = CC;
- locp->nextchar = NEXTC;
- }
- return 1;
-}
-
-int sgmlloc(linenop, filenamep)
-unsigned long *linenop;
-char **filenamep;
-{
- int level = es;
- int es;
-
- for (es = level; es >= 0 && !FILESW; es--)
- ;
- if (es < 0)
- return 0;
- *linenop = RCNT;
- *filenamep = ioflid(SCBFCB);
- return 1;
-}
-
-/*
-Local Variables:
-c-indent-level: 5
-c-continued-statement-offset: 5
-c-brace-offset: -5
-c-argdecl-indent: 0
-c-label-offset: -5
-End:
-*/
diff --git a/usr.bin/sgmls/sgmls/sgml2.c b/usr.bin/sgmls/sgmls/sgml2.c
deleted file mode 100644
index df75b6a..0000000
--- a/usr.bin/sgmls/sgmls/sgml2.c
+++ /dev/null
@@ -1,522 +0,0 @@
-/* Added exiterr() for terminal errors to prevent SGML.MSG errors. */
-#include "sgmlincl.h" /* #INCLUDE statements for SGML parser. */
-static int iorc; /* Return code from io* functions */
-/* ENTDEF: Process an entity definition and return the pointer to it.
- The entity text must be in permanent storage.
- There is no checking to see if the entity already exists;
- the caller must have done that.
-*/
-#ifdef USE_PROTOTYPES
-PECB entdef(UNCH *ename, UNCH estore, union etext *petx)
-#else
-PECB entdef(ename, estore, petx)
-UNCH *ename; /* Entity name (with length and EOS). */
-UNCH estore; /* Entity storage class. */
-union etext *petx; /* Ptr to entity text union. */
-#endif
-{
- PECB p;
-
- p = (PECB)hin((THASH)etab, ename, hash(ename, ENTHASH), ENTSZ);
- memcpy((UNIV)&p->etx, (UNIV)petx, ETEXTSZ);
- p->estore = estore;
- TRACEECB("ENTDEF", p);
- return(p);
-}
-/* ENTFIND: If an entity exists, return ptr to its ecb.
- Return NULL if it is not defined.
-*/
-PECB entfind(ename)
-UNCH *ename; /* Entity name (with length and EOS). */
-{
- PECB p;
-
- p = (PECB)hfind((THASH)etab, ename, hash(ename, ENTHASH));
- TRACEECB("ENTFIND", p);
- return p;
-}
-/* ENTREF: Process a general or parameter entity reference.
- If the entity is defined it returns the return code from ENTOPEN.
- It returns ENTUNDEF for undefined parameter entity references
- and for general entity references when defaulting is not allowed.
- Otherwise, it uses the default entity text.
-*/
-int entref(ename)
-UNCH *ename; /* Entity name (with length and EOS). */
-{
- PECB ecb; /* Entity control block. */
-
- /* Get the entity control block, if the entity has been defined. */
- if ((ecb = (PECB)hfind((THASH)etab, ename, hash(ename, ENTHASH)))==0
- || ecb->estore == 0) {
- if (ename[1] == lex.d.pero || ecbdeflt == 0) {
- sgmlerr(35, (struct parse *)0, ename+1, (UNCH *)0);
- return(ENTUNDEF);
- }
- else
- ecb = usedef(ename);
- }
- return(entopen(ecb));
-}
-/* ENTOPEN: Open a newly referenced entity.
- Increment the stack pointer (es) and initialize the new entry.
- ENTDATA if entity is CDATA or SDATA, ENTPI if it is PI,
- 0 if normal and all o.k.; <0 if not.
-*/
-int entopen(ecb)
-struct entity *ecb; /* Entity control block. */
-{
- int i; /* Loop counter. */
-
- /* See if we have exceeded the entity nesting level. */
- if (es>=ENTLVL) {
- sgmlerr(34, (struct parse *)0, ecb->ename+1, ntoa(ENTLVL));
- return(ENTMAX);
- }
- if (docelsw) sgmlerr(234, (struct parse *)0, (UNCH *)0, (UNCH *)0);
- /* If entity is an etd, pi, or data, return it without creating an scb. */
- switch (ecb->estore) {
- case ESN:
- if (NEXTYPE(ecb->etx.n)!=ESNSUB) {
- if (!NEDCNDEFINED(ecb->etx.n))
- sgmlerr(78, (struct parse *)0, NEDCN(ecb->etx.n)+1,
- ecb->ename+1);
- }
- else {
-#if 0
- if (!NEID(ecb->etx.n)) {
- sgmlerr(149, (struct parse *)0, ecb->ename + 1, (UNCH *)0);
- return ENTFILE;
- }
-#endif
- if (sw.nopen >= sd.subdoc)
- sgmlerr(188, (struct parse *)0,
- (UNCH *)NULL, (UNCH *)NULL);
- }
- data = (UNCH *)ecb->etx.n;
- entdatsw = NDECONT;
- return(ENTDATA);
- case ESC:
- case ESX:
- datalen = ustrlen(ecb->etx.c);
- /* Ignore reference to empty CDATA entity. */
- if (datalen == 0 && ecb->estore == ESC) return(0);
- data = ecb->etx.c;
- entdatsw = (ecb->estore==ESC) ? CDECONT : SDECONT;
- return(ENTDATA);
- case ESI:
- datalen = ustrlen(ecb->etx.c);
- data = ecb->etx.c;
- entpisw = 4;
- return(ENTPI);
- }
- /* If the same entity is already open, send msg and ignore it.
- Level 0 needn't be tested, as its entity name is always *DOC.
- */
- for (i = 0; ++i<=es;) if (scbs[i].ecb.enext==ecb) {
- sgmlerr(36, (struct parse *)0, ecb->ename+1, (UNCH *)0);
- return(ENTLOOP);
- }
- /* Update SCB if entity trace is wanted in messages or entity is a file.
- (Avoid this at start when es==-1 or memory will be corrupted.)
- */
- if (es >= 0 && (sw.swenttr || FILESW)) scbset();
-
- /* Stack the new source control block (we know there is room). */
- ++es; /* Increment scbs index. */
- RCNT = CCO = RSCC = 0; /* No records or chars yet. */
- COPIEDSW = 0;
- memcpy((UNIV)&ECB, (UNIV)ecb, (UNS)ENTSZ); /* Copy the ecb into the scb. */
- ECBPTR = ecb; /* Save the ecb pointer in scb.ecb.enext. */
- TRACEECB("ENTOPEN", ECBPTR);
-
- /* For memory entities, the read buffer is the entity text.
- The text starts at FBUF, so FPOS should be FBUF-1
- because it is bumped before each character is read.
- */
- if (ECB.estore<ESFM) {FPOS = (FBUF = ECB.etx.c)-1; return 0;}
-
- /* For file entities, suspend any open file and do first read. */
- if (ECB.etx.x == 0) {
- --es;
- switch (ecb->estore) {
- case ESF:
- sgmlerr(149, (struct parse *)0, ecb->ename + 1, (UNCH *)0);
- break;
- case ESP:
- sgmlerr(229, (struct parse *)0, ecb->ename + 2, (UNCH *)0);
- break;
- default:
- abort();
- }
- return ENTFILE;
- }
- fileopen(); /* Open new external file. */
- if (iorc<0) { /* If open not successful: */
- FPOS = FBUF-1; /* Clean CCNT for OPEN error msg.*/
- filerr(32, ecb->ename+1);
- --es; /* Pop the stack. */
- return(ENTFILE);
- }
- filepend(es); /* Suspend any open file. */
- fileread(); /* First read of file must be ok.*/
- return 0;
-}
-/* ENTGET: Get next record of entity (if there is one).
- Otherwise, close the file (if entity is a file) and
- pop the entity stack. If nothing else is on the stack,
- return -1 to advise the caller.
-*/
-int entget()
-{
- RSCC += (CCO = FPOS-FBUF);
- /* Characters-in-record (ignore EOB/EOF). */
- if (es == tages)
- tagctr += CCO; /* Update tag length counter. */
- switch (*FPOS) {
- case EOBCHAR: /* End of file buffer: refill it. */
- rbufs[-2] = FPOS[-2];
- rbufs[-1] = FPOS[-1];
- fileread(); /* Read the file. */
- if (iorc > 0) break;
- readerr:
- filerr(31, ENTITY+1); /* Treat error as EOF. */
- case EOFCHAR: /* End of file: close it. */
- fileclos(); /* Call SGMLIO to close file. */
- conterr:
- if (es==0) { /* Report if it is primary file. */
- FPOS = FBUF-1; /* Preserve CCNT for omitted end-tags. */
- return -1;
- }
- case EOS: /* End of memory entity: pop the stack. */
- TRACEECB("ENTPOP", ECBPTR);
- if (COPIEDSW) {
- frem((UNIV)(FBUF + 1));
- COPIEDSW = 0;
- }
- --es; /* Pop the SCB stack. */
- if (FBUF) break; /* Not a PEND file. */
- filecont(); /* Resume previous file. */
- if (iorc<0) { /* If CONT not successful: */
- filerr(94, ENTITY+1);
- goto conterr;
- }
- fileread(); /* Read the file. */
- if (iorc<=0) goto readerr; /* If READ not successful: */
- rbufs[-1] = SCB.pushback;
- FPOS += CCO;
- CCO = 0;
- if (delmscsw && es==0) { /* End of DTD. */
- delmscsw = 0;
- *rbufs = lex.d.msc;
- }
- break;
- }
- return 0;
-}
-/* USEDEF: Use the default value for an entity reference.
- Returns the ECB for the defaulted entity.
-*/
-PECB usedef(ename)
-UNCH *ename; /* Entity name (with length and EOS). */
-{
- union etext etx; /* Save return from entgen. */
- PECB ecb; /* Entity control block. */
- PNE pne = 0; /* Ptr to NDATA entity control block. */
- UNCH estore; /* Default entity storage type. */
-
- if ((estore = ecbdeflt->estore)<ESFM) /* Default is an internal string. */
- etx.c = ecbdeflt->etx.c;
- else {
- /* Move entity name into fpi. */
- fpidf.fpinm = ename + 1;
- if ((etx.x = entgen(&fpidf))==0)
- sgmlerr(150, (struct parse *)0, ename + 1, (UNCH *)0);
- if (estore==ESN) {
- memcpy((UNIV)(pne=(PNE)rmalloc((UNS)NESZ)),(UNIV)ecbdeflt->etx.n,(UNS)NESZ);
- NEID(pne) = etx.x;
- etx.n = pne;
- }
- }
- if (sw.swrefmsg) sgmlerr(45, (struct parse *)0, ename+1, (UNCH *)0);
- ++ds.ecbcnt;
- ecb = entdef(ename, estore, &etx);
- ecb->dflt = 1;
- if (pne) NEENAME(pne) = ecb->ename;
- return(ecb);
-}
-/* SCBSET: Set source control block to current location in the current entity.
- This routine is called by SGML when it returns to the text
- processor and by ERROR when it reports an error.
-*/
-VOID scbset()
-{
- if (es >= 0 && FBUF) {
- CC = *FPOS;
- if (*FPOS == DELNONCH)
- NEXTC = FPOS[1];
- else
- NEXTC = 0;
- CCO = FPOS + 1 - FBUF;
- }
-}
-/* FILEOPEN: Call IOOPEN to open an external entity (file).
-*/
-VOID fileopen() /* Open an external entity's file. */
-{
- iorc = ioopen(ECB.etx.x, &SCBFCB);
-}
-/* FILEREAD: Call IOREAD to read an open external entity (file).
-*/
-VOID fileread() /* Read the current external entity's file. */
-{
- int newfile;
- iorc = ioread(SCBFCB, rbufs, &newfile);
- FPOS = (FBUF = rbufs) - 1; /* Actual read buffer. */
- if (newfile) RCNT = 0;
-}
-/* FILEPEND: Call IOPEND to close an open external entity (file) temporarily.
-*/
-VOID filepend(es) /* Close the current external entity's file. */
-int es; /* Local index to scbs. */
-{
- while (--es>=0) { /* Find last external file on stack. */
- int off;
- if (!FILESW) continue; /* Not an external file. */
- if (!FBUF) continue; /* Already suspended. */
- off = CCO;
- assert(off >= -1);
- if (off < 0) off = 0;
- else CCO = 0;
- FPOS -= CCO;
- SCB.pushback = FPOS[-1];
- FBUF = 0; /* Indicate pending file. */
- RSCC += off; /* Update characters-in-record counter. */
- if (es == tages)
- tagctr += off; /* Update tag length counter. */
- iopend(SCBFCB, off, rbufs);
- return;
- }
-}
-/* FILECONT: Call IOCONT to reopen an external entity (file).
-*/
-VOID filecont() /* Open an external entity's file. */
-{
- iorc = iocont(SCBFCB);
-}
-/* FILECLOS: Call IOCLOSE to close an open external entity (file).
-*/
-VOID fileclos() /* Close the current external entity's file. */
-{
- if (!SCBFCB)
- return;
- ioclose(SCBFCB);
- /* The fcb will have been freed by sgmlio.
- Make sure we don't access it again. */
- SCBFCB = NULL;
-}
-/* ERROR: Interface to text processor SGML I/O services for error handling.
-*/
-VOID error(e)
-struct error *e;
-{
- scbset(); /* Update location in source control block. */
- msgprint(e);
-}
-/* PTRSRCH: Find a pointer in a list and return its index.
- Search key must be on list as there is no limit test.
- This routine is internal only -- not for user data.
-*/
-UNIV mdnmtab[] = {
- (UNIV)key[KATTLIST],
- (UNIV)key[KDOCTYPE],
- (UNIV)key[KELEMENT],
- (UNIV)key[KENTITY],
- (UNIV)key[KLINKTYPE],
- (UNIV)key[KLINK],
- (UNIV)key[KNOTATION],
- (UNIV)sgmlkey,
- (UNIV)key[KSHORTREF],
- (UNIV)key[KUSELINK],
- (UNIV)key[KUSEMAP]
-};
-UNIV pcbtab[] = {
- (UNIV)&pcbconc,
- (UNIV)&pcbcone,
- (UNIV)&pcbconm,
- (UNIV)&pcbconr,
- (UNIV)&pcbetag,
- (UNIV)&pcbgrcm,
- (UNIV)&pcbgrcs,
- (UNIV)&pcbgrnm,
- (UNIV)&pcbgrnt,
- (UNIV)&pcblitc,
- (UNIV)&pcblitp,
- (UNIV)&pcblitr,
- (UNIV)&pcblitt,
- (UNIV)&pcblitv,
- (UNIV)&pcbmd,
- (UNIV)&pcbmdc,
- (UNIV)&pcbmdi,
- (UNIV)&pcbmds,
- (UNIV)&pcbmsc,
- (UNIV)&pcbmsi,
- (UNIV)&pcbmsrc,
- (UNIV)&pcbpro,
- (UNIV)&pcbref,
- (UNIV)&pcbstag,
- (UNIV)&pcbval,
- (UNIV)&pcbeal,
- (UNIV)&pcbsd,
-};
-UNS ptrsrch(ptrtab, ptr)
-UNIV ptrtab[];
-UNIV ptr;
-{
- UNS i;
-
- for (i = 0; ; ++i)
- if (ptrtab[i] == ptr)
- break;
- return i;
-}
-/* MDERR: Process errors for markup declarations.
- Prepare the special parameters that only exist for
- markup declaration errors.
-*/
-VOID mderr(number, parm1, parm2)
-UNS number; /* Error number. */
-UNCH *parm1; /* Additional parameters (or NULL). */
-UNCH *parm2; /* Additional parameters (or NULL). */
-{
- struct error err;
- errorinit(&err, subdcl ? MDERR : MDERR2, number);
- err.parmno = parmno;
- err.subdcl = subdcl;
- err.eparm[0] = (UNIV)parm1;
- err.eparm[1] = (UNIV)parm2;
- err.errsp = (sizeof(pcbtab)/sizeof(pcbtab[0])) + ptrsrch(mdnmtab,
- (UNIV)mdname);
- error(&err);
-}
-/* SGMLERR: Process errors for SGML parser.
-*/
-VOID sgmlerr(number, pcb, parm1, parm2)
-UNS number; /* Error number. */
-struct parse *pcb; /* Current parse control block. */
-UNCH *parm1; /* Error message parameters. */
-UNCH *parm2; /* Error message parameters. */
-{
- struct error err;
- errorinit(&err, DOCERR, number);
- if (!pcb) pcb = prologsw ? propcb : conpcb;
- err.errsp = ptrsrch(pcbtab, (UNIV)pcb);
- err.eparm[0] = (UNIV)parm1;
- err.eparm[1] = (UNIV)parm2;
- error(&err);
-}
-/* SAVERR: Save an error for possible later use.
-*/
-UNIV saverr(number, pcb, parm1, parm2)
-UNS number; /* Error number. */
-struct parse *pcb; /* Current parse control block. */
-UNCH *parm1; /* Error message parameters. */
-UNCH *parm2; /* Error message parameters. */
-{
- struct error err;
- errorinit(&err, DOCERR, number);
- if (!pcb) pcb = prologsw ? propcb : conpcb;
- err.errsp = ptrsrch(pcbtab, (UNIV)pcb);
- err.eparm[0] = (UNIV)parm1;
- err.eparm[1] = (UNIV)parm2;
- scbset();
- return msgsave(&err);
-}
-/* SAVMDERR: Save an md error for possible later use.
-*/
-UNIV savmderr(number, parm1, parm2)
-UNS number; /* Error number. */
-UNCH *parm1; /* Additional parameters (or NULL). */
-UNCH *parm2; /* Additional parameters (or NULL). */
-{
- struct error err;
- errorinit(&err, subdcl ? MDERR : MDERR2, number);
- err.parmno = parmno;
- err.subdcl = subdcl;
- err.eparm[0] = (UNIV)parm1;
- err.eparm[1] = (UNIV)parm2;
- err.errsp = (sizeof(pcbtab)/sizeof(pcbtab[0])) + ptrsrch(mdnmtab,
- (UNIV)mdname);
- scbset();
- return msgsave(&err);
-}
-/* SVDERR: Print a saved error.
-*/
-VOID svderr(p)
-UNIV p;
-{
- msgsprint(p);
-}
-/* EXITERR: Process terminal errors for SGML parser.
-*/
-VOID exiterr(number, pcb)
-UNS number; /* Error number. */
-struct parse *pcb; /* Current parse control block. */
-{
- struct error err;
- errorinit(&err, EXITERR, number);
- if (!pcb) pcb = prologsw ? propcb : conpcb;
- err.errsp = ptrsrch(pcbtab, (UNIV)pcb);
- error(&err);
- /* The error handler should have exited. */
- abort();
-}
-/* SYNERR: Process syntax errors for SGML parser.
-*/
-VOID synerr(number, pcb)
-UNS number; /* Error number. */
-struct parse *pcb; /* Current parse control block. */
-{
- struct error err;
- errorinit(&err, DOCERR, number);
- err.errsp = ptrsrch(pcbtab, (UNIV)pcb);
- error(&err);
-}
-/* FILERR: Process a file access error.
-*/
-VOID filerr(number, parm)
-UNS number;
-UNCH *parm;
-{
- struct error err;
- errorinit(&err, FILERR, number);
- err.eparm[0] = (UNIV)parm;
- err.sverrno = errno;
- error(&err);
-}
-/* ERRORINIT: Constructor for struct error.
-*/
-VOID errorinit(e, type, number)
-struct error *e;
-UNS type;
-UNS number;
-{
- int i;
- e->errtype = type;
- e->errnum = number;
- e->errsp = 0;
- for (i = 0; i < MAXARGS; i++)
- e->eparm[i] = 0;
- e->parmno = 0;
- e->subdcl = 0;
-}
-/*
-Local Variables:
-c-indent-level: 5
-c-continued-statement-offset: 5
-c-brace-offset: -5
-c-argdecl-indent: 0
-c-label-offset: -5
-comment-column: 30
-End:
-*/
diff --git a/usr.bin/sgmls/sgmls/sgmlaux.h b/usr.bin/sgmls/sgmls/sgmlaux.h
deleted file mode 100644
index 6073e66..0000000
--- a/usr.bin/sgmls/sgmls/sgmlaux.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* This file controls the interface between the parser core and the auxiliary
-functions in entgen.c, sgmlio.c, and sgmlmsg.c */
-
-#include "std.h"
-#include "entity.h"
-#include "sgmldecl.h"
-
-/* Error types (ERRTYPE) for calls to error-handling services
- performed for SGML by the text processor (SGMLIO).
- NOTE: Strings in these blocks have no lengths, but cannot exceed
- NAMELEN (plus 1 more byte for the zero terminator).
-*/
-#define FILERR 0 /* Error: file access. */
-#define DOCERR 1 /* Error: in document markup. */
-#define MDERR 2 /* Error: in markup declaration with subdcl. */
-#define MDERR2 3 /* Error: in markup declaration with no subdcl. */
-#define EXITERR 4 /* Error: terminal error in document markup. */
-/* Quantities affecting error messages and their arguments.
-*/
-#define MAXARGS 2 /* Maximum number of arguments in a msg. */
-
-/* NOTE: Error handler must return, or next call to SGML must be RSET or END,
- except for EXITERR errors which must not return.
-*/
-struct error { /* IPB for error messages. */
- UNS errtype; /* Type of error: DOC, MD, MD2, FIL. */
- UNS errnum; /* Error number. */
- UNS errsp; /* Special parameter index in message file. */
- int sverrno; /* Saved value of errno. */
- int parmno; /* MDERROR: declaration parameter number. */
- UNCH *subdcl; /* MDERROR: subject of declaration. */
- UNIV eparm[MAXARGS]; /* Ptrs to arguments (no length, but EOS). */
-};
-
-struct location {
- int filesw;
- unsigned long rcnt;
- int ccnt;
- UNCH curchar;
- UNCH nextchar;
- UNCH *ename;
- UNIV fcb;
-};
-
-int ioopen P((UNIV, UNIV*));
-VOID ioclose P((UNIV));
-int ioread P((UNIV, UNCH *, int *));
-VOID iopend P((UNIV, int, UNCH *));
-int iocont P((UNIV));
-VOID ioinit P((struct switches *));
-char *ioflid P((UNIV));
-
-UNIV entgen P((struct fpi *));
-VOID entginit P((struct switches *));
-
-VOID msgprint P((struct error *));
-VOID msginit P((struct switches *));
-UNIV msgsave P((struct error *));
-VOID msgsprint P((UNIV));
-VOID msgsfree P((UNIV));
-int msgcnterr P((void));
-
-
-int inprolog P((void));
-UNCH *getgi P((int));
-
-int getlocation P((int, struct location *));
-UNIV rmalloc P((unsigned int));
-UNIV rrealloc P((UNIV, UNS));
-VOID frem P((UNIV));
-VOID exiterr P((unsigned int,struct parse *));
-char *getsubst P((void));
diff --git a/usr.bin/sgmls/sgmls/sgmldecl.c b/usr.bin/sgmls/sgmls/sgmldecl.c
deleted file mode 100644
index 6ef6b68..0000000
--- a/usr.bin/sgmls/sgmls/sgmldecl.c
+++ /dev/null
@@ -1,1804 +0,0 @@
-/* sgmldecl.c -
- SGML declaration parsing.
-
- Written by James Clark (jjc@jclark.com).
-*/
-
-#include "sgmlincl.h"
-
-/* Symbolic names for the error numbers that are be generated only by
-this module. */
-
-#define E_SHUNCHAR 159
-#define E_STANDARD 163
-#define E_SIGNIFICANT 164
-#define E_BADLIT 165
-#define E_SCOPE 166
-#define E_XNUM 167
-#define E_BADVERSION 168
-#define E_NMUNSUP 169
-#define E_XNMLIT 170
-#define E_CHARDESC 171
-#define E_CHARDUP 172
-#define E_CHARRANGE 173
-#define E_7BIT 174
-#define E_CHARMISSING 175
-#define E_SHUNNED 176
-#define E_NONSGML 177
-#define E_CAPSET 178
-#define E_CAPMISSING 179
-#define E_SYNTAX 180
-#define E_CHARNUM 181
-#define E_SWITCHES 182
-#define E_INSTANCE 183
-#define E_ZEROFEATURE 184
-#define E_YESNO 185
-#define E_CAPACITY 186
-#define E_NOTSUPPORTED 187
-#define E_FORMAL 189
-#define E_BADCLASS 190
-#define E_MUSTBENON 191
-#define E_BADBASECHAR 199
-#define E_SYNREFUNUSED 200
-#define E_SYNREFUNDESC 201
-#define E_SYNREFUNKNOWN 202
-#define E_SYNREFUNKNOWNSET 203
-#define E_FUNDUP 204
-#define E_BADFUN 205
-#define E_FUNCHAR 206
-#define E_GENDELIM 207
-#define E_SRDELIM 208
-#define E_BADKEY 209
-#define E_BADQUANTITY 210
-#define E_BADNAME 211
-#define E_REFNAME 212
-#define E_DUPNAME 213
-#define E_QUANTITY 214
-#define E_QTOOBIG 215
-#define E_NMSTRTCNT 219
-#define E_NMCHARCNT 220
-#define E_NMDUP 221
-#define E_NMBAD 222
-#define E_NMMINUS 223
-#define E_UNKNOWNSET 227
-#define E_TOTALCAP 235
-
-#define CANON_NMC '.' /* Canonical name character. */
-#define CANON_NMS 'A' /* Canonical name start character. */
-#define CANON_MIN ':' /* Canonical minimum data character. */
-
-#define SUCCESS 1
-#define FAIL 0
-#define SIZEOF(v) (sizeof(v)/sizeof(v[0]))
-#define matches(tok, str) (ustrcmp((tok)+1, (str)) == 0)
-
-static UNCH standard[] = "ISO 8879:1986";
-
-#define REFERENCE_SYNTAX "ISO 8879:1986//SYNTAX Reference//EN"
-#define CORE_SYNTAX "ISO 8879:1986//SYNTAX Core//EN"
-
-static UNCH (*newkey)[REFNAMELEN+1] = 0;
-
-struct pmap {
- char *name;
- UNIV value;
-};
-
-/* The reference capacity set. */
-#define REFCAPSET \
-{ 35000L, 35000L, 35000L, 35000L, 35000L, 35000L, 35000L, 35000L, 35000L, \
-35000L, 35000L, 35000L, 35000L, 35000L, 35000L, 35000L, 35000L }
-
-long refcapset[NCAPACITY] = REFCAPSET;
-
-/* A pmap of known capacity sets. */
-
-static struct pmap capset_map[] = {
- { "ISO 8879:1986//CAPACITY Reference//EN", (UNIV)refcapset },
- { 0 },
-};
-
-/* Table of capacity names. Must match *CAP in sgmldecl.h. */
-
-char *captab[] = {
- "TOTALCAP",
- "ENTCAP",
- "ENTCHCAP",
- "ELEMCAP",
- "GRPCAP",
- "EXGRPCAP",
- "EXNMCAP",
- "ATTCAP",
- "ATTCHCAP",
- "AVGRPCAP",
- "NOTCAP",
- "NOTCHCAP",
- "IDCAP",
- "IDREFCAP",
- "MAPCAP",
- "LKSETCAP",
- "LKNMCAP",
-};
-
-/* The default SGML declaration. */
-#define MAXNUMBER 99999999L
-
-/* Reference quantity set */
-
-#define REFATTCNT 40
-#define REFATTSPLEN 960
-#define REFBSEQLEN 960
-#define REFDTAGLEN 16
-#define REFDTEMPLEN 16
-#define REFENTLVL 16
-#define REFGRPCNT 32
-#define REFGRPGTCNT 96
-#define REFGRPLVL 16
-#define REFNORMSEP 2
-#define REFPILEN 240
-#define REFTAGLEN 960
-#define REFTAGLVL 24
-
-#define ALLOC_MAX 65534
-
-#define BIGINT 30000
-
-#define MAXATTCNT ((ALLOC_MAX/sizeof(struct ad)) - 2)
-#define MAXATTSPLEN BIGINT
-#define MAXBSEQLEN BIGINT
-#define MAXDTAGLEN 16
-#define MAXDTEMPLEN 16
-#define MAXENTLVL ((ALLOC_MAX/sizeof(struct source)) - 1)
-#define MAXGRPCNT MAXGRPGTCNT
-/* Must be between 96 and 253 */
-#define MAXGRPGTCNT 253
-#define MAXGRPLVL MAXGRPGTCNT
-#define MAXLITLEN BIGINT
-/* This guarantees that NAMELEN < LITLEN (ie there's always space for a name
-in a buffer intended for a literal.) */
-#define MAXNAMELEN (REFLITLEN - 1)
-#define MAXNORMSEP 2
-#define MAXPILEN BIGINT
-#define MAXTAGLEN BIGINT
-#define MAXTAGLVL ((ALLOC_MAX/sizeof(struct tag)) - 1)
-
-/* Table of quantity names. Must match Q* in sgmldecl.h. */
-
-static char *quantity_names[] = {
- "ATTCNT",
- "ATTSPLEN",
- "BSEQLEN",
- "DTAGLEN",
- "DTEMPLEN",
- "ENTLVL",
- "GRPCNT",
- "GRPGTCNT",
- "GRPLVL",
- "LITLEN",
- "NAMELEN",
- "NORMSEP",
- "PILEN",
- "TAGLEN",
- "TAGLVL",
-};
-
-static int max_quantity[] = {
- MAXATTCNT,
- MAXATTSPLEN,
- MAXBSEQLEN,
- MAXDTAGLEN,
- MAXDTEMPLEN,
- MAXENTLVL,
- MAXGRPCNT,
- MAXGRPGTCNT,
- MAXGRPLVL,
- MAXLITLEN,
- MAXNAMELEN,
- MAXNORMSEP,
- MAXPILEN,
- MAXTAGLEN,
- MAXTAGLVL,
-};
-
-static char *quantity_changed;
-
-/* Non-zero means the APPINFO parameter was not NONE. */
-static int appinfosw = 0;
-
-struct sgmldecl sd = {
- REFCAPSET, /* capacity */
-#ifdef SUPPORT_SUBDOC
- MAXNUMBER, /* subdoc */
-#else /* not SUPPORT_SUBDOC */
- 0, /* subdoc */
-#endif /* not SUPPORT_SUBDOC */
- 1, /* formal */
- 1, /* omittag */
- 1, /* shorttag */
- 1, /* shortref */
- { 1, 0 }, /* general/entity name case translation */
- { /* reference quantity set */
- REFATTCNT,
- REFATTSPLEN,
- REFBSEQLEN,
- REFDTAGLEN,
- REFDTEMPLEN,
- REFENTLVL,
- REFGRPCNT,
- REFGRPGTCNT,
- REFGRPLVL,
- REFLITLEN,
- REFNAMELEN,
- REFNORMSEP,
- REFPILEN,
- REFTAGLEN,
- REFTAGLVL,
- },
-};
-
-static int systemcharset[] = {
-0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
-16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
-32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
-48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
-64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
-80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
-96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
-112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
-128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
-144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
-160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
-176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
-192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
-208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
-224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
-240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255,
-};
-
-/* This is a private use designating sequence that by convention
-refers to the whole system character set whatever it is. */
-
-#define SYSTEM_CHARSET_DESIGNATING_SEQUENCE "ESC 2/5 2/15 3/0"
-
-static struct pmap charset_map[] = {
- { "ESC 2/5 4/0", (UNIV)iso646charset }, /* ISO 646 IRV */
- { "ESC 2/8 4/2", (UNIV)iso646G0charset }, /* ISO Registration Number 6, ASCII */
- { "ESC 2/8 4/0", (UNIV)iso646G0charset }, /* ISO Registration Number 6, ASCII */
- { "ESC 2/13 4/1", (UNIV)iso8859_1charset }, /* Latin 1 */
- { "ESC 2/1 4/0", (UNIV)iso646C0charset }, /* ISO 646, C0 */
- { "ESC 2/2 4/3", (UNIV)iso6429C1charset }, /* ISO 6429, C1 */
- { SYSTEM_CHARSET_DESIGNATING_SEQUENCE, (UNIV)systemcharset },
- /* system character set */
- { 0 }
-};
-
-static int synrefcharset[256]; /* the syntax reference character set */
-
-#define CHAR_NONSGML 01
-#define CHAR_SIGNIFICANT 02
-#define CHAR_MAGIC 04
-#define CHAR_SHUNNED 010
-
-static UNCH char_flags[256];
-static int done_nonsgml = 0;
-static UNCH *nlextoke = 0; /* new lextoke */
-static UNCH *nlextran = 0; /* new lextran */
-#define MAX_SAVED_ERRS 4
-static UNIV saved_errs[MAX_SAVED_ERRS];
-static int nsaved_errs = 0;
-
-static UNCH kcharset[] = "CHARSET";
-static UNCH kbaseset[] = "BASESET";
-static UNCH kdescset[] = "DESCSET";
-static UNCH kunused[] = "UNUSED";
-static UNCH kcapacity[] = "CAPACITY";
-static UNCH kpublic[] = "PUBLIC";
-static UNCH ksgmlref[] = "SGMLREF";
-static UNCH kscope[] = "SCOPE";
-static UNCH kdocument[] = "DOCUMENT";
-static UNCH kinstance[] = "INSTANCE";
-static UNCH ksyntax[] = "SYNTAX";
-static UNCH kswitches[] = "SWITCHES";
-static UNCH kfeatures[] = "FEATURES";
-static UNCH kminimize[] = "MINIMIZE";
-static UNCH kdatatag[] = "DATATAG";
-static UNCH komittag[] = "OMITTAG";
-static UNCH krank[] = "RANK";
-static UNCH kshorttag[] = "SHORTTAG";
-static UNCH klink[] = "LINK";
-static UNCH ksimple[] = "SIMPLE";
-static UNCH kimplicit[] = "IMPLICIT";
-static UNCH kexplicit[] = "EXPLICIT";
-static UNCH kother[] = "OTHER";
-static UNCH kconcur[] = "CONCUR";
-static UNCH ksubdoc[] = "SUBDOC";
-static UNCH kformal[] = "FORMAL";
-static UNCH kyes[] = "YES";
-static UNCH kno[] = "NO";
-static UNCH kappinfo[] = "APPINFO";
-static UNCH knone[] = "NONE";
-static UNCH kshunchar[] = "SHUNCHAR";
-static UNCH kcontrols[] = "CONTROLS";
-static UNCH kfunction[] = "FUNCTION";
-static UNCH krs[] = "RS";
-static UNCH kre[] = "RE";
-static UNCH kspace[] = "SPACE";
-static UNCH knaming[] = "NAMING";
-static UNCH klcnmstrt[] = "LCNMSTRT";
-static UNCH kucnmstrt[] = "UCNMSTRT";
-static UNCH klcnmchar[] = "LCNMCHAR";
-static UNCH kucnmchar[] = "UCNMCHAR";
-static UNCH knamecase[] = "NAMECASE";
-static UNCH kdelim[] = "DELIM";
-static UNCH kgeneral[] = "GENERAL";
-static UNCH kentity[] = "ENTITY";
-static UNCH kshortref[] = "SHORTREF";
-static UNCH knames[] = "NAMES";
-static UNCH kquantity[] = "QUANTITY";
-
-#define sderr mderr
-
-static UNIV pmaplookup P((struct pmap *, char *));
-static UNCH *ltous P((long));
-static VOID sdfixstandard P((UNCH *, int));
-static int sdparm P((UNCH *, struct parse *));
-static int sdname P((UNCH *, UNCH *));
-static int sdckname P((UNCH *, UNCH *));
-static int sdversion P((UNCH *));
-static int sdcharset P((UNCH *));
-static int sdcsdesc P((UNCH *, int *));
-static int sdpubcapacity P((UNCH *));
-static int sdcapacity P((UNCH *));
-static int sdscope P((UNCH *));
-static VOID setlexical P((void));
-static VOID noemptytag P((void));
-static int sdpubsyntax P((UNCH *));
-static int sdsyntax P((UNCH *));
-static int sdxsyntax P((UNCH *));
-static int sdtranscharnum P((UNCH *));
-static int sdtranschar P((int));
-static int sdshunchar P((UNCH *));
-static int sdsynref P((UNCH *));
-static int sdfunction P((UNCH *));
-static int sdnaming P((UNCH *));
-static int sddelim P((UNCH *));
-static int sdnames P((UNCH *));
-static int sdquantity P((UNCH *));
-static int sdfeatures P((UNCH *));
-static int sdappinfo P((UNCH *));
-static VOID sdsaverr P((UNS, UNCH *, UNCH *));
-
-static VOID bufsalloc P((void));
-static VOID bufsrealloc P((void));
-
-/* Parse the SGML declaration. Return non-zero if there was some appinfo. */
-
-int sgmldecl()
-{
- int i;
- int errsw = 0;
- UNCH endbuf[REFNAMELEN+2]; /* buffer for parsing terminating > */
- static int (*section[]) P((UNCH *)) = {
- sdversion,
- sdcharset,
- sdcapacity,
- sdscope,
- sdsyntax,
- sdfeatures,
- sdappinfo,
- };
- /* These are needed if we use mderr. */
- parmno = 0;
- mdname = sgmlkey;
- subdcl = NULL;
- nsaved_errs = 0;
- for (i = 0; i < SIZEOF(section); i++)
- if ((*section[i])(tbuf) == FAIL) {
- errsw = 1;
- break;
- }
- if (sd.formal) {
- /* print saved errors */
- int i;
- for (i = 0; i < nsaved_errs; i++)
- svderr(saved_errs[i]);
- }
- else {
- /* free saved errors */
- int i;
- for (i = 0; i < nsaved_errs; i++)
- msgsfree(saved_errs[i]);
- }
-
- if (!errsw)
- setlexical();
- bufsrealloc();
- /* Parse the >. Don't overwrite the appinfo. */
- if (!errsw)
- sdparm(endbuf, 0);
- /* We must exit if we hit end of document. */
- if (pcbsd.action == EOD_)
- exiterr(161, &pcbsd);
- if (!errsw && pcbsd.action != ESGD)
- sderr(126, (UNCH *)0, (UNCH *)0);
- return appinfosw;
-}
-
-/* Parse the literal (which should contain the version of the
-standard) at the beginning of a SGML declaration. */
-
-static int sdversion(tbuf)
-UNCH *tbuf;
-{
- if (sdparm(tbuf, &pcblitv) != LIT1) {
- sderr(123, (UNCH *)0, (UNCH *)0);
- return FAIL;
- }
- sdfixstandard(tbuf, 0);
- if (ustrcmp(tbuf, standard) != 0)
- sderr(E_BADVERSION, tbuf, standard);
- return SUCCESS;
-}
-
-/* Parse the CHARSET section. Use one token lookahead. */
-
-static int sdcharset(tbuf)
-UNCH *tbuf;
-{
- int i;
- int status[256];
-
- if (sdname(tbuf, kcharset) == FAIL) return FAIL;
- (void)sdparm(tbuf, 0);
-
- if (sdcsdesc(tbuf, status) == FAIL)
- return FAIL;
-
-#if 0
- for (i = 128; i < 256; i++)
- if (status[i] != UNDESC)
- break;
- if (i >= 256) {
- /* Only a 7-bit character set was described. Fill it out to 8-bits. */
- for (i = 128; i < 256; i++)
- status[i] = UNUSED;
-#if 0
- sderr(E_7BIT, (UNCH *)0, (UNCH *)0);
-#endif
- }
-#endif
- /* Characters that are declared UNUSED in the document character set
- are assigned to non-SGML. */
- for (i = 0; i < 256; i++) {
- if (status[i] == UNDESC) {
-#if 0
- sderr(E_CHARMISSING, ltous((long)i), (UNCH *)0);
-#endif
- char_flags[i] |= CHAR_NONSGML;
- }
- else if (status[i] == UNUSED)
- char_flags[i] |= CHAR_NONSGML;
- }
- done_nonsgml = 1;
- return SUCCESS;
-}
-
-/* Parse a character set description. Uses one character lookahead. */
-
-static int sdcsdesc(tbuf, status)
-UNCH *tbuf;
-int *status;
-{
- int i;
- int nsets = 0;
- struct fpi fpi;
-
- for (i = 0; i < 256; i++)
- status[i] = UNDESC;
-
- for (;;) {
- int nchars;
- int *baseset = 0;
-
- if (pcbsd.action != NAS1) {
- if (nsets == 0) {
- sderr(120, (UNCH *)0, (UNCH *)0);
- return FAIL;
- }
- break;
- }
- if (!matches(tbuf, kbaseset)) {
- if (nsets == 0) {
- sderr(118, tbuf+1, kbaseset);
- return FAIL;
- }
- break;
- }
- nsets++;
- MEMZERO((UNIV)&fpi, FPISZ);
- if (sdparm(tbuf, &pcblitv) != LIT1) {
- sderr(123, (UNCH *)0, (UNCH *)0);
- return FAIL;
- }
- fpi.fpipubis = tbuf;
- /* Give a warning if it is not a CHARSET fpi. */
- if (parsefpi(&fpi))
- sdsaverr(E_FORMAL, (UNCH *)0, (UNCH *)0);
- else if (fpi.fpic != FPICHARS)
- sdsaverr(E_BADCLASS, kcharset, (UNCH *)0);
- else {
- fpi.fpipubis[fpi.fpil + fpi.fpill] = '\0';
- baseset = (int *)pmaplookup(charset_map,
- (char *)fpi.fpipubis + fpi.fpil);
- if (!baseset)
- sderr(E_UNKNOWNSET, fpi.fpipubis + fpi.fpil, (UNCH *)0);
- }
- if (sdname(tbuf, kdescset) == FAIL) return FAIL;
- nchars = 0;
- for (;;) {
- long start, count;
- long basenum;
- if (sdparm(tbuf, 0) != NUM1)
- break;
- start = atol((char *)tbuf);
- if (sdparm(tbuf, 0) != NUM1) {
- sderr(E_XNUM, (UNCH *)0, (UNCH *)0);
- return FAIL;
- }
- count = atol((char *)tbuf);
- switch (sdparm(tbuf, &pcblitv)) {
- case NUM1:
- basenum = atol((char *)tbuf);
- break;
- case LIT1:
- basenum = UNKNOWN;
- break;
- case NAS1:
- if (matches(tbuf, kunused)) {
- basenum = UNUSED;
- break;
- }
- /* fall through */
- default:
- sderr(E_CHARDESC, ltous(start), (UNCH *)0);
- return FAIL;
- }
- if (start + count > 256)
- sderr(E_CHARRANGE, (UNCH *)0, (UNCH *)0);
- else {
- int i;
- int lim = (int)start + count;
- for (i = (int)start; i < lim; i++) {
- if (status[i] != UNDESC)
- sderr(E_CHARDUP, ltous((long)i), (UNCH *)0);
- else if (basenum == UNUSED || basenum == UNKNOWN)
- status[i] = (int)basenum;
- else if (baseset == 0)
- status[i] = UNKNOWN_SET;
- else {
- int n = basenum + (i - start);
- if (n < 0 || n > 255)
- sderr(E_CHARRANGE, (UNCH *)0, (UNCH *)0);
- else {
- if (baseset[n] == UNUSED)
- sderr(E_BADBASECHAR, ltous((long)n),
- (UNCH *)0);
- status[i] = baseset[n];
- }
- }
- }
- }
- nchars++;
- }
- if (nchars == 0) {
- sderr(E_XNUM, (UNCH *)0, (UNCH *)0);
- return FAIL;
- }
- }
- return SUCCESS;
-}
-
-/* Parse the CAPACITY section. Uses one token lookahead. */
-
-static int sdcapacity(tbuf)
-UNCH *tbuf;
-{
- int ncap;
- int i;
-
- if (sdckname(tbuf, kcapacity) == FAIL)
- return FAIL;
- if (sdparm(tbuf, 0) != NAS1) {
- sderr(120, (UNCH *)0, (UNCH *)0);
- return FAIL;
- }
- if (matches(tbuf, kpublic))
- return sdpubcapacity(tbuf);
- if (!matches(tbuf, ksgmlref)) {
- sderr(E_CAPACITY, tbuf+1, (UNCH *)0);
- return FAIL;
- }
- memcpy((UNIV)sd.capacity, (UNIV)refcapset, sizeof(sd.capacity));
- ncap = 0;
- for (;;) {
- int capno = -1;
- int i;
-
- if (sdparm(tbuf, 0) != NAS1)
- break;
- for (i = 0; i < SIZEOF(captab); i++)
- if (matches(tbuf, captab[i])) {
- capno = i;
- break;
- }
- if (capno < 0)
- break;
- if (sdparm(tbuf, 0) != NUM1) {
- sderr(E_XNUM, (UNCH *)0, (UNCH *)0);
- return FAIL;
- }
- sd.capacity[capno] = atol((char *)tbuf);
- ncap++;
- }
- if (ncap == 0) {
- sderr(E_CAPMISSING, (UNCH *)0, (UNCH *)0);
- return FAIL;
- }
- for (i = 1; i < NCAPACITY; i++)
- if (sd.capacity[i] > sd.capacity[0])
- sderr(E_TOTALCAP, (UNCH *)captab[i], (UNCH *)0);
- return SUCCESS;
-}
-
-/* Parse a CAPACITY section that started with PUBLIC. Must do one
-token lookahead, since sdcapacity() also does. */
-
-static int sdpubcapacity(tbuf)
-UNCH *tbuf;
-{
- UNIV ptr;
- if (sdparm(tbuf, &pcblitv) != LIT1) {
- sderr(123, (UNCH *)0, (UNCH *)0);
- return FAIL;
- }
- sdfixstandard(tbuf, 1);
- ptr = pmaplookup(capset_map, (char *)tbuf);
- if (!ptr)
- sderr(E_CAPSET, tbuf, (UNCH *)0);
- else
- memcpy((UNIV)sd.capacity, (UNIV)ptr, sizeof(sd.capacity));
- (void)sdparm(tbuf, 0);
- return SUCCESS;
-}
-
-/* Parse the SCOPE section. Uses no lookahead. */
-
-static int sdscope(tbuf)
-UNCH *tbuf;
-{
- if (sdckname(tbuf, kscope) == FAIL)
- return FAIL;
- if (sdparm(tbuf, 0) != NAS1) {
- sderr(120, (UNCH *)0, (UNCH *)0);
- return FAIL;
- }
- if (matches(tbuf, kdocument))
- ;
- else if (matches(tbuf, kinstance))
- sderr(E_INSTANCE, (UNCH *)0, (UNCH *)0);
- else {
- sderr(E_SCOPE, tbuf+1, (UNCH *)0);
- return FAIL;
- }
- return SUCCESS;
-}
-
-/* Parse the SYNTAX section. Uses one token lookahead. */
-
-static int sdsyntax(tbuf)
-UNCH *tbuf;
-{
- if (sdname(tbuf, ksyntax) == FAIL) return FAIL;
- if (sdparm(tbuf, 0) != NAS1) {
- sderr(120, (UNCH *)0, (UNCH *)0);
- return FAIL;
- }
- if (matches(tbuf, kpublic))
- return sdpubsyntax(tbuf);
- return sdxsyntax(tbuf);
-}
-
-/* Parse the SYNTAX section which starts with PUBLIC. Uses one token
-lookahead. */
-
-static int sdpubsyntax(tbuf)
-UNCH *tbuf;
-{
- int nswitches;
- if (sdparm(tbuf, &pcblitv) != LIT1)
- return FAIL;
- sdfixstandard(tbuf, 1);
- if (ustrcmp(tbuf, CORE_SYNTAX) == 0)
- sd.shortref = 0;
- else if (ustrcmp(tbuf, REFERENCE_SYNTAX) == 0)
- sd.shortref = 1;
- else
- sderr(E_SYNTAX, tbuf, (UNCH *)0);
- if (sdparm(tbuf, 0) != NAS1)
- return SUCCESS;
- if (!matches(tbuf, kswitches))
- return SUCCESS;
- nswitches = 0;
- for (;;) {
- int errsw = 0;
-
- if (sdparm(tbuf, 0) != NUM1)
- break;
- if (atol((char *)tbuf) > 255) {
- sderr(E_CHARNUM, (UNCH *)0, (UNCH *)0);
- errsw = 1;
- }
- if (sdparm(tbuf, 0) != NUM1) {
- sderr(E_XNUM, (UNCH *)0, (UNCH *)0);
- return FAIL;
- }
- if (!errsw) {
- if (atol((char *)tbuf) > 255)
- sderr(E_CHARNUM, (UNCH *)0, (UNCH *)0);
- }
- nswitches++;
- }
- if (nswitches == 0) {
- sderr(E_XNUM, (UNCH *)0, (UNCH *)0);
- return FAIL;
- }
- sderr(E_SWITCHES, (UNCH *)0, (UNCH *)0);
- return SUCCESS;
-}
-
-/* Parse an explicit concrete syntax. Uses one token lookahead. */
-
-static
-int sdxsyntax(tbuf)
-UNCH *tbuf;
-{
- static int (*section[]) P((UNCH *)) = {
- sdshunchar,
- sdsynref,
- sdfunction,
- sdnaming,
- sddelim,
- sdnames,
- sdquantity,
- };
- int i;
-
- for (i = 0; i < SIZEOF(section); i++)
- if ((*section[i])(tbuf) == FAIL)
- return FAIL;
- return SUCCESS;
-}
-
-/* Parse the SHUNCHAR section. Uses one token lookahead. */
-
-static
-int sdshunchar(tbuf)
-UNCH *tbuf;
-{
- int i;
- for (i = 0; i < 256; i++)
- char_flags[i] &= ~CHAR_SHUNNED;
-
- if (sdckname(tbuf, kshunchar) == FAIL)
- return FAIL;
-
- if (sdparm(tbuf, 0) == NAS1) {
- if (matches(tbuf, knone)) {
- (void)sdparm(tbuf, 0);
- return SUCCESS;
- }
- if (matches(tbuf, kcontrols)) {
- for (i = 0; i < 256; i++)
- if (ISASCII(i) && iscntrl(i))
- char_flags[i] |= CHAR_SHUNNED;
- if (sdparm(tbuf, 0) != NUM1)
- return SUCCESS;
- }
- }
- if (pcbsd.action != NUM1) {
- sderr(E_SHUNCHAR, (UNCH *)0, (UNCH *)0);
- return FAIL;
- }
- do {
- long n = atol((char *)tbuf);
- if (n > 255)
- sderr(E_CHARNUM, (UNCH *)0, (UNCH *)0);
- else
- char_flags[(int)n] |= CHAR_SHUNNED;
- } while (sdparm(tbuf, 0) == NUM1);
- return SUCCESS;
-}
-
-/* Parse the syntax reference character set. Uses one token lookahead. */
-
-static
-int sdsynref(tbuf)
-UNCH *tbuf;
-{
- return sdcsdesc(tbuf, synrefcharset);
-}
-
-/* Translate a character number from the syntax reference character set
-to the system character set. If it can't be done, give an error message
-and return -1. */
-
-static
-int sdtranscharnum(tbuf)
-UNCH *tbuf;
-{
- long n = atol((char *)tbuf);
- if (n > 255) {
- sderr(E_CHARNUM, (UNCH *)0, (UNCH *)0);
- return -1;
- }
- return sdtranschar((int)n);
-}
-
-
-static
-int sdtranschar(n)
-int n;
-{
- int ch = synrefcharset[n];
- if (ch >= 0)
- return ch;
- switch (ch) {
- case UNUSED:
- sderr(E_SYNREFUNUSED, ltous((long)n), (UNCH *)0);
- break;
- case UNDESC:
- sderr(E_SYNREFUNDESC, ltous((long)n), (UNCH *)0);
- break;
- case UNKNOWN:
- sderr(E_SYNREFUNKNOWN, ltous((long)n), (UNCH *)0);
- break;
- case UNKNOWN_SET:
- sderr(E_SYNREFUNKNOWNSET, ltous((long)n), (UNCH *)0);
- break;
- default:
- abort();
- }
- return -1;
-}
-
-
-/* Parse the function section. Uses two tokens lookahead. "NAMING"
-could be a function name. */
-
-static
-int sdfunction(tbuf)
-UNCH *tbuf;
-{
- static UNCH *fun[] = { kre, krs, kspace };
- static int funval[] = { RECHAR, RSCHAR, ' ' };
- int i;
- int had_tab = 0;
- int changed = 0; /* attempted to change reference syntax */
-
- if (sdckname(tbuf, kfunction) == FAIL)
- return FAIL;
- for (i = 0; i < SIZEOF(fun); i++) {
- int ch;
- if (sdname(tbuf, fun[i]) == FAIL)
- return FAIL;
- if (sdparm(tbuf, 0) != NUM1) {
- sderr(E_XNUM, (UNCH *)0, (UNCH *)0);
- return FAIL;
- }
- ch = sdtranscharnum(tbuf);
- if (ch >= 0 && ch != funval[i])
- changed = 1;
- }
- for (;;) {
- int tabsw = 0;
- int namingsw = 0;
- if (sdparm(tbuf, 0) != NAS1) {
- sderr(120, (UNCH *)0, (UNCH *)0);
- return FAIL;
- }
- if (matches(tbuf, (UNCH *)"TAB")) {
- tabsw = 1;
- if (had_tab)
- sderr(E_FUNDUP, (UNCH *)0, (UNCH *)0);
- }
- else {
- for (i = 0; i < SIZEOF(fun); i++)
- if (matches(tbuf, fun[i]))
- sderr(E_BADFUN, fun[i], (UNCH *)0);
- if (matches(tbuf, knaming))
- namingsw = 1;
- else
- changed = 1;
- }
- if (sdparm(tbuf, 0) != NAS1) {
- sderr(120, (UNCH *)0, (UNCH *)0);
- return FAIL;
- }
- if (namingsw) {
- if (matches(tbuf, klcnmstrt))
- break;
- changed = 1;
- }
- if (sdparm(tbuf, 0) != NUM1) {
- sderr(E_XNUM, (UNCH *)0, (UNCH *)0);
- return FAIL;
- }
- if (tabsw && !had_tab) {
- int ch = sdtranscharnum(tbuf);
- if (ch >= 0 && ch != TABCHAR)
- changed = 1;
- had_tab = 1;
- }
-
- }
- if (!had_tab)
- changed = 1;
- if (changed)
- sderr(E_FUNCHAR, (UNCH *)0, (UNCH *)0);
- return SUCCESS;
-}
-
-/* Parse the NAMING section. Uses no lookahead. */
-
-static
-int sdnaming(tbuf)
-UNCH *tbuf;
-{
- int i;
- int bad = 0;
- static UNCH *classes[] = { klcnmstrt, kucnmstrt, klcnmchar, kucnmchar };
- static UNCH *types[] = { kgeneral, kentity };
-
-#define NCLASSES SIZEOF(classes)
-
- int bufsize = 4; /* allocated size of buf */
- UNCH *buf = (UNCH *)rmalloc(bufsize); /* holds characters
- in naming classes */
- int bufi = 0; /* next index into buf */
- int start[NCLASSES]; /* index of first character for each class */
- int count[NCLASSES]; /* number of characters for each class */
-
- for (i = 0; i < NCLASSES; i++) {
- UNCH *s;
-
- if (sdckname(tbuf, classes[i]) == FAIL) {
- frem((UNIV)buf);
- return FAIL;
- }
- if (sdparm(tbuf, &pcblitp) != LIT1) {
- sderr(123, (UNCH *)0, (UNCH *)0);
- frem((UNIV)buf);
- return FAIL;
- }
- start[i] = bufi;
-
- for (s = tbuf; *s; s++) {
- int c = *s;
- if (c == DELNONCH) {
- c = UNSHIFTNON(*s);
- s++;
- }
- c = sdtranschar(c);
- if (c < 0)
- bad = 1;
- else if ((char_flags[c] & (CHAR_SIGNIFICANT | CHAR_MAGIC))
- && c != '.' && c != '-') {
- int class = lextoke[c];
- if (class == SEP || class == SP || class == NMC
- || class == NMS || class == NU)
- sderr(E_NMBAD, ltous((long)c), (UNCH *)0);
- else
- sderr(E_NMUNSUP, ltous((long)c), (UNCH *)0);
- bad = 1;
- }
- if (bufi >= bufsize)
- buf = (UNCH *)rrealloc((UNIV)buf, bufsize *= 2);
- buf[bufi++] = c;
- }
-
- count[i] = bufi - start[i];
- (void)sdparm(tbuf, 0);
- }
- if (!bad && count[0] != count[1]) {
- sderr(E_NMSTRTCNT, (UNCH *)0, (UNCH *)0);
- bad = 1;
- }
- if (!bad && count[2] != count[3]) {
- sderr(E_NMCHARCNT, (UNCH *)0, (UNCH *)0);
- bad = 1;
- }
- if (!bad) {
- nlextoke = (UNCH *)rmalloc(256);
- memcpy((UNIV)nlextoke, lextoke, 256);
- nlextoke['.'] = nlextoke['-'] = INV;
-
- nlextran = (UNCH *)rmalloc(256);
- memcpy((UNIV)nlextran, lextran, 256);
-
- for (i = 0; i < count[0]; i++) {
- UNCH lc = buf[start[0] + i];
- UNCH uc = buf[start[1] + i];
- nlextoke[lc] = NMS;
- nlextoke[uc] = NMS;
- nlextran[lc] = uc;
- }
-
- for (i = 0; i < count[2]; i++) {
- UNCH lc = buf[start[2] + i];
- UNCH uc = buf[start[3] + i];
- if (nlextoke[lc] == NMS) {
- sderr(E_NMDUP, ltous((long)lc), (UNCH *)0);
- bad = 1;
- }
- else if (nlextoke[uc] == NMS) {
- sderr(E_NMDUP, ltous((long)uc), (UNCH *)0);
- bad = 1;
- }
- else {
- nlextoke[lc] = NMC;
- nlextoke[uc] = NMC;
- nlextran[lc] = uc;
- }
- }
- if (nlextoke['-'] != NMC) {
- sderr(E_NMMINUS, (UNCH *)0, (UNCH *)0);
- bad = 1;
- }
- if (bad) {
- if (nlextoke) {
- frem((UNIV)nlextoke);
- nlextoke = 0;
- }
- if (nlextran) {
- frem((UNIV)nlextran);
- nlextran = 0;
- }
- }
- }
-
- frem((UNIV)buf);
-
- if (sdckname(tbuf, knamecase) == FAIL)
- return FAIL;
- for (i = 0; i < SIZEOF(types); ++i) {
- if (sdname(tbuf, types[i]) == FAIL)
- return FAIL;
- if (sdparm(tbuf, 0) != NAS1) {
- sderr(120, (UNCH *)0, (UNCH *)0);
- return FAIL;
- }
- if (matches(tbuf, kyes))
- sd.namecase[i] = 1;
- else if (matches(tbuf, kno))
- sd.namecase[i] = 0;
- else {
- sderr(E_YESNO, tbuf+1, (UNCH *)0);
- return FAIL;
- }
- }
- return SUCCESS;
-}
-
-/* Parse the DELIM section. Uses one token lookahead. */
-
-static
-int sddelim(tbuf)
-UNCH *tbuf;
-{
- int changed = 0;
- if (sdname(tbuf, kdelim) == FAIL
- || sdname(tbuf, kgeneral) == FAIL
- || sdname(tbuf, ksgmlref) == FAIL)
- return FAIL;
- for (;;) {
- if (sdparm(tbuf, 0) != NAS1) {
- sderr(120, (UNCH *)0, (UNCH *)0);
- return FAIL;
- }
- if (matches(tbuf, kshortref))
- break;
- if (sdparm(tbuf, &pcblitp) != LIT1) {
- sderr(123, (UNCH *)0, (UNCH *)0);
- return FAIL;
- }
- changed = 1;
- }
- if (changed) {
- sderr(E_GENDELIM, (UNCH *)0,(UNCH *)0);
- changed = 0;
- }
- if (sdparm(tbuf, 0) != NAS1) {
- sderr(120, (UNCH *)0, (UNCH *)0);
- return FAIL;
- }
- if (matches(tbuf, ksgmlref))
- sd.shortref = 1;
- else if (matches(tbuf, knone))
- sd.shortref = 0;
- else {
- sderr(118, tbuf+1, ksgmlref); /* probably they forgot SGMLREF */
- return FAIL;
- }
- while (sdparm(tbuf, &pcblitp) == LIT1)
- changed = 1;
- if (changed)
- sderr(E_SRDELIM, (UNCH *)0, (UNCH *)0);
- return SUCCESS;
-}
-
-/* Parse the NAMES section. Uses one token lookahead. */
-
-static
-int sdnames(tbuf)
-UNCH *tbuf;
-{
- int i;
- if (sdckname(tbuf, knames) == FAIL)
- return FAIL;
- if (sdname(tbuf, ksgmlref) == FAIL)
- return FAIL;
-
- while (sdparm(tbuf, 0) == NAS1) {
- int j;
- if (matches(tbuf, kquantity))
- break;
- for (i = 0; i < NKEYS; i++)
- if (matches(tbuf, key[i]))
- break;
- if (i >= NKEYS) {
- sderr(E_BADKEY, tbuf+1, (UNCH *)0);
- return FAIL;
- }
- if (sdparm(tbuf, &pcblitp) != NAS1) {
- sderr(120, (UNCH *)0, (UNCH *)0);
- return FAIL;
- }
- if (!newkey) {
- newkey = (UNCH (*)[REFNAMELEN+1])rmalloc((REFNAMELEN+1)*NKEYS);
- MEMZERO((UNIV)newkey, (REFNAMELEN+1)*NKEYS);
- }
- for (j = 0; j < NKEYS; j++) {
- if (matches(tbuf, key[j])) {
- sderr(E_REFNAME, tbuf + 1, (UNCH *)0);
- break;
- }
- if (matches(tbuf, newkey[j])) {
- sderr(E_DUPNAME, tbuf + 1, (UNCH *)0);
- break;
- }
- }
- if (j >= NKEYS)
- ustrcpy(newkey[i], tbuf + 1);
- }
- /* Now install the new keys. */
- if (newkey) {
- for (i = 0; i < NKEYS; i++)
- if (newkey[i][0] != '\0') {
- UNCH temp[REFNAMELEN + 1];
-
- ustrcpy(temp, key[i]);
- ustrcpy(key[i], newkey[i]);
- ustrcpy(newkey[i], temp);
- }
- }
- return SUCCESS;
-}
-
-/* Parse the QUANTITY section. Uses one token lookahead. */
-
-static int sdquantity(tbuf)
-UNCH *tbuf;
-{
- int quantity[NQUANTITY];
- int i;
-
- for (i = 0; i < NQUANTITY; i++)
- quantity[i] = -1;
- if (sdckname(tbuf, kquantity) == FAIL)
- return FAIL;
- if (sdname(tbuf, ksgmlref) == FAIL)
- return FAIL;
- while (sdparm(tbuf, 0) == NAS1 && !matches(tbuf, kfeatures)) {
- long n;
- for (i = 0; i < SIZEOF(quantity_names); i++)
- if (matches(tbuf, quantity_names[i]))
- break;
- if (i >= SIZEOF(quantity_names)) {
- sderr(E_BADQUANTITY, tbuf + 1, (UNCH *)0);
- return FAIL;
- }
- if (sdparm(tbuf, 0) != NUM1) {
- sderr(E_XNUM, (UNCH *)0, (UNCH *)0);
- return FAIL;
- }
- n = atol((char *)tbuf);
- if (n < sd.quantity[i])
- sderr(E_QUANTITY, (UNCH *)quantity_names[i],
- ltous((long)sd.quantity[i]));
- else if (n > max_quantity[i]) {
- sderr(E_QTOOBIG, (UNCH *)quantity_names[i],
- ltous((long)max_quantity[i]));
- quantity[i] = max_quantity[i];
- }
- else
- quantity[i] = (int)n;
- }
- for (i = 0; i < NQUANTITY; i++)
- if (quantity[i] > 0) {
- sd.quantity[i] = quantity[i];
- if (!quantity_changed)
- quantity_changed = (char *)rmalloc(NQUANTITY);
- quantity_changed[i] = 1;
- }
- return SUCCESS;
-}
-
-/* Parse the FEATURES section. Uses no lookahead. */
-
-static int sdfeatures(tbuf)
-UNCH *tbuf;
-{
- static struct {
- UNCH *name;
- UNCH argtype; /* 0 = no argument, 1 = boolean, 2 = numeric */
- UNIV valp; /* UNCH * if boolean, long * if numeric. */
- } features[] = {
- { kminimize, 0, 0 },
- { kdatatag, 1, 0 },
- { komittag, 1, (UNIV)&sd.omittag },
- { krank, 1, 0 },
- { kshorttag, 1, (UNIV)&sd.shorttag },
- { klink, 0, 0 },
- { ksimple, 2, 0 },
- { kimplicit, 1, 0 },
- { kexplicit, 2, 0 },
- { kother, 0, 0 },
- { kconcur, 2, 0 },
- { ksubdoc, 2, (UNIV)&sd.subdoc },
- { kformal, 1, (UNIV)&sd.formal },
- };
-
- int i;
-
- if (sdckname(tbuf, kfeatures) == FAIL)
- return FAIL;
- for (i = 0; i < SIZEOF(features); i++) {
- if (sdname(tbuf, features[i].name) == FAIL) return FAIL;
- if (features[i].argtype > 0) {
- long n;
- if (sdparm(tbuf, 0) != NAS1) {
- sderr(120, (UNCH *)0, (UNCH *)0);
- return FAIL;
- }
- if (matches(tbuf, kyes)) {
- if (features[i].argtype > 1) {
- if (sdparm(tbuf, 0) != NUM1) {
- sderr(E_XNUM, (UNCH *)0, (UNCH *)0);
- return FAIL;
- }
- n = atol((char *)tbuf);
- if (n == 0)
- sderr(E_ZEROFEATURE, features[i].name, (UNCH *)0);
- }
- else
- n = 1;
- }
- else if (matches(tbuf, kno))
- n = 0;
- else {
- sderr(E_YESNO, tbuf+1, (UNCH *)0);
- return FAIL;
- }
- if (features[i].valp == 0) {
- if (n > 0)
- sderr(E_NOTSUPPORTED, features[i].name,
- (UNCH *)0);
- }
- else if (features[i].argtype > 1)
- *(long *)features[i].valp = n;
- else
- *(UNCH *)features[i].valp = (UNCH)n;
- }
- }
- if (!sd.shorttag)
- noemptytag();
- return SUCCESS;
-}
-
-/* Parse the APPINFO section. Uses no lookahead. */
-
-static int sdappinfo(tbuf)
-UNCH *tbuf;
-{
- if (sdname(tbuf, kappinfo) == FAIL) return FAIL;
- switch (sdparm(tbuf, &pcblitv)) {
- case LIT1:
- appinfosw = 1;
- break;
- case NAS1:
- if (matches(tbuf, knone))
- break;
- sderr(118, tbuf+1, knone);
- return FAIL;
- default:
- sderr(E_XNMLIT, knone, (UNCH *)0);
- return FAIL;
- }
- return SUCCESS;
-}
-
-/* Change a prefix of ISO 8879-1986 to ISO 8879:1986. Amendment 1 to
-the standard requires the latter. */
-
-static VOID sdfixstandard(tbuf, silently)
-UNCH *tbuf;
-int silently;
-{
- if (strncmp((char *)tbuf, "ISO 8879-1986", 13) == 0) {
- if (!silently)
- sderr(E_STANDARD, (UNCH *)0, (UNCH *)0);
- tbuf[8] = ':';
- }
-}
-
-static int sdname(tbuf, key)
-UNCH *tbuf;
-UNCH *key;
-{
- if (sdparm(tbuf, 0) != NAS1) {
- sderr(120, (UNCH *)0, (UNCH *)0);
- return FAIL;
- }
- if (!matches(tbuf, key)) {
- sderr(118, tbuf+1, key);
- return FAIL;
- }
- return SUCCESS;
-}
-
-static int sdckname(tbuf, key)
-UNCH *tbuf;
-UNCH *key;
-{
- if (pcbsd.action != NAS1) {
- sderr(120, (UNCH *)0, (UNCH *)0);
- return FAIL;
- }
- if (!matches(tbuf, key)) {
- sderr(118, tbuf+1, key);
- return FAIL;
- }
- return SUCCESS;
-}
-
-/* Parse a SGML declaration parameter. If lpcb is NULL, pt must be
-REFNAMELEN+2 characters long, otherwise at least LITLEN+2 characters
-long. LPCB should be NULL if a literal is not allowed. */
-
-static int sdparm(pt, lpcb)
-UNCH *pt; /* Token buffer. */
-struct parse *lpcb; /* PCB for literal parse. */
-{
- for (;;) {
- parse(&pcbsd);
- if (pcbsd.action != ISIG)
- break;
- sderr(E_SIGNIFICANT, (UNCH *)0, (UNCH *)0);
- }
- ++parmno;
- switch (pcbsd.action) {
- case LIT1:
- if (!lpcb) {
- sderr(E_BADLIT, (UNCH *)0, (UNCH *)0);
- REPEATCC;
- return pcbsd.action = INV_;
- }
- parselit(pt, lpcb, REFLITLEN, lex.d.lit);
- return pcbsd.action;
- case LIT2:
- if (!lpcb) {
- sderr(E_BADLIT, (UNCH *)0, (UNCH *)0);
- REPEATCC;
- return pcbsd.action = INV_;
- }
- parselit(pt, lpcb, REFLITLEN, lex.d.lita);
- return pcbsd.action = LIT1;
- case NAS1:
- parsenm(pt, 1);
- return pcbsd.action;
- case NUM1:
- parsetkn(pt, NU, REFNAMELEN);
- return pcbsd.action;
- }
- return pcbsd.action;
-}
-
-VOID sdinit()
-{
- int i;
- /* Shunned character numbers in the reference concrete syntax. */
- static UNCH refshun[] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
- 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 127, 255
- };
- UNCH **p;
- /* A character is magic if it is a non-SGML character used for
- some internal purpose in the parser. */
- char_flags[EOS] |= CHAR_MAGIC;
- char_flags[EOBCHAR] |= CHAR_MAGIC;
- char_flags[EOFCHAR] |= CHAR_MAGIC;
- char_flags[GENRECHAR] |= CHAR_MAGIC;
- char_flags[DELNONCH] |= CHAR_MAGIC;
- char_flags[DELCDATA] |= CHAR_MAGIC;
- char_flags[DELSDATA] |= CHAR_MAGIC;
-
- /* Figure out the significant SGML characters. */
- for (p = lextabs; *p; p++) {
- UNCH datclass = (*p)[CANON_DATACHAR];
- UNCH nonclass = (*p)[CANON_NONSGML];
- for (i = 0; i < 256; i++)
- if (!(char_flags[i] & CHAR_MAGIC)
- && (*p)[i] != datclass && (*p)[i] != nonclass)
- char_flags[i] |= CHAR_SIGNIFICANT;
- }
- for (i = 0; i < SIZEOF(refshun); i++)
- char_flags[refshun[i]] |= CHAR_SHUNNED;
- for (i = 0; i < 256; i++)
- if (ISASCII(i) && iscntrl(i))
- char_flags[i] |= CHAR_SHUNNED;
- bufsalloc();
-}
-
-
-static
-VOID bufsalloc()
-{
- scbs = (struct source *)rmalloc((REFENTLVL+1)*sizeof(struct source));
- tbuf = (UNCH *)rmalloc(REFATTSPLEN+REFLITLEN+1);
- /* entbuf is used for parsing numeric character references */
- entbuf = (UNCH *)rmalloc(REFNAMELEN + 2);
-}
-
-static
-VOID bufsrealloc()
-{
- UNS size;
-
- if (ENTLVL != REFENTLVL)
- scbs = (struct source *)rrealloc((UNIV)scbs,
- (ENTLVL+1)*sizeof(struct source));
- /* Calculate the size for tbuf. */
- size = LITLEN + ATTSPLEN;
- if (PILEN > size)
- size = PILEN;
- if (BSEQLEN > size)
- size = BSEQLEN;
- if (size != REFATTSPLEN + REFLITLEN)
- tbuf = (UNCH *)rrealloc((UNIV)tbuf, size + 1);
- if (NAMELEN != REFNAMELEN)
- entbuf = (UNCH *)rrealloc((UNIV)entbuf, NAMELEN + 2);
-}
-
-
-/* Check that the non-SGML characters are compatible with the concrete
-syntax and munge the lexical tables accordingly. If IMPLIED is
-non-zero, then the SGML declaration was implied; in this case, don't
-give error messages about shunned characters not being declared
-non-SGML. Also make any changes that are required by the NAMING section.
-*/
-
-static VOID setlexical()
-{
- int i;
- UNCH **p;
-
- if (nlextoke) {
- /* Handle characters that were made significant by the
- NAMING section. */
- for (i = 0; i < 256; i++)
- if (nlextoke[i] == NMC || nlextoke[i] == NMS)
- char_flags[i] |= CHAR_SIGNIFICANT;
- }
-
- for (i = 0; i < 256; i++)
- if (char_flags[i] & CHAR_SIGNIFICANT) {
- /* Significant SGML characters musn't be non-SGML. */
- if (char_flags[i] & CHAR_NONSGML) {
- UNCH buf[2];
- buf[0] = i;
- buf[1] = '\0';
- sderr(E_NONSGML, buf, (UNCH *)0);
- char_flags[i] &= ~CHAR_NONSGML;
- }
- }
- else {
- /* Shunned characters that are not significant SGML characters
- must be non-SGML. */
- if ((char_flags[i] & (CHAR_SHUNNED | CHAR_NONSGML))
- == CHAR_SHUNNED) {
- sderr(E_SHUNNED, ltous((long)i), (UNCH *)0);
- char_flags[i] |= CHAR_NONSGML;
- }
- }
-
-
- /* Now munge the lexical tables. */
- for (p = lextabs; *p; p++) {
- UNCH nonclass = (*p)[CANON_NONSGML];
- UNCH datclass = (*p)[CANON_DATACHAR];
- UNCH nmcclass = (*p)[CANON_NMC];
- UNCH nmsclass = (*p)[CANON_NMS];
- UNCH minclass = (*p)[CANON_MIN];
- for (i = 0; i < 256; i++) {
- if (char_flags[i] & CHAR_NONSGML) {
- /* We already know that it's not significant. */
- if (!(char_flags[i] & CHAR_MAGIC))
- (*p)[i] = nonclass;
- }
- else {
- if (char_flags[i] & CHAR_MAGIC) {
- sderr(E_MUSTBENON, ltous((long)i), (UNCH *)0);
- }
- else if (!(char_flags[i] & CHAR_SIGNIFICANT))
- (*p)[i] = datclass;
- else if (*p == lexmin) {
- /* If it used to be NONSGML, but its now significant,
- treat it like a datachar. */
- if ((*p)[i] == nonclass)
- (*p)[i] = datclass;
- }
- else if (nlextoke
- /* This relies on the fact that lextoke
- occurs last in lextabs. */
- && lextoke[i] != nlextoke[i]) {
- switch (nlextoke[i]) {
- case NMC:
- (*p)[i] = nmcclass;
- break;
- case NMS:
- (*p)[i] = nmsclass;
- break;
- case INV:
- /* This will happen if period is not a
- name character. */
- (*p)[i] = minclass;
- break;
- default:
- abort();
- }
- }
- }
- }
- }
- if (nlextran) {
- memcpy((UNIV)lextran, (UNIV)nlextran, 256);
- frem((UNIV)nlextran);
- }
- if (nlextoke) {
- frem((UNIV)nlextoke);
- nlextoke = 0;
- }
-
-}
-
-/* Munge parse tables so that empty start and end tags are not recognized. */
-
-static VOID noemptytag()
-{
- static struct parse *pcbs[] = { &pcbconm, &pcbcone, &pcbconr, &pcbconc };
- int i;
-
- for (i = 0; i < SIZEOF(pcbs); i++) {
- int maxclass, maxstate;
- int j, k, act;
- UNCH *plex = pcbs[i]->plex;
- UNCH **ptab = pcbs[i]->ptab;
-
- /* Figure out the maximum lexical class. */
- maxclass = 0;
- for (j = 0; j < 256; j++)
- if (plex[j] > maxclass)
- maxclass = plex[j];
-
- /* Now figure out the maximum state number and at the same time
- change actions. */
-
- maxstate = 0;
-
- for (j = 0; j <= maxstate; j += 2) {
- for (k = 0; k <= maxclass; k++)
- if (ptab[j][k] > maxstate)
- maxstate = ptab[j][k];
- /* If the '>' class has an empty start or end tag action,
- change it to the action that the NMC class has. */
- act = ptab[j + 1][plex['>']];
- if (act == NET_ || act == NST_)
- ptab[j + 1][plex['>']] = ptab[j + 1][plex['_']];
- }
- }
-}
-
-/* Lookup the value of the entry in pmap PTR whose key is KEY. */
-
-static UNIV pmaplookup(ptr, key)
-struct pmap *ptr;
-char *key;
-{
- for (; ptr->name; ptr++)
- if (strcmp(key, ptr->name) == 0)
- return ptr->value;
- return 0;
-}
-
-/* Return an ASCII representation of N. */
-
-static UNCH *ltous(n)
-long n;
-{
- static char buf[sizeof(long)*3 + 2];
- sprintf(buf, "%ld", n);
- return (UNCH *)buf;
-}
-
-VOID sgmlwrsd(fp)
-FILE *fp;
-{
- int i;
- int changed;
- char *p;
- char uc[256]; /* upper case characters (with different lower
- case characters) */
- char lcletter[256]; /* LC letters: a-z */
-
- fprintf(fp, "<!SGML \"%s\"\n", standard);
- fprintf(fp,
- "CHARSET\nBASESET \"-//Dummy//CHARSET Dummy//%s\"\nDESCSET\n",
- SYSTEM_CHARSET_DESIGNATING_SEQUENCE);
-
- if (!done_nonsgml) {
- done_nonsgml = 1;
- for (i = 0; i < 256; i++)
- if ((char_flags[i] & (CHAR_SIGNIFICANT | CHAR_SHUNNED))
- == CHAR_SHUNNED)
- char_flags[i] |= CHAR_NONSGML;
- }
- i = 0;
- while (i < 256) {
- int j;
- for (j = i + 1; j < 256; j++)
- if ((char_flags[j] & CHAR_NONSGML)
- != (char_flags[i] & CHAR_NONSGML))
- break;
- if (char_flags[i] & CHAR_NONSGML)
- fprintf(fp, "%d %d UNUSED\n", i, j - i);
- else
- fprintf(fp, "%d %d %d\n", i, j - i, i);
- i = j;
- }
- fprintf(fp, "CAPACITY\n");
- changed = 0;
- for (i = 0; i < NCAPACITY; i++)
- if (refcapset[i] != sd.capacity[i]) {
- if (!changed) {
- fprintf(fp, "SGMLREF\n");
- changed = 1;
- }
- fprintf(fp, "%s %ld\n", captab[i], sd.capacity[i]);
- }
- if (!changed)
- fprintf(fp, "PUBLIC \"%s\"\n", capset_map[0].name);
- fprintf(fp, "SCOPE DOCUMENT\n");
-
- fprintf(fp, "SYNTAX\nSHUNCHAR");
- for (i = 0; i < 256; i++)
- if (char_flags[i] & CHAR_SHUNNED)
- break;
- if (i == 256)
- fprintf(fp, " NONE\n");
- else {
- for (; i < 256; i++)
- if (char_flags[i] & CHAR_SHUNNED)
- fprintf(fp, " %d", i);
- fprintf(fp, "\n");
- }
-
- fprintf(fp,
- "BASESET \"-//Dummy//CHARSET Dummy//%s\"\nDESCSET 0 256 0\n",
- SYSTEM_CHARSET_DESIGNATING_SEQUENCE);
-
- fprintf(fp, "FUNCTION\nRE %d\nRS %d\nSPACE %d\nTAB SEPCHAR %d\n",
- RECHAR, RSCHAR, ' ', TABCHAR);
-
- MEMZERO((UNIV)uc, 256);
- for (i = 0; i < 256; i++)
- if (lextran[i] != i)
- uc[lextran[i]] = 1;
-
- MEMZERO((UNIV)lcletter, 256);
- for (p = "abcdefghijklmnopqrstuvwxyz"; *p; p++)
- lcletter[(unsigned char)*p]= 1;
-
- fprintf(fp, "NAMING\n");
- fputs("LCNMSTRT \"", fp);
- for (i = 0; i < 256; i++)
- if (lextoke[i] == NMS && !uc[i] && !lcletter[i])
- fprintf(fp, "&#%d;", i);
- fputs("\"\n", fp);
- fputs("UCNMSTRT \"", fp);
- for (i = 0; i < 256; i++)
- if (lextoke[i] == NMS && !uc[i] && !lcletter[i])
- fprintf(fp, "&#%d;", lextran[i]);
- fputs("\"\n", fp);
- fputs("LCNMCHAR \"", fp);
- for (i = 0; i < 256; i++)
- if (lextoke[i] == NMC && !uc[i])
- fprintf(fp, "&#%d;", i);
- fputs("\"\n", fp);
- fputs("UCNMCHAR \"", fp);
- for (i = 0; i < 256; i++)
- if (lextoke[i] == NMC && !uc[i])
- fprintf(fp, "&#%d;", lextran[i]);
- fputs("\"\n", fp);
-
- fprintf(fp, "NAMECASE\nGENERAL %s\nENTITY %s\n",
- sd.namecase[0] ? "YES" : "NO",
- sd.namecase[1] ? "YES" : "NO");
- fprintf(fp, "DELIM\nGENERAL SGMLREF\nSHORTREF %s\n",
- sd.shortref ? "SGMLREF" : "NONE");
- fprintf(fp, "NAMES SGMLREF\n");
- if (newkey) {
- /* The reference key was saved in newkey. */
- for (i = 0; i < NKEYS; i++)
- if (newkey[i][0])
- fprintf(fp, "%s %s\n", newkey[i], key[i]);
- }
- fprintf(fp, "QUANTITY SGMLREF\n");
- if (quantity_changed)
- for (i = 0; i < NQUANTITY; i++)
- if (quantity_changed[i])
- fprintf(fp, "%s %d\n", quantity_names[i], sd.quantity[i]);
- fprintf(fp,
- "FEATURES\nMINIMIZE\nDATATAG NO OMITTAG %s RANK NO SHORTTAG %s\n",
- sd.omittag ? "YES" : "NO",
- sd.shorttag ? "YES" : "NO");
- fprintf(fp, "LINK SIMPLE NO IMPLICIT NO EXPLICIT NO\n");
- fprintf(fp, "OTHER CONCUR NO ");
- if (sd.subdoc > 0)
- fprintf(fp, "SUBDOC YES %ld ", sd.subdoc);
- else
- fprintf(fp, "SUBDOC NO ");
- fprintf(fp, "FORMAL %s\n", sd.formal ? "YES" : "NO");
- fprintf(fp, "APPINFO NONE");
- fprintf(fp, ">\n");
-}
-
-/* Save an error to be printed only if FORMAL is declared as YES. */
-
-static
-VOID sdsaverr(number, parm1, parm2)
-UNS number;
-UNCH *parm1;
-UNCH *parm2;
-{
- saved_errs[nsaved_errs++] = savmderr(number, parm1, parm2);
-}
-
-/*
-Local Variables:
-c-indent-level: 5
-c-continued-statement-offset: 5
-c-brace-offset: -5
-c-argdecl-indent: 0
-c-label-offset: -5
-End:
-*/
diff --git a/usr.bin/sgmls/sgmls/sgmldecl.h b/usr.bin/sgmls/sgmls/sgmldecl.h
deleted file mode 100644
index 1111f72..0000000
--- a/usr.bin/sgmls/sgmls/sgmldecl.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* sgmldecl.h: SGML declaration parsing. */
-
-#define QATTCNT 0
-#define QATTSPLEN 1
-#define QBSEQLEN 2
-#define QDTAGLEN 3
-#define QDTEMPLEN 4
-#define QENTLVL 5
-#define QGRPCNT 6
-#define QGRPGTCNT 7
-#define QGRPLVL 8
-#define QLITLEN 9
-#define QNAMELEN 10
-#define QNORMSEP 11
-#define QPILEN 12
-#define QTAGLEN 13
-#define QTAGLVL 14
-
-#define NQUANTITY (QTAGLVL+1)
-
-#define TOTALCAP 0
-#define ENTCAP 1
-#define ENTCHCAP 2
-#define ELEMCAP 3
-#define GRPCAP 4
-#define EXGRPCAP 5
-#define EXNMCAP 6
-#define ATTCAP 7
-#define ATTCHCAP 8
-#define AVGRPCAP 9
-#define NOTCAP 10
-#define NOTCHCAP 11
-#define IDCAP 12
-#define IDREFCAP 13
-#define MAPCAP 14
-#define LKSETCAP 15
-#define LKNMCAP 16
-
-extern char *captab[];
-
-struct sgmldecl {
- long capacity[NCAPACITY];
- long subdoc;
- UNCH formal;
- UNCH omittag;
- UNCH shorttag;
- UNCH shortref;
- UNCH namecase[2]; /* case translation of general/entity names */
- int quantity[NQUANTITY];
-};
-
-extern struct sgmldecl sd;
-
-#define OMITTAG (sd.omittag)
-#define SUBDOC (sd.subdoc)
-#define SHORTTAG (sd.shorttag)
-#define FORMAL (sd.formal)
-
-#define ATTCNT (sd.quantity[QATTCNT])
-#define ATTSPLEN (sd.quantity[QATTSPLEN])
-#define BSEQLEN (sd.quantity[QBSEQLEN])
-#define ENTLVL (sd.quantity[QENTLVL])
-#define GRPGTCNT (sd.quantity[QGRPGTCNT])
-#define GRPCNT (sd.quantity[QGRPCNT])
-#define GRPLVL (sd.quantity[QGRPLVL])
-#define LITLEN (sd.quantity[QLITLEN])
-#define NAMELEN (sd.quantity[QNAMELEN])
-#define NORMSEP (sd.quantity[QNORMSEP])
-#define PILEN (sd.quantity[QPILEN])
-#define TAGLEN (sd.quantity[QTAGLEN])
-#define TAGLVL (sd.quantity[QTAGLVL])
-
-#define NAMECASE (sd.namecase[0])
-#define ENTCASE (sd.namecase[1])
-
-#define YES 1
-#define NO 0
-
-#define UNUSED -1
-#define UNKNOWN -2
-#define UNDESC -3
-#define UNKNOWN_SET -4
-
-extern int iso646charset[];
-extern int iso646G0charset[];
-extern int iso646C0charset[];
-extern int iso8859_1charset[];
-extern int iso6429C1charset[];
-
-
diff --git a/usr.bin/sgmls/sgmls/sgmlfnsm.h b/usr.bin/sgmls/sgmls/sgmlfnsm.h
deleted file mode 100644
index 3003d67..0000000
--- a/usr.bin/sgmls/sgmls/sgmlfnsm.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/* SGMLFNSM.H: SGML function declarations (ANSI prototypes). */
-VOID adlfree P((struct ad *, int));
-VOID adlval P((int,struct etd *));
-VOID aenttst P((int, UNCH *));
-int allhit P((struct thdr *,unsigned long *,int,int));
-VOID ambig P((void));
-VOID ambigfree P((void));
-int amemget P((struct ad *,int,UNCH *));
-int anmget P((int,UNCH *));
-int anmtgrp P((struct parse *,struct ad *,int,UNS *,int));
-int antvget P((int,UNCH *,UNCH **));
-int anyhit P((unsigned long *));
-int attval P((int,UNCH *,int,struct ad *));
-VOID charrefa P((UNCH *));
-int charrefn P((UNCH *, struct parse *));
-int context P((struct etd *,struct thdr *,struct mpos *,UNCH *,int));
-struct etd **copygrp P((struct etd **,unsigned int));
-int datachar P((int, struct parse *));
-struct dcncb *dcnfind P((UNCH *));
-VOID destack P((void));
-int econtext P((struct thdr *,struct mpos *,UNCH *));
-VOID endprolog P((void));
-struct entity *entfind P((UNCH *));
-int entopen P((struct entity *));
-/* VOID eposset P((void)); NOT YET IN USE. */
-VOID error P((struct error *));
-VOID errorinit P((struct error *, unsigned, unsigned));
-int etag P((void));
-int etagetd P((struct parse *));
-VOID etdadl P((struct etd *));
-VOID etdcan P((UNCH *));
-struct etd *etddef P((UNCH *));
-struct etd *etdref P((UNCH *));
-VOID exclude P((void));
-VOID fileclos P((void));
-VOID filecont P((void));
-VOID fileopen P((void));
-VOID filepend P((int));
-VOID fileread P((void));
-VOID filerr P((unsigned, UNCH *));
-VOID fixdatt P((struct dcncb *));
-struct parse *getpcb P((int));
-int groupopt P((struct thdr *,struct mpos *));
-int groupreq P((struct etd *,struct thdr *,struct mpos *));
-int grpsz P((struct thdr *,int));
-int hash P((UNCH *,int));
-struct hash *hfind P((struct hash **,UNCH *,int));
-struct hash *hin P((struct hash **,UNCH *,int,unsigned int));
-int iddef P((UNCH *));
-VOID idrck P((void));
-struct fwdref *idref P((UNCH *));
-VOID idreftst P((int,UNCH *));
-int ingrp P((struct etd **,struct etd *));
-VOID initatt P((struct ad *));
-int mapsrch P((struct map *,UNCH *));
-VOID mdadl P((UNCH *));
-int mdattdef P((int, int));
-VOID mddtde P((UNCH *));
-VOID mddtds P((UNCH *));
-VOID mdelem P((UNCH *));
-VOID mdentity P((UNCH *));
-VOID mderr P((unsigned int,UNCH *,UNCH *));
-struct parse *mdms P((UNCH *,struct parse *));
-int mdmse P((void));
-VOID mdnadl P((UNCH *));
-VOID mdnot P((UNCH *));
-VOID mdsrmdef P((UNCH *));
-VOID mdsrmuse P((UNCH *));
-int netetd P((struct parse *));
-VOID newtoken P((struct thdr *,struct mpos *,UNCH *));
-int nstetd P((void));
-UNCH *ntoa P((int));
-int offbit P((unsigned long *,int,int));
-int parsecon P((UNCH *,struct parse *));
-int parsefpi P((struct fpi *));
-struct thdr *parsegcm P((struct parse *,struct thdr *,struct thdr *));
-VOID parselit P((UNCH *,struct parse *,unsigned int,UNCH));
-struct thdr *parsemod P((int));
-int parsepro P((void));
-VOID parseseq P((UNCH *,int));
-VOID parsetag P((struct parse *));
-int parseval P((UNCH *,unsigned int,UNCH *));
-int pexmex P((struct etd *));
-unsigned int ptrsrch P((UNIV *,UNIV));
-UNCH *pubfield P((UNCH *,UNCH *,UNCH,UNS *));
-UNCH *replace P((UNCH *,UNCH *));
-UNCH *sandwich P((UNCH *,UNCH *,UNCH *));
-UNIV saverr P((unsigned int,struct parse *,UNCH *,UNCH *));
-UNIV savmderr P((unsigned int,UNCH *,UNCH *));
-VOID scbset P((void));
-VOID sdinit P((void));
-VOID setcurchar P((int));
-VOID setdtype P((void));
-int sgmlact P((UNCH));
-int sgmldecl P((void));
-VOID sgmlerr P((unsigned int,struct parse *,UNCH *,UNCH *));
-int shortref P((int,struct parse *));
-struct srh *srhfind P((UNCH *));
-VOID stack P((struct etd *));
-int stag P((int));
-int stagetd P((struct parse *));
-VOID startdtd P((void));
-UNCH *savenm P((UNCH *));
-UNCH *savestr P((UNCH *));
-VOID storedatt P((PNE));
-VOID svderr P((UNIV));
-VOID synerr P((unsigned int,struct parse *));
-int testend P((struct thdr *,struct mpos *,int,int));
-int tokenopt P((struct thdr *,struct mpos *));
-int tokenreq P((struct etd *,struct thdr *,struct mpos *));
-UNS vallen P((int,int,UNCH *));
-struct dcncb *dcndef P((UNCH *));
-struct entity *entdef P((UNCH *,UNCH,union etext *));
-int entget P((void));
-int entref P((UNCH *));
-struct etd *etdset P((struct etd *,UNCH,struct thdr *,struct etd **,
- struct etd **, struct entity **));
-struct hash *hout P((struct hash **,UNCH *,int));
-struct fpi *mdextid P((UNCH *,struct fpi *,UNCH *,UNCH *,struct ne *));
-int parse P((struct parse *));
-struct ad *parseatt P((struct ad *,UNCH *));
-unsigned int parsegrp P((struct etd **,struct parse *, UNCH *));
-unsigned int parsngrp P((struct dcncb **,struct parse *, UNCH *));
-int parsemd P((UNCH *,int,struct parse *,unsigned int));
-UNCH *parsenm P((UNCH *,int));
-UNCH *parsetkn P((UNCH *,UNCH,int));
-UNCH *s2valnm P((UNCH *,UNCH *,UNCH,int));
-struct srh *srhdef P((UNCH *));
-int tokdata P((UNCH *, int));
-struct entity *usedef P((UNCH *));
diff --git a/usr.bin/sgmls/sgmls/sgmlincl.h b/usr.bin/sgmls/sgmls/sgmlincl.h
deleted file mode 100644
index c4eb5cc..0000000
--- a/usr.bin/sgmls/sgmls/sgmlincl.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/* SGMLINCL.H: Include file for parser core. */
-#ifndef SGMLINCL /* Don't include this file more than once. */
-#define SGMLINCL 1
-#include "config.h"
-#include "std.h"
-#include "entity.h" /* Templates for entity control blocks. */
-#include "action.h" /* Action names for all parsing. */
-#include "adl.h" /* Definitions for attribute list processing. */
-#include "error.h" /* Symbols for error codes. */
-#include "etype.h" /* Definitions for element type processing. */
-#include "keyword.h" /* Definitions for keyword processing. */
-#include "lextoke.h" /* Symbols for tokenization lexical classes. */
-#include "source.h" /* Templates for source entity control blocks. */
-#include "synxtrn.h" /* Declarations for concrete syntax constants. */
-#include "sgmlxtrn.h" /* External variable declarations. */
-#include "trace.h" /* Declarations for internal trace functions. */
-#include "sgmlmain.h"
-#include "sgmlaux.h"
-#include "sgmlfnsm.h" /* ANSI C: Declarations for SGML functions. */
-#endif /* ndef SGMLINCL */
diff --git a/usr.bin/sgmls/sgmls/sgmlio.c b/usr.bin/sgmls/sgmls/sgmlio.c
deleted file mode 100644
index c78bb7a..0000000
--- a/usr.bin/sgmls/sgmls/sgmlio.c
+++ /dev/null
@@ -1,384 +0,0 @@
-/* sgmlio.c -
- IO functions for core parser.
-
- Written by James Clark (jjc@jclark.com).
-*/
-
-/* SGML must see a file in which records start with RS and end with
- RE, and EOFCHAR (Ctl-Z) is present at the end. This module must
- supply these characters if they are not naturally present in the
- file. SGML will open two files at a time: when an entity is
- nested, the new file is opened before closing the old in order to
- make sure the open is successful. If it is, the original open file
- is closed temporarily (IOPEND); when the stack is popped, the new
- file is closed and the original file is re-opened (IOCONT). SGML
- will check error returns for the initial open of a file and all
- reads, and for re-openings when the stack is popped, but not for
- closes. Returning <0 indicates an error; 0 or more is a successful
- operation, except for IOREAD where the return value is the number
- of characters read, and must exceed 0 to be successful. The first
- READ must always be successful, and normally consists of just
- priming the buffer with EOBCHAR (or RS EOBCHAR). SGMLIO must
- assure that there is an EOBCHAR at the end of each block read,
- except for the last block of the entity, which must have an
- EOFCHAR.
-
- SGML views an entity as a contiguous whole, without regard to its
- actual form of storage. SGMLIO supports entities that are
- equivalent to a single file of one or more records, or to a
- concatenation of files.
-*/
-
-/* Uses only stream I/O. This module should be portable to most ANSI
- systems. */
-/* We try to ensure that if an IO operation fails, then errno will contain
- a meaningful value (although it may be zero.) */
-
-#include "config.h"
-#ifdef HAVE_O_NOINHERIT
-#include <fcntl.h>
-#include <io.h>
-#endif /* HAVE_O_NOINHERIT */
-
-#include "sgmlaux.h" /* Include files for auxiliary functions.. */
-
-#ifdef HAVE_O_NOINHERIT
-#define FOPENR(file) nifopen(file)
-FILE *nifopen P((char *));
-#else /* not HAVE_O_NOINHERIT */
-#define FOPENR(file) fopen((file), "r")
-#endif /* not HAVE_O_NOINHERIT */
-
-struct iofcb { /* I/O file control block. */
- FILE *fp; /* File handle. */
- fpos_t off; /* Offset in file of current read block. */
- char *next; /* Next file (NULL if no more). */
- char *file; /* Current file (no length byte). */
- int pendoff; /* Offset into line when file suspended. */
- char bol; /* Non-zero if currently at beginning of line. */
- char first; /* Non-zero if the first read. */
- char wasbol; /* Non-zero if current block was at beginning of line. */
- char canseek;
- UNCH *pendbuf; /* Saved partial buffer for suspended file
- that can't be closed and reopened. */
-};
-
-static char *lastfile; /* The name of the last file closed. */
-static int bufsize; /* Size of buffer passed to ioread(). */
-static char ismagic[256]; /* Table of magic chars that need to be prefixed
- by DELNONCH. */
-static int stdinused = 0;
-
-static char *nextstr P((char *)); /* Iterate over list of strings. */
-static FILE *openfile P((char *, char *));
-static int closefile P((FILE *));
-static int isreg P((FILE *));
-
-VOID ioinit(swp)
-struct switches *swp;
-{
- ismagic[EOBCHAR] = 1;
- ismagic[EOFCHAR] = 1;
- ismagic[EOS] = 1;
- ismagic[(UNCH)DELNONCH] = 1;
- ismagic[(UNCH)GENRECHAR] = 1;
- bufsize = swp->swbufsz;
-}
-
-int ioopen(id, pp)
-UNIV id;
-UNIV *pp;
-{
- struct iofcb *f;
- char *s;
- errno = 0;
- if (!id)
- return -1;
- s = id;
- if (!*s)
- return -1;
- f = (struct iofcb *)rmalloc((UNS)sizeof(struct iofcb));
- f->file = s;
- f->next = nextstr(s);
- errno = 0;
- f->fp = openfile(f->file, &f->canseek);
- f->bol = 1;
- f->first = 1;
- f->pendbuf = 0;
- *pp = (UNIV)f;
- return f->fp ? 1 : -1;
-}
-
-VOID ioclose(p)
-UNIV p;
-{
- struct iofcb *f = (struct iofcb *)p;
- if (f->fp)
- closefile(f->fp);
- lastfile = f->file;
- frem((UNIV)f);
-}
-
-VOID iopend(p, off, buf)
-UNIV p;
-int off;
-UNCH *buf;
-{
- struct iofcb *f = (struct iofcb *)p;
- if (!f->canseek) {
- UNCH *s;
- for (s = buf + off; *s != EOFCHAR && *s != EOBCHAR; s++)
- ;
- s++;
- f->pendbuf = (UNCH *)rmalloc((UNS)(s - buf - off));
- memcpy((UNIV)f->pendbuf, (UNIV)(buf + off), (UNS)(s - buf - off));
- return;
- }
- f->bol = 0;
- if (f->wasbol) {
- if (off == 0)
- f->bol = 1;
- else
- off--;
- }
- f->pendoff = off;
- if (f->fp) {
- fclose(f->fp);
- f->fp = 0;
- }
-}
-
-int iocont(p)
-UNIV p;
-{
- struct iofcb *f = (struct iofcb *)p;
- int c = EOF;
- int off = f->pendoff;
-
- if (!f->canseek)
- return 0;
-
- errno = 0;
- f->fp = FOPENR(f->file);
- if (!f->fp)
- return -1;
- if (fsetpos(f->fp, &f->off))
- return -1;
- while (--off >= 0) {
- c = getc(f->fp);
- if (c != EOF && ismagic[c])
- off--;
- }
- if (c == '\n')
- f->bol = 1;
- if (ferror(f->fp))
- return -1;
- return 0;
-}
-
-/* Return -1 on error, otherwise the number of bytes read. The
-strategy is to concatenate the files, insert a RS at the beginning of
-each line, and change each '\n' into a RE. The returned data
-shouldn't cross a file boundary, otherwise error messages might be
-inaccurate. The first read must always succeed. */
-
-int ioread(p, buf, newfilep)
-UNIV p;
-UNCH *buf;
-int *newfilep;
-{
- int i = 0;
- struct iofcb *f = (struct iofcb *)p;
- FILE *fp;
- int c;
-
- *newfilep = 0;
- if (f->first) {
- buf[i] = EOBCHAR;
- f->first = 0;
- return 1;
- }
- if (f->pendbuf) {
- for (i = 0;
- (buf[i] = f->pendbuf[i]) != EOBCHAR && buf[i] != EOFCHAR;
- i++)
- ;
- frem((UNIV)f->pendbuf);
- f->pendbuf = 0;
- return i + 1;
- }
- fp = f->fp;
- for (;;) {
- errno = 0;
- if (f->canseek && fgetpos(fp, &f->off))
- f->canseek = 0;
- errno = 0;
- c = getc(fp);
- if (c != EOF)
- break;
- if (ferror(fp))
- return -1;
- if (closefile(fp) == EOF)
- return -1;
- if (!f->next){
- f->fp = 0;
- buf[0] = EOFCHAR;
- return 1;
- }
- f->file = f->next;
- f->next = nextstr(f->next);
- *newfilep = 1;
- errno = 0;
- fp = f->fp = openfile(f->file, &f->canseek);
- if (!fp)
- return -1;
- f->bol = 1;
- }
- if (f->bol) {
- f->bol = 0;
- buf[i++] = RSCHAR;
- f->wasbol = 1;
- }
- else
- f->wasbol = 0;
- errno = 0;
- for (;;) {
- if (c == '\n') {
- f->bol = 1;
- buf[i++] = RECHAR;
- break;
- }
- if (ismagic[c]) {
- buf[i++] = DELNONCH;
- buf[i++] = SHIFTNON(c);
- }
- else
- buf[i++] = c;
- if (i >= bufsize - 2)
- break;
- c = getc(fp);
- if (c == EOF) {
- if (ferror(fp))
- return -1;
- /* This is in the middle of a line. */
- break;
- }
- }
- buf[i++] = EOBCHAR;
- return i;
-}
-
-static char *nextstr(p)
-char *p;
-{
- p = strchr(p, '\0');
- return *++p ? p : 0;
-}
-
-/* Return the filename associated with p. If p is NULL, return the filename
-of the last file closed. */
-
-char *ioflid(p)
-UNIV p;
-{
- if (!p)
- return lastfile;
- return ((struct iofcb *)p)->file;
-}
-
-static
-FILE *openfile(name, seekp)
-char *name;
-char *seekp;
-{
- FILE *fp;
- if (strcmp(name, STDINNAME) == 0) {
- if (stdinused)
- return 0;
- stdinused = 1;
- *seekp = 0;
- return stdin;
- }
- fp = FOPENR(name);
- if (fp)
- *seekp = isreg(fp);
- return fp;
-}
-
-/* Return -1 on error, 0 otherwise. */
-
-static
-int closefile(fp)
-FILE *fp;
-{
- if (fp == stdin) {
- stdinused = 0;
- clearerr(fp);
- return 0;
- }
- else
- return fclose(fp);
-}
-
-#ifdef HAVE_O_NOINHERIT
-
-/* This is the same as fopen(name, "r") except that it tells DOS that
-the file descriptor should not be inherited by child processes. */
-
-FILE *nifopen(name)
-char *name;
-{
- int fd = open(name, O_RDONLY|O_NOINHERIT|O_TEXT);
- if (fd < 0)
- return 0;
- return fdopen(fd, "r");
-}
-
-#endif /* HAVE_O_NOINHERIT */
-
-#ifdef HAVE_SYS_STAT_H
-
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#ifndef S_ISREG
-#ifdef S_IFMT
-#ifdef S_IFREG
-#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
-#endif /* S_IFREG */
-#endif /* S_IFMT */
-#endif /* not S_ISREG */
-
-#endif /* HAVE_SYS_STAT_H */
-
-/* Return 1 if fp might be associated with a regular file. 0
-otherwise. We check this because on many Unix systems lseek() will
-succeed on a (pseudo-)terminal although terminals aren't seekable in
-the way we need. */
-
-static
-int isreg(fp)
-FILE *fp;
-{
-#ifdef S_ISREG
- struct stat sb;
-
- /* This assumes that a system that has S_ISREG will also have
- fstat() and fileno(). */
- if (fstat(fileno(fp), &sb) == 0)
- return S_ISREG(sb.st_mode);
-#endif /* S_ISREG */
- return 1;
-}
-
-
-/*
-Local Variables:
-c-indent-level: 5
-c-continued-statement-offset: 5
-c-brace-offset: -5
-c-argdecl-indent: 0
-c-label-offset: -5
-comment-column: 30
-End:
-*/
diff --git a/usr.bin/sgmls/sgmls/sgmlmain.h b/usr.bin/sgmls/sgmls/sgmlmain.h
deleted file mode 100644
index 3911f76..0000000
--- a/usr.bin/sgmls/sgmls/sgmlmain.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/* SGMLMAIN: Main interface to SGML services.
-
-Preprocessor variable names are the only supported interface
-to data maintained by SGML. They are defined in this file or in adl.h.
-*/
-/* Return control block types (RCBTYPE) from calls to parser (SGML):
- Names and strings follow the convention for the IPBs.
-*/
-enum sgmlevent {
- SGMLEOD, /* End of document. */
- SGMLDAF, /* Data found. */
- SGMLSTG, /* Start-tag found. */
- SGMLETG, /* End-tag found. */
- SGMLREF, /* Record end found. */
- SGMLPIS, /* Processing instruction (string). */
- SGMLAPP /* APPINFO (string) */
-};
-
-struct rcbdata { /* Return control block: DAF EOD REF PIS APP. */
- UNS contersw; /* 1=context error; 2,4,8=data type; 0=not. */
- UNS datalen; /* Length of data or PI (0=single nonchar). */
- UNCH *data; /* Data, PI, single nonSGML, or NDATA ecb ptr. */
-};
-
-struct rcbtag { /* Return control block for STG and ETG. */
- UNS contersw; /* 1=context error; 2=NET enabled; 0/0=not. */
- UNS tagmin; /* Minim: NONE NULL NET DATA; implied by S/ETAG */
- UNCH *curgi; /* Start-tag (or end-tag) GI. */
- union {
- struct ad *al; /* Start-tag: attribute list. */
- UNCH *oldgi; /* End-tag: resumed GI. */
- } ru;
- struct ad *lal; /* Start-tag: link attribute list (UNUSED). */
- UNS format; /* Format class for default processing. */
- struct etd *tagreal; /* Dummy etd or ptr to GI that implied this tag.*/
- int etictr; /* Number of elements on stack with NET enabled.*/
- UNCH *srmnm; /* Current SHORTREF map name (NULL=#EMPTY). */
-};
-
-/* Accessors for rcbdata and rcbtag. */
-/* Datatype abbreviations: C=unsigned char S=string U=unsigned int L=4 bytes
- A=array P=ptr to structure N=name (see sgmlcb.h)
-*/
-/* Data control block fields: processing instructions (SGMLPIS).
-*/
-#define PDATA(d) ((d).data) /*S PI string. */
-#define PDATALEN(d) ((d).datalen) /*U Length of PI string. */
-#define PIESW(d) (((d).contersw & 4)) /*U 1=PIDATA entity returned. */
-/* Data control block fields: other data types.
-*/
-#define CDATA(d) ((d).data) /*S CDATA content string. */
-#define CDATALEN(d) ((d).datalen) /*U Length of CDATA content string. */
-#define CONTERSW(d) (((d).contersw &1))/*U 1=CDATA or TAG out of context. */
-#define CDESW(d) (((d).contersw & 2)) /*U 1=CDATA entity returned. */
-#define SDESW(d) (((d).contersw & 4)) /*U 1=SDATA entity returned. */
-#define NDESW(d) (((d).contersw & 8)) /*U 1=NDATA entity returned. */
-#define NEPTR(d) ((PNE)(d).data) /*P Ptr to NDATA control block. */
-#define MARKUP(d) ((d).data) /*A Markup delimiter strings. */
-#define DTYPELEN(d) ((d).datalen) /*U Length of doc type name +len+EOS. */
-#define DOCTYPE(d) ((d).data) /*S Document type name (with len+EOS). */
-#define ADATA(d) ((d).data) /*S APPINFO */
-#define ADATALEN(d) ((d).datalen) /*U Length of APPINFO string. */
-/* Tag control block fields.
-*/
-#define ALPTR(t) ((t).ru.al) /*P Ptr to SGML attribute list. */
-#define CURGI(t) ((t).curgi+1) /*N GI of started or ended element. */
-#define OLDGI(t) ((t).ru.oldgi) /*S GI of resumed element. */
-#define TAGMIN(t) (t).tagmin /*U Minimization for current tag. */
-#define TAGREAL(t) ((t).tagreal) /*P Dummy etd that implied this tag. */
-#define TAGRLNM(t) ((UNCH *)(t).tagreal) /*P GI of tag that implied this tag.*/
-#define ETISW(t) (((t).contersw & 2)) /*U 1=NET delimiter enabled by ETI. */
-#define PEXSW(t) (((t).contersw & 4)) /*U 1=Element was plus exception. */
-#define MTYSW(t) (((t).contersw & 8)) /*U 1=Element is empty. */
-#define ETICTR(t) ((t).etictr) /*U Number of active NET delimiters. */
-#define SRMNM(t) ((t).srmnm) /*S Name of current SHORTREF map. */
-#define SRMCNT(t) ((t).contersw) /*U Number of SHORTREF maps defined. */
-#define FORMAT(t) ((t).format) /*U Format class.*/
-
-/* These function names are chosen so as to be distinct in the first 6
-letters. */
-
-/* Initialize. */
-struct markup *sgmlset P((struct switches *));
-/* Cleanup and return capacity usage statistics. */
-VOID sgmlend P((struct sgmlcap *));
-/* Set document entity. */
-int sgmlsdoc P((UNIV));
-/* Get entity. */
-int sgmlgent P((UNCH *, PNE *, UNCH **));
-/* Mark an entity. Return is non-zero if already marked.*/
-int sgmlment P((UNCH *));
-/* Get the next sgml event. */
-enum sgmlevent sgmlnext P((struct rcbdata *, struct rcbtag *));
-/* Get the error count. */
-int sgmlgcnterr P((void));
-/* Get the current location. */
-int sgmlloc P((unsigned long *, char **));
-/* Write out the SGML declaration. */
-VOID sgmlwrsd P((FILE *));
-/* Note subdocument capacity usage. */
-VOID sgmlsubcap P((long *));
diff --git a/usr.bin/sgmls/sgmls/sgmlmsg.c b/usr.bin/sgmls/sgmls/sgmlmsg.c
deleted file mode 100644
index 4d98c55..0000000
--- a/usr.bin/sgmls/sgmls/sgmlmsg.c
+++ /dev/null
@@ -1,514 +0,0 @@
-/* sgmlmsg.c -
- message handling for core parser
-
- Written by James Clark (jjc@jclark.com).
-*/
-
-#include "config.h"
-#include "sgmlaux.h"
-#include "msg.h"
-
-static nl_catd catd;
-
-#define TEXT_SET 1 /* message set number for text of messages */
-#define HEADER_SET 2 /* message set number for header strings */
-#define PARM_SET 3 /* message set number for special parameters */
-
-#ifdef HAVE_EXTENDED_PRINTF
-#define xfprintf fprintf
-#else
-extern int xfprintf VP((FILE *, char *,...));
-#endif
-
-#define SIZEOF(v) (sizeof(v)/sizeof(v[0]))
-
-static char *gettext P((int));
-static char *getheader P((int));
-static char *getparm P((int));
-static VOID elttrace P((FILE *, int));
-static int printit P((FILE *, struct error *));
-static char *transparm P((UNCH *, char *));
-static VOID spaces P((FILE *, int));
-
-#define PARMBUFSIZ 50
-static char parmbuf[PARMBUFSIZ*2];
-static char *parmbuf1 = parmbuf;
-static char *parmbuf2 = parmbuf + PARMBUFSIZ;
-
-static char *prog; /* program name */
-static int sweltr; /* non-zero means print an element trace */
-static int swenttr; /* non-zero means print an entity trace */
-static int cnterr = 0;
-static VOID (*die) P((void));
-
-static char *headers[] = {
-"In file included",
-"SGML error", /* parameters: type, severity, number */
-"Unsupported feature", /* type U errors */
-"Error", /* for type R errors */
-"Warning", /* severity type I */
-" at %s, %.0sline %lu", /* ignore entity name and ccnt */
-" at entity %s, line %lu",
-"%.0s%.0s in declaration parameter %d", /* ignore first two parameters */
-"%.0s in declaration parameter %d", /* ignore first parameter */
-"%.0s", /* parse mode */
-" at end of file",
-" at end of entity",
-" at record start",
-" at record end",
-" at \"%c\"",
-" at \"\\%03o\"",
-" accessing \"%s\"",
-"Element structure:"
-};
-
-/* Indexes into headers[] */
-
-#define HDRPFX 0
-#define HDRALL 1
-#define HDRUNSUP 2
-#define HDRSYS 3
-#define HDRWARN 4
-#define HDRLOC 5
-#define HDRELOC 6
-#define HDRMD 7
-#define HDRMD2 8
-#define HDRMODE 9
-#define HDREOF 10
-#define HDREE 11
-#define HDRRS 12
-#define HDRRE 13
-#define HDRPRT 14
-#define HDRCTL 15
-#define HDRFIL 16
-#define HDRELT 17
-
-/* Special parameters (error::errsp) */
-static char *parms[] = {
-"character data",
-"element content",
-"mixed content",
-"replaceable character data",
-"tag close",
-"content model group",
-"content model occurrence indicator",
-"name group",
-"name token group",
-"system data",
-"parameter literal",
-"attribute value literal",
-"tokenized attribute value literal",
-"minimum literal",
-"markup declaration",
-"markup declaration comment",
-"ignored markup declaration",
-"declaration subset",
-"CDATA marked section",
-"IGNORE marked section",
-"RCDATA marked section",
-"prolog",
-"reference",
-"attribute specification list",
-"tokenized attribute value",
-"attribute specification list close",
-"SGML declaration",
-"attribute definition list",
-"document type",
-"element",
-"entity",
-"link type",
-"link set",
-"notation",
-"SGML",
-"short reference mapping",
-"link set use",
-"short reference use",
-};
-
-static FILE *tfp; /* temporary file for saved messages */
-
-struct saved {
- long start;
- long end;
- char exiterr;
- char countit;
-};
-
-VOID msgprint(e)
-struct error *e;
-{
- if (printit(stderr, e))
- ++cnterr;
- fflush(stderr);
- if (e->errtype == EXITERR) {
- if (die) {
- (*die)();
- abort();
- }
- else
- exit(EXIT_FAILURE);
- }
-}
-
-/* Save an error message. */
-
-UNIV msgsave(e)
-struct error *e;
-{
- struct saved *sv;
-
- sv = (struct saved *)rmalloc(sizeof(struct saved));
- if (!tfp) {
- tfp = tmpfile();
- if (!tfp)
- exiterr(160, (struct parse *)0);
- }
- sv->start = ftell(tfp);
- sv->countit = (char)printit(tfp, e);
- sv->end = ftell(tfp);
- sv->exiterr = (char)(e->errtype == EXITERR);
- return (UNIV)sv;
-}
-
-/* Print a saved error message. */
-
-VOID msgsprint(p)
-UNIV p;
-{
- struct saved *sv = (struct saved *)p;
- long cnt;
-
- assert(p != 0);
- assert(tfp != 0);
- if (fseek(tfp, sv->start, SEEK_SET) < 0)
- return;
- /* Temporary files are opened in binary mode, so this is portable. */
- cnt = sv->end - sv->start;
- while (--cnt >= 0) {
- int c = getc(tfp);
- if (c == EOF)
- break;
- putc(c, stderr);
- }
- fflush(stderr);
- if (sv->countit)
- ++cnterr;
- if (sv->exiterr)
- exit(EXIT_FAILURE);
-}
-
-/* Free a sved error message. */
-
-VOID msgsfree(p)
-UNIV p;
-{
- frem(p);
-}
-
-/* Return 1 if it should be counted as an error. */
-
-static int printit(efp, e)
-FILE *efp;
-struct error *e;
-{
- int indent;
- int countit;
- int hdrcode;
- int filelevel = -1, prevfilelevel = -1, toplevel;
- struct location loc;
- char type[2], severity[2];
-
- assert(e->errnum < SIZEOF(messages));
- assert(messages[e->errnum].text != NULL);
- if (prog) {
- fprintf(efp, "%s: ", prog);
- indent = strlen(prog) + 2; /* don't rely on return value of fprintf */
- /* Don't want to waste too much space on indenting. */
- if (indent > 10)
- indent = 4;
- }
- else
- indent = 4;
-
- for (toplevel = 0; getlocation(toplevel, &loc); toplevel++)
- if (loc.filesw) {
- prevfilelevel = filelevel;
- filelevel = toplevel;
- }
- toplevel--;
-
- if (e->errtype == FILERR) {
- toplevel--;
- filelevel = prevfilelevel;
- }
- if (swenttr && filelevel > 0) {
- int level = 0;
- int middle = 0; /* in the middle of a line */
- do {
- (void)getlocation(level, &loc);
- if (loc.filesw) {
- if (middle) {
- fputs(":\n", efp);
- spaces(efp, indent);
- }
- else
- middle = 1;
- xfprintf(efp, getheader(HDRPFX));
- xfprintf(efp, getheader(HDRLOC), ioflid(loc.fcb),
- loc.ename, loc.rcnt, loc.ccnt);
- }
- else if (middle)
- xfprintf(efp, getheader(HDRELOC),
- loc.ename, loc.rcnt + 1, loc.ccnt);
- }
- while (++level != filelevel);
- if (middle) {
- fputs(":\n", efp);
- spaces(efp, indent);
- }
- }
-
- /* We use strings for the type and severity,
- so that the format can use %.0s to ignore them. */
-
- type[0] = messages[e->errnum].type;
- type[1] = '\0';
- severity[0] = messages[e->errnum].severity;
- severity[1] = '\0';
-
- countit = (severity[0] != 'I');
- if (!countit)
- hdrcode = HDRWARN;
- else if (type[0] == 'R')
- hdrcode = HDRSYS;
- else if (type[0] == 'U')
- hdrcode = HDRUNSUP;
- else
- hdrcode = HDRALL;
-
- xfprintf(efp, getheader(hdrcode), type, severity, e->errnum);
-
- if (filelevel >= 0) {
- (void)getlocation(filelevel, &loc);
- xfprintf(efp, getheader(HDRLOC),
- ioflid(loc.fcb), loc.ename, loc.rcnt, loc.ccnt);
- while (filelevel < toplevel) {
- ++filelevel;
- if (swenttr) {
- (void)getlocation(filelevel, &loc);
- xfprintf(efp, getheader(HDRELOC),
- loc.ename, loc.rcnt + 1, loc.ccnt);
- }
- }
- }
-
- /* It is necessary to copy the result of getparm() because
- the specification of catgets() says in can return a
- pointer to a static buffer which may get overwritten
- by the next call to catgets(). */
-
- switch (e->errtype) {
- case MDERR:
- strncpy(parmbuf, getparm(e->errsp), PARMBUFSIZ*2 - 1);
- xfprintf(efp, getheader(HDRMD), parmbuf,
- (e->subdcl ? e->subdcl : (UNCH *)""), e->parmno);
- break;
- case MDERR2:
- /* no subdcl parameter */
- strncpy(parmbuf, getparm(e->errsp), PARMBUFSIZ*2 - 1);
- xfprintf(efp, getheader(HDRMD2), parmbuf, e->parmno);
- break;
- case DOCERR:
- case EXITERR:
- if (toplevel < 0)
- break;
- strncpy(parmbuf, getparm(e->errsp), PARMBUFSIZ*2 - 1);
- xfprintf(efp, getheader(HDRMODE), parmbuf);
- switch (loc.curchar) {
- case EOFCHAR:
- xfprintf(efp, getheader(HDREOF));
- break;
- case RSCHAR:
- xfprintf(efp, getheader(HDRRS));
- break;
- case RECHAR:
- xfprintf(efp, getheader(HDRRE));
- break;
- case DELNONCH:
- xfprintf(efp, getheader(HDRCTL), UNSHIFTNON(loc.nextchar));
- break;
- case EOS:
- xfprintf(efp, getheader(HDREE));
- break;
- case EOBCHAR:
- break;
- default:
- if (ISASCII(loc.curchar) && isprint(loc.curchar))
- xfprintf(efp, getheader(HDRPRT), loc.curchar);
- else
- xfprintf(efp, getheader(HDRCTL), loc.curchar);
- break;
- }
- break;
- case FILERR:
- if (getlocation(toplevel + 1, &loc))
- xfprintf(efp, getheader(HDRFIL), ioflid(loc.fcb));
- break;
- }
- fputs(":\n", efp);
-
- if (e->errtype == FILERR && e->sverrno != 0) {
- char *errstr = strerror(e->sverrno);
- UNS len = strlen(errstr);
- /* Strip a trailing newline if there is one. */
- if (len > 0 && errstr[len - 1] == '\n')
- len--;
- spaces(efp, indent);
- for (; len > 0; len--, errstr++)
- putc(*errstr, efp);
- fputs(":\n", efp);
- }
-
- spaces(efp, indent);
-
- xfprintf(efp, gettext(e->errnum),
- transparm((UNCH *)e->eparm[0], parmbuf1),
- transparm((UNCH *)e->eparm[1], parmbuf2));
- putc('\n', efp);
-
- if (sweltr)
- elttrace(efp, indent);
- return countit;
-}
-
-/* Print an element trace. */
-static VOID elttrace(efp, indent)
-FILE *efp;
-int indent;
-{
- int i = 1;
- UNCH *gi;
-
- gi = getgi(i);
- if (!gi)
- return;
- spaces(efp, indent);
- xfprintf(efp, getheader(HDRELT));
- do {
- fprintf(efp, " %s", (char *)gi);
- gi = getgi(++i);
- } while (gi);
- putc('\n', efp);
-}
-
-static VOID spaces(efp, indent)
-FILE *efp;
-int indent;
-{
- while (--indent >= 0)
- putc(' ', efp);
-}
-
-VOID msginit(swp)
-struct switches *swp;
-{
- catd = swp->catd;
- prog = swp->prog;
- sweltr = swp->sweltr;
- swenttr = swp->swenttr;
- die = swp->die;
-}
-
-/* Return the error count. */
-
-int msgcnterr()
-{
- return cnterr;
-}
-
-/* Transform a parameter into a form suitable for printing. */
-
-static char *transparm(s, buf)
-UNCH *s;
-char *buf;
-{
- char *ptr;
- int cnt;
-
- if (!s)
- return 0;
-
- ptr = buf;
- cnt = PARMBUFSIZ - 4; /* space for `...\0' */
-
- while (*s) {
- UNCH ch = *s++;
- if (ch == DELNONCH) {
- if (*s == '\0')
- break;
- ch = UNSHIFTNON(*s);
- s++;
- }
- if (ch == DELCDATA || ch == DELSDATA)
- ;
- else if (ch == '\\') {
- if (cnt < 2)
- break;
- *ptr++ = '\\';
- *ptr++ = '\\';
- cnt -= 2;
- }
- else if (ISASCII(ch) && isprint(ch)) {
- if (cnt < 1)
- break;
- *ptr++ = ch;
- cnt--;
- }
- else {
- if (cnt < 4)
- break;
- sprintf(ptr, "\\%03o", ch);
- ptr += 4;
- cnt -= 4;
- }
- }
- if (!*s)
- *ptr = '\0';
- else
- strcpy(ptr, "...");
- return buf;
-}
-
-/* The message and set numbers in the catgets function must be > 0. */
-
-static char *gettext(n)
-int n;
-{
- assert(n > 0 && n < SIZEOF(messages));
- assert(messages[n].text != 0);
- return catgets(catd, TEXT_SET, n, messages[n].text);
-}
-
-static char *getheader(n)
-int n;
-{
- assert(n >= 0 && n < SIZEOF(headers));
- return catgets(catd, HEADER_SET, n + 1, headers[n]);
-}
-
-static char *getparm(n)
-int n;
-{
- assert(n >= 0 && n < SIZEOF(parms));
- return catgets(catd, PARM_SET, n + 1, parms[n]);
-}
-
-/*
-Local Variables:
-c-indent-level: 5
-c-continued-statement-offset: 5
-c-brace-offset: -5
-c-argdecl-indent: 0
-c-label-offset: -5
-End:
-*/
diff --git a/usr.bin/sgmls/sgmls/sgmls.1 b/usr.bin/sgmls/sgmls/sgmls.1
deleted file mode 100644
index bd92c92..0000000
--- a/usr.bin/sgmls/sgmls/sgmls.1
+++ /dev/null
@@ -1,970 +0,0 @@
-'\" $Id$
-'\" t
-.\" Uncomment the next line to get a man page accurate for MS-DOS
-.\"nr Os 1
-.\" Uncomment the next line if tracing is enabled.
-.\"nr Tr 1
-.if \n(.g .if !r Os .nr Os 0
-.tr \(ts"
-.ds S \s-1SGML\s0
-.de TS
-.br
-.sp .5
-..
-.de TE
-.br
-.sp .5
-..
-.de TQ
-.br
-.ns
-.TP \\$1
-..
-.TH SGMLS 1
-.SH NAME
-sgmls \- a validating SGML parser
-.sp
-An \*S System Conforming to
-.if n .br
-International Standard ISO 8879 \(em
-.br
-Standard Generalized Markup Language
-.SH SYNOPSIS
-.B sgmls
-[
-.B \-deglprsuv
-]
-[
-.BI \-c file
-]
-.if \n(Os=1 \{\
-[
-.BI \-f file
-]
-.\}
-[
-.BI \-i name
-]
-[
-.BI \-m file
-]
-.if \n(Tr \{\
-[
-.BI \-x flags
-]
-[
-.BI \-y flags
-]
-.\}
-[
-.I filename\|.\|.\|.
-]
-.SH DESCRIPTION
-.I Sgmls
-parses and validates
-the \*S document entity in
-.I filename\|.\|.\|.
-and prints on the standard output a simple \s-1ASCII\s0 representation of its
-Element Structure Information Set.
-(This is the information set which a structure-controlled
-conforming \*S application should act upon.)
-Note that the document entity may be spread amongst several files;
-for example, the SGML declaration, document type declaration and document
-instance set could each be in a separate file.
-If no filenames are specified, then
-.I sgmls
-will read the document entity from the standard input.
-A filename of
-.B \-
-can also be used to refer to the standard input.
-.LP
-The following options are available:
-.TP
-.BI \-c file
-Report any capacity limits that are exceeded
-and write a report of capacity usage to
-.IR file .
-The report is in the format of a RACT result.
-RACT is the Reference Application for Capacity Testing defined in the
-Proposed American National Standard
-.I
-Conformance Testing for Standard Generalized Markup Language (SGL) Systems
-(X3.190-199X),
-Draft July 1991.
-.TP
-.B \-d
-Warn about duplicate entity declarations.
-.TP
-.B \-e
-Describe open entities in error messages.
-Error messages always include the position of the most recently
-opened external entity.
-.if \n(Os=1 \{\
-.TP
-.BI \-f file
-Redirect errors to
-.IR file .
-.\}
-.TP
-.B \-g
-Show the \s-1GI\s0s of open elements in error messages.
-.TP
-.BI \-i name
-Pretend that
-.RS
-.IP
-.BI <!ENTITY\ %\ name\ \(tsINCLUDE\(ts>
-.LP
-occurs at the start of the document type declaration subset
-in the \*S document entity.
-Since repeated definitions of an entity are ignored,
-this definition will take precedence over any other definitions
-of this entity in the document type declaration.
-Multiple
-.B \-i
-options are allowed.
-If the \*S declaration replaces the reserved name
-.B INCLUDE
-then the new reserved name will be the replacement text of the entity.
-Typically the document type declaration will contain
-.IP
-.BI <!ENTITY\ %\ name\ \(tsIGNORE\(ts>
-.LP
-and will use
-.BI % name ;
-in the status keyword specification of a marked section declaration.
-In this case the effect of the option will be to cause the marked
-section not to be ignored.
-.RE
-.TP
-.B \-l
-Output
-.B L
-commands giving the current line number and filename.
-.TP
-.BI \-m file
-Map public identifiers and entity names to system identifiers
-using the catalog entry file
-.IR file .
-Multiple
-.B \-m
-options are allowed.
-Catalog entry files specified with the
-.B -m
-option will be searched before the defaults.
-.TP
-.B \-p
-Parse only the prolog.
-.I Sgmls
-will exit after parsing the document type declaration.
-Implies
-.BR \-s .
-.TP
-.B \-r
-Warn about defaulted references.
-.TP
-.B \-s
-Suppress output.
-Error messages will still be printed.
-.TP
-.B \-u
-Warn about undefined elements: elements used in the DTD but not defined.
-.TP
-.B \-v
-Print the version number.
-.if \n(Tr \{\
-.TP
-.BI \-x flags
-.br
-.ns
-.TP
-.BI \-y flags
-Enable debugging output;
-.B \-x
-applies to the document body,
-.B \-y
-to the prolog.
-Each character in the
-.I flags
-argument enables tracing of a particular activity.
-.RS
-.TP
-.B t
-Trace state transitions.
-.TP
-.B a
-Trace attribute activity.
-.TP
-.B c
-Trace context checking.
-.TP
-.B d
-Trace declaration parsing.
-.TP
-.B e
-Trace entities.
-.TP
-.B g
-Trace groups.
-.TP
-.B i
-Trace \s-1ID\s0s.
-.TP
-.B m
-Trace marked sections.
-.TP
-.B n
-Trace notations.
-.RE
-.\}
-.SS "Entity Manager"
-An external entity resides in one or more files.
-The entity manager component of
-.I sgmls
-maps a sequence of files into an entity in three sequential stages:
-.IP 1.
-each carriage return character is turned into a non-SGML character;
-.IP 2.
-each newline character is turned into a record end character,
-and at the same time
-a record start character is inserted at the beginning of each line;
-.IP 3.
-the files are concatenated.
-.LP
-A system identifier is
-interpreted as a list of filenames separated by
-.if \n(Os=0 colons.
-.if \n(Os=1 semi-colons.
-A filename of
-.B \-
-can be used to refer to the standard input.
-.LP
-If a system identifier is not specified,
-then the entity manager can generate one using catalog
-entry files in the format defined in the SGML Open Draft Technical
-Resolution on Entity Management. A catalog entry file contains a
-sequence of entries in one of the following four forms:
-.TP
-.BI PUBLIC\ pubid\ sysid
-This specifies that
-.I sysid
-should be used as the system identifier if the public
-identifier is
-.IR pubid .
-.I Sysid
-is a system identifier as defined in ISO 8879 and
-.I pubid
-is a public identifier as defined in ISO 8879.
-.TP
-.BI ENTITY\ name\ sysid
-This specifies that
-.I sysid
-should be used as the system identifier if the entity is a general
-entity whose name is
-.IR name .
-.TP
-.BI ENTITY\ % name\ sysid
-This specifies that
-.I sysid
-should be used as the system identifier if the entity is a parameter
-entity whose name is
-.IR name .
-Note that there is no space between the
-.B %
-and the
-.IR name .
-.TP
-.BI DOCTYPE\ name\ sysid
-This specifies that
-.I sysid
-should be used as the system identifier if the entity is an
-entity declared in a document type declaration whose document type name is
-.IR name .
-.LP
-The last two forms are extensions to the SGML Open format.
-The delimiters can be omitted from the
-.I sysid
-provided it does not contain any white space.
-Comments are allowed between parameters delimited by
-.B --
-as in SGML.
-The environment variable
-.B \s-1SGML_CATALOG_FILES\s0
-contains a
-.if \n(Os=0 colon-separated
-.if \n(Os=1 semicolon-separated
-list of catalog entry files.
-These will be searched after any catalog entry files specified
-using the
-.B \-m
-option.
-If this environment variable is not set,
-then a system dependent list of catalog entry files will be used.
-A match in a catalog entry file for a PUBLIC entry will take
-precedence over a match in the same file for an ENTITY
-or DOCTYPE entry.
-A filename in a system identifier in a catalog entry file
-is interpreted relative to the directory containing the catalog
-entry file.
-.LP
-If no match can be found in a catalog entry file, then the entity
-manager will attempt to generate a filename using the public
-identifier (if there is one) and other information available to it.
-Notation identifiers are not subject to this treatment. This process
-is controlled by the environment variable
-.BR \s-1SGML_PATH\s0 ;
-this contains a
-.if \n(Os=0 colon-separated
-.if \n(Os=1 semicolon-separated
-list of filename templates.
-A filename template is a filename that may contain
-substitution fields; a substitution field is a
-.B %
-character followed by a single letter that indicates the value
-of the substitution.
-The value of a substitution can either be a string
-or it can be
-.IR null .
-The entity manager transforms the list of
-filename templates into a list of filenames by substituting for each
-substitution field and discarding any template
-that contained a substitution field whose value was null.
-It then uses the first resulting filename that exists and is readable.
-Substitution values are transformed before being used for substitution:
-firstly, any names that were subject to upper case substitution
-are folded to lower case;
-secondly,
-.if \n(Os=0 \{\
-.\" Unix
-space characters are mapped to underscores
-and slashes are mapped to percents.
-.\}
-.if \n(Os=1 \{\
-.\" MS-DOS
-the characters
-.B +,./:=?
-and space characters are deleted.
-.\}
-The value of the
-.B %S
-field is not transformed.
-The values of substitution fields are as follows:
-.TP
-.B %%
-A single
-.BR % .
-.TP
-.B %D
-The entity's data content notation.
-This substitution will succeed only for external data entities.
-.TP
-.B %N
-The entity, notation or document type name.
-.TP
-.B %P
-The public identifier if there was a public identifier,
-otherwise null.
-.TP
-.B %S
-The system identifier if there was a system identifier
-otherwise null.
-.TP
-.B %X
-(This is provided mainly for compatibility with \s-1ARCSGML\s0.)
-A three-letter string chosen as follows:
-.LP
-.RS
-.ne 11
-.TS
-tab(&);
-c|c|c s
-c|c|c s
-c|c|c|c
-c|c|c|c
-l|lB|lB|lB.
-&&With public identifier
-&&_
-&No public&Device&Device
-&identifier&independent&dependent
-_
-Data or subdocument entity&nsd&pns&vns
-General SGML text entity&gml&pge&vge
-Parameter entity&spe&ppe&vpe
-Document type definition&dtd&pdt&vdt
-Link process definition&lpd&plp&vlp
-.TE
-.LP
-The device dependent version is selected if the public text class
-allows a public text display version but no public text display
-version was specified.
-.RE
-.TP
-.B %Y
-The type of thing for which the filename is being generated:
-.TS
-tab(&);
-l lB.
-SGML subdocument entity&sgml
-Data entity&data
-General text entity&text
-Parameter entity&parm
-Document type definition&dtd
-Link process definition&lpd
-.TE
-.LP
-The value of the following substitution fields will be null
-unless a valid formal public identifier was supplied.
-.TP
-.B %A
-Null if the text identifier in the
-formal public identifier contains an unavailable text indicator,
-otherwise the empty string.
-.TP
-.B %C
-The public text class, mapped to lower case.
-.TP
-.B %E
-The public text designating sequence (escape sequence)
-if the public text class is
-.BR \s-1CHARSET\s0 ,
-otherwise null.
-.TP
-.B %I
-The empty string if the owner identifier in the formal public identifier
-is an \s-1ISO\s0 owner identifier,
-otherwise null.
-.TP
-.B %L
-The public text language, mapped to lower case,
-unless the public text class is
-.BR \s-1CHARSET\s0 ,
-in which case null.
-.TP
-.B %O
-The owner identifier (with the
-.B +//
-or
-.B \-//
-prefix stripped.)
-.TP
-.B %R
-The empty string if the owner identifier in the formal public identifier
-is a registered owner identifier,
-otherwise null.
-.TP
-.B %T
-The public text description.
-.TP
-.B %U
-The empty string if the owner identifier in the formal public identifier
-is an unregistered owner identifier,
-otherwise null.
-.TP
-.B %V
-The public text display version.
-This substitution will be null if the public text class
-does not allow a display version or if no version was specified.
-If an empty version was specified, a value of
-.B default
-will be used.
-.LP
-Normally if the external identifier for an entity includes a system
-identifier, the entity manager will use the specified system
-identifier and not attempt to generate one.
-If, however,
-.B \s-1SGML_PATH\s0
-uses the
-.B %S
-field,
-then the entity manager will first search for a matching
-entry in the catalog entry files.
-If a match is found, then this will be used instead of the
-specified system identifier.
-Otherwise,
-if the specified system identifier does not contain any
-.if \n(Os=0 colons,
-.if \n(Os=1 semi-colons,
-the entity manager will use
-.B \s-1SGML_PATH\s0
-to generate a filename.
-Otherwise the entity manager will use the specified system identifier.
-.br
-.ne 18
-.SS "System declaration"
-The system declaration for
-.I sgmls
-is as follows:
-.LP
-.TS
-tab(&);
-c1 s1 s1 s1 s1 s1 s1 s1 s
-c s s s s s s s s
-l l s s s s s s s
-l l s s s s s s s
-l l s s s s s s s
-l l l s s s s s s
-c s s s s s s s s
-l l l l l l l l l
-l l l l l l l l l
-l l l l l l l l l
-l l s s s s s s s
-l l l s s s s s s
-l l l s s s s s s
-c s s s s s s s s
-l l l l l l l l l.
-SYSTEM "ISO 8879:1986"
-CHARSET
-BASESET&"ISO 646-1983//CHARSET
-&\h'\w'"'u'International Reference Version (IRV)//ESC 2/5 4/0"
-DESCSET&0\0128\00
-CAPACITY&PUBLIC&"ISO 8879:1986//CAPACITY Reference//EN"
-FEATURES
-MINIMIZE&DATATAG&NO&OMITTAG&YES&RANK&NO&SHORTTAG&YES
-LINK&SIMPLE&NO&IMPLICIT&NO&EXPLICIT&NO
-OTHER&CONCUR&NO&SUBDOC&YES 1&FORMAL&YES
-SCOPE&DOCUMENT
-SYNTAX&PUBLIC&"ISO 8879:1986//SYNTAX Reference//EN"
-SYNTAX&PUBLIC&"ISO 8879:1986//SYNTAX Core//EN"
-VALIDATE
-&GENERAL&YES&MODEL&YES&EXCLUDE&YES&CAPACITY&YES
-&NONSGML&YES&SGML&YES&FORMAL&YES
-.T&
-c s s s s s s s s
-l l l l l l l l l.
-SDIF
-&PACK&NO&UNPACK&NO
-.TE
-.LP
-Exceeding a capacity limit will be ignored unless the
-.B \-c
-option is given.
-.LP
-The memory usage of
-.I sgmls
-is not a function of the capacity points used by a document;
-however,
-.I sgmls
-can handle capacities significantly greater than the reference capacity set.
-.LP
-In some environments,
-higher values may be supported for the \s-1SUBDOC\s0 parameter.
-.LP
-Documents that do not use optional features are also supported.
-For example, if
-.B FORMAL\ NO
-is specified in the \*S declaration,
-public identifiers will not be required to be valid formal public identifiers.
-.LP
-Certain parts of the concrete syntax may be changed:
-.RS
-.LP
-The shunned character numbers can be changed.
-.LP
-Eight bit characters can be assigned to
-\s-1LCNMSTRT\s0, \s-1UCNMSTRT\s0, \s-1LCNMCHAR\s0 and \s-1UCNMCHAR\s0.
-.LP
-Uppercase substitution can be performed or not performed
-both for entity names and for other names.
-.LP
-Either short reference delimiters assigned by the reference delimiter set
-or no short reference delimiters are supported.
-.LP
-The reserved names can be changed.
-.LP
-The quantity set can be increased within certain limits
-subject to there being sufficient memory available.
-The upper limit on \s-1\%NAMELEN\s0 is 239.
-The upper limits on
-\s-1\%ATTCNT\s0, \s-1\%ATTSPLEN\s0, \s-1\%BSEQLEN\s0, \s-1\%ENTLVL\s0,
-\s-1\%LITLEN\s0, \s-1\%PILEN\s0, \s-1\%TAGLEN\s0, and \s-1\%TAGLVL\s0
-are more than thirty times greater than the reference limits.
-The upper limit on
-\s-1\%GRPCNT\s0, \s-1\%GRPGTCNT\s0, and \s-1\%GRPLVL\s0 is 253.
-\s-1\%NORMSEP\s0
-cannot be changed.
-\s-1\%DTAGLEN\s0
-are
-\s-1\%DTEMPLEN\s0
-irrelevant since
-.I sgmls
-does not support the
-\s-1\%DATATAG\s0
-feature.
-.RE
-.SS "\*S declaration"
-The \*S declaration may be omitted,
-the following declaration will be implied:
-.TS
-tab(&);
-c1 s1 s1 s1 s1 s1 s1 s1 s
-c s s s s s s s s
-l l s s s s s s s.
-<!SGML "ISO 8879:1986"
-CHARSET
-BASESET&"ISO 646-1983//CHARSET
-&\h'\w'"'u'International Reference Version (IRV)//ESC 2/5 4/0"
-DESCSET&\0\00\0\09\0UNUSED
-&\0\09\0\02\0\09
-&\011\0\02\0UNUSED
-&\013\0\01\013
-&\014\018\0UNUSED
-&\032\095\032
-&127\0\01\0UNUSED
-.T&
-l l l s s s s s s
-l l s s s s s s s
-l l l s s s s s s
-c s s s s s s s s
-l l l l l l l l l.
-CAPACITY&PUBLIC&"ISO 8879:1986//CAPACITY Reference//EN"
-SCOPE&DOCUMENT
-SYNTAX&PUBLIC&"ISO 8879:1986//SYNTAX Reference//EN"
-FEATURES
-MINIMIZE&DATATAG&NO&OMITTAG&YES&RANK&NO&SHORTTAG&YES
-LINK&SIMPLE&NO&IMPLICIT&NO&EXPLICIT&NO
-OTHER&CONCUR&NO&SUBDOC&YES 99999999&FORMAL&YES
-.T&
-c s s s s s s s s.
-APPINFO NONE>
-.TE
-with the exception that characters 128 through 254 will be assigned to
-\s-1DATACHAR\s0.
-.LP
-.I Sgmls
-identifies base character sets using the designating sequence in the
-public identifier. The following designating sequences are
-recognized:
-.TS
-tab(&);
-c c c c c
-c c c c ^
-c c c c ^
-l n n n l.
-Designating&ISO&Minimum&Number&Description
-Escape&Registration&Character&of&
-Sequence&Number&Number&Characters&
-_
-ESC 2/5 4/0&-&0&128&full set of ISO 646 IRV
-ESC 2/8 4/0&2&33&94&G0 set of ISO 646 IRV
-ESC 2/8 4/2&6&33&94&G0 set of ASCII
-ESC 2/13 4/1&100&32&96&G1 set of ISO 8859-1
-ESC 2/1 4/0&1&0&32&C0 set of ISO 646
-ESC 2/2 4/3&77&0&32&C1 set of ISO 6429
-ESC 2/5 2/15 3/0&-&0&256&the system character set
-.TE
-.LP
-When one of the G0 sets is used as a base set, the characters SPACE
-and DELETE are treated as occurring at positions 32 and 127
-respectively; although these characters are not part of the character
-sets designated by the escape sequences, this mimics the behaviour of
-ISO 2022 with respect to these code positions.
-.SS "Output format"
-The output is a series of lines.
-Lines can be arbitrarily long.
-Each line consists of an initial command character
-and one or more arguments.
-Arguments are separated by a single space,
-but when a command takes a fixed number of arguments
-the last argument can contain spaces.
-There is no space between the command character and the first argument.
-Arguments can contain the following escape sequences.
-.TP
-.B \e\e
-A
-.BR \e.
-.TP
-.B \en
-A record end character.
-.TP
-.B \e|
-Internal \s-1SDATA\s0 entities are bracketed by these.
-.TP
-.BI \e nnn
-The character whose code is
-.I nnn
-octal.
-.LP
-A record start character will be represented by
-.BR \e012 .
-Most applications will need to ignore
-.B \e012
-and translate
-.B \en
-into newline.
-.LP
-The possible command characters and arguments are as follows:
-.TP
-.BI ( gi
-The start of an element whose generic identifier is
-.IR gi .
-Any attributes for this element
-will have been specified with
-.B A
-commands.
-.TP
-.BI ) gi
-The end an element whose generic identifier is
-.IR gi .
-.TP
-.BI \- data
-Data.
-.TP
-.BI & name
-A reference to an external data entity
-.IR name ;
-.I name
-will have been defined using an
-.B E
-command.
-.TP
-.BI ? pi
-A processing instruction with data
-.IR pi .
-.TP
-.BI A name\ val
-The next element to start has an attribute
-.I name
-with value
-.I val
-which takes one of the following forms:
-.RS
-.TP
-.B IMPLIED
-The value of the attribute is implied.
-.TP
-.BI CDATA\ data
-The attribute is character data.
-This is used for attributes whose declared value is
-.BR \s-1CDATA\s0 .
-.TP
-.BI NOTATION\ nname
-The attribute is a notation name;
-.I nname
-will have been defined using a
-.B N
-command.
-This is used for attributes whose declared value is
-.BR \s-1NOTATION\s0 .
-.TP
-.BI ENTITY\ name\|.\|.\|.
-The attribute is a list of general entity names.
-Each entity name will have been defined using an
-.BR I ,
-.B E
-or
-.B S
-command.
-This is used for attributes whose declared value is
-.B \s-1ENTITY\s0
-or
-.BR \s-1ENTITIES\s0 .
-.TP
-.BI TOKEN\ token\|.\|.\|.
-The attribute is a list of tokens.
-This is used for attributes whose declared value is anything else.
-.RE
-.TP
-.BI D ename\ name\ val
-This is the same as the
-.B A
-command, except that it specifies a data attribute for an
-external entity named
-.IR ename .
-Any
-.B D
-commands will come after the
-.B E
-command that defines the entity to which they apply, but
-before any
-.B &
-or
-.B A
-commands that reference the entity.
-.TP
-.BI N nname
-.IR nname.
-Define a notation
-This command will be preceded by a
-.B p
-command if the notation was declared with a public identifier,
-and by a
-.B s
-command if the notation was declared with a system identifier.
-A notation will only be defined if it is to be referenced
-in an
-.B E
-command or in an
-.B A
-command for an attribute with a declared value of
-.BR \s-1NOTATION\s0 .
-.TP
-.BI E ename\ typ\ nname
-Define an external data entity named
-.I ename
-with type
-.I typ
-.RB ( \s-1CDATA\s0 ,
-.B \s-1NDATA\s0
-or
-.BR \s-1SDATA\s0 )
-and notation
-.IR not.
-This command will be preceded by one or more
-.B f
-commands giving the filenames generated by the entity manager from the system
-and public identifiers,
-by a
-.B p
-command if a public identifier was declared for the entity,
-and by a
-.B s
-command if a system identifier was declared for the entity.
-.I not
-will have been defined using a
-.B N
-command.
-Data attributes may be specified for the entity using
-.B D
-commands.
-An external data entity will only be defined if it is to be referenced in a
-.B &
-command or in an
-.B A
-command for an attribute whose declared value is
-.B \s-1ENTITY\s0
-or
-.BR \s-1ENTITIES\s0 .
-.TP
-.BI I ename\ typ\ text
-Define an internal data entity named
-.I ename
-with type
-.I typ
-.RB ( \s-1CDATA\s0
-or
-.BR \s-1SDATA\s0 )
-and entity text
-.IR text .
-An internal data entity will only be defined if it is referenced in an
-.B A
-command for an attribute whose declared value is
-.B \s-1ENTITY\s0
-or
-.BR \s-1ENTITIES\s0 .
-.TP
-.BI S ename
-Define a subdocument entity named
-.IR ename .
-This command will be preceded by one or more
-.B f
-commands giving the filenames generated by the entity manager from the system
-and public identifiers,
-by a
-.B p
-command if a public identifier was declared for the entity,
-and by a
-.B s
-command if a system identifier was declared for the entity.
-A subdocument entity will only be defined if it is referenced
-in a
-.B {
-command
-or in an
-.B A
-command for an attribute whose declared value is
-.B \s-1ENTITY\s0
-or
-.BR \s-1ENTITIES\s0 .
-.TP
-.BI s sysid
-This command applies to the next
-.BR E ,
-.B S
-or
-.B N
-command and specifies the associated system identifier.
-.TP
-.BI p pubid
-This command applies to the next
-.BR E ,
-.B S
-or
-.B N
-command and specifies the associated public identifier.
-.TP
-.BI f filename
-This command applies to the next
-.B E
-or
-.B S
-command and specifies an associated filename.
-There will be more than one
-.B f
-command for a single
-.B E
-or
-.B S
-command if the system identifier used a
-.if \n(Os=0 colon.
-.if \n(Os=1 semi-colon.
-.TP
-.BI { ename
-The start of the \*S subdocument entity
-.IR ename ;
-.I ename
-will have been defined using a
-.B S
-command.
-.TP
-.BI } ename
-The end of the \*S subdocument entity
-.IR ename .
-.TP
-.BI L lineno\ file
-.TQ
-.BI L lineno
-Set the current line number and filename.
-The
-.I filename
-argument will be omitted if only the line number has changed.
-This will be output only if the
-.B \-l
-option has been given.
-.TP
-.BI # text
-An \s-1APPINFO\s0 parameter of
-.I text
-was specified in the \*S declaration.
-This is not strictly part of the ESIS, but a structure-controlled
-application is permitted to act on it.
-No
-.B #
-command will be output if
-.B \s-1APPINFO\s0\ \s-1NONE\s0
-was specified.
-A
-.B #
-command will occur at most once,
-and may be preceded only by a single
-.B L
-command.
-.TP
-.B C
-This command indicates that the document was a conforming \*S document.
-If this command is output, it will be the last command.
-An \*S document is not conforming if it references a subdocument entity
-that is not conforming.
-.SH BUGS
-Some non-SGML characters in literals are counted as two characters for the
-purposes of quantity and capacity calculations.
-.SH "SEE ALSO"
-The \*S Handbook, Charles F. Goldfarb
-.br
-\s-1ISO\s0 8879 (Standard Generalized Markup Language),
-International Organization for Standardization
-.SH ORIGIN
-\s-1ARCSGML\s0 was written by Charles F. Goldfarb.
-.LP
-.I Sgmls
-was derived from \s-1ARCSGML\s0 by James Clark (jjc@jclark.com),
-to whom bugs should be reported.
diff --git a/usr.bin/sgmls/sgmls/sgmlxtrn.c b/usr.bin/sgmls/sgmls/sgmlxtrn.c
deleted file mode 100644
index 74d7894..0000000
--- a/usr.bin/sgmls/sgmls/sgmlxtrn.c
+++ /dev/null
@@ -1,225 +0,0 @@
-/* Standard Generalized Markup Language Users' Group (SGMLUG)
- SGML Parser Materials (ARCSGML 1.0)
-
-(C) 1983-1988 Charles F. Goldfarb (assigned to IBM Corporation)
-(C) 1988-1991 IBM Corporation
-
-Licensed to the SGML Users' Group for distribution under the terms of
-the following license: */
-
-char license[] =
-"SGMLUG hereby grants to any user: (1) an irrevocable royalty-free,\n\
-worldwide, non-exclusive license to use, execute, reproduce, display,\n\
-perform and distribute copies of, and to prepare derivative works\n\
-based upon these materials; and (2) the right to authorize others to\n\
-do any of the foregoing.\n";
-
-#include "sgmlincl.h"
-
-/* SGMLXTRN: Storage allocation and initialization for all public variables.
- Exceptions: Constants lex????? and del????? are defined in
- LEX?????.C modules; constants pcb????? are defined in PCB?????.c.
-*/
-int badresw = 0; /* 1=REF_ out of context; 0=valid. */
-int charmode = 0; /* >0=in #CHARS; 0=not. */
-int conactsw = 0; /* 1=return saved content action 0=get new one.*/
-int conrefsw = 0; /* 1=content reference att specified; 0=no. */
-int contersv = 0; /* Save contersw while processing pending REF. */
-int contersw = 0; /* 1=element or #CHARS out of context; 0=valid. */
-int datarc = 0; /* Return code for data: DAF_ or REF_. */
-int delmscsw = 0; /* 1=DELMSC must be read on return to es==0. */
-int didreq = 0; /* 1=required implied tag processed; 0=no. */
-int docelsw = 0; /* 1=had document element; 0=no */
-int dostag = 0; /* 1=retry newetd instead of parsing; 0=parse. */
-int dtdsw = 0; /* DOCTYPE declaration found: 1=yes; 0=no. */
-int entdatsw = 0; /* 2=CDATA entity; 4=SDATA; 8=NDATA; 0=none. */
-int entpisw = 0; /* 4=PI entity occurred; 0=not. */
-int eodsw = 0; /* 1=eod found in error; 0=not yet. */
-int eofsw = 0; /* 1=eof found in body of document; 0=not yet. */
-int es = -1; /* Index of current source in stack. */
-int etagimct = 0; /* Implicitly ended elements left on stack. */
-int etagimsw = 0; /* 1=end-tag implied by other end-tag; 0=not. */
-int etagmin = MINNONE; /* Minim: NONE NULL NET DATA; implied by S/ETAG*/
-int etictr = 0; /* Number of "NET enabled" tags on stack. */
-int etisw = 0; /* 1=tag ended with eti; 0=did not. */
-int indtdsw = 0; /* Are we in the DTD? 1=yes; 0=no. */
-int mslevel = 0; /* Nesting level of marked sections. */
-int msplevel = 0; /* Nested MS levels subject to special parse. */
-int prologsw = 1; /* 1=in prolog; 0=not. */
-int pss = 0; /* SGMLACT: scbsgml stack level. */
-int sgmlsw = 0; /* SGML declaration found: 1=yes; 0=no. */
-int stagmin = MINNONE; /* Minimization: NONE, NULL tag, implied by STAG*/
-int tagctr = 0; /* Tag source chars read. */
-int tages = -1; /* ES level at start of tag. */
-int ts = -1; /* Index of current tag in stack. */
-struct parse *propcb = &pcbpro; /* Current PCB for prolog parse. */
-int aentctr = 0; /* Number of ENTITY tokens in this att list. */
-int conact = 0; /* Return code from content parse. */
-int conrefsv = 0; /* Save conrefsw when doing implied start-tag.*/
-int dtdrefsw = 0; /* External DTD? 1=yes; 0=no. */
-int etiswsv = 0; /* Save etisw when processing implied start-tag.*/
-int grplvl = 0; /* Current level of nested grps in model. */
-int idrctr = 0; /* Number of IDREF tokens in this att list. */
-int mdessv = 0; /* ES level at start of markup declaration. */
-int notadn = 0; /* Position of NOTATION attribute in list. */
-int parmno = 0; /* Current markup declaration parameter number. */
-int pexsw = 0; /* 1=tag valid solely because of plus exception.*/
-int rcessv = 0; /* ES level at start of RCDATA content. */
-int tagdelsw = 0; /* 1=tag ended with delimiter; 0=no delimiter. */
-int tokencnt = 0; /* Number of tokens found in attribute value. */
-struct entity *ecbdeflt = 0; /* #DEFAULT ecb (NULL if no default entity). */
-struct etd *docetd = 0; /* The etd for the document as a whole. */
-struct etd *etagreal = 0; /* Actual or dummy etd that implied this tag. */
-struct etd *newetd = 0; /* The etd for a start- or end-tag recognized. */
-struct etd *nextetd = 0; /* ETD that must come next (only one choice). */
-struct etd *lastetd = 0; /* most recently ended ETD. */
-struct etd *stagreal = 0; /* Actual or dummy etd that implied this tag. */
-struct parse *conpcb = 0; /* Current PCB for content parse. */
-UNCH *data = 0; /* Pointer to returned data in buffer. */
-UNCH *mdname = 0; /* Name of current markup declaration. */
-UNCH *ptcon = 0; /* Current pointer into tbuf. */
-UNCH *ptpro = 0; /* Current pointer into tbuf. */
-UNCH *rbufs = 0; /* DOS file read area: start position for read. */
-UNCH *subdcl = 0; /* Subject of markup declaration (e.g., GI). */
-UNS conradn = 0; /* 1=CONREF attribute in list (0=no). */
-UNS datalen = 0; /* Length of returned data in buffer. */
-UNS entlen = 0; /* Length of TAG or EXTERNAL entity text. */
-UNS idadn = 0; /* Number of ID attribute (0 if none). */
-UNS noteadn = 0; /* Number of NOTATION attribute (0 if none). */
-UNS reqadn = 0; /* Num of atts with REQUIRED default (0=none). */
-int grplongs; /* Number of longs for GRPCNT bitvector. */
-
-/* Variable arrays and structures.
-*/
-struct ad *al = 0; /* Current attribute list work area. */
-struct dcncb *dcntab[1]; /* List of data content notation names. */
-struct entity *etab[ENTHASH]; /* Entity hash table. */
-struct etd *etdtab[ETDHASH]; /* Element type definition hash table. */
-struct fpi fpidf; /* Fpi for #DEFAULT entity. */
-struct id *itab[IDHASH]; /* Unique identifier hash table. */
-struct etd **nmgrp = 0; /* Element name group */
-PDCB *nnmgrp = 0; /* Notation name group */
-struct restate *scbsgml = 0; /* SGMLACT: return action state stack. */
-struct source *scbs = 0; /* Stack of open sources ("SCB stack"). */
-struct srh *srhtab[1]; /* List of SHORTREF table headers. */
-struct sgmlstat ds; /* Document statistics. */
-struct switches sw; /* Parser control switches set by text proc. */
-struct tag *tags = 0; /* Stack of open elements ("tag stack"). */
-struct thdr *gbuf = 0; /* Buffer for creating group. */
-struct thdr prcon[3]; /* 0-2: Model for *DOC content. */
-struct thdr undechdr; /* 0:Default model hdr for undeclared content.*/
-UNCH *dtype = 0; /* Document type name. */
-UNCH *entbuf = 0; /* Buffer for entity reference name. */
-UNCH fce[2]; /* String form of FCE char.
- (fce[1] must be EOS).*/
-/* Buffer for non-SGML character reference.*/
-UNCH nonchbuf[2] = { DELNONCH };
-UNCH *tbuf; /* Work area for tokenization. */
-UNCH *lbuf = 0; /* In tbuf: Literal parse area.*/
-UNCH *sysibuf = 0; /* Buffer for system identifiers. */
-UNCH *pubibuf = 0; /* Buffer for public identifiers. */
-UNCH *nmbuf = 0; /* Name buffer used by mdentity. */
-struct mpos *savedpos;
-
-/* Constants.
-*/
-struct map dctab[] = { /* Keywords for declared content parameter.*/
- { key[KRCDATA], MRCDATA+MPHRASE },
- { key[KCDATA], MCDATA+MPHRASE },
- { key[KANY], MANY+MCHARS+MGI },
- { key[KEMPTY], MNONE+MPHRASE },
- { NULL, 0 }
-};
-struct map deftab[] = { /* Default value keywords. */
- { key[KIMPLIED], DNULL },
- { key[KREQUIRED], DREQ },
- { key[KCURRENT], DCURR },
- { key[KCONREF], DCONR },
- { key[KFIXED], DFIXED},
- { NULL, 0}
-};
-struct map dvtab[] = { /* Declared value: keywords and type codes.*/
-/* TYPE NUMBER */
-/* grp ANMTGRP Case 1 0 Grp size */
-/* grp member ANMTGRP Case 0 Position */
-/* grp ANOTEGRP Case 1 1 Grp size */
- { key[KNOTATION], ANOTEGRP}, /* Case 1 Position */
- { key[KCDATA], ACHARS }, /* Case 2 Always 0 */
- { key[KENTITY], AENTITY }, /* Case 3 Normal 1 */
- { key[KID], AID }, /* Case 4 Normal 1 */
- { key[KIDREF], AIDREF }, /* Case 5 Normal 1 */
- { key[KNAME], ANAME }, /* Case 6 Normal 1 */
- { key[KNMTOKEN], ANMTOKE }, /* Case 7 Normal 1 */
- { key[KNUMBER], ANUMBER }, /* Case 8 Normal 1 */
- { key[KNUTOKEN], ANUTOKE }, /* Case 9 Normal 1 */
- { key[KENTITIES], AENTITYS}, /* Case A Normal 1 */
- { key[KIDREFS], AIDREFS }, /* Case B # tokens */
- { key[KNAMES], ANAMES }, /* Case C # tokens */
- { key[KNMTOKENS], ANMTOKES}, /* Case D # tokens */
- { key[KNUMBERS], ANUMBERS}, /* Case E # tokens */
- { key[KNUTOKENS], ANUTOKES}, /* Case F # tokens */
- { NULL, 0 } /* Case 0 ERROR */
-};
-struct map enttab[] = { /* Entity declaration second parameter. */
- { key[KCDATA], ESC },
- { key[KSDATA], ESX },
- { key[KMS], ESMS},
- { key[KPI], ESI },
- { key[KSTARTTAG], ESS },
- { key[KENDTAG], ESE },
- { key[KMD], ESMD},
- { NULL, 0 }
-};
-struct map exttab[] = { /* Keywords for external identifier. */
- { key[KSYSTEM], EDSYSTEM },
- { key[KPUBLIC], EDPUBLIC },
- { NULL, 0 }
-};
-struct map extettab[] = { /* Keywords for external entity type. */
- { key[KCDATA], ESNCDATA },
- { key[KNDATA], ESNNDATA },
- { key[KSDATA], ESNSDATA },
- { key[KSUBDOC], ESNSUB },
- { NULL, 0 }
-};
-struct map funtab[] = { /* Function character reference names. */
- { key[KRE], RECHAR },
- { key[KRS], RSCHAR },
- { key[KSPACE], SPCCHAR },
- /* We should use an extra table for added functions. */
- { (UNCH *)"TAB", TABCHAR },
- { NULL, 0 }
-};
-struct map mstab[] = { /* Marked section keywords. */
- { key[KTEMP], MSTEMP },
- { key[KINCLUDE], MSTEMP }, /* Treat INCLUDE like TEMP; both are NOPs.*/
- { key[KRCDATA], MSRCDATA},
- { key[KCDATA], MSCDATA },
- { key[KIGNORE], MSIGNORE},
- { NULL, 0 }
-};
-struct map pubcltab[] = { /* Names for public text class. */
- { (UNCH *)"CAPACITY", FPICAP },
- { (UNCH *)"CHARSET", FPICHARS},
- { (UNCH *)"DOCUMENT", FPIDOC },
- { (UNCH *)"DTD", FPIDTD },
- { (UNCH *)"ELEMENTS", FPIELEM },
- { (UNCH *)"ENTITIES", FPIENT },
- { (UNCH *)"LPD", FPILPD },
- { (UNCH *)"NONSGML", FPINON },
- { (UNCH *)"NOTATION", FPINOT },
- { (UNCH *)"SHORTREF", FPISHORT},
- { (UNCH *)"SUBDOC", FPISUB },
- { (UNCH *)"SYNTAX", FPISYN },
- { (UNCH *)"TEXT", FPITEXT },
- { NULL, 0 }
-};
-UNCH indefent[] = "\12#DEFAULT"; /* Internal name: default entity name. */
-UNCH indefetd[] = "\12*DOCTYPE"; /* Internal name: default document type. */
-UNCH indocent[] = "\12*SGMLDOC"; /* Internal name: SGML document entity. */
-UNCH indocetd[] = "\6*DOC"; /* Internal name: document level etd. */
-UNCH indtdent[] = "\11*DTDENT"; /* Internal name: external DTD entity. */
-
-struct etd dumetd[3];
-struct entity *dumpecb;
-UNCH sgmlkey[] = "SGML";
diff --git a/usr.bin/sgmls/sgmls/sgmlxtrn.h b/usr.bin/sgmls/sgmls/sgmlxtrn.h
deleted file mode 100644
index e551200..0000000
--- a/usr.bin/sgmls/sgmls/sgmlxtrn.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/* SGMLXTRN.H: External declarations for SGML public variables.
- Exceptions: Constants lex????? and del????? are defined in
- LEX?????.C modules; constants pcb????? are defined in PCB?????.c.
-*/
-#ifndef SGMLXTRN /* Don't include this file more than once. */
-#define SGMLXTRN
-extern int badresw; /* 1=REF_ out of context; 0=valid. */
-extern int charmode; /* >0=in #CHARS; 0=not. */
-extern int conactsw; /* 1=return saved content action 0=get new one.*/
-extern int conrefsw; /* 1=content reference att specified; 0=no. */
-extern int contersv; /* Save contersw while processing pending REF. */
-extern int contersw; /* 1=element or #CHARS out of context; 0=valid. */
-extern int datarc; /* Return code for data: DAF_ or REF_. */
-extern int delmscsw; /* 1=DELMSC must be read on return to es==0. */
-extern int didreq; /* 1=required implied tag processed; 0=no. */
-extern int docelsw; /* 1=had document element; 0=no */
-extern int dostag; /* 1=retry newetd instead of parsing; 0=parse. */
-extern int dtdsw; /* DOCTYPE declaration found: 1=yes; 0=no. */
-extern int entdatsw; /* 2=CDATA entity; 4=SDATA; 8=NDATA; 0=none. */
-extern int entpisw; /* 4=PI entity occurred; 0=not. */
-extern int eodsw; /* 1=eod found in error; 0=not yet. */
-extern int eofsw; /* 1=eof found in body of document; 0=not yet. */
-extern int etagimct; /* Implicitly ended elements left on stack. */
-extern int etagimsw; /* 1=end-tag implied by other end-tag; 0=not. */
-extern int etagmin; /* Minim: NONE NULL NET DATA; implied by S/ETAG*/
-extern int etictr; /* Number of "NET enabled" tags on stack. */
-extern int etisw; /* 1=tag ended with eti; 0=did not. */
-extern int indtdsw; /* Are we in the DTD? 1=yes; 0=no. */
-extern int mslevel; /* Nesting level of marked sections. */
-extern int msplevel; /* Nested MS levels subject to special parse. */
-extern int prologsw; /* 1=in prolog; 0=not. */
-extern int pss; /* SGMLACT: scbsgml stack level. */
-extern int sgmlsw; /* SGML declaration found: 1=yes; 0=no. */
-extern int stagmin; /* Minimization: NONE, NULL tag, implied by STAG*/
-extern int tagctr; /* Tag source chars read. */
-extern int tages; /* ES level at start of tag. */
-extern int ts; /* Index of current tag in stack. */
-extern struct parse *propcb; /* Current PCB for prolog parse. */
-extern int aentctr; /* Number of ENTITY tokens in this att list. */
-extern int conact; /* Return code from content parse. */
-extern int conrefsv; /* Save conrefsw when doing implied start-tag.*/
-extern int dtdrefsw; /* External DTD? 1=yes; 0=no. */
-extern int etiswsv; /* Save etisw when processing implied start-tag.*/
-extern int grplvl; /* Current level of nested grps in model. */
-extern int idrctr; /* Number of IDREF tokens in this att list. */
-extern int mdessv; /* ES level at start of markup declaration. */
-extern int notadn; /* Position of NOTATION attribute in list. */
-extern int parmno; /* Current markup declaration parameter number. */
-extern int pexsw; /* 1=tag valid solely because of plus exception.*/
-extern int rcessv; /* ES level at start of RCDATA content. */
-extern int tagdelsw; /* 1=tag ended with delimiter; 0=no delimiter. */
-extern int tokencnt; /* Number of tokens found in attribute value. */
-extern struct entity *ecbdeflt; /* #DEFAULT ecb (NULL if no default entity). */
-extern struct etd *docetd; /* The etd for the document as a whole. */
-extern struct etd *etagreal; /* Actual or dummy etd that implied this tag. */
-extern struct etd *newetd; /* The etd for a start- or end-tag recognized. */
-extern struct etd *nextetd; /* ETD that must come next (only one choice). */
-extern struct etd *lastetd; /* Most recently ended ETD. */
-extern struct etd *stagreal; /* Actual or dummy etd that implied this tag. */
-extern struct parse *conpcb; /* Current PCB for content parse. */
-extern UNCH *data; /* Pointer to returned data in buffer. */
-extern UNCH *mdname; /* Name of current markup declaration. */
-extern UNCH *ptcon; /* Current pointer into tbuf. */
-extern UNCH *ptpro; /* Current pointer into tbuf. */
-extern UNCH *rbufs; /* DOS file read area: start position for read. */
-extern UNCH *subdcl; /* Subject of markup declaration (e.g., GI). */
-extern UNS conradn; /* 1=CONREF attribute in list (0=no). */
-extern UNS datalen; /* Length of returned data in buffer. */
-extern UNS entlen; /* Length of TAG or EXTERNAL entity text. */
-extern UNS idadn; /* Number of ID attribute (0 if none). */
-extern UNS noteadn; /* Number of NOTATION attribute (0 if none). */
-extern UNS reqadn; /* Num of atts with REQUIRED default (0=none). */
-extern int grplongs; /* Number of longs for GRPCNT bitvector. */
-/* Variable arrays and structures.
-*/
-extern struct ad *al; /* Current attribute list work area. */
-extern struct dcncb *dcntab[];/* List of data content notation names. */
-extern struct entity *etab[]; /* Entity hash table. */
-extern struct etd *etdtab[]; /* Element type definition hash table. */
-extern struct fpi fpidf; /* Fpi for #DEFAULT entity. */
-extern struct id *itab[]; /* Unique identifier hash table. */
-extern struct etd **nmgrp; /* Element name group */
-extern PDCB *nnmgrp; /* Notation name group */
-extern struct restate *scbsgml; /* SGMLACT: return action state stack. */
-extern struct srh *srhtab[]; /* List of SHORTREF table headers. */
-extern struct sgmlstat ds; /* Document statistics. */
-extern struct switches sw; /* Parser control switches set by text proc. */
-extern struct tag *tags; /* Stack of open elements ("tag stack"). */
-extern struct thdr *gbuf; /* Buffer for creating group. */
-extern struct thdr prcon[]; /* 0-2: Model for *DOC content. */
-extern struct thdr undechdr; /* 0: Default model hdr for undeclared content. */
-extern UNCH *dtype; /* Document type name. */
-extern UNCH *entbuf; /* Buffer for entity reference name. */
-extern UNCH fce[]; /* String form of FCE char (fce[1] must be EOS).*/
-extern UNCH nonchbuf[]; /* Buffer for valid nonchar character reference.*/
-extern UNCH *tbuf; /* Work area for tokenization. */
-extern UNCH *lbuf; /* In tbuf: Literal parse area; TAGLEN limit.*/
-extern struct entity *dumpecb; /* SRMNULL points to this. */
-extern UNCH *sysibuf;
-extern UNCH *pubibuf;
-extern UNCH *nmbuf; /* Name buffer used by mdentity. */
-extern struct mpos *savedpos;
-
-/* Constants.
-*/
-extern int scbsgmnr; /* SCBSGML: new record; do not ignore RE. */
-extern int scbsgmst; /* SCBSGML: trailing stag or markup; ignore RE. */
-extern struct map dctab[]; /* Keywords for declared content parameter. */
-extern struct map deftab[]; /* Default value keywords. */
-extern struct map dvtab[]; /* Declared value: keywords and type codes.*/
-extern struct map enttab[]; /* Entity declaration second parameter. */
-extern struct map exttab[]; /* Keywords for external identifier. */
-extern struct map extettab[]; /* Keywords for external entity type. */
-extern struct map funtab[]; /* Function character reference names. */
-extern struct map mstab[]; /* Marked section keywords. */
-extern struct map pubcltab[]; /* Keywords for public text class. */
-extern UNCH indefent[]; /* Internal name: default entity name. */
-extern UNCH indefetd[]; /* Internal name: default document type. */
-extern UNCH indocent[]; /* Internal name: SGML document entity. */
-extern UNCH indocetd[]; /* Internal name: etd for document as a whole. */
-extern UNCH indtdent[]; /* Internal name: external DTD entity. */
-extern char license[]; /* SGML Users' Group free license. */
-#endif /* ndef SGMLXTRN */
diff --git a/usr.bin/sgmls/sgmls/source.h b/usr.bin/sgmls/sgmls/source.h
deleted file mode 100644
index 32cc85a..0000000
--- a/usr.bin/sgmls/sgmls/source.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/* SOURCE.H: Entity and source control block structures and definitions.
-*/
-#define ENTHASH 503 /* Size of entity hash table. Must be prime. */
-/* Entity storage class values for estore member of entity structure. */
-#define EST 1 /* String: Tag (usually a fixed STARTGI). */
- /* <MDENTITY sets these:> */
-#define ESMD 2 /* String: Markup declaration. */
-#define ESMS 3 /* String: Marked section. */
-#define ESM 4 /* String: ordinary text. */
- /* <ENTOPEN treats these specially:> */
-#define ESS 5 /* ETD: Start-tag. */
-#define ESE 6 /* ETD: End-tag. */
-#define ESI 7 /* String: PI. */
-#define ESX 8 /* String: SDATA general entity. */
-#define ESC 9 /* String: CDATA general entity. */
- /* </MDENTITY> <MDEXTID sets these:> */
-#define ESFM 10 /* LPU: minimum external (file) storage class. */
-#define ESN 10 /* XCB: N/C/SDATA or SUBDOC control block. */
- /* </ENTOPEN> */
-#define ESF 11 /* LPU: General entity. */
-#define ESP 12 /* LPU: Parameter entity. */
-#define ESD 13 /* LPU: Document type definition. */
-#define ESL 14 /* LPU: Link process definition. */
-#define ESK 15 /* LPU: Data content notation. */
- /* </MDEXTID> */
-
-union etext { /* Entity text. */
- UNIV x; /* External ID generated by system. */
- UNCH *c; /* Character string. */
- struct ne *n; /* N/C/SDATA or SUBDOC entity control block. */
-};
-#define ETEXTSZ sizeof(union etext)
-struct entity { /* Entity control block. */
- struct entity *enext; /* Next entity in chain. */
- UNCH *ename; /* Entity name with length and EOS. */
- UNCH estore; /* Storage class (see values above). */
- UNCH dflt; /* Declared as default entity. */
- UNCH mark; /* For use by for sgmlment. */
- union etext etx; /* Entity text. */
-};
-#define ENTSZ sizeof(struct entity)
-typedef struct entity *PECB; /* Ptr to entity control block. */
-typedef struct entity **TECB; /* Table of entity control blocks. */
-
-struct source { /* Source control block. */
- struct entity ecb; /* Entity control block. */
- unsigned long rcnt; /* Source record number. */
- int ccnt; /* Source record chars since last RS. */
- int curoff; /* Offset of curchar (chars read in this block).*/
- UNCH curchar; /* Current character. */
- UNCH nextchar; /* If curchar was DELNONCH, next character. */
- UNIV fcb; /* SGMLIO fcb ptr returned by OPEN. */
- UNCH *fbuf; /* 1st char in buffer (0=PEND) or entity text. */
- UNCH *fpos; /* Current char in buffer or entity text. */
- UNCH pushback; /* Character before pend position */
- char copied; /* Is this a copy of the internal entity? */
-};
-#define SCBSZ sizeof(struct source)
-typedef struct source *PSCB; /* Ptr to source control block. */
-
-extern int es; /* Index of current source in stack. */
-extern struct source *scbs; /* Stack of open sources ("SCB stack"). */
-
-/* Member definitions for source and entity control blocks.
-*/
-#define SCB (scbs[es]) /* Ptr to current source control block. */
-
-#define ECB SCB.ecb /* Pointer to current entity control block. */
-#define FBUF SCB.fbuf /* Pointer to start of entity buffer. */
-#define FPOS SCB.fpos /* Pointer to current char of current source. */
-#define RSCC SCB.ccnt /* CCNT at start of block (across EOB/EOS/EOF). */
-#define CCO SCB.curoff /* Offset in read buffer of current char. */
-#define CC SCB.curchar /* Current character of current source entity. */
-#define NEXTC SCB.nextchar /* Next character in current source entity. */
-#define CCNT (SCB.ccnt+CCO) /* Position of CC in current record (RS=0). */
-#define RCNT SCB.rcnt /* Position of record in entity (origin=1). */
-#define SCBFCB SCB.fcb /* Current file control block (if FILESW). */
-#define ECBPTR ((ECB.enext)) /* Pointer to this entity's ECB. */
-#define ENTITY ((ECB.ename)) /* Current entity name. */
-#define FILESW (ECB.estore>=ESFM) /* 1=Entity is external file; 0=internal. */
-#define NEWCC (++FPOS) /* Get next current character. */
-#define REPEATCC (--FPOS) /* Repeat previous current character. */
-#define COPIEDSW SCB.copied /* Non-zero means entity was copied. */
-
-struct srh { /* Short reference map header. */
- struct srh *enext; /* Next short reference map in chain. */
- UNCH *ename; /* Short reference map name. */
- TECB srhsrm; /* Ptr to short reference map. */
-};
-#define SRHSZ (sizeof(struct srh))
-typedef struct srh *PSRH; /* Ptr to short reference map header. */
-#define SRMNULL (&dumpecb) /* Dummy ptr to empty short reference map. */
-
-/* Definitions for ENTOPEN/ENTREF return codes.
-*/
-#define ENTUNDEF -1 /* Callers of ENTOPEN: entity undefined. */
-#define ENTLOOP -2 /* ENTOPEN: endless loop entity. */
-#define ENTMAX -3 /* ENTOPEN: too many open entities. */
-#define ENTFILE -4 /* ENTOPEN: file I/O error. */
-#define ENTDATA -5 /* ENTOPEN: CDATA or SDATA entity. */
-#define ENTPI -6 /* ENTOPEN: PI entity. */
-
-/* Definitions for ENTDATA switches set in contersw.
-*/
-#define CDECONT 2 /* 0010 CDATA entity referenced. */
-#define SDECONT 4 /* 0100 SDATA entity referenced. */
-#define NDECONT 8 /* 1000 NDATA entity referenced. */
-
-/* Definitions for manipulating signed source character counters.
-*/
-#define CTRSET(CTR) (CTR = (int) -(FPOS+1-FBUF)) /* Init source char ctr. */
-#define CTRGET(CTR) (CTR + (int) (FPOS+1-FBUF)) /* Read source char ctr. */
-
-
diff --git a/usr.bin/sgmls/sgmls/std.h b/usr.bin/sgmls/sgmls/std.h
deleted file mode 100644
index 4e6e856..0000000
--- a/usr.bin/sgmls/sgmls/std.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/* std.h -
- Include standard header files.
-*/
-
-#ifndef STD_H
-#define STD_H 1
-
-#include <stdio.h>
-#include <ctype.h>
-#include <errno.h>
-#include <assert.h>
-#ifdef SUPPORT_SUBDOC
-#include <signal.h>
-#endif /* SUPPORT_SUBDOC */
-
-#ifndef STDDEF_H_MISSING
-#include <stddef.h>
-#endif /* not STDDEF_H_MISSING */
-
-#ifndef LIMITS_H_MISSING
-#include <limits.h>
-#endif /* not LIMITS_H_MISSING */
-
-#ifndef UINT_MAX
-#define UINT_MAX (sizeof(unsigned int) == 2 ? 0x7fff : \
- (sizeof(unsigned int) == 4 ? 0x7fffffff : cant_guess_UINT_MAX))
-#endif
-
-#ifdef VARARGS
-#include <varargs.h>
-#else
-#include <stdarg.h>
-#endif
-
-#ifdef BSD_STRINGS
-#include <strings.h>
-#define memcpy(to, from, n) bcopy(from, to, n)
-#define memcmp(p, q, n) bcmp(p, q, n)
-#define strchr(s, c) index(s, c)
-#define strrchr(s, c) rindex(s, c)
-#else /* not BSD_STRINGS */
-#include <string.h>
-#endif /* not BSD_STRINGS */
-
-extern char *strerror();
-
-#ifdef STDLIB_H_MISSING
-UNIV malloc();
-UNIV calloc();
-UNIV realloc();
-char *getenv();
-long atol();
-#else /* not STDLIB_H_MISSING */
-#include <stdlib.h>
-#endif /* not STDLIB_H_MISSING */
-
-#ifdef REMOVE_MISSING
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif /* HAVE_UNISTD_H */
-#define remove unlink
-#endif /* REMOVE_MISSING */
-
-#ifdef RAISE_MISSING
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif /* HAVE_UNISTD_H */
-#define raise(sig) kill(getpid(), sig)
-#endif /* RAISE_MISSING */
-
-#ifndef offsetof
-#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
-#endif
-
-#ifndef EXIT_FAILURE
-#define EXIT_FAILURE 1
-#endif
-#ifndef EXIT_SUCCESS
-#define EXIT_SUCCESS 0
-#endif
-
-#ifndef SEEK_SET
-#define SEEK_SET 0
-#define SEEK_CUR 1
-#define SEEK_END 2
-#endif
-
-#ifdef FPOS_MISSING
-typedef long fpos_t;
-#define fsetpos(stream, pos) fseek(stream, *(pos), SEEK_SET)
-#define fgetpos(stream, pos) ((*(pos) = ftell(stream)) == -1L)
-#endif /* FPOS_MISSING */
-
-/* Old BSD systems lack L_tmpnam and tmpnam(). This is a partial
-emulation using mktemp(). It requires that the argument to tmpnam()
-be non-NULL. */
-
-#ifndef L_tmpnam
-#define tmpnam_template "/tmp/sgmlsXXXXXX"
-#define L_tmpnam (sizeof(tmpnam_template))
-#undef tmpnam
-#define tmpnam(buf) \
- (mktemp(strcpy(buf, tmpnam_template)) == 0 || (buf)[0] == '\0' ? 0 : (buf))
-#endif /* not L_tmpnam */
-
-#ifndef errno
-extern int errno;
-#endif
-
-#endif /* not STD_H */
diff --git a/usr.bin/sgmls/sgmls/stklen.c b/usr.bin/sgmls/sgmls/stklen.c
deleted file mode 100644
index 43af5dd..0000000
--- a/usr.bin/sgmls/sgmls/stklen.c
+++ /dev/null
@@ -1,2 +0,0 @@
-/* This tells Borland C++ to allocate a 14k stack. */
-unsigned _stklen = 14*1024;
diff --git a/usr.bin/sgmls/sgmls/strerror.c b/usr.bin/sgmls/sgmls/strerror.c
deleted file mode 100644
index f5679c0..0000000
--- a/usr.bin/sgmls/sgmls/strerror.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/* strerror.c -
- ANSI C strerror() function.
-
- Written by James Clark (jjc@jclark.com).
-*/
-
-#include "config.h"
-
-#ifdef STRERROR_MISSING
-#include <stdio.h>
-
-char *strerror(n)
-int n;
-{
- extern int sys_nerr;
- extern char *sys_errlist[];
- static char buf[sizeof("Error ") + 1 + 3*sizeof(int)];
-
- if (n >= 0 && n < sys_nerr && sys_errlist[n] != 0)
- return sys_errlist[n];
- else {
- sprintf(buf, "Error %d", n);
- return buf;
- }
-}
-
-#endif /* STRERROR_MISSING */
-/*
-Local Variables:
-c-indent-level: 5
-c-continued-statement-offset: 5
-c-brace-offset: -5
-c-argdecl-indent: 0
-c-label-offset: -5
-End:
-*/
diff --git a/usr.bin/sgmls/sgmls/synrf.c b/usr.bin/sgmls/sgmls/synrf.c
deleted file mode 100644
index 2076107..0000000
--- a/usr.bin/sgmls/sgmls/synrf.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/* SYNRF: Reserved names and other constants for reference concrete syntax.
-*/
-#include "config.h"
-#include "entity.h" /* Templates for entity control blocks. */
-#include "synxtrn.h" /* Declarations for concrete syntax constants. */
-#include "adl.h" /* Definitions for attribute list processing. */
-UNCH key[NKEYS][REFNAMELEN+1] = {
- "ANY",
- "ATTLIST",
- "CDATA",
- "CONREF",
- "CURRENT",
- "DEFAULT",
- "DOCTYPE",
- "ELEMENT",
- "EMPTY",
- "ENDTAG",
- "ENTITIES",
- "ENTITY",
- "FIXED",
- "ID",
- "IDLINK",
- "IDREF",
- "IDREFS",
- "IGNORE",
- "IMPLIED",
- "INCLUDE",
- "INITIAL",
- "LINK",
- "LINKTYPE",
- "MD",
- "MS",
- "NAME",
- "NAMES",
- "NDATA",
- "NMTOKEN",
- "NMTOKENS",
- "NOTATION",
- "NUMBER",
- "NUMBERS",
- "NUTOKEN",
- "NUTOKENS",
- "O",
- "PCDATA",
- "PI",
- "POSTLINK",
- "PUBLIC",
- "RCDATA",
- "RE",
- "REQUIRED",
- "RESTORE",
- "RS",
- "SDATA",
- "SHORTREF",
- "SIMPLE",
- "SPACE",
- "STARTTAG",
- "SUBDOC",
- "SYSTEM",
- "TEMP",
- "USELINK",
- "USEMAP"
-};
-/*
-Local Variables:
-c-indent-level: 5
-c-continued-statement-offset: 5
-c-brace-offset: -5
-c-argdecl-indent: 0
-c-label-offset: -5
-End:
-*/
diff --git a/usr.bin/sgmls/sgmls/synxtrn.h b/usr.bin/sgmls/sgmls/synxtrn.h
deleted file mode 100644
index 1cdf9a0..0000000
--- a/usr.bin/sgmls/sgmls/synxtrn.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/* SYNXTRN.H: External declarations for concrete syntax constants.
-*/
-/* Short References
-*/
-#define SRCT 32 /* Number of short reference delimiters. */
-#define SRMAXLEN 3 /* Maximum length of a SHORTREF delimiter. */
-#define SRNPRT 8 /* Number of non-printable SHORTREF delimiters. */
-struct srdel {
- struct map dtb[SRCT+2]; /* LEXCNM: Short reference delimiters. */
- char *pdtb[SRNPRT+1]; /* LEXCNM: Printable form of unprintable SRs. */
- int fce; /* LEXCNM: Index of first FCE in srdeltab. */
- int hyp2; /* LEXCNM: Index of "two hyphens" in srdeltab. */
- int data; /* LEXCNM: Index of first SR with data char. */
- int hyp; /* LEXCNM: Index of hyphen in srdeltab. */
- int prtmin; /* LEXCNM: Index of 1st printable SR. */
- int spc; /* LEXCNM: Index of space in srdeltab. */
- int lbr; /* LEXCNM: Index of left bracket in srdeltab. */
- int rbr; /* LEXCNM: Index of right bracket in srdeltab. */
-};
-struct delim {
- UNCH genre; /* LEXCON: Generated RE; cannot be markup. */
- UNCH lit; /* LEXMARK: Char used as LIT delimiter.*/
- UNCH lita; /* LEXMARK: Char used as LITA delimiter.*/
- UNCH mdc; /* LEXLMS: Char used as MDC delimiter.*/
- UNCH msc; /* LEXCON: Char used as MSC delimiter. */
- UNCH net; /* LEXCON: Char used as NET when enabled.*/
- UNCH pero; /* LEXMARK: Char used as PERO delimiter. */
- UNCH pic; /* LEXCON: Char used as PIC delimiter.*/
- UNCH tago; /* LEXCON: Char used as TAGO when enabled.*/
-};
-struct lexcode {
- UNCH fce; /* LEXCNM: FRE character as entity reference. */
- UNCH fre; /* LEXCON: Free character not an entity ref. */
- UNCH litc; /* LEXLMS: Literal close delimiter enabled. */
- UNCH minlitc; /* LEXMIN: Literal close delimiter enabled. */
- UNCH msc; /* LEXLMS: Marked section close delim enabled. */
- UNCH net; /* LEXCON: Null end-tag delimiter enabled. */
- UNCH nonet; /* LEXCON: NET disabled; still used as ETI. */
- UNCH spcr; /* LEXCNM: Space in use as SHORTREF delimiter. */
- UNCH tago; /* LEXCON: Tag open delimiter enabled. */
- UNCH cde; /* LEXLMS: CDATA/SDATA delimiters. */
-};
-struct lexical {
- struct markup m; /* Markup strings for text processor. */
- struct srdel s; /* Short reference delimiters. */
- struct delim d; /* General delimiter characters. */
- struct lexcode l; /* Lexical table code assignments. */
-};
-extern struct lexical lex; /* Delimiter set constants. */
-extern UNCH lexcnm[]; /* Lexical table: mixed content. */
-extern UNCH lexcon[]; /* Lexical table for content (except mixed). */
-extern UNCH lexgrp[]; /* Lexical table for groups. */
-extern UNCH lexlms[]; /* Lexical table: literals and marked sections. */
-extern UNCH lexmin[]; /* Lexical table: minimum data literal. */
-extern UNCH lexmark[]; /* Lexical table for markup. */
-extern UNCH lexsd[]; /* Lexical table for SGML declaration. */
-extern UNCH lextran[]; /* Case translation table for SGML names. */
-extern UNCH lextoke[]; /* Lexical table for tokenization. */
-extern UNCH *lextabs[]; /* List of all lexical tables. */
-extern struct parse pcbconc; /* PCB: character data. */
-extern struct parse pcbcone; /* PCB: element content (no data allowed). */
-extern struct parse pcbconm; /* PCB: mixed content (data allowed). */
-extern struct parse pcbconr; /* PCB: replaceable character data. */
-extern struct parse pcbetag; /* PCB: end-tags. */
-extern struct parse pcbgrcm; /* PCB: content model group. */
-extern struct parse pcbgrcs; /* PCB: content model suffix. */
-extern struct parse pcbgrnm; /* PCB: name group. */
-extern struct parse pcbgrnt; /* PCB: name token group. */
-extern struct parse pcblitc; /* PCB: literal with CDATA. */
-extern struct parse pcblitp; /* PCB: literal with CDATA, parm & char refs. */
-extern struct parse pcblitr; /* PCB: attribute value with general refs. */
-extern struct parse pcblitt; /* PCB: tokenized attribute value. */
-extern struct parse pcblitv; /* PCB: literal with CDATA, function char trans.*/
-extern struct parse pcbmd; /* PCB: markup declaration. */
-extern struct parse pcbmdc; /* PCB: comment declaration. */
-extern struct parse pcbmdi; /* PCB: markup declaration (ignored). */
-extern struct parse pcbmds; /* PCB: markup declaration subset. */
-extern struct parse pcbmsc; /* PCB: marked section in CDATA mode. */
-extern struct parse pcbmsi; /* PCB: marked section in IGNORE mode. */
-extern struct parse pcbmsrc; /* PCB: marked section in RCDATA mode. */
-extern struct parse pcbpro; /* PCB: prolog. */
-extern struct parse pcbref; /* PCB: reference. */
-extern struct parse pcbstag; /* PCB: start-tag. */
-extern struct parse pcbval; /* PCB: attribute value. */
-extern struct parse pcbeal; /* PCB: end of attribute list. */
-extern struct parse pcbsd; /* PCB: SGML declaration. */
-extern int pcbcnda; /* PCBCONM: data in buffer. */
-extern int pcbcnet; /* PCBCONM: markup found or data buffer flushed.*/
-extern int pcbmdtk; /* PCBMD: token expected. */
-extern int pcbstan; /* PCBSTAG: attribute name expected. */
-extern int pcblittda; /* PCBLITT: data character found */
-
-#define KANY 0
-#define KATTLIST 1
-#define KCDATA 2
-#define KCONREF 3
-#define KCURRENT 4
-#define KDEFAULT 5
-#define KDOCTYPE 6
-#define KELEMENT 7
-#define KEMPTY 8
-#define KENDTAG 9
-#define KENTITIES 10
-#define KENTITY 11
-#define KFIXED 12
-#define KID 13
-#define KIDLINK 14
-#define KIDREF 15
-#define KIDREFS 16
-#define KIGNORE 17
-#define KIMPLIED 18
-#define KINCLUDE 19
-#define KINITIAL 20
-#define KLINK 21
-#define KLINKTYPE 22
-#define KMD 23
-#define KMS 24
-#define KNAME 25
-#define KNAMES 26
-#define KNDATA 27
-#define KNMTOKEN 28
-#define KNMTOKENS 29
-#define KNOTATION 30
-#define KNUMBER 31
-#define KNUMBERS 32
-#define KNUTOKEN 33
-#define KNUTOKENS 34
-#define KO 35
-#define KPCDATA 36
-#define KPI 37
-#define KPOSTLINK 38
-#define KPUBLIC 39
-#define KRCDATA 40
-#define KRE 41
-#define KREQUIRED 42
-#define KRESTORE 43
-#define KRS 44
-#define KSDATA 45
-#define KSHORTREF 46
-#define KSIMPLE 47
-#define KSPACE 48
-#define KSTARTTAG 49
-#define KSUBDOC 50
-#define KSYSTEM 51
-#define KTEMP 52
-#define KUSELINK 53
-#define KUSEMAP 54
-
-#define NKEYS (KUSEMAP+1)
-
-extern UNCH key[NKEYS][REFNAMELEN+1];
-
-/* Holds the SGML keyword (not alterable by concrete syntax). */
-extern UNCH sgmlkey[];
diff --git a/usr.bin/sgmls/sgmls/tools.h b/usr.bin/sgmls/sgmls/tools.h
deleted file mode 100644
index 57ce45a..0000000
--- a/usr.bin/sgmls/sgmls/tools.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* TOOLS.H: Definitions for type declarations, printing, bit handling, etc.
-*/
-
-#if CHAR_SIGNED
-typedef unsigned char UNCH;
-#else
-typedef char UNCH;
-#endif
-
-#if CHAR_SIGNED
-#define ustrcmp(s1, s2) strcmp((char *)(s1), (char *)(s2))
-#define ustrcpy(s1, s2) strcpy((char *)(s1), (char *)(s2))
-#define ustrchr(s, c) (UNCH *)strchr((char *)(s), c)
-#define ustrncmp(s1, s2, n) strncmp((char *)(s1), (char *)(s2), n)
-#define ustrncpy(s1, s2, n) strncpy((char *)(s1), (char *)(s2), n)
-#define ustrlen(s1) strlen((char *)(s1))
-#else
-#define ustrcmp strcmp
-#define ustrcpy strcpy
-#define ustrchr strchr
-#define ustrncmp strncmp
-#define ustrncpy strncpy
-#define ustrlen strlen
-#endif
-
-#if 0
-int ustrcmp(UNCH *, UNCH *);
-UNCH *ustrchr(UNCH *, int);
-int ustrncmp(UNCH *, UNCH *, UNS);
-int ustrncpy(UNCH *, UNCH *, UNS);
-int ustrlen(UNCH *);
-#endif
-
-typedef unsigned UNS;
-
-#ifdef USE_ISASCII
-#define ISASCII(c) isascii(c)
-#else
-#define ISASCII(c) (1)
-#endif
-
-#ifdef BSD_STRINGS
-#define MEMZERO(s, n) bzero(s, n)
-#else /* not BSD_STRINGS */
-#define MEMZERO(s, n) memset(s, '\0', n)
-#endif /* not BSD_STRINGS */
-
-/* Macros for bit manipulation.
-*/
-#define SET(word, bits) ((word) |= (bits)) /* Turn bits on */
-#define RESET(word, bits) ((word) &= ~(bits)) /* Turn bits off */
-#define GET(word, bits) ((word) & (bits)) /* 1=any bit on */
-#define BITOFF(word, bits) (GET(word, bits)==0) /* 1=no bits on */
-#define BITON(word, bits) ((word) & (bits)) /* 1=any bit on */
-
-#define ETDCDATA (dumetd) /* Dummy etd pointer for #PCDATA. */
-#define ETDNULL (dumetd + 1) /* Dummy etd pointer for null tag. */
-#define ETDNET (dumetd + 2) /* Dummy etd pointer for NET delimiter. */
-#define BADPTR(p) \
- ((p) == NULL || (p) == ETDCDATA || (p) == ETDNULL || (p) == ETDNET)
-#define PTRNUM(p) ((p) == NULL ? 0 : ((p) - dumetd) + 1)
-
-#ifdef USE_PROTOTYPES
-#define P(parms) parms
-#else
-#define P(parms) ()
-#endif
-
-/* VP is used for prototypes of varargs functions. You can't have a
-prototype if the function is defined using varargs.h rather than
-stdarg.h. */
-#ifdef VARARGS
-#define VP(parms) ()
-#else
-#define VP(parms) P(parms)
-#endif
diff --git a/usr.bin/sgmls/sgmls/trace.h b/usr.bin/sgmls/sgmls/trace.h
deleted file mode 100644
index f917a26..0000000
--- a/usr.bin/sgmls/sgmls/trace.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/* TRACE.H: Declarations for internal trace functions. */
-
-#ifdef TRACE
-
-/* Trace variables.
-*/
-extern int trace; /* Switch: 1=trace state transitions; 0=don't. */
-extern int atrace; /* Switch: 1=trace attribute activity; 0=don't. */
-extern int ctrace; /* Switch: 1=trace context checking; 0=don't. */
-extern int dtrace; /* Switch: 1=trace declaration parsing; 0=don't.*/
-extern int etrace; /* Switch: 1=trace entity activity; 0=don't.*/
-extern int gtrace; /* Switch: 1=trace group creations; 0=don't. */
-extern int itrace; /* Switch: 1=trace ID activity; 0=don't. */
-extern int mtrace; /* Switch: 1=trace MS activity; 0=don't. */
-extern int ntrace; /* Switch: 1=trace data notation activity. */
-extern char emd[]; /* For "EMD" parameter type in dtrace calls. */
-
-VOID traceadl P((struct ad *));
-VOID tracecon P((int,int,int,struct parse *,int,int));
-VOID tracedcn P((struct dcncb *));
-VOID tracedsk P((struct tag *,struct tag *,int,int));
-VOID traceecb P((char *,struct entity *));
-VOID traceend P((char *,struct thdr *,struct mpos *,int,int));
-VOID traceesn P((struct ne *));
-VOID traceetd P((struct etd *));
-VOID traceetg P((struct tag *,struct etd *,int,int));
-VOID tracegi P((char *,struct etd *,struct thdr *,struct mpos *));
-VOID tracegml P((struct restate *,int,int,int));
-VOID tracegrp P((struct etd **));
-VOID traceid P((char *,struct id *));
-VOID tracemd P((char *));
-VOID tracemod P((struct thdr *));
-VOID tracems P((int,int,int,int));
-VOID tracengr P((struct dcncb **));
-VOID tracepcb P((struct parse *));
-VOID tracepro P((void));
-VOID traceset P((void));
-VOID tracesrm P((char *,struct entity **,UNCH *));
-VOID tracestg P((struct etd *,int,int,struct etd *,int));
-VOID tracestk P((struct tag *,int,int));
-VOID tracetkn P((int,UNCH *));
-VOID traceval P((struct parse *,unsigned int,UNCH *,int));
-
-#define TRACEADL(al) ((void)(atrace && (traceadl(al), 1)))
-#define TRACECON(etagimct, dostag, datarc, pcb, conrefsw, didreq) \
- ((void)(gtrace \
- && (tracecon(etagimct, dostag, datarc, pcb, conrefsw, didreq), 1)))
-#define TRACEDCN(dcn) ((void)(ntrace && (tracedcn(dcn), 1)))
-#define TRACEDSK(pts, ptso, ts3, etictr) \
- ((void)(gtrace && (tracedsk(pts, ptso, ts3, etictr), 1)))
-#define TRACEECB(action, p) \
- ((void)(etrace && (traceecb(action, p), 1)))
-#define TRACEEND(stagenm, mod, pos, rc, opt) \
- ((void)(ctrace && (traceend(stagenm, mod, pos, rc, opt), 1)))
-#define TRACEESN(p) \
- ((void)((etrace || atrace || ntrace) && (traceesn(p), 1)))
-#define TRACEETD(p) ((void)(gtrace && (traceetd(p), 1)))
-#define TRACEETG(pts, curetd, tsl, etagimct) \
- ((void)(gtrace && (traceetg(pts, curetd, tsl, etagimct), 1)))
-#define TRACEGI(stagenm, gi, mod, pos) \
- ((void)(ctrace && (tracegi(stagenm, gi, mod, pos), 1)))
-#define TRACEGML(scb, pss, conactsw, conact) \
- ((void)(trace && (tracegml(scb, pss, conactsw, conact), 1)))
-#define TRACEGRP(p) ((void)(gtrace && (tracegrp(p), 1)))
-#define TRACEID(action, p) ((void)(itrace && (traceid(action, p), 1)))
-#define TRACEMD(p) ((void)(dtrace && (tracemd(p), 1)))
-#define TRACEMOD(p) ((void)(gtrace && (tracemod(p), 1)))
-#define TRACEMS(action, code, mslevel, msplevel) \
- ((void)(mtrace && (tracems(action, code, mslevel, msplevel), 1)))
-#define TRACENGR(p) ((void)(gtrace && (tracengr(p), 1)))
-#define TRACEPCB(p) ((void)(trace && (tracepcb(p), 1)))
-#define TRACEPRO() (tracepro())
-#define TRACESET() (traceset())
-#define TRACESRM(action, pg, gi) \
- ((void)(etrace && (tracesrm(action, pg, gi), 1)))
-#define TRACESTG(curetd, dataret, rc, nextetd, mexts) \
- ((void)(gtrace && (tracestg(curetd, dataret, rc, nextetd, mexts), 1)))
-#define TRACESTK(pts, ts2, etictr) \
- ((void)(gtrace && (tracestk(pts, ts2, etictr), 1)))
-#define TRACETKN(scope, lextoke) \
- ((void)(trace && (tracetkn(scope, lextoke), 1)))
-#define TRACEVAL(pcb, atype, aval, tokencnt) \
- ((void)(atrace && (traceval(pcb, atype, aval, tokencnt), 1)))
-
-#else /* not TRACE */
-
-#define TRACEADL(al) /* empty */
-#define TRACECON(etagimct, dostag, datarc, pcb, conrefsw, didreq) /* empty */
-#define TRACEDCN(dcn) /* empty */
-#define TRACEDSK(pts, ptso, ts3, etictr) /* empty */
-#define TRACEECB(action, p) /* empty */
-#define TRACEEND(stagenm, mod, pos, rc, opt) /* empty */
-#define TRACEESN(p) /* empty */
-#define TRACEETG(pts, curetd, tsl, etagimct) /* empty */
-#define TRACEETD(p) /* empty */
-#define TRACEGI(stagenm, gi, mod, pos) /* empty */
-#define TRACEGML(scb, pss, conactsw, conact) /* empty */
-#define TRACEGRP(p) /* empty */
-#define TRACEID(action, p) /* empty */
-#define TRACEMD(p) /* empty */
-#define TRACEMOD(p) /* empty */
-#define TRACEMS(action, code, mslevel, msplevel) /* empty */
-#define TRACENGR(p) /* empty */
-#define TRACEPCB(p) /* empty */
-#define TRACEPRO() /* empty */
-#define TRACESET() /* empty */
-#define TRACESRM(action, pg, gi) /* empty */
-#define TRACESTG(curetd, dataret, rc, nextetd, mexts) /* empty */
-#define TRACESTK(pts, ts2, etictr) /* empty */
-#define TRACETKN(scope, lextoke) /* empty */
-#define TRACEVAL(pcb, atype, aval, tokencnt) /* empty */
-
-#endif /* not TRACE */
diff --git a/usr.bin/sgmls/sgmls/traceset.c b/usr.bin/sgmls/sgmls/traceset.c
deleted file mode 100644
index e57003f..0000000
--- a/usr.bin/sgmls/sgmls/traceset.c
+++ /dev/null
@@ -1,462 +0,0 @@
-#include "sgmlincl.h" /* #INCLUDE statements for SGML parser. */
-
-#ifdef TRACE
-
-#include "context.h"
-
-/* Token status: RCHIT RCMISS RCEND RCREQ RCNREQ */
-#define STATUX tags[ts].status
-
-/* Trace variables.
-*/
-int trace = 0; /* Switch: 1=trace state transitions; 0=don't. */
-int atrace = 0; /* Switch: 1=trace attribute activity; 0=don't. */
-int ctrace = 0; /* Switch: 1=trace context checking; 0=don't. */
-int dtrace = 0; /* Switch: 1=trace declaration parsing; 0=don't.*/
-int etrace = 0; /* Switch: 1=trace entity activity; 0=don't.*/
-int gtrace = 0; /* Switch: 1=trace group creations; 0=don't. */
-int itrace = 0; /* Switch: 1=trace ID activity; 0=don't. */
-int mtrace = 0; /* Switch: 1=trace MS activity; 0=don't. */
-int ntrace = 0; /* Switch: 1=trace notation activity; 0=don't. */
-char emd[] = "EMD"; /* For "EMD" parameter type in dtrace calls. */
-
-/* Return a printable representation of c.
-*/
-static
-char *printable(c)
-int c;
-{
- static char buf[5];
- if (c >= 040 && c < 0177) {
- buf[0] = c;
- buf[1] = '\0';
- }
- else
- sprintf(buf, "\\%03o", (UNCH)c);
- return buf;
-}
-
-static
-VOID dotrace(s)
-char *s;
-{
- trace = (s && strchr(s, 't') != 0);
- atrace = (s && strchr(s, 'a') != 0);
- ctrace = (s && strchr(s, 'c') != 0);
- dtrace = (s && strchr(s, 'd') != 0);
- etrace = (s && strchr(s, 'e') != 0);
- gtrace = (s && strchr(s, 'g') != 0);
- itrace = (s && strchr(s, 'i') != 0);
- mtrace = (s && strchr(s, 'm') != 0);
- ntrace = (s && strchr(s, 'n') != 0);
-}
-/* TRACESET: Set switches for tracing body of document.
-*/
-VOID traceset()
-{
- dotrace(sw.trace);
-
- if (trace||atrace||ctrace||dtrace||etrace||gtrace||itrace||mtrace||ntrace)
- fprintf(stderr,
-"TRACESET: state=%d;att=%d;con=%d;dcl=%d;ent=%d;grp=%d;id=%d;ms=%d;dcn=%d.\n",
- trace, atrace, ctrace, dtrace, etrace, gtrace, itrace,
- mtrace, ntrace);
-}
-/* TRACEPRO: Set switches for tracing prolog.
- */
-VOID tracepro()
-{
- dotrace(sw.ptrace);
-
- if (trace||atrace||dtrace||etrace||gtrace||mtrace||ntrace)
- fprintf(stderr,
- "TRACEPRO: state=%d; att=%d; dcl=%d; ent=%d; grp=%d; ms=%d; dcn=%d.\n",
- trace, atrace, dtrace, etrace, gtrace, mtrace, ntrace);
-}
-/* TRACEPCB: Trace character just parsed and other pcb data.
- */
-VOID tracepcb(pcb)
-struct parse *pcb;
-{
- fprintf(stderr, "%-8s %2u-%2u-%2u-%2u from %s [%3d] in %s, %lu:%d.\n",
- pcb->pname, pcb->state, pcb->input, pcb->action,
- pcb->newstate, printable(*FPOS), *FPOS, ENTITY+1, RCNT,
- RSCC+FPOS+1-FBUF);
-}
-/* TRACETKN: Trace character just read during token parse.
- */
-VOID tracetkn(scope, lextoke)
-int scope;
-UNCH lextoke[]; /* Lexical table for token and name parses. */
-{
- fprintf(stderr, "TOKEN %2d-%2d from %s [%3d] in %s, %lu:%d.\n",
- scope, lextoke[*FPOS],
- printable(*FPOS), *FPOS, ENTITY+1, RCNT,
- RSCC+FPOS+1-FBUF);
-}
-/* TRACEGML: Trace state of main SGML driver routine.
- */
-VOID tracegml(scb, pss, conactsw, conact)
-struct restate *scb;
-int pss, conactsw, conact;
-{
- fprintf(stderr,
- "SGML%02d %2d-%2d-%2d-%2d in main driver; conactsw=%d; conact=%d.\n",
- pss, scb[pss].sstate, scb[pss].sinput, scb[pss].saction,
- scb[pss].snext, conactsw, conact);
-}
-/* TRACEVAL: Trace parse of an attribute value that is a token list.
- */
-VOID traceval(pcb, atype, aval, tokencnt)
-struct parse *pcb;
-UNS atype; /* Type of token list expected. */
-UNCH *aval; /* Value string to be parsed as token list. */
-int tokencnt; /* Number of tokens found in attribute value. */
-{
- fprintf(stderr,
- "%-8s %2d-%2d-%2d-%2d at %p, atype=%02x, tokencnt=%d: ",
- pcb->pname, pcb->state, pcb->input, pcb->action,
- pcb->newstate, (UNIV)aval, atype, tokencnt);
- fprintf(stderr, "%s\n", aval);
-}
-/* TRACESTK: Trace entry just placed on tag stack.
- */
-VOID tracestk(pts, ts2, etictr)
-struct tag *pts; /* Stack entry for this tag. */
-int ts2; /* Stack depth. */
-int etictr; /* Number of "netok" tags on stack. */
-{
- fprintf(stderr,
- "STACK %s begun; stack depth %d; tflag=%02x; etictr=%d",
- pts->tetd->etdgi+1, ts2, pts->tflags, etictr);
- fprintf(stderr, " srm=%s.\n",
- pts->tsrm!=SRMNULL ? (char *)(pts->tsrm[0]->ename+1) : "#EMPTY");
-}
-/* TRACEDSK: Trace entry just removed from tag stack.
- */
-VOID tracedsk(pts, ptso, ts3, etictr)
-struct tag *pts; /* Stack entry for new open tag. */
-struct tag *ptso; /* Stack entry for tag just ended. */
-int ts3; /* Stack depth. */
-int etictr; /* Number of "netok" tags on stack. */
-{
- fprintf(stderr,
- "DESTACK %s ended; otflag=%02x; %s resumed; depth=%d; tflag=%02x; etictr=%d",
- ptso->tetd->etdgi+1, ptso->tflags,
- pts->tetd->etdgi+1, ts3, pts->tflags, etictr);
- fprintf(stderr, " srm=%s.\n",
- pts->tsrm!=SRMNULL ? (char *)(pts->tsrm[0]->ename+1) : "#EMPTY");
-}
-/* TRACECON: Trace interactions between content parse and stag/context
- processing.
- */
-VOID tracecon(etagimct, dostag, datarc, pcb, conrefsw, didreq)
-int etagimct; /* Implicitly ended elements left on stack. */
-int dostag; /* 1=retry newetd instead of parsing; 0=parse. */
-int datarc; /* Return code for data: DAF_ or REF_ or zero. */
-struct parse *pcb; /* Parse control block for this parse. */
-int conrefsw; /* 1=content reference att specified; 0=no. */
-int didreq; /* 1=required implied empty tag processed; 0=no.*/
-{
- fprintf(stderr,
- "CONTENT etagimct=%d dostag=%d datarc=%d pname=%s action=%d \
-conrefsw=%d didreq=%d\n",
- etagimct, dostag, datarc, pcb->pname, pcb->action,
- conrefsw, didreq);
-}
-/* TRACESTG: Trace start-tag context validation input and results.
- */
-VOID tracestg(curetd, dataret, rc, nextetd, mexts)
-struct etd *curetd; /* The etd for this tag. */
-int dataret; /* Data pending: DAF_ REF_ 0=not #PCDATA. */
-int rc; /* Return code from context or other test. */
-struct etd *nextetd; /* The etd for a forced start-tag (if rc==2). */
-int mexts; /* >0=stack level of minus grp; -1=plus; 0=none.*/
-{
- fprintf(stderr,
- "STARTTAG newetd=%p; dataret=%d; rc=%d; nextetd=%p; mexts=%d.\n",
- (UNIV)curetd, dataret, rc, (UNIV)nextetd, mexts);
-}
-/* TRACEETG: Trace end-tag matching test on stack.
- */
-VOID traceetg(pts, curetd, tsl, etagimct)
-struct tag *pts; /* Stack entry for this tag. */
-struct etd *curetd; /* The etd for this tag. */
-int tsl; /* Temporary stack level for looping. */
-int etagimct; /* Num of implicitly ended tags left on stack. */
-{
- fprintf(stderr,
- "ENDTAG tsl=%d; newetd=%p; stacketd=%p; tflags=%02x; etagimct=%d.\n",
- tsl, (UNIV)curetd, (UNIV)pts->tetd, pts->tflags, etagimct);
-}
-/* TRACEECB: Trace entity control block activity.
- */
-VOID traceecb(action, p)
-char *action;
-struct entity *p;
-{
- static char estype1[] = " TMMMSEIXCNFPDLK";
- static char estype2[] = " DS ";
- if (!p)
- return;
- fprintf(stderr,
- "%-8s (es=%d) type %c%c entity %s at %p containing ",
- action, es, estype1[p->estore], estype2[p->estore], p->ename+1,
- (UNIV)p);
- if (p->estore==ESN && strcmp(action, "ENTDEF"))
- traceesn(p->etx.n);
- else if (p->etx.x==0)
- fprintf(stderr, "[NOTHING]");
- else
- fprintf(stderr, "%s",
- p->etx.c[0] ? (char *)p->etx.c : "[EMPTY]");
- putc('\n', stderr);
-}
-/* TRACEDCN: Trace data content notation activity.
- */
-VOID tracedcn(p)
-struct dcncb *p;
-{
- fprintf(stderr,
- "DCN dcn=%p; adl=%p; notation is %s\n",
- (UNIV)p, (UNIV)p->adl, p->ename+1);
- if (p->adl)
- traceadl(p->adl);
-}
-/* TRACEESN: Print a data entity control block.
- */
-VOID traceesn(p)
-PNE p;
-{
- fprintf(stderr, "ESN Entity name is %s; entity type is %s.\n",
- (NEENAME(p)!=0) ? ((char *)NEENAME(p))+1 : "[UNDEFINED]",
- /* NEXTYPE(p)); */
- (NEXTYPE(p)==1 ? "CDATA" : (NEXTYPE(p)==2 ? "NDATA" : "SDATA")));
- fprintf(stderr, " System ID is %s\n",
- (NEID(p)!=0) ? (char *)NEID(p) : "[UNDEFINED]");
- if (p->nedcn!=0)
- tracedcn(p->nedcn);
-}
-/* TRACESRM: Print the members of a short reference map.
- */
-VOID tracesrm(action, pg, gi)
-char *action;
-TECB pg;
-UNCH *gi;
-{
- int i = 0; /* Loop counter. */
-
- if (pg==SRMNULL)
- fprintf(stderr, "%-8s SHORTREF table empty for %s.\n", action, gi);
- else {
- fprintf(stderr, "%-8s %s at %p mapped for %s.\n",
- action, pg[0]->ename+1, (UNIV)pg,
- gi ? (char *)gi : "definition");
- while (++i<=lex.s.dtb[0].mapdata)
- if (pg[i])
- fprintf(stderr, "%14s%02u %p %s\n",
- "SR", i, (UNIV)pg[i], pg[i]->ename+1);
- }
-}
-/* TRACEADL: Print an attribute definition list.
- */
-VOID traceadl(al)
-struct ad al[];
-{
- int i=0;
-
- fprintf(stderr, "ADLIST %p %d membe%s; %d attribut%s\n",
- (UNIV)al, ADN(al), ADN(al)==1 ? "r" : "rs", AN(al),
- AN(al)==1 ? "e" : "es");
- while (++i<=ADN(al)) {
- fprintf(stderr,
- (BITOFF(ADFLAGS(al,i), AGROUP) && ADTYPE(al,i)<=ANOTEGRP)
- ? " %p %-8s %02x %02x %2d %2d %p %p\n"
- : " %p %-8s %02x %02x %2d %2d %p %p\n",
- &al[i], ADNAME(al,i), ADFLAGS(al,i), ADTYPE(al,i), ADNUM(al,i),
- ADLEN(al,i), ADVAL(al,i), ADDATA(al,i).x);
- if (ADVAL(al,i)) {
- fprintf(stderr, "%s", ADVAL(al,i));
- if (ADTYPE(al,i)==AENTITY && ADDATA(al,i).n!=0) {
- fprintf(stderr, "=>");
- traceesn(ADDATA(al,i).n);
- }
- else if (ADTYPE(al,i)==ANOTEGRP) {
- fprintf(stderr, "=>");
- tracedcn(ADDATA(al,i).x);
- }
- }
- else
- fprintf(stderr, "[%s]",
- GET(ADFLAGS(al,i), AREQ)
- ? "REQUIRED"
- : (GET(ADFLAGS(al,i), ACURRENT) ? "CURRENT" : "NULL"));
- }
- fprintf(stderr, "\n");
-}
-/* TRACEMOD: Print the members of a model.
- */
-VOID tracemod(pg)
-struct thdr pg[];
-{
- fprintf(stderr, "MODEL %p %02x %d\n",
- (UNIV)&pg[0], pg[0].ttype, pg[0].tu.tnum);
- if ((pg[0].ttype & MKEYWORD) == 0) {
- int i;
-
- for (i = 1; i < pg[0].tu.tnum + 2; i++) {
- if (GET(pg[i].ttype, TTMASK) == TTETD)
- fprintf(stderr, " %p %02x %s\n",
- (UNIV)&pg[i], pg[i].ttype, pg[i].tu.thetd->etdgi+1);
- else if (GET(pg[i].ttype, TTMASK) == TTCHARS)
- fprintf(stderr, " %p %02x %s\n",
- (UNIV)&pg[i], pg[i].ttype, "#PCDATA");
- else
- fprintf(stderr, " %p %02x %d\n",
- (UNIV)&pg[i], pg[i].ttype, pg[i].tu.tnum);
- }
- }
- fprintf(stderr, "\n");
-}
-/* TRACEGRP: Print the members of a name (i.e., etd) group.
- */
-VOID tracegrp(pg)
-struct etd *pg[];
-{
- int i = -1; /* Loop counter. */
-
- fprintf(stderr, "ETDGRP %p\n", (UNIV)pg);
- while (pg[++i]!=0)
- fprintf(stderr, " %p %s\n", (UNIV)pg[i], pg[i]->etdgi+1);
-}
-/* TRACENGR: Print the members of a notation (i.e., dcncb) group.
- */
-VOID tracengr(pg)
-struct dcncb *pg[];
-{
- int i = -1; /* Loop counter. */
-
- fprintf(stderr, "DCNGRP %p\n", (UNIV)pg);
- while (pg[++i]!=0)
- fprintf(stderr, " %p %s\n", (UNIV)pg[i], pg[i]->ename+1);
-}
-/* TRACEETD: Print an element type definition.
- */
-VOID traceetd(p)
-struct etd *p; /* Pointer to an etd. */
-{
- fprintf(stderr,
-"ETD etd=%p %s min=%02x cmod=%p ttype=%02x mex=%p, pex=%p, ",
- (UNIV)p, p->etdgi+1, p->etdmin, (UNIV)p->etdmod,
- p->etdmod->ttype, (UNIV)p->etdmex, (UNIV)p->etdpex);
- fprintf(stderr, "adl=%p, srm=%s.\n",
- (UNIV)p->adl,
- (p->etdsrm==SRMNULL)
- ? "#EMPTY"
- : (p->etdsrm) ? (char *)(p->etdsrm[0]->ename+1) : "#CURRENT");
-}
-/* TRACEID: Print an ID control block.
- */
-VOID traceid(action, p)
-char *action;
-struct id *p; /* Pointer to an ID. */
-{
- fprintf(stderr, "%-8s %s at %p is %s; ", action, p->idname+1, (UNIV)p,
- p->iddefed ? "defined" : "undefined");
- fprintf(stderr, "last ref=%p\n", (UNIV)p->idrl);
-}
-/* TRACEMD: Trace a markup declaration parameter.
- */
-VOID tracemd(parmid)
-char *parmid; /* Parameter identifier. */
-{
- fprintf(stderr, "MDPARM %-8s for %-8s, token %02d, type %02u, %s.\n",
- mdname, subdcl ? (char *)subdcl : "[NONE]", parmno, pcbmd.action, parmid);
-}
-/* TRACEMS: Trace marked section activity.
- */
-VOID tracems(action, code, mslevel, msplevel)
-int action; /* 1=began new level; 0=resumed previous. */
-int code;
-int mslevel; /* Nesting level of marked sections. */
-int msplevel; /* Nested MS levels subject to special parse. */
-{
- fprintf(stderr,
- "MS%c %2d %s nesting level %d (msp %d).\n",
- (action ? ' ' : 'E'), code, (action ? "began" : "resumed"),
- mslevel, msplevel);
-}
-
-static
-VOID tracehits(h)
-unsigned long *h;
-{
- int i;
- fprintf(stderr, " H=");
- for (i = grplongs - 1; i >= 0; --i)
- fprintf(stderr, "%0*lx", LONGBITS/4, h[i]);
-}
-
-/* TRACEGI: Trace GI testing stages in CONTEXT.C processing.
- */
-VOID tracegi(stagenm, gi, mod, pos)
-char *stagenm;
-struct etd *gi; /* ETD of new GI. */
-struct thdr mod[]; /* Model of current open element. */
-struct mpos pos[]; /* Position in open element's model. */
-{
- int i = 0; /* Loop counter. */
-
- fprintf(stderr, "%-10s %d:", stagenm, P);
- while (++i<=P)
- fprintf(stderr, " %d-%d", pos[i].g, pos[i].t);
- fprintf(stderr, " (%u) gocc=%02x gtype=%02x gnum=%d",
- M, GOCC, GTYPE, GNUM);
- tracehits(H);
- fprintf(stderr, " status=%d Tstart=%d\n", STATUX, Tstart);
- fprintf(stderr,
- "=>%-8s tocc=%02x ttype=%02x thetd=%p (%s) gietd=%p (%s)\n",
- tags[ts].tetd->etdgi+1, TOCC, TTYPE, (UNIV)TOKEN.tu.thetd,
- (TTYPE
- ? (TTYPE==TTETD ? (char *)(TOKEN.tu.thetd->etdgi+1) : "#GROUP")
- : "#PCDATA"),
- (UNIV)gi,
- (gi==ETDCDATA ? "#PCDATA" : (char *)(gi->etdgi+1)));
-}
-/* TRACEEND: Trace testing for end of group in CONTEXT.C processing.
- */
-VOID traceend(stagenm, mod, pos, rc, opt)
-char *stagenm;
-struct thdr mod[]; /* Model of current open element. */
-struct mpos pos[]; /* Position in open element's model. */
-int rc; /* Return code: RCNREQ RCHIT RCMISS RCEND */
-int opt; /* ALLHIT parm: 1=test optionals; 0=ignore. */
-{
- int i = 0; /* Loop counter. */
-
- fprintf(stderr, "%-10s %d:", stagenm, P);
- while (++i<=P)
- fprintf(stderr, " %d-%d", pos[i].g, pos[i].t);
- fprintf(stderr, " (%u) gocc=%02x gtype=%02x gnum=%d",
- M, GOCC, GTYPE, GNUM);
- tracehits(H);
- fprintf(stderr, " status=%d Tstart=%d\n", STATUX, Tstart);
- fprintf(stderr, "=>%-8s tocc=%02x ttype=%02x thetd=%p (%s)",
- tags[ts].tetd->etdgi+1, TOCC, TTYPE, (UNIV)TOKEN.tu.thetd,
- (TTYPE
- ? (TTYPE==TTETD ? (char *)(TOKEN.tu.thetd->etdgi+1) : "#GROUP")
- : "#PCDATA"));
- fprintf(stderr, " rc=%d offbitT=%d allhit=%d\n",
- rc, offbit(H, (int)T, GNUM), allhit(&GHDR, H, 0, opt));
-}
-
-#endif /* TRACE */
-/*
-Local Variables:
-c-indent-level: 5
-c-continued-statement-offset: 5
-c-brace-offset: -5
-c-argdecl-indent: 0
-c-label-offset: -5
-End:
-*/
diff --git a/usr.bin/sgmls/sgmls/unix.cfg b/usr.bin/sgmls/sgmls/unix.cfg
deleted file mode 100644
index 0bc8410..0000000
--- a/usr.bin/sgmls/sgmls/unix.cfg
+++ /dev/null
@@ -1,147 +0,0 @@
-/* unix.cfg: Configuration file for sgmls on Unix. */
-
-/* A list of filename templates to use for searching for external entities.
-The filenames are separated by the character specified in PATH_FILE_SEP.
-See sgmls.man for details. */
-#define DEFAULT_PATH "/usr/local/lib/sgml/%O/%C/%T:%N.%X:%N.%D"
-/* The character that separates the filenames templates. */
-#define PATH_FILE_SEP ':'
-/* The character that separates filenames in a system identifier.
-Usually the same as PATH_FILE_SEP. */
-#define SYSID_FILE_SEP ':'
-/* The environment variable that contains the list of filename templates. */
-#define PATH_ENV_VAR "SGML_PATH"
-
-/* MIN_DAT_SUBS_FROM and MIN_DATS_SUBS_TO tell sgmls how to transform a name
-or system identifier into a legal filename. A character in
-MIN_DAT_SUBS_FROM will be transformed into the character in the
-corresponding position in MIN_DAT_SUBS_TO. If there is no such
-position, then the character is removed. */
-/* This says that spaces should be transformed to underscores, and
-slashes to percents. */
-#define MIN_DAT_SUBS_FROM " /"
-#define MIN_DAT_SUBS_TO "_%"
-
-/* Define this to allow tracing. */
-/* #define TRACE 1 */
-
-/* Define this you want support for subdocuments. This is implemented
-using features that are not part of Standard C, so you might not want
-to define it if you are porting to a new system. Otherwise I suggest
-you leave it defined. */
-#define SUPPORT_SUBDOC 1
-
-/* Define HAVE_EXTENDED_PRINTF if your *printf functions supports
-X/Open extensions; if they do, then, for example,
-
- printf("%2$s%1$s", "bar", "foo")
-
-should print `foobar'. */
-
-/* #define HAVE_EXTENDED_PRINTF 1 */
-
-/* Define HAVE_CAT if your system provides the X/Open message
-catalogue functions catopen() and catgets(), and you want to use them.
-An implementations of these functions is included and will be used if
-you don't define this. On SunOS 4.1.1, if you do define this you
-should set CC=/usr/xpg2bin/cc in the makefile. */
-
-/* #define HAVE_CAT 1 */
-
-#ifdef __STDC__
-/* Define this if your compiler supports prototypes. */
-#define USE_PROTOTYPES 1
-#endif
-
-/* Can't use <stdarg.h> without prototypes. */
-#ifndef USE_PROTOTYPES
-#define VARARGS 1
-#endif
-
-/* If your compiler defines __STDC__ but doesn't provide <stdarg.h>,
-you must define VARARGS yourself here. */
-/* #define VARARGS 1 */
-
-/* Define this if you do not have strerror(). */
-#define STRERROR_MISSING 1
-
-/* Define this unless the character testing functions in ctype.h
-are defined for all values representable as an unsigned char. You do
-not need to define this if your system is ANSI C conformant. You
-should define for old Unix systems. */
-/* #define USE_ISASCII 1 */
-
-/* Define this if your system provides the BSD style string operations
-rather than ANSI C ones (eg bcopy() rather than memcpy(), and index()
-rather than strchr()). */
-/* #define BSD_STRINGS 1 */
-
-/* Define this if you have getopt(). */
-#define HAVE_GETOPT 1
-
-/* Define this if you have access(). */
-#define HAVE_ACCESS 1
-
-/* Define this if you have <unistd.h>. */
-#define HAVE_UNISTD_H 1
-
-/* Define this if you have <sys/stat.h>. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define this if you have waitpid(). */
-#define HAVE_WAITPID 1
-
-/* Define this if your system is POSIX.1 (ISO 9945-1:1990) compliant. */
-#define POSIX 1
-
-/* Define this if you have the vfork() system call. */
-#define HAVE_VFORK 1
-
-/* Define this if you have <vfork.h>. */
-#define HAVE_VFORK_H 1
-
-/* Define this if you don't have <stdlib.h> */
-/* #define STDLIB_H_MISSING 1 */
-
-/* Define this if you don't have <stddef.h> */
-/* #define STDDEF_H_MISSING 1 */
-
-/* Define this if you don't have <limits.h> */
-/* #define LIMITS_H_MISSING 1 */
-
-/* Define this if you don't have remove(); unlink() will be used instead. */
-#define REMOVE_MISSING 1
-
-/* Define this if you don't have raise(); kill() will be used instead. */
-#define RAISE_MISSING 1
-
-/* Define this if you don't have fsetpos() and fgetpos(). */
-#define FPOS_MISSING 1
-
-/* Universal pointer type. */
-/* If your compiler doesn't fully support void *, change `void' to `char'. */
-typedef void *UNIV;
-
-/* If your compiler doesn't support void as a function return type,
-change `void' to `int'. */
-typedef void VOID;
-
-/* If you don't have an ANSI C conformant <limits.h>, define
-CHAR_SIGNED as 1 or 0 according to whether the `char' type is signed.
-The <limits.h> on some versions of System Release V 3.2 is not ANSI C
-conformant: the value of CHAR_MIN is 0 even though the `char' type is
-signed. */
-
-/* #define CHAR_SIGNED 1 */
-/* #define CHAR_SIGNED 0 */
-#ifndef CHAR_SIGNED
-#include <limits.h>
-#if CHAR_MIN < 0
-#define CHAR_SIGNED 1
-#else
-#define CHAR_SIGNED 0
-#endif
-#endif /* not CHAR_SIGNED */
-
-/* Assume the system character set is ISO Latin-1. */
-#include "latin1.h"
diff --git a/usr.bin/sgmls/sgmls/unixproc.c b/usr.bin/sgmls/sgmls/unixproc.c
deleted file mode 100644
index 9e79d62..0000000
--- a/usr.bin/sgmls/sgmls/unixproc.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/* unixproc.c -
-
- Unix implementation of run_process().
-
- Written by James Clark (jjc@jclark.com).
-*/
-
-#include "config.h"
-
-#ifdef SUPPORT_SUBDOC
-
-#ifdef POSIX
-
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-
-#endif /* POSIX */
-
-#include "std.h"
-#include "entity.h"
-#include "appl.h"
-
-#ifndef POSIX
-
-#define WIFSTOPPED(s) (((s) & 0377) == 0177)
-#define WIFSIGNALED(s) (((s) & 0377) != 0 && ((s) & 0377 != 0177))
-#define WIFEXITED(s) (((s) & 0377) == 0)
-#define WEXITSTATUS(s) (((s) >> 8) & 0377)
-#define WTERMSIG(s) ((s) & 0177)
-#define WSTOPSIG(s) (((s) >> 8) & 0377)
-#define _SC_OPEN_MAX 0
-#define sysconf(name) (20)
-typedef int pid_t;
-
-#endif /* not POSIX */
-
-#ifndef HAVE_VFORK
-#define vfork() fork()
-#endif /* not HAVE_VFORK */
-
-#ifdef HAVE_VFORK_H
-#include <vfork.h>
-#endif /* HAVE_VFORK_H */
-
-int run_process(argv)
-char **argv;
-{
- pid_t pid;
- int status;
- int ret;
-
- /* Can't trust Unix implementations to support fflush(NULL). */
- fflush(stderr);
- fflush(stdout);
-
- pid = vfork();
- if (pid == 0) {
- /* child */
- int i;
- int open_max = (int)sysconf(_SC_OPEN_MAX);
-
- for (i = 3; i < open_max; i++)
- (void)close(i);
- execvp(argv[0], argv);
- appl_error(E_EXEC, argv[0], strerror(errno));
- fflush(stderr);
- _exit(127);
- }
- if (pid < 0) {
- appl_error(E_FORK, strerror(errno));
- return -1;
- }
- /* parent */
- while ((ret = wait(&status)) != pid)
- if (ret < 0) {
- appl_error(E_WAIT, strerror(errno));
- return -1;
- }
- if (WIFSIGNALED(status)) {
- appl_error(E_SIGNAL, argv[0], WTERMSIG(status));
- return -1;
- }
- /* Must have exited normally. */
- return WEXITSTATUS(status);
-}
-
-#endif /* SUPPORT_SUBDOC */
-
-/*
-Local Variables:
-c-indent-level: 5
-c-continued-statement-offset: 5
-c-brace-offset: -5
-c-argdecl-indent: 0
-c-label-offset: -5
-End:
-*/
diff --git a/usr.bin/sgmls/sgmls/version.c b/usr.bin/sgmls/sgmls/version.c
deleted file mode 100644
index f3b2d7c..0000000
--- a/usr.bin/sgmls/sgmls/version.c
+++ /dev/null
@@ -1 +0,0 @@
-char *version_string = "1.1.91";
diff --git a/usr.bin/sgmls/sgmls/xfprintf.c b/usr.bin/sgmls/sgmls/xfprintf.c
deleted file mode 100644
index 1c50469..0000000
--- a/usr.bin/sgmls/sgmls/xfprintf.c
+++ /dev/null
@@ -1,564 +0,0 @@
-/* xfprintf.c -
- X/Open extended v?fprintf implemented in terms of v?fprintf.
-
- Written by James Clark (jjc@jclark.com).
-*/
-
-/* Compile with:
-
- -DVARARGS to use varargs.h instead of stdarg.h
- -DLONG_DOUBLE_MISSING if your compiler doesn't like `long double'
- -DFP_SUPPORT to include floating point stuff
-*/
-
-#include "config.h"
-
-#ifndef HAVE_EXTENDED_PRINTF
-
-#include "std.h"
-
-#ifdef lint
-/* avoid stupid lint warnings */
-#undef va_arg
-#define va_arg(ap, type) (ap, (type)0)
-#endif
-
-#ifdef FP_SUPPORT
-#ifdef LONG_DOUBLE_MISSING
-typedef double long_double;
-#else
-typedef long double long_double;
-#endif
-#endif /* FP_SUPPORT */
-
-#ifdef USE_PROTOTYPES
-#define P(parms) parms
-#else
-#define P(parms) ()
-#endif
-
-#ifdef VARARGS
-typedef int (*printer)();
-#else
-typedef int (*printer)(UNIV, const char *, ...);
-#endif
-
-enum arg_type {
- NONE,
- INT,
- UNSIGNED,
- LONG,
- UNSIGNED_LONG,
-#ifdef FP_SUPPORT
- DOUBLE,
- LONG_DOUBLE,
-#endif /* FP_SUPPORT */
- PCHAR,
- PINT,
- PLONG,
- PSHORT
-};
-
-union arg {
- int i;
- unsigned u;
- long l;
- unsigned long ul;
-#ifdef FP_SUPPORT
- double d;
- long_double ld;
-#endif /* FP_SUPPORT */
- char *pc;
- UNIV pv;
- int *pi;
- short *ps;
- long *pl;
-};
-
-#define NEXT 0
-#define MISSING 10
-
-struct spec {
- enum arg_type type;
- char pos;
- char field_width;
- char precision;
-};
-
-#define FLAG_CHARS "-+ #0"
-
-static int parse_spec P((const char **, struct spec *));
-static int find_arg_types P((const char *, enum arg_type *));
-static void get_arg P((enum arg_type, va_list *, union arg *));
-static int do_arg P((UNIV, printer, const char *, enum arg_type, union arg *));
-static int xdoprt P((UNIV, printer, const char *, va_list));
-static int printit P((UNIV, printer, const char *, va_list, int, union arg *));
-static int maybe_positional P((const char *));
-
-/* Return 1 if sucessful, 0 otherwise. **pp points to character after % */
-
-static int parse_spec(pp, sp)
-const char **pp;
-struct spec *sp;
-{
- char modifier = 0;
- sp->pos = NEXT;
- if (isdigit((unsigned char)(**pp)) && (*pp)[1] == '$') {
- if (**pp == '0')
- return 0;
- sp->pos = **pp - '0';
- *pp += 2;
- }
-
- while (**pp != '\0' && strchr(FLAG_CHARS, **pp))
- *pp += 1;
-
- /* handle the field width */
-
- sp->field_width = MISSING;
- if (**pp == '*') {
- *pp += 1;
- if (isdigit((unsigned char)**pp) && (*pp)[1] == '$') {
- if (**pp == '0')
- return 0;
- sp->field_width = **pp - '0';
- *pp += 2;
- }
- else
- sp->field_width = NEXT;
- }
- else {
- while (isdigit((unsigned char)**pp))
- *pp += 1;
- }
-
- /* handle the precision */
- sp->precision = MISSING;
- if (**pp == '.') {
- *pp += 1;
- if (**pp == '*') {
- *pp += 1;
- if (isdigit((unsigned char)**pp) && (*pp)[1] == '$') {
- if (**pp == '0')
- return 0;
- sp->precision = **pp - '0';
- *pp += 2;
- }
- else
- sp->precision = NEXT;
- }
- else {
- while (isdigit((unsigned char)**pp))
- *pp += 1;
- }
- }
- /* handle h l or L */
-
- if (**pp == 'h' || **pp == 'l' || **pp == 'L') {
- modifier = **pp;
- *pp += 1;
- }
-
- switch (**pp) {
- case 'd':
- case 'i':
- sp->type = modifier == 'l' ? LONG : INT;
- break;
- case 'o':
- case 'u':
- case 'x':
- case 'X':
- sp->type = modifier == 'l' ? UNSIGNED_LONG : UNSIGNED;
- break;
-#ifdef FP_SUPPORT
- case 'e':
- case 'E':
- case 'f':
- case 'g':
- case 'G':
- sp->type = modifier == 'L' ? LONG_DOUBLE : DOUBLE;
- break;
-#endif /* FP_SUPPORT */
- case 'c':
- sp->type = INT;
- break;
- case 's':
- sp->type = PCHAR;
- break;
- case 'p':
- /* a pointer to void has the same representation as a pointer to char */
- sp->type = PCHAR;
- break;
- case 'n':
- if (modifier == 'h')
- sp->type = PSHORT;
- else if (modifier == 'l')
- sp->type = PLONG;
- else
- sp->type = PINT;
- break;
- case '%':
- sp->type = NONE;
- break;
- default:
- return 0;
- }
- *pp += 1;
- return 1;
-}
-
-
-static int find_arg_types(format, arg_type)
- const char *format;
- enum arg_type *arg_type;
-{
- int i, pos;
- const char *p;
- struct spec spec;
-
- for (i = 0; i < 9; i++)
- arg_type[i] = NONE;
-
- pos = 0;
-
- p = format;
- while (*p)
- if (*p == '%') {
- p++;
- if (!parse_spec(&p, &spec))
- return 0;
- if (spec.type != NONE) {
- int n;
- if (spec.pos == NEXT)
- n = pos++;
- else
- n = spec.pos - 1;
- if (n < 9) {
- enum arg_type t = arg_type[n];
- if (t != NONE && t != spec.type)
- return 0;
- arg_type[n] = spec.type;
- }
- }
- if (spec.field_width != MISSING) {
- int n;
- if (spec.field_width == NEXT)
- n = pos++;
- else
- n = spec.field_width - 1;
- if (n < 9) {
- enum arg_type t = arg_type[n];
- if (t != NONE && t != INT)
- return 0;
- arg_type[n] = INT;
- }
- }
- if (spec.precision != MISSING) {
- int n;
- if (spec.precision == NEXT)
- n = pos++;
- else
- n = spec.precision - 1;
- if (n < 9) {
- enum arg_type t = arg_type[n];
- if (t != NONE && t != INT)
- return 0;
- arg_type[n] = INT;
- }
- }
- }
- else
- p++;
- return 1;
-}
-
-static void get_arg(arg_type, app, argp)
- enum arg_type arg_type;
- va_list *app;
- union arg *argp;
-{
- switch (arg_type) {
- case NONE:
- break;
- case INT:
- argp->i = va_arg(*app, int);
- break;
- case UNSIGNED:
- argp->u = va_arg(*app, unsigned);
- break;
- case LONG:
- argp->l = va_arg(*app, long);
- break;
- case UNSIGNED_LONG:
- argp->ul = va_arg(*app, unsigned long);
- break;
-#ifdef FP_SUPPORT
- case DOUBLE:
- argp->d = va_arg(*app, double);
- break;
- case LONG_DOUBLE:
- argp->ld = va_arg(*app, long_double);
- break;
-#endif /* FP_SUPPORT */
- case PCHAR:
- argp->pc = va_arg(*app, char *);
- break;
- case PINT:
- argp->pi = va_arg(*app, int *);
- break;
- case PSHORT:
- argp->ps = va_arg(*app, short *);
- break;
- case PLONG:
- argp->pl = va_arg(*app, long *);
- break;
- default:
- abort();
- }
-}
-
-static int do_arg(handle, func, buf, arg_type, argp)
- UNIV handle;
- printer func;
- const char *buf;
- enum arg_type arg_type;
- union arg *argp;
-{
- switch (arg_type) {
- case NONE:
- return (*func)(handle, buf);
- case INT:
- return (*func)(handle, buf, argp->i);
- case UNSIGNED:
- return (*func)(handle, buf, argp->u);
- case LONG:
- return (*func)(handle, buf, argp->l);
- case UNSIGNED_LONG:
- return (*func)(handle, buf, argp->ul);
-#ifdef FP_SUPPORT
- case DOUBLE:
- return (*func)(handle, buf, argp->d);
- case LONG_DOUBLE:
- return (*func)(handle, buf, argp->ld);
-#endif /* FP_SUPPORT */
- case PCHAR:
- return (*func)(handle, buf, argp->pc);
- case PINT:
- return (*func)(handle, buf, argp->pi);
- case PSHORT:
- return (*func)(handle, buf, argp->ps);
- case PLONG:
- return (*func)(handle, buf, argp->pl);
- default:
- abort();
- }
- /* NOTREACHED */
-}
-
-static int printit(handle, func, p, ap, nargs, arg)
- UNIV handle;
- printer func;
- const char *p;
- va_list ap;
- int nargs;
- union arg *arg;
-{
- char buf[512]; /* enough for a spec */
- int count = 0;
- int pos = 0;
-
- while (*p)
- if (*p == '%') {
- char *q;
- struct spec spec;
- const char *start;
- int had_field_width;
- union arg *argp;
- union arg a;
- int res;
-
- start = ++p;
- if (!parse_spec(&p, &spec))
- abort(); /* should have caught it in find_arg_types */
-
- buf[0] = '%';
- q = buf + 1;
-
- if (spec.pos != NEXT)
- start += 2;
-
- /* substitute in precision and field width if necessary */
- had_field_width = 0;
- while (start < p) {
- if (*start == '*') {
- char c;
- int n, val;
-
- start++;
- if (!had_field_width && spec.field_width != MISSING) {
- c = spec.field_width;
- had_field_width = 1;
- }
- else
- c = spec.precision;
- if (c == NEXT)
- n = pos++;
- else {
- start += 2;
- n = c - 1;
- }
- if (n >= nargs)
- val = va_arg(ap, int);
- else
- val = arg[n].i;
-
- /* ignore negative precision */
- if (val >= 0 || q[-1] != '.') {
- (void)sprintf(q, "%d", val);
- q = strchr(q, '\0');
- }
- }
- else
- *q++ = *start++;
- }
- *q++ = '\0';
-
- argp = 0;
- if (spec.type != NONE) {
- int n = spec.pos == NEXT ? pos++ : spec.pos - 1;
- if (n >= nargs) {
- get_arg(spec.type, &ap, &a);
- argp = &a;
- }
- else
- argp = arg + n;
- }
-
- res = do_arg(handle, func, buf, spec.type, argp);
- if (res < 0)
- return -1;
- count += res;
- }
- else {
- if ((*func)(handle, "%c", *p++) < 0)
- return -1;
- count++;
- }
- return count;
-}
-
-/* Do a quick check to see if it may contains any positional thingies. */
-
-static int maybe_positional(format)
- const char *format;
-{
- const char *p;
-
- p = format;
- for (;;) {
- p = strchr(p, '$');
- if (!p)
- return 0;
- if (p - format >= 2
- && isdigit((unsigned char)p[-1])
- && (p[-2] == '%' || p[-2] == '*'))
- break; /* might be a positional thingy */
- }
- return 1;
-}
-
-static int xdoprt(handle, func, format, ap)
- UNIV handle;
- printer func;
- const char *format;
- va_list ap;
-{
- enum arg_type arg_type[9];
- union arg arg[9];
- int nargs, i;
-
- if (!find_arg_types(format, arg_type))
- return -1;
-
- for (nargs = 0; nargs < 9; nargs++)
- if (arg_type[nargs] == NONE)
- break;
-
- for (i = nargs; i < 9; i++)
- if (arg_type[i] != NONE)
- return -1;
-
- for (i = 0; i < nargs; i++)
- get_arg(arg_type[i], &ap, arg + i);
-
- return printit(handle, func, format, ap, nargs, arg);
-}
-
-#ifdef VARARGS
-static int do_fprintf(va_alist) va_dcl
-#else
-static int do_fprintf(UNIV p, const char *format,...)
-#endif
-{
-#ifdef VARARGS
- UNIV p;
- const char *format;
-#endif
- va_list ap;
- int res;
-
-#ifdef VARARGS
- va_start(ap);
- p = va_arg(ap, UNIV);
- format = va_arg(ap, char *);
-#else
- va_start(ap, format);
-#endif
-
- res = vfprintf((FILE *)p, format, ap);
- va_end(ap);
- return res;
-}
-
-#ifdef VARARGS
-int xfprintf(va_alist) va_dcl
-#else
-int xfprintf(FILE *fp, const char *format, ...)
-#endif
-{
-#ifdef VARARGS
- FILE *fp;
- char *format;
-#endif
- va_list ap;
- int res;
-
-#ifdef VARARGS
- va_start(ap);
- fp = va_arg(ap, FILE *);
- format = va_arg(ap, char *);
-#else
- va_start(ap, format);
-#endif
- if (maybe_positional(format))
- res = xdoprt((UNIV)fp, do_fprintf, format, ap);
- else
- res = vfprintf(fp, format, ap);
- va_end(ap);
- return res;
-}
-
-int xvfprintf(fp, format, ap)
- FILE *fp;
- const char *format;
- va_list ap;
-{
- int res;
- if (maybe_positional(format))
- res = xdoprt((UNIV)fp, do_fprintf, format, ap);
- else
- res = vfprintf(fp, format, ap);
- return res;
-}
-
-#endif /* not HAVE_EXTENDED_PRINTF */
diff --git a/usr.bin/sgmls/unix.cfg b/usr.bin/sgmls/unix.cfg
deleted file mode 100644
index 4245511..0000000
--- a/usr.bin/sgmls/unix.cfg
+++ /dev/null
@@ -1,165 +0,0 @@
-/* unix.cfg: Configuration file for sgmls on Unix. */
-
-/* A list of filename templates to use for searching for external entities.
-The filenames are separated by the character specified in PATH_FILE_SEP.
-See sgmls.man for details. */
-#define DEFAULT_PATH "/usr/local/lib/sgml/%O/%C/%T:%N.%X:%N.%D"
-/* The character that separates the filenames templates. */
-#define PATH_FILE_SEP ':'
-/* The character that separates filenames in a system identifier.
-Usually the same as PATH_FILE_SEP. */
-#define SYSID_FILE_SEP ':'
-/* The environment variable that contains the list of filename templates. */
-#define PATH_ENV_VAR "SGML_PATH"
-/* A macro that returns non-zero if the filename is relative to the
- current directory. */
-#define FILE_IS_RELATIVE(p) ((p)[0] != '/')
-/* A string containing the characters that can separate the directory
- part of a filename from the basename. */
-#define DIR_BASE_SEP "/"
-/* The environment variable that contains the list of catalog entry files.
- Filenames are separated by PATH_FILE_SEP. */
-#define CATALOG_FILES_ENV_VAR "SGML_CATALOG_FILES"
-/* Default list of catalog entry files. */
-#define DEFAULT_CATALOG_FILES "CATALOG:/usr/local/lib/sgml/CATALOG"
-
-/* MIN_DAT_SUBS_FROM and MIN_DATS_SUBS_TO tell sgmls how to transform a name
-or system identifier into a legal filename. A character in
-MIN_DAT_SUBS_FROM will be transformed into the character in the
-corresponding position in MIN_DAT_SUBS_TO. If there is no such
-position, then the character is removed. */
-/* This says that spaces should be transformed to underscores, and
-slashes to percents. */
-#define MIN_DAT_SUBS_FROM " /"
-#define MIN_DAT_SUBS_TO "_%"
-
-/* Define this to allow tracing. */
-/* #define TRACE 1 */
-
-/* Define this you want support for subdocuments. This is implemented
-using features that are not part of Standard C, so you might not want
-to define it if you are porting to a new system. Otherwise I suggest
-you leave it defined. */
-#define SUPPORT_SUBDOC 1
-
-/* Define HAVE_EXTENDED_PRINTF if your *printf functions supports
-X/Open extensions; if they do, then, for example,
-
- printf("%2$s%1$s", "bar", "foo")
-
-should print `foobar'. */
-
-/* #define HAVE_EXTENDED_PRINTF 1 */
-
-/* Define HAVE_CAT if your system provides the X/Open message
-catalogue functions catopen() and catgets(), and you want to use them.
-An implementations of these functions is included and will be used if
-you don't define this. On SunOS 4.1.1, if you do define this you
-should set CC=/usr/xpg2bin/cc in the makefile. */
-
-/* #define HAVE_CAT 1 */
-
-#ifdef __STDC__
-/* Define this if your compiler supports prototypes. */
-#define USE_PROTOTYPES 1
-#endif
-
-/* Can't use <stdarg.h> without prototypes. */
-#ifndef USE_PROTOTYPES
-#define VARARGS 1
-#endif
-
-/* If your compiler defines __STDC__ but doesn't provide <stdarg.h>,
-you must define VARARGS yourself here. */
-/* #define VARARGS 1 */
-
-/* Define this if you do not have strerror(). */
-#define STRERROR_MISSING 1
-
-/* Define this unless the character testing functions in ctype.h
-are defined for all values representable as an unsigned char. You do
-not need to define this if your system is ANSI C conformant. You
-should define for old Unix systems. */
-/* #define USE_ISASCII 1 */
-
-/* Define this if your system provides the BSD style string operations
-rather than ANSI C ones (eg bcopy() rather than memcpy(), and index()
-rather than strchr()). */
-/* #define BSD_STRINGS 1 */
-
-/* Define this if you have getopt(). */
-#define HAVE_GETOPT 1
-
-/* Define this if you have access(). */
-#define HAVE_ACCESS 1
-
-/* Define this if you have <unistd.h>. */
-#define HAVE_UNISTD_H 1
-
-/* Define this if you have <sys/stat.h>. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define this if you have waitpid(). */
-#define HAVE_WAITPID 1
-
-/* Define this if your system is POSIX.1 (ISO 9945-1:1990) compliant. */
-#define POSIX 1
-
-/* Define this if you have the vfork() system call. */
-#define HAVE_VFORK 1
-
-/* Define this if you have <vfork.h>. */
-#define HAVE_VFORK_H 1
-
-/* Define this if you don't have <stdlib.h> */
-/* #define STDLIB_H_MISSING 1 */
-
-/* Define this if you don't have <stddef.h> */
-/* #define STDDEF_H_MISSING 1 */
-
-/* Define this if you don't have <limits.h> */
-/* #define LIMITS_H_MISSING 1 */
-
-/* Define this if you don't have remove(); unlink() will be used instead. */
-#define REMOVE_MISSING 1
-
-/* Define this if you don't have raise(); kill() will be used instead. */
-#define RAISE_MISSING 1
-
-/* Define this if you don't have fsetpos() and fgetpos(). */
-#define FPOS_MISSING 1
-
-/* Universal pointer type. */
-/* If your compiler doesn't fully support void *, change `void' to `char'. */
-typedef void *UNIV;
-
-/* If your compiler doesn't support void as a function return type,
-change `void' to `int'. */
-typedef void VOID;
-
-/* If your compiler doesn't understand const, define it to be nothing. */
-#ifndef __STDC__
-#ifndef const
-#define const /* as nothing */
-#endif
-#endif
-
-/* If you don't have an ANSI C conformant <limits.h>, define
-CHAR_SIGNED as 1 or 0 according to whether the `char' type is signed.
-The <limits.h> on some versions of System Release V 3.2 is not ANSI C
-conformant: the value of CHAR_MIN is 0 even though the `char' type is
-signed. */
-
-/* #define CHAR_SIGNED 1 */
-/* #define CHAR_SIGNED 0 */
-#ifndef CHAR_SIGNED
-#include <limits.h>
-#if CHAR_MIN < 0
-#define CHAR_SIGNED 1
-#else
-#define CHAR_SIGNED 0
-#endif
-#endif /* not CHAR_SIGNED */
-
-/* Assume the system character set is ISO Latin-1. */
-#include "latin1.h"
OpenPOWER on IntegriCloud