Initial import of the CDE 2.1.30 sources from the Open Group.

This commit is contained in:
Peter Howkins
2012-03-10 18:21:40 +00:00
commit 83b6996daa
18978 changed files with 3945623 additions and 0 deletions

View File

@@ -0,0 +1,113 @@
XCOMM $XConsortium: Imakefile /main/10 1996/10/09 14:05:24 drk $
/* parser Imakefile */
HTAG2 = ..
HTAG2SRC = $(HTAG2)/htag2
SDLPARSERSRC = $(HTAG2)/parser
SDLELTDEFSRC = $(HTAG2)/eltdef
SDLDTDFILE = $(HTAG2SRC)/sdl.dtd
SDLUTILSRC = $(HTAG2)/util
SDLBUILDSRC = $(HTAG2)/build
SDLUTILLIB = $(HTAG2)/util/libutil.a
INCLUDES = -I. -I$(SDLUTILSRC) -I$(HTAG2SRC) -I$(SDLBUILDSRC) \
-I$(SDLELTDEFSRC)
SRCS = parser.c actutil.c \
closent.c code.c cyclent.c dcurelt.c \
end.c entity.c \
error.c getsign.c \
input.c level.c lookent.c \
minim.c optstrg.c param.c parent.c \
parutil.c pi.c \
scan.c setpar.c start.c string.c struct.c \
text.c
OBJS = parser.o actutil.o \
closent.o code.o cyclent.o dcurelt.o \
end.o entity.o \
error.o getsign.o \
input.o level.o lookent.o \
minim.o optstrg.o param.o parent.o \
parutil.o pi.o \
scan.o setpar.o start.o string.o struct.o \
text.o
XLATEOBJECTS = $(HTAG2SRC)/LocaleXlate.o $(HTAG2SRC)/XlationSvc.o
APPLOBJECTS = \
$(HTAG2SRC)/custom.o \
$(HTAG2SRC)/sdl.o \
$(HTAG2SRC)/option.o \
$(HTAG2SRC)/out.o \
$(XLATEOBJECTS)
ELT_H = \
$(SDLELTDEFSRC)/entity2.h \
$(SDLELTDEFSRC)/globdec.h \
$(SDLELTDEFSRC)/globdef.h \
$(SDLELTDEFSRC)/if.h \
$(SDLELTDEFSRC)/pval.h \
$(SDLELTDEFSRC)/signon.h \
$(SDLELTDEFSRC)/signonx.h
ELT_C = \
$(SDLELTDEFSRC)/efile.c \
$(SDLELTDEFSRC)/entfile.c \
$(SDLELTDEFSRC)/pfile.c \
$(SDLELTDEFSRC)/sfile.c \
$(SDLELTDEFSRC)/stfile.c \
$(SDLELTDEFSRC)/tfile.c
ELT_DEFS = $(ELT_H) $(ELT_C)
#ifdef SunArchitecture
.NO_PARALLEL:
#endif
LOCAL_LIBRARIES = $(SDLUTILLIB)
SYS_LIBRARIES = $(XLIB) DtClientSysLibs
#if defined (SunArchitecture)
SYS_LIBRARIES = $(XLIB) -lm -ldl -lgen -lC
#endif /* SunArchitecture */
all:: $(HTAG2SRC)/dthelp_htag2
other_dirs:
cd $(SDLELTDEFSRC); make
cd $(HTAG2SRC); make
NormalLibraryObjectRule()
NormalProgramTarget(parser,$(OBJS) $(APPLOBJECTS),delim.h $(LOCAL_LIBRARIES) other_dirs,$(LOCAL_LIBRARIES),)
CPRODS = case.c context.h delim.h
CTRASH = error delim.dat
$(HTAG2SRC)/dthelp_htag2: parser
$(RM) $(HTAG2SRC)/dthelp_htag2
$(CP) parser $(HTAG2SRC)/dthelp_htag2
$(CPRODS): $(SDLUTILSRC)/context $(HTAG2SRC)/delim.par context.dat
$(RM) $(CPRODS) $(CTRASH)
/* get application-specific delim.dat */
$(CP) $(HTAG2SRC)/delim.par delim.dat
$(SDLUTILSRC)/context
$(SDLUTILSRC)/context:
cd $(SDLUTILSRC); make context
$(APPLOBJECTS):
cd $(HTAG2SRC); make
$(ELT_DEFS):
cd $(SDLELTDEFSRC); make
clean::
$(RM) $(CPRODS) $(CTRASH) parser *.o
depend:: $(SRCS)
includes:: $(CPRODS)
DependTarget()

View File

@@ -0,0 +1,316 @@
/* $XConsortium: actutil.c /main/3 1995/11/08 10:48:36 rswiston $ */
/*
Copyright 1986 Tandem Computers Incorporated.
This product and information is proprietary of Tandem Computers Incorporated.
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
*/
/* Actutil.c contains utility procedures for processing actions specified
in the interface definition.*/
#include <stdio.h>
#include <malloc.h>
#if defined(MSDOS)
#include <process.h>
#endif
#include <string.h>
#include "basic.h"
#include "trie.h"
#include "dtdext.h"
#include "parser.h"
#define M_IFDEF
#include "if.h"
#include "delim.h"
#include "context.h"
#include "signon.h"
/* When an explicit or implied end-tag occurs */
void m_endaction(m_elt)
M_ELEMENT m_elt;
{
M_ELEMENT m_action;
char buffer[2*MAXD+M_NAMELEN+1];
if (m_tagtrace) {
if (m_element[m_elt - 1].content != M_NONE) {
if (m_toptstat == M_OTHER) {
strcpy(buffer, "\n");
m_trace(buffer);
}
sprintf(buffer,
"%s%s%s",
m_etago,
m_nameofelt(m_elt),
m_tagc);
m_trace(buffer);
}
m_toptstat = M_OTHER;
}
if (m_action = m_findact(m_elt, m_ecarray)) {
m_stackpar = m_stacktop;
m_endcase(m_action);
}
if (m_action = m_findact(m_elt, m_etarray)) {
m_stackpar = m_stacktop->stparam;
m_textout(&m_string[m_action - 1], FALSE, TRUE);
}
}
/* Find appropriate action according to current stack */
int m_findact(elt, array)
M_ELEMENT elt;
int *array;
{
int chainlen = 0;
int index;
if (! array[elt - 1]) return(FALSE);
if (m_stacktop->element != elt) {
m_error("Program error in findact");
m_exit(TRUE);
}
/* There is an action for this element with no context specification */
if (m_action[array[elt - 1] - 1].data) {
chainlen = 1;
index = array[elt - 1];
}
/* Only actions for this element have context specified */
else {
chainlen = 0;
index = 0;
}
m_findchain(m_stacktop->oldtop, array[elt - 1], chainlen, &chainlen,
&index, FALSE);
return(index ? m_action[index - 1].data : FALSE);
}
/* Recursive procedure called by findact() to search m_action */
#if defined(M_PROTO)
void m_findchain(M_PARSE *stackptr, int start, int chainin, int *chainout, int *index, LOGICAL wild)
#else
void m_findchain(stackptr, start, chainin, chainout, index, wild)
M_PARSE *stackptr;
int start;
int chainin;
int *chainout;
int *index;
LOGICAL wild;
#endif
{
int node;
M_PARSE *stackp;
for (node = m_action[start - 1].son ; node;
node = m_action[node - 1].next) {
if (m_action[node - 1].element == 1)
m_findchain(stackptr, node, chainin, chainout, index, TRUE);
else for (stackp = stackptr;
stackp->oldtop;
stackp = stackp->oldtop) {
if (stackp->element == m_action[node - 1].element - 1) {
if (m_action[node - 1].data)
if (chainin + 1 > *chainout ||
(chainin + 1 == *chainout && node < *index)) {
*chainout = chainin + 1;
*index = node;
}
m_findchain(stackp->oldtop, node, chainin + 1, chainout,
index, FALSE);
}
if (! wild) break;
}
}
}
/* Process global end string. In separate procedure to keep all references
to if.h in one source file and minimize recompilation if interface
changes. */
void m_globes(M_NOPAR)
{
M_WCHAR *wc_string;
wc_string = MakeWideCharString(&m_string[m_ges]);
if (m_ges) m_stcaction(wc_string, FALSE, TRUE);
m_free(wc_string,"wide character string");
}
/* Process global start string. In separate procedure to keep all references
to if.h in one source file and minimize recompilation if interface
changes. */
void m_globss(M_NOPAR)
{
M_WCHAR *wc_string;
wc_string = MakeWideCharString(&m_string[m_gss]);
if (m_gss) m_stcaction(wc_string, TRUE, FALSE);
m_free(wc_string,"wide character string");
}
/* When an explicit or implied start-tag occurs */
void m_strtaction(m_elt)
M_ELEMENT m_elt;
{
int m_par, m_i;
M_WCHAR *m_p;
M_ELEMENT m_action;
static char newpar[] = "\n ";
static char quote[] = " = \"";
char buffer[M_NAMELEN + 1 +
(sizeof(quote) + sizeof(newpar) - 2 > MAXD ?
sizeof(quote) + sizeof(newpar) - 2 :
MAXD)
];
m_start = TRUE;
m_getline(&m_stacktop->file, &m_stacktop->line);
if (m_tagtrace) {
sprintf(buffer, "%s%s", m_stago, m_nameofelt(m_elt));
m_trace(buffer);
for (m_i = 0, m_par = m_element[m_elt - 1].parptr;
m_i < m_element[m_elt - 1].parcount;
m_i++, m_par++)
if (m_stacktop->param[m_i]) {
sprintf(buffer, "%s%s%s",
newpar, &m_pname[m_parameter[m_par - 1].paramname], quote);
m_trace(buffer);
buffer[1] = M_EOS;
for (m_p = m_stacktop->param[m_i] ; *m_p ; m_p++)
if (*m_p != '"') {
buffer[0] = *m_p;
m_trace(buffer);
}
else {
sprintf(buffer, "%s%d", m_cro, '"');
m_trace(buffer);
buffer[1] = M_EOS;
}
buffer[0] = '"';
m_trace(buffer);
}
if (m_element[m_elt - 1].parcount) {
buffer[0] = '\n';
buffer[1] = M_EOS;
m_trace(buffer);
}
sprintf(buffer, "%s\n", m_tagc);
m_trace(buffer);
m_toptstat = M_TOPTSTARTTAG;
}
if (m_action = m_findact(m_elt, m_scarray)) {
m_stackpar = m_stacktop;
m_strtcase(m_action);
}
if (m_action = m_findact(m_elt, m_stcarray)) {
m_stacktop->stccase = m_action;
m_stacktop->stparam = m_stacktop;
}
if (m_action = m_findact(m_elt, m_starray)) {
m_stackpar = m_stacktop->stparam;
m_textout(&m_string[m_action - 1], TRUE, FALSE);
}
if (m_action = m_findact(m_elt, m_tcarray)) {
m_stacktop->cdcase = m_action;
m_stacktop->cdparam = m_stacktop;
}
if (m_action = m_findact(m_elt, m_pcarray)) {
m_stacktop->picase = m_action;
m_stacktop->piparam = m_stacktop;
}
}
/* Output a start-string or end-string */
#if defined(M_PROTO)
void m_textout(char *format, LOGICAL start, LOGICAL end)
#else
void m_textout(format, start, end)
char *format;
LOGICAL start;
LOGICAL end;
#endif
{
M_WCHAR name[M_NAMELEN + 1];
int i, par;
LOGICAL found;
M_WCHAR *string;
M_WCHAR *p;
M_WCHAR *q;
M_WCHAR *r;
M_WCHAR *s;
M_WCHAR *new;
int stringlen;
int changelen;
int unused;
stringlen = strlen(format) + 1;
unused = 0;
string = (M_WCHAR *) m_malloc(stringlen, "string space");
for (p = string ; *format ; )
{
if (*format == M_ESCAPECHAR)
{
for (i = 0, format++ ; i < M_NAMELEN ; i++, format++)
{
mbtowc(&name[i], format, 1);
if (m_cttype(name[i]) == M_NONNAME ||
(m_cttype(name[i]) != M_NMSTART && i == 0)
) break;
}
if (! i)
{
char mb;
mb = M_ESCAPECHAR;
mbtowc(p, &mb, 1);
p++;
/* Double escape character used to insert a single escape character
in the output string */
if (*format == M_ESCAPECHAR) format++;
continue;
}
name[i] = M_EOS;
for (found = FALSE, i = 0,
par = m_element[m_stacktop->element - 1].parptr;
i < m_element[m_stacktop->element - 1].parcount;
i++, par++)
if (! m_wcupstrcmp(&m_pname[m_parameter[par - 1].paramname], name))
{
q = m_stacktop->param[i];
if (! q)
{
found = TRUE;
unused += w_strlen(name) + 1;
break;
}
changelen = w_strlen(q) - w_strlen(name) - 1 - unused;
if (changelen > 0)
{
new = (M_WCHAR *) m_malloc(stringlen + changelen,
"string space");
for (r = string, s = new ; r < p ; ) *s++ = *r++;
m_free(string, "string space");
string = new;
stringlen = stringlen + changelen;
p = s;
unused = 0;
}
else if (changelen < 0) unused = -changelen;
found = TRUE;
break;
}
if (! found)
{
char mb;
mb = M_ESCAPECHAR;
mbtowc(p, &mb, 1);
p++;
q = name;
}
if (q) while (*q) *p++ = *q++;
}
else *p++ = *format++;
}
*p = M_EOS;
m_stcaction(string, start, end);
m_free(string, "string space");
}

View File

@@ -0,0 +1,2 @@
/* $XConsortium: addinput.c /main/3 1995/11/08 10:48:50 rswiston $ */
/* Obsolete */

View File

@@ -0,0 +1,133 @@
/* $XConsortium: charconv.h /main/3 1995/11/08 10:49:04 rswiston $ */
EXTERN M_WCHAR pc8_to_r8 [256]
#if defined(DEFINE)
= {
'\000','\001','\002','\003','\004','\005','\006','\007','\010','\011',
'\012','\013','\014','\015','\016','\017','\020','\021','\022','\023',
'\024','\025','\026','\027','\030','\031','\032','\033','\034','\035',
'\036','\037','\040','\041','\042','\043','\044','\045','\046','\047',
'\050','\051','\052','\053','\054','\055','\056','\057','\060','\061',
'\062','\063','\064','\065','\066','\067','\070','\071','\072','\073',
'\074','\075','\076','\077','\100','\101','\102','\103','\104','\105',
'\106','\107','\110','\111','\112','\113','\114','\115','\116','\117',
'\120','\121','\122','\123','\124','\125','\126','\127','\130','\131',
'\132','\133','\134','\135','\136','\137','\140','\141','\142','\143',
'\144','\145','\146','\147','\150','\151','\152','\153','\154','\155',
'\156','\157','\160','\161','\162','\163','\164','\165','\166','\167',
'\170','\171','\172','\173','\174','\175','\176','\177','\264','\317',
'\305','\300','\314','\310','\324','\265','\301','\315','\311','\335',
'\321','\331','\330','\320','\334','\327','\323','\302','\316','\312',
'\303','\313','\357','\332','\333','\277','\273','\274','\120','\276',
'\304','\325','\306','\307','\267','\266','\371','\372','\271','\055',
'\052','\370','\367','\270','\373','\375','\374','\374','\374','\174',
'\053','\043','\053','\053','\043','\043','\174','\043','\043','\053',
'\043','\053','\053','\053','\053','\053','\055','\053','\043','\053',
'\043','\043','\043','\043','\043','\075','\043','\043','\053','\043',
'\053','\053','\043','\043','\053','\053','\043','\053','\053','\374',
'\374','\374','\374','\374','\052','\336','\052','\052','\052','\052',
'\363','\052','\052','\052','\052','\052','\052','\326','\052','\052',
'\052','\376','\052','\052','\174','\174','\057','\176','\263','\362',
'\362','\052','\052','\052','\374','\377'
}
#endif
;
EXTERN M_WCHAR pc8dn_to_r8 [256]
#if defined(DEFINE)
= {
'\000','\001','\002','\003','\004','\005','\006','\007','\010','\011',
'\012','\013','\014','\015','\016','\017','\020','\021','\022','\023',
'\024','\025','\026','\027','\030','\031','\032','\033','\034','\035',
'\036','\037','\040','\041','\042','\043','\044','\045','\046','\047',
'\050','\051','\052','\053','\054','\055','\056','\057','\060','\061',
'\062','\063','\064','\065','\066','\067','\070','\071','\072','\073',
'\074','\075','\076','\077','\100','\101','\102','\103','\104','\105',
'\106','\107','\110','\111','\112','\113','\114','\115','\116','\117',
'\120','\121','\122','\123','\124','\125','\126','\127','\130','\131',
'\132','\133','\134','\135','\136','\137','\140','\141','\142','\143',
'\144','\145','\146','\147','\150','\151','\152','\153','\154','\155',
'\156','\157','\160','\161','\162','\163','\164','\165','\166','\167',
'\170','\171','\172','\173','\174','\175','\176','\177','\264','\317',
'\305','\300','\314','\310','\324','\265','\301','\315','\311','\335',
'\321','\331','\330','\320','\334','\327','\323','\302','\316','\312',
'\303','\313','\357','\332','\333','\326','\273','\322','\114','\154',
'\304','\325','\306','\307','\267','\266','\352','\351','\271','\342',
'\341','\154','\156','\270','\052','\272','\374','\374','\374','\174',
'\053','\043','\053','\053','\043','\043','\174','\043','\043','\053',
'\043','\053','\053','\053','\053','\053','\055','\053','\043','\053',
'\043','\043','\043','\043','\043','\075','\043','\043','\053','\043',
'\053','\053','\043','\043','\053','\053','\043','\053','\053','\374',
'\374','\374','\374','\374','\052','\336','\052','\052','\052','\052',
'\363','\052','\052','\052','\052','\052','\052','\326','\052','\052',
'\052','\376','\052','\052','\174','\174','\057','\176','\263','\362',
'\362','\052','\052','\052','\374','\377'
}
#endif
;
EXTERN M_WCHAR r8_to_pc8 [256]
#if defined(DEFINE)
= {
'\000','\001','\002','\003','\004','\005','\006','\007','\010','\011',
'\012','\013','\014','\015','\016','\017','\020','\021','\022','\023',
'\024','\025','\026','\027','\030','\031','\032','\033','\034','\035',
'\036','\037','\040','\041','\042','\043','\044','\045','\046','\047',
'\050','\051','\052','\053','\054','\055','\056','\057','\060','\061',
'\062','\063','\064','\065','\066','\067','\070','\071','\072','\073',
'\074','\075','\076','\077','\100','\101','\102','\103','\104','\105',
'\106','\107','\110','\111','\112','\113','\114','\115','\116','\117',
'\120','\121','\122','\123','\124','\125','\126','\127','\130','\131',
'\132','\133','\134','\135','\136','\137','\140','\141','\142','\143',
'\144','\145','\146','\147','\150','\151','\152','\153','\154','\155',
'\156','\157','\160','\161','\162','\163','\164','\165','\166','\167',
'\170','\171','\172','\173','\174','\175','\176','\177','\200','\201',
'\202','\203','\204','\205','\206','\207','\210','\211','\212','\213',
'\214','\215','\216','\217','\220','\221','\222','\223','\224','\225',
'\226','\227','\230','\231','\232','\233','\234','\235','\236','\237',
'\040','\101','\101','\105','\105','\105','\111','\111','\047','\140',
'\136','\042','\176','\125','\125','\234','\055','\131','\171','\370',
'\200','\207','\245','\244','\255','\250','\052','\234','\235','\052',
'\237','\233','\203','\210','\223','\226','\240','\202','\242','\243',
'\205','\212','\225','\227','\204','\211','\224','\201','\217','\214',
'\117','\222','\206','\241','\355','\221','\216','\215','\231','\232',
'\220','\213','\341','\117','\101','\101','\141','\104','\144','\111',
'\111','\117','\117','\117','\157','\123','\163','\125','\131','\230',
'\052','\052','\372','\346','\052','\052','\304','\254','\253','\246',
'\247','\256','\376','\257','\361','\040'
}
#endif
;
EXTERN M_WCHAR r8_to_pc8dn [256]
#if defined(DEFINE)
= {
'\000','\001','\002','\003','\004','\005','\006','\007','\010','\011',
'\012','\013','\014','\015','\016','\017','\020','\021','\022','\023',
'\024','\025','\026','\027','\030','\031','\032','\033','\034','\035',
'\036','\037','\040','\041','\042','\043','\044','\045','\046','\047',
'\050','\051','\052','\053','\054','\055','\056','\057','\060','\061',
'\062','\063','\064','\065','\066','\067','\070','\071','\072','\073',
'\074','\075','\076','\077','\100','\101','\102','\103','\104','\105',
'\106','\107','\110','\111','\112','\113','\114','\115','\116','\117',
'\120','\121','\122','\123','\124','\125','\126','\127','\130','\131',
'\132','\133','\134','\135','\136','\137','\140','\141','\142','\143',
'\144','\145','\146','\147','\150','\151','\152','\153','\154','\155',
'\156','\157','\160','\161','\162','\163','\164','\165','\166','\167',
'\170','\171','\172','\173','\174','\175','\176','\177','\200','\201',
'\202','\203','\204','\205','\206','\207','\210','\211','\212','\213',
'\214','\215','\216','\217','\220','\221','\222','\223','\224','\225',
'\226','\227','\230','\231','\232','\233','\234','\235','\236','\237',
'\040','\101','\101','\105','\105','\105','\111','\111','\047','\140',
'\136','\042','\176','\125','\125','\234','\055','\131','\171','\370',
'\200','\207','\245','\244','\255','\250','\257','\234','\131','\052',
'\146','\143','\203','\210','\223','\226','\240','\202','\242','\243',
'\205','\212','\225','\227','\204','\211','\224','\201','\217','\214',
'\235','\222','\206','\241','\233','\221','\216','\215','\231','\232',
'\220','\213','\341','\117','\101','\252','\251','\104','\144','\111',
'\111','\117','\117','\247','\246','\123','\163','\125','\131','\230',
'\052','\052','\372','\346','\052','\052','\304','\052','\052','\052',
'\052','\074','\376','\076','\361','\040'
}
#endif
;

View File

@@ -0,0 +1,14 @@
/* $XConsortium: closent.c /main/3 1995/11/08 10:49:21 rswiston $ */
/* Copyright 1988, 1989 Hewlett-Packard Co. */
/* Default close SYSTEM entity procedure */
#include "userinc.h"
#include "globdec.h"
void m_closent(m_ptr)
void *m_ptr ;
{
fclose((FILE *) m_ptr) ;
}

View File

@@ -0,0 +1,23 @@
/* $XConsortium: code.c /main/3 1995/11/08 10:49:34 rswiston $ */
/*
Copyright 1986 Tandem Computers Incorporated.
This product and information is proprietary of Tandem Computers Incorporated.
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
*/
/* Code.c executes code entities specified in the interface. */
#include "userinc.h"
#include "globdef.h"
#include <time.h>
/* Include generated file */
#include "entfile.c"
/* When a reference to a CODE entity is encountered */
void m_codeent(m_ent)
int m_ent ;
{
(*m_ctable[m_ent])() ;
}

View File

@@ -0,0 +1,681 @@
m_comment
comcon:comcon {
/* $XConsortium: context.dat /main/3 1995/07/17 19:58:23 lehors $ */
/*
Copyright 1986 Tandem Computers Incorporated.
This product and information is proprietary of Tandem Computers Incorporated.
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
Context.dat defines the state transitions for program PARSER.
*/
}
pdecl:pdecl,
decl:decl,
mapname:mapname,
endmap:endmap,
entname:entname,
entval:entval,
dupent:dupent,
typedentval:typedentval,
typedupent:typedupent,
entend:entend {m_readcomments() ;}
;
m_mdo
preamble:pdecl
datacon:decl
elcon:decl
netdatacon:decl
netelcon:decl
poundcdata:decl
netcdata:decl
;
m_mdc
entend:preamble
perror:preamble
pdecl:preamble
endmap:start
decl:start
derror:start
;
m_usemap
decl:mapname
;
m_addmap
decl:amapname {
if (m_conform) m_mberr1("%s not provided in IS 8879",
m_addmap) ;
}
;
m_empty
mapname:endmap {m_setmap(1, TRUE) ;}
amapname:endmap {m_setmap(1, FALSE) ;}
;
m_entkw
pdecl:entname
;
m_entst
entval:typedentval {if (m_entity) m_entity->type = M_STARTTAG ;}
dupent:typedupent {m_eduptype(M_STARTTAG) ;}
;
m_entet
entval:typedentval {if (m_entity) m_entity->type = M_ENDTAG ;}
dupent:typedupent {m_eduptype(M_ENDTAG) ;}
;
m_entcdata
entval:typedentval {if (m_entity) m_entity->type = M_CDATAENT ;}
dupent:typedupent {m_eduptype(M_CDATAENT) ;}
;
m_entsdata
entval:typedentval {if (m_entity) m_entity->type = M_SDATA ;}
dupent:typedupent {m_eduptype(M_SDATA) ;}
;
m_entsystem
entval:typedentval {if (m_entity) m_entity->type = M_SYSTEM ;}
dupent:typedupent {m_eduptype(M_SYSTEM) ;}
;
m_entmd
entval:typedentval {if (m_entity) m_entity->type = M_MD ;}
dupent:typedupent {m_eduptype(M_MD) ;}
;
m_entpi
entval:typedentval {if (m_entity) m_entity->type = M_PI ;}
dupent:typedupent {m_eduptype(M_PI) ;}
;
m_stago
datacon:selement,
elcon:selement,
netdatacon:selement,
netelcon:selement,
poundcdata:selement,
netcdata:selement {m_scannet = FALSE ;}
eelement:selement {
if (! m_stacktop->oldtop)
m_scanel = m_arc[m_state[0].first - 1].label ;
else m_scanel = m_stacktop->element ;
m_etcomplete() ;
}
selement:selement {
if (! m_stacktop->oldtop)
m_scanel = m_arc[m_state[0].first - 1].label ;
else m_scanel = m_stacktop->element ;
m_stcomplete() ;
}
attname:selement {
m_stcomplete() ;
}
needvi:selement {
m_attvonly(m_saveatt) ;
m_stcomplete() ;
}
etagend:selement {m_etcomplete() ;}
;
m_etago
elcon:eelement
datacon:eelement
netelcon:eelement
netdatacon:eelement
poundcdata:eelement
netcdata:eelement
cdatael:eelement
rcdatael:eelement
netelcdata:eelement
netrcdata:eelement
eelement:eelement {
if (! m_stacktop->oldtop)
m_scanel = m_arc[m_state[0].first - 1].label ;
else m_scanel = m_stacktop->element ;
m_etcomplete() ;
}
selement:eelement {
if (! m_stacktop->oldtop)
m_scanel = m_arc[m_state[0].first - 1].label ;
else m_scanel = m_stacktop->element ;
m_stcomplete() ;
}
attname:eelement {m_stcomplete() ;}
needvi:eelement {
m_attvonly(m_saveatt) ;
m_stcomplete() ;
}
etagend:eelement {m_etcomplete() ;}
;
m_pio
datacon:procint
elcon:procint
netdatacon:procint
netelcon:procint
selement:procint {
if (! m_stacktop->oldtop)
m_scanel = m_arc[m_state[0].first - 1].label ;
else m_scanel = m_stacktop->element ;
m_stcomplete() ;
}
eelement:procint {
if (! m_stacktop->oldtop)
m_scanel = m_arc[m_state[0].first - 1].label ;
else m_scanel = m_stacktop->element ;
m_etcomplete() ;
}
poundcdata:procint
netcdata:procint
attname:procint {m_stcomplete() ;}
needvi:procint {
m_attvonly(m_saveatt) ;
m_stcomplete() ;
}
etagend:procint {m_etcomplete() ;}
;
m_tagc
eelement:start {
if (! m_stacktop->oldtop)
m_scanel = m_arc[m_state[0].first - 1].label ;
else m_scanel = m_stacktop->element ;
m_stacktop->holdre = FALSE ;
m_etcomplete() ;
}
selement:start {
if (! m_stacktop->oldtop)
m_scanel = m_arc[m_state[0].first - 1].label ;
else m_scanel = m_stacktop->element ;
m_stcomplete() ;
}
attname:start {m_stcomplete() ;}
etagend:start {m_etcomplete() ;}
needvi:start {
m_attvonly(m_saveatt) ;
m_stcomplete() ;
}
;
m_pic
procint:start {
m_pi[m_pilen] = M_EOS ;
m_piaction(m_pi, NULL, M_NULLVAL) ;
m_pilen = 0 ;
}
pierror:start
;
m_vi
needvi:attval {m_findatt() ;}
;
m_lit
attname:litcon
attval:litcon
litcon:litcon
;
m_litdelim
entval:litent,
typedentval:litent,
dupent:dlitent,
typedupent:dlitent {m_entclen = 0 ;}
litent:entend,
elitent:entend {
if (m_entity) {
m_entcontent[m_entclen] = M_EOS ;
m_entity->content =
(M_WCHAR *) m_malloc(m_entclen + 1, "entity content") ;
w_strcpy(m_entity->content, m_entcontent) ;
}
}
dlitent:entend,
edlitent:entend {
m_entcontent[m_entclen] = M_EOS ;
if (w_strcmp(m_entity->content, m_entcontent))
m_err1("Redefinition of entity %s ignored", m_entity->name) ;
}
;
m_lita
attname:litacon
attval:litacon
litacon:litacon
;
m_litadelim
entval:litaent,
typedentval:litaent,
dupent:dlitaent,
typedupent:dlitaent {m_entclen = 0 ;}
litaent:entend,
elitaent:entend {
if (m_entity) {
m_entcontent[m_entclen] = M_EOS ;
m_entity->content =
(M_WCHAR *) m_malloc(m_entclen + 1, "entity content") ;
w_strcpy(m_entity->content, m_entcontent) ;
}
}
dlitaent:entend,
edlitaent:entend {
m_entcontent[m_entclen] = M_EOS ;
if (w_strcmp(m_entity->content, m_entcontent))
m_err1("Redefinition of entity %s ignored", m_entity->name) ;
}
;
m_cro
litcon:litcon
litacon:litacon
poundcdata:poundcdata
netcdata:netcdata
elcon:poundcdata
netelcon:netcdata
rcdatael:rcdatael
netrcdata:netrcdata
;
m_litrs
litcon:litcon
litacon:litacon
poundcdata:poundcdata
netcdata:netcdata
elcon:elcon
netelcon:netelcon
;
m_litscr
litcon:litcon
litacon:litacon
poundcdata:poundcdata
netcdata:netcdata
elcon:elcon
netelcon:netelcon
;
m_litre
litcon:litcon
litacon:litacon
poundcdata:poundcdata
netcdata:netcdata
elcon:elcon
netelcon:netelcon
;
m_litecr
litcon:litcon
litacon:litacon
poundcdata:poundcdata
netcdata:netcdata
elcon:elcon
netelcon:netelcon
;
m_litspace
litcon:litcon
litacon:litacon
poundcdata:poundcdata
netcdata:netcdata
elcon:elcon
netelcon:netelcon
;
m_litcspace
litcon:litcon
litacon:litacon
poundcdata:poundcdata
netcdata:netcdata
elcon:elcon
netelcon:netelcon
;
m_littab
litcon:litcon
litacon:litacon
poundcdata:poundcdata
netcdata:netcdata
elcon:elcon
netelcon:netelcon
;
m_litctab
litcon:litcon
litacon:litacon
poundcdata:poundcdata
netcdata:netcdata
elcon:elcon
netelcon:netelcon
;
m_ero
rcdatael:rcdatael
netrcdata:netrcdata
poundcdata:poundcdata
netcdata:netcdata
datacon:datacon
elcon:elcon
netdatacon:netdatacon
netelcon:netelcon
preamble:preamble
litcon:litcon
litacon:litacon
entinlit:entinlit
;
m_refc
entref:entref
;
m_net
netdatacon:start,
netelcon:start,
netcdata:start,
netelcdata:start,
netrcdata:start {m_nullendtag() ;}
selement:start {
m_scannet = TRUE ;
if (! m_stacktop->oldtop)
m_scanel = m_arc[m_state[0].first - 1].label ;
else m_scanel = m_stacktop->element ;
m_stcomplete() ;
}
attname:start {
m_scannet = TRUE ;
m_stcomplete() ;
}
needvi:start {
m_scannet = TRUE ;
m_attvonly(m_saveatt) ;
m_stcomplete() ;
}
;
m_endfile
datacon:datacon
elcon:elcon
netdatacon:netdatacon
netelcon:netelcon
poundcdata:poundcdata
netcdata:netcdata
preamble:preamble {
m_startdoc() ;
if (! m_state[2].final) m_error("Empty document") ;
}
rcdatael:rcdatael
netrcdata:netrcdata
rcnewent:rcnewent
cdatael:cdatael
netelcdata:netelcdata
eelement:start {
if (! m_wholetag)
m_mberr1("Missing %s in end-tag", m_tagc) ;
if (! m_stacktop->oldtop)
m_scanel = m_arc[m_state[0].first - 1].label ;
else m_scanel = m_stacktop->element ;
m_stacktop->holdre = FALSE ;
m_etcomplete() ;
}
selement:start {
if (! m_wholetag)
m_mberr1("Missing %s in start-tag", m_tagc) ;
if (! m_stacktop->oldtop)
m_scanel = m_arc[m_state[0].first - 1].label ;
else m_scanel = m_stacktop->element ;
m_stcomplete() ;
}
attname:start {
if (! m_wholetag)
m_mberr1("Invalid parameter or missing %s", m_tagc) ;
m_stcomplete() ;
}
etagend:start {
if (! m_wholetag)
m_mberr1("Missing %s delimiter in end-tag", m_tagc) ;
m_etcomplete() ;
}
needvi:start {
if (! m_wholetag)
m_mberr1("Invalid parameter or missing %s", m_tagc) ;
m_attvonly(m_saveatt) ;
m_stcomplete() ;
}
attval:start {
if (! m_wholetag)
m_mberr1("Invalid parameter or missing %s", m_tagc) ;
m_err1("Expecting value for %s",
&m_pname[m_parameter[m_ppsave - 1].paramname]) ;
m_stcomplete() ;
}
;
m_name
mapname:endmap {m_ckmap(m_name, TRUE) ;}
amapname:endmap {m_ckmap(m_name, FALSE) ;}
entname:entval {
m_ntrent(m_name) ;
if (! m_entity) m_curcon = PERROR ;
}
selement:attname {
{
int i ;
if (m_scanel = m_eltname()) {
for (i = 0 ; i < m_element[m_scanel - 1].parcount ; i++)
m_poccur[i] = 0 ;
}
else m_curcon = START ;
}
}
eelement:etagend {
if (m_scanel = m_eltname()) m_stacktop->holdre = FALSE ;
else
if (m_element[m_stacktop->element - 1].content == M_CDATA ||
m_element[m_stacktop->element - 1].content == M_RCDATA) {
m_ckend(m_stacktop->element, FALSE) ;
m_curcon = START ;
}
else m_curcon = START ;
}
attname:needvi {if (m_validinpar(m_name))
w_strcpy(m_saveatt, m_name) ;}
attval:attname {m_attval(m_name) ;}
needvi:needvi {
m_attvonly(m_saveatt) ;
if (m_validinpar(m_name))
w_strcpy(m_saveatt, m_name) ;
}
;
m_text
litcon:litcon
litacon:litacon
entinlit:entinlit
litent:litent {m_longent(ELITENT) ;}
litaent:litaent {m_longent(ELITAENT) ;}
dlitent:dlitent {m_longent(EDLITENT) ;}
dlitaent:dlitaent {m_longent(EDLITAENT) ;}
elitent:elitent
elitaent:elitaent
edlitent:edlitent
edlitaent:edlitaent
perror:perror
derror:derror
pdecl:perror,
decl:derror {m_error("Invalid markup declaration") ;}
rcdatael:rcdatael,
netrcdata:netrcdata,
rcnewent:rcnewent,
cdatael:cdatael,
netelcdata:netelcdata,
poundcdata:poundcdata,
netcdata:netcdata {m_textaction(m_scanval) ;}
procint:procint {
m_pi[m_pilen++] = m_scanval ;
if (m_pilen > M_PILEN) {
m_error("Processing instruction too long") ;
m_pi[m_pilen - 1] = M_EOS ;
m_piaction(m_pi, NULL, M_NULLVAL) ;
m_curcon = PIERROR ;
m_pilen = 0 ;
}
}
pierror:pierror
datacon:poundcdata,
netdatacon:netcdata {m_strtcdata(m_scanval) ;}
;
m_blackspace
elcon:poundcdata,
netelcon:netcdata {m_strtcdata(m_scanval) ;}
preamble:start {
m_ungetachar((int) m_scanval, M_NORMAL, TRUE) ;
m_startdoc() ;
}
amapname:derror,
mapname:derror,
endmap:derror {m_error("Invalid usemap declaration") ;}
typedentval:perror,
entname:perror,
entval:perror,
typedupent:perror,
dupent:perror
{
m_error("Invalid ENTITY declaration") ;
if (m_entity)
{
m_entcontent[m_entclen] = M_EOS ;
m_entity->content =
(M_WCHAR *) m_malloc(m_entclen + 1, "entity content") ;
w_strcpy(m_entity->content, m_entcontent) ;
}
}
entend:perror
{
m_error("Unexpected characters within ENTITY declaration") ;
if (m_entity)
{
m_entcontent[m_entclen] = M_EOS ;
m_entity->content =
(M_WCHAR *) m_malloc(m_entclen + 1, "entity content") ;
w_strcpy(m_entity->content, m_entcontent) ;
}
}
selement:poundcdata {
if (! m_stacktop->oldtop)
m_scanel = m_arc[m_state[0].first - 1].label ;
else m_scanel = m_stacktop->element ;
m_strtcdata(m_scanval) ;
}
eelement:poundcdata {
if (! m_stacktop->oldtop)
m_scanel = m_arc[m_state[0].first - 1].label ;
else m_scanel = m_stacktop->element ;
m_etcomplete() ;
m_strtcdata(m_scanval) ;
}
;
m_literal
attname:attname {m_attvonly(m_literal) ;}
attval:attname {m_attval(m_literal) ;}
;
m_entityend
eelement:start {
if (! m_wholetag)
m_mberr1("Missing %s in entity containing end-tag", m_tagc) ;
if (! m_stacktop->oldtop)
m_scanel = m_arc[m_state[0].first - 1].label ;
else m_scanel = m_stacktop->element ;
m_stacktop->holdre = FALSE ;
m_etcomplete() ;
}
selement:start {
if (! m_wholetag)
m_mberr1("Missing %s in entity containing start-tag", m_tagc) ;
if (! m_stacktop->oldtop)
m_scanel = m_arc[m_state[0].first - 1].label ;
else m_scanel = m_stacktop->element ;
m_stcomplete() ;
}
attname:start {
if (! m_wholetag)
m_mberr1(
"Invalid parameter or missing %s in entity containing start-tag",
m_tagc) ;
m_stcomplete() ;
}
etagend:start {
if (! m_wholetag)
m_mberr1("Missing %s in entity containing end-tag", m_tagc) ;
m_etcomplete() ;
}
needvi:start {
if (! m_wholetag)
m_mberr1(
"Invalid parameter or missing %s in entity containing start-tag",
m_tagc) ;
m_attvonly(m_saveatt) ;
m_stcomplete() ;
}
attval:start {
if (! m_wholetag)
m_mberr1(
"Invalid parameter or missing %s in entity containing start-tag",
m_tagc) ;
m_err1("Expecting value for %s",
&m_pname[m_parameter[m_ppsave - 1].paramname]) ;
m_stcomplete() ;
}
;

View File

@@ -0,0 +1,57 @@
/* $XConsortium: cyclent.c /main/3 1995/11/08 10:49:50 rswiston $ */
/*
Copyright 1988, 1989 Hewlett-Packard Co.
*/
/* Cyclent.c contains procedure m_cyclent(), callable by interface
designers, to cycle through all defined entities, returning information
about them */
#include <stdio.h>
#include "basic.h"
#include "trie.h"
#include "dtdext.h"
#include "parser.h"
#include "entext.h"
#if defined(M_PROTO)
M_WCHAR *m_cyclent(LOGICAL init, unsigned char *type, M_WCHAR **content, unsigned char *wheredef)
#else
M_WCHAR *m_cyclent(init, type, content, wheredef)
LOGICAL init ;
unsigned char *type ;
M_WCHAR **content ;
unsigned char *wheredef ;
#endif
{
static M_TRIE *current ;
static M_TRIE *ancestor[M_NAMELEN + 1] ;
static length = 0 ;
static M_WCHAR name[M_NAMELEN + 1] ;
if (init) {
current = m_enttrie->data ;
length = 0 ;
}
if (length < 0) return(NULL) ;
while (current->symbol) {
ancestor[length] = current ;
name[length++] = current->symbol ;
current = current->data ;
}
name[length] = M_EOS ;
*type = ((M_ENTITY *) current->data)->type ;
*content = ((M_ENTITY *) current->data)->content ;
*wheredef = ((M_ENTITY *) current->data)->wheredef ;
while (length >= 0) {
if (current->next) {
current = current->next ;
break ;
}
length-- ;
if (length < 0) break ;
current = ancestor[length] ;
}
return(name) ;
}

View File

@@ -0,0 +1,23 @@
/* $XConsortium: dcurelt.c /main/3 1995/11/08 10:50:02 rswiston $ */
/*
Copyright 1988, 1989 Hewlett-Packard Co.
*/
#include "userinc.h"
#include "globdec.h"
/* Displays current element after some error messages */
void m_dispcurelt(file, line)
M_WCHAR *file ;
int line ;
{
char *mb_parent;
m_errline("Current element is ") ;
mb_parent = MakeMByteString(m_parent(0));
m_errline(mb_parent) ;
m_free(mb_parent,"multi-byte string");
m_errline(" begun on ") ;
m_dumpline(file, line) ;
m_errline(".\n") ;
}

View File

@@ -0,0 +1,39 @@
/* $XConsortium: delfree.c /main/3 1995/11/08 10:50:16 rswiston $ */
/* Copyright (c) 1988 Hewlett-Packard Co. */
/* Versions of m_free and m_malloc for debugging. */
/**/
#include <malloc.h>
#include <stdio.h>
#include "basic.h"
#include "trie.h"
#include "dtd.h"
#include "parser.h"
m_free(block, msg)
char *block ;
char *msg ;
{
free(block) ;
fprintf(m_outfile, "%5u:%5u- Freed %s\n",
(unsigned int) ((unsigned long) block >> 16),
(unsigned int) block, msg) ;
}
char *m_mallocx(size, msg)
int size ;
char *msg ;
{
char *p ;
if (! size) return(NULL) ;
p = malloc(size) ;
if (! p) {
m_err1("Unable to allocate space for %s", msg) ;
exit(TRUE) ;
}
fprintf(m_outfile, "%5u:%5u- Allocated %s\n",
(unsigned int) ((unsigned long) p >> 16), (unsigned int) p, msg) ;
return(p) ;
}

View File

@@ -0,0 +1,28 @@
/* $XConsortium: dmpline.c /main/3 1995/11/08 10:50:31 rswiston $ */
/*
Copyright 1988, 1989 Hewlett-Packard Co.
*/
#include "userinc.h"
#include "globdec.h"
/* Write input file and line number for an error message */
void m_dumpline(file, line)
M_WCHAR *file ;
int line ;
{
char buffer[10] ;
m_errline("Line ") ;
sprintf(buffer, "%d", line) ;
m_errline(buffer) ;
if (file)
{
char mb_file;
m_errline(" of File ") ;
mb_file = MakeMByteString(file);
m_errline(mb_file) ;
m_free(mb_file,"multi-byte string");
}
}

View File

@@ -0,0 +1,23 @@
/* $XConsortium: end.c /main/3 1995/11/08 10:50:46 rswiston $ */
/*
Copyright 1986 Tandem Computers Incorporated.
This product and information is proprietary of Tandem Computers Incorporated.
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
*/
/* End.c executes end-code specified in the interface. */
#include "userinc.h"
#include "globdec.h"
/* Include generated file */
#include "efile.c"
/* Perform the m_action-th end-code in the interface */
void m_endcase(m_action)
int m_action ;
{
(*m_etable[m_action])() ;
}

View File

@@ -0,0 +1,95 @@
/* $XConsortium: entity.c /main/3 1995/11/08 10:51:00 rswiston $ */
/*
Copyright 1986 Tandem Computers Incorporated.
This product and information is proprietary of Tandem Computers Incorporated.
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
*/
/* Entity.c contains procedures pertaining to entities */
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#if defined(MSDOS)
#include <process.h>
#endif
#include "basic.h"
#include "trie.h"
#include "context.h"
#include "dtdext.h"
#include "parser.h"
#include "entext.h"
/* Process the name in a usemap delaration */
#if defined(M_PROTO)
void m_ckmap(M_WCHAR *name, LOGICAL useoradd)
#else
void m_ckmap(name, useoradd)
M_WCHAR *name ;
LOGICAL useoradd ;
#endif
{
int mapid ;
if (mapid = m_packedlook(m_maptree, name))
m_setmap(mapid + 1, useoradd) ;
else m_err1("Undefined short reference map %s", name) ;
}
/* Check type specified in entity declaration for previously defined
entity. Testing to see if the new declaration is identical to the
original one. */
void m_eduptype(type)
int type ;
{
if ((int) m_entity->type != type) {
m_err1("Redefinition of entity %s ignored", m_entity->name) ;
m_entity = NULL ;
m_curcon = TYPEDENTVAL ;
}
}
/* Tests if an entity is too long */
void m_longent(context)
int context ;
{
if (m_entclen >= M_LITLEN) {
m_curcon = context ;
m_error("Entity content too long") ;
}
else m_entcontent[m_entclen++] = m_scanval ;
}
/* Enters an entity name into the entity name tree */
void m_ntrent(p)
M_WCHAR *p ;
{
M_ENTITY *new ;
new = (M_ENTITY *) m_malloc(sizeof(M_ENTITY), "entity") ;
if (m_entity = (M_ENTITY *) m_ntrtrie(p, m_enttrie, (M_TRIE *) new)) {
m_free(new, "entity") ;
if (m_entity->wheredef == M_DPARSER) {
if (m_entdupchk) {
m_err1("Redefinition of entity %s ignored", p) ;
m_entity = NULL ;
}
else m_curcon = DUPENT ;
}
else {
if (m_entity->content) {
m_err1("Warning: Redefinition of predefined entity %s", p) ;
m_entity->type = M_GENERAL ;
m_entity->content = NULL ;
}
m_entity->wheredef = M_DPARSER ;
}
return ;
}
m_entity = new ;
m_entity->type = M_GENERAL ;
m_entity->wheredef = M_DPARSER ;
m_entity->content = NULL ;
m_entity->name = (M_WCHAR *) m_malloc(w_strlen(p) + 1, "entity name") ;
w_strcpy(m_entity->name, p) ;
}

View File

@@ -0,0 +1,14 @@
/* $XConsortium: eprefix.c /main/3 1995/11/08 10:51:14 rswiston $ */
/*
Copyright 1988, 1989 Hewlett-Packard Co.
*/
#include "userinc.h"
#include "globdec.h"
/* Write error message prefix */
void m_eprefix(M_NOPAR)
{
m_errline("\n*****\n") ;
}

View File

@@ -0,0 +1,20 @@
/* $XConsortium: errline.c /main/3 1995/11/08 10:51:28 rswiston $ */
/*
Copyright 1988, 1989 Hewlett-Packard Co.
*/
#include "userinc.h"
#include "globdec.h"
/* Process error message text */
void m_errline(p)
M_WCHAR *p ;
{
char mb_p;
mb_p = MakeMByteString(p);
fputs(mb_p, m_errfile) ;
fputs(mb_p, stderr) ;
m_free(mb_p,"multi-byte string");
}

View File

@@ -0,0 +1,466 @@
/* $XConsortium: error.c /main/3 1995/11/08 10:51:44 rswiston $ */
/*
Copyright 1986 Tandem Computers Incorporated.
This product and information is proprietary of Tandem Computers Incorporated.
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
*/
/* Util.c contains general utilities for program PARSER */
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#if defined(MSDOS)
#include <process.h>
#endif
#include "basic.h"
#include "trie.h"
#include "dtdext.h"
#include "parser.h"
#include "entext.h"
/* Issue error message (no arguments) */
void m_error(text)
char *text;
{
m_startmsg();
m_errline(text);
m_esuffix();
}
/* Issue error message (one argument) */
#if defined(M_PROTO)
void m_err1(
const char *text,
const M_WCHAR *arg)
#else
void m_err1(text, arg)
char *text;
M_WCHAR *arg;
#endif
{
char *buffer, *mb_arg;
m_startmsg();
/* Subtract 2 characters for the %s and add an EOS*/
mb_arg = MakeMByteString(arg);
buffer = (char *)
m_malloc(strlen(text) + strlen(mb_arg) - 2 + 1, "error message");
sprintf(buffer, text, mb_arg);
m_errline(buffer);
m_free(buffer, "error message");
m_free(mb_arg,"multi-byte string");
m_esuffix();
}
#if defined(M_PROTO)
void m_mberr1(
const char *text,
const char *arg)
#else
void m_err1(text, arg)
char *text;
char *arg;
#endif
{
M_WCHAR *wc_arg;
wc_arg = MakeWideCharString(arg);
m_err1(text, wc_arg);
m_free(wc_arg,"wide character string");
}
/* Issue error message (two arguments) */
#if defined(M_PROTO)
void m_err2(
const char *text,
const M_WCHAR *arg1,
const M_WCHAR *arg2)
#else
void m_err2(text, arg1, arg2)
char *text;
M_WCHAR *arg1;
M_WCHAR *arg2;
#endif
{
char *buffer;
char *mb_arg1,*mb_arg2;
m_startmsg();
/* Subtract 2 characters for each of 2 %s's and add an EOS*/
mb_arg1 = MakeMByteString(arg1);
mb_arg2 = MakeMByteString(arg2);
buffer = (char *) m_malloc(
strlen(text) + strlen(mb_arg1) + strlen(mb_arg2) - 4 + 1,
"error message");
sprintf(buffer, text, mb_arg1, mb_arg2);
m_errline(buffer);
m_free(buffer, "error message");
m_free(mb_arg1,"multi-byte string");
m_free(mb_arg2,"multi-byte string");
m_esuffix();
}
/* Issue error message (three arguments) */
#if defined(M_PROTO)
void m_err3(
char *text,
M_WCHAR *arg1,
M_WCHAR *arg2,
M_WCHAR *arg3)
#else
void m_err3(text, arg1, arg2, arg3)
char *text;
M_WCHAR *arg1;
M_WCHAR *arg2;
M_WCHAR *arg3;
#endif
{
char *buffer;
char *mb_arg1, *mb_arg2, *mb_arg3;
m_startmsg();
/* Subtract 2 characters for each of 3 %s's and add an EOS*/
mb_arg1 = MakeMByteString(arg1);
mb_arg2 = MakeMByteString(arg2);
mb_arg3 = MakeMByteString(arg3);
buffer = (char *) m_malloc(
strlen(text) +
strlen(mb_arg1) +
strlen(mb_arg2) +
strlen(mb_arg3) - 6 + 1,
"error message");
sprintf(buffer, text, mb_arg1, mb_arg2, mb_arg3);
m_errline(buffer);
m_free(buffer, "error message");
m_free(mb_arg1,"multi-byte string");
m_free(mb_arg2,"multi-byte string");
m_free(mb_arg3,"multi-byte string");
m_esuffix();
}
/* Issue error message (four arguments) */
#if defined(M_PROTO)
void m_err4(
char *text,
M_WCHAR *arg1,
M_WCHAR *arg2,
M_WCHAR *arg3,
M_WCHAR *arg4)
#else
void m_err4(text, arg1, arg2, arg3, arg4)
char *text;
M_WCHAR *arg1;
M_WCHAR *arg2;
M_WCHAR *arg3;
M_WCHAR *arg4;
#endif
{
char *buffer;
char *mb_arg1, *mb_arg2,*mb_arg3,*mb_arg4;
m_startmsg();
/* Subtract 2 characters for each of 4 %s's and add an EOS*/
mb_arg1 = MakeMByteString(arg1);
mb_arg2 = MakeMByteString(arg2);
mb_arg3 = MakeMByteString(arg3);
mb_arg4 = MakeMByteString(arg4);
buffer = (char *) m_malloc(
strlen(text) +
strlen(mb_arg1) +
strlen(mb_arg2) +
strlen(mb_arg3) +
strlen(mb_arg4) - 8 + 1,
"error message");
sprintf(buffer, text, arg1, arg2, arg3, arg4);
m_errline(buffer);
m_free(buffer, "error message");
m_free(mb_arg1,"multi-byte string");
m_free(mb_arg2,"multi-byte string");
m_free(mb_arg3,"multi-byte string");
m_free(mb_arg4,"multi-byte string");
m_esuffix();
}
/* Issue error message (five arguments) */
#if defined(M_PROTO)
void m_err5(
char *text,
M_WCHAR *arg1,
M_WCHAR *arg2,
M_WCHAR *arg3,
M_WCHAR *arg4,
M_WCHAR *arg5)
#else
void m_err5(text, arg1, arg2, arg3, arg4, arg5)
char *text;
M_WCHAR *arg1;
M_WCHAR *arg2;
M_WCHAR *arg3;
M_WCHAR *arg4;
M_WCHAR *arg5;
#endif
{
char *buffer;
char *mb_arg1, *mb_arg2, *mb_arg3, *mb_arg4, *mb_arg5;
m_startmsg();
/* Subtract 2 characters for each of 5 %s's and add an EOS*/
mb_arg1 = MakeMByteString(arg1);
mb_arg2 = MakeMByteString(arg2);
mb_arg3 = MakeMByteString(arg3);
mb_arg4 = MakeMByteString(arg4);
mb_arg5 = MakeMByteString(arg5);
buffer = (char *) m_malloc(
strlen(text) +
strlen(mb_arg1) +
strlen(mb_arg2) +
strlen(mb_arg3) +
strlen(mb_arg4) +
strlen(mb_arg5) - 10 + 1,
"error message");
sprintf(buffer,
text,
mb_arg1,
mb_arg2,
mb_arg3,
mb_arg4,
mb_arg5);
m_errline(buffer);
m_free(buffer, "error message");
m_free(mb_arg1,"multi-byte string");
m_free(mb_arg2,"multi-byte string");
m_free(mb_arg3,"multi-byte string");
m_free(mb_arg4,"multi-byte string");
m_free(mb_arg5,"multi-byte string");
m_esuffix();
}
/* Issue error message (six arguments) */
#if defined(M_PROTO)
void m_err6(
char *text,
M_WCHAR *arg1,
M_WCHAR *arg2,
M_WCHAR *arg3,
M_WCHAR *arg4,
M_WCHAR *arg5,
M_WCHAR *arg6)
#else
void m_err6(text, arg1, arg2, arg3, arg4, arg5, arg6)
char *text;
M_WCHAR *arg1;
M_WCHAR *arg2;
M_WCHAR *arg3;
M_WCHAR *arg4;
M_WCHAR *arg5;
M_WCHAR *arg6;
#endif
{
char *buffer;
char *mb_arg1, *mb_arg2, *mb_arg3, *mb_arg4, *mb_arg5, *mb_arg6;
m_startmsg();
/* Subtract 2 characters for each of 6 %s's and add an EOS*/
mb_arg1 = MakeMByteString(arg1);
mb_arg2 = MakeMByteString(arg2);
mb_arg3 = MakeMByteString(arg3);
mb_arg4 = MakeMByteString(arg4);
mb_arg5 = MakeMByteString(arg5);
mb_arg6 = MakeMByteString(arg6);
buffer = (char *) m_malloc(
strlen(text) +
strlen(mb_arg1) +
strlen(mb_arg2) +
strlen(mb_arg3) +
strlen(mb_arg4) +
strlen(mb_arg5) +
strlen(mb_arg6) - 12 + 1,
"error message");
sprintf(buffer,
text,
mb_arg1,
mb_arg2,
mb_arg3,
mb_arg4,
mb_arg5,
mb_arg6);
m_errline(buffer);
m_free(buffer, "error message");
m_free(mb_arg1,"multi-byte string");
m_free(mb_arg2,"multi-byte string");
m_free(mb_arg3,"multi-byte string");
m_free(mb_arg4,"multi-byte string");
m_free(mb_arg5,"multi-byte string");
m_free(mb_arg6,"multi-byte string");
m_esuffix();
}
/* Issue error message (seven arguments) */
#if defined(M_PROTO)
void m_err7(
char *text,
M_WCHAR *arg1,
M_WCHAR *arg2,
M_WCHAR *arg3,
M_WCHAR *arg4,
M_WCHAR *arg5,
M_WCHAR *arg6,
M_WCHAR *arg7)
#else
void m_err7(text, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
char *text;
M_WCHAR *arg1;
M_WCHAR *arg2;
M_WCHAR *arg3;
M_WCHAR *arg4;
M_WCHAR *arg5;
M_WCHAR *arg6;
M_WCHAR *arg7;
#endif
{
char *buffer;
char *mb_arg1, *mb_arg2, *mb_arg3, *mb_arg4, *mb_arg5, *mb_arg6, *mb_arg7;
m_startmsg();
/* Subtract 2 characters for each of 7 %s's and add an EOS*/
mb_arg1 = MakeMByteString(arg1);
mb_arg2 = MakeMByteString(arg2);
mb_arg3 = MakeMByteString(arg3);
mb_arg4 = MakeMByteString(arg4);
mb_arg5 = MakeMByteString(arg5);
mb_arg6 = MakeMByteString(arg6);
mb_arg7 = MakeMByteString(arg7);
buffer = (char *) m_malloc(
strlen(text) +
strlen(mb_arg1) +
strlen(mb_arg2) +
strlen(mb_arg3) +
strlen(mb_arg4) +
strlen(mb_arg5) +
strlen(mb_arg6) +
strlen(mb_arg7) - 14 + 1,
"error message");
sprintf(buffer,
text,
mb_arg1,
mb_arg2,
mb_arg3,
mb_arg4,
mb_arg5,
mb_arg6,
mb_arg7);
m_errline(buffer);
m_free(buffer, "error message");
m_free(mb_arg1,"multi-byte string");
m_free(mb_arg2,"multi-byte string");
m_free(mb_arg3,"multi-byte string");
m_free(mb_arg4,"multi-byte string");
m_free(mb_arg5,"multi-byte string");
m_free(mb_arg6,"multi-byte string");
m_free(mb_arg7,"multi-byte string");
m_esuffix();
}
/* Getline.c returns the name of the current input file and the number
of the current line */
void m_getline(file, line)
M_WCHAR **file;
int *line;
{
int i;
if (m_sysecnt) {
for (i = m_eopencnt ; i ; i--)
if (m_opene[i - 1]->type == M_SYSTEM) break;
*file = m_opene[i - 1]->content;
}
else *file = NULL;
*line = m_line[m_sysecnt];
}
/* Dump last characters read from input stream to give context to
an error message */
void m_lastchars(M_NOPAR)
{
int i;
M_WCHAR buffer[2];
buffer[1] = M_EOS;
if (m_svlnwrap[m_sysecnt] || m_svlncnt[m_sysecnt])
m_errline("...");
if (m_svlnwrap[m_sysecnt])
for (i = m_svlncnt[m_sysecnt] ; i < M_LINELENGTH ; i++)
{
char *mb_buffer;
buffer[0] = (M_WCHAR) m_saveline[i][m_sysecnt];
if (buffer[0] == (M_WCHAR) -1)
{
m_errline("\n");
}
else
{
mb_buffer = MakeMByteString(buffer);
m_errline(mb_buffer);
m_free(mb_buffer,"multi-byte string");
}
}
for (i = 0 ; i < m_svlncnt[m_sysecnt] ; i++)
{
char *mb_buffer;
buffer[0] = (M_WCHAR) m_saveline[i][m_sysecnt];
if (buffer[0] == (M_WCHAR) -1)
{
m_errline("\n");
}
else
{
mb_buffer = MakeMByteString(buffer);
m_errline(mb_buffer);
m_free(mb_buffer,"multi-byte string");
}
}
if ((m_svlncnt[m_sysecnt] &&
m_saveline[m_svlncnt[m_sysecnt] - 1][m_sysecnt] != M_RE) ||
(! m_svlncnt[m_sysecnt] && m_svlnwrap[m_sysecnt] &&
m_saveline[M_LINELENGTH - 1][m_sysecnt] != M_RE)
) m_errline("...\n");
}
/* Display information about the current element */
void m_showcurelt(M_NOPAR)
{
if (m_stacktop->oldtop)
m_dispcurelt(m_stacktop->file, m_stacktop->line);
}
/* Start an error message */
void m_startmsg(M_NOPAR)
{
m_eprefix();
m_errexit = TRUE;
}
/* Return the name of the current input file (most recently opened, but
unclosed SYSTEM entity) */
M_WCHAR *m_thisfile(M_NOPAR)
{
int i;
if (m_sysecnt) {
for (i = m_eopencnt ; i ; i--)
if (m_opene[i - 1]->type == M_SYSTEM)
return(m_opene[i - 1]->content);
}
return(NULL);
}
/* Return the line number in the current input file */
int m_thisline(M_NOPAR)
{
return(m_line[m_sysecnt]);
}

View File

@@ -0,0 +1,24 @@
/* $XConsortium: esuffix.c /main/3 1995/11/08 10:52:01 rswiston $ */
/*
Copyright 1988, 1989 Hewlett-Packard Co.
*/
#include "userinc.h"
#include "globdec.h"
#if defined(MSDOS)
#include <process.h>
#endif
/* Write error message suffix */
void m_esuffix(M_NOPAR)
{
m_errline("\n") ;
m_dumpline(m_thisfile(), m_thisline()) ;
m_errline(":\n") ;
m_lastchars() ;
if (++m_errcnt == m_errlim) {
m_error("Too many errors, processing stopped") ;
m_exit(TRUE) ;
}
}

View File

@@ -0,0 +1,19 @@
/* $XConsortium: exit.c /main/3 1995/11/08 10:52:16 rswiston $ */
/*
Copyright 1988, 1989 Hewlett-Packard Co.
*/
#include "userinc.h"
#include "globdec.h"
#if defined(MSDOS)
#include <process.h>
#endif
/* Default version of PARSER m_exit(). Allows interface control if
internal error causes PARSER to halt. */
void m_exit(status)
int status ;
{
exit(status) ;
}

View File

@@ -0,0 +1,77 @@
/* $XConsortium: findpar.c /main/3 1995/11/08 10:52:30 rswiston $ */
/*
Copyright 1989 Hewlett-Packard Co.
*/
#include <stdio.h>
#include "basic.h"
#include "trie.h"
#include "dtdext.h"
#include "parser.h"
/* Function callable by interface designers. Returns index in parameter
list of a specified parameter for an element (i.e., 1 for first parameter
specified in the DTD, 2 for second, etc.). First parameter, elt, is
the name of the element. Second parameter is the name of the parameter
or NULL. Third parameter is used only if second parameter is NULL. In
the latter case, function returns first keyword parameter, if any, for
which the specified value is a legal value and otherwise first
Returns 0 if elt is not a valid element name, if param is specified
but is not a valid parameter name, or if param is NULL and value is
not a valid value of any of elt's parameters. */
#if defined(M_PROTO)
int m_findpar( const char *elt , const char *param , const M_WCHAR *value )
#else
int m_findpar(elt, param, value)
char *elt ;
char *param ;
M_WCHAR *value ;
#endif /* M_PROTO */
{
M_ELEMENT eltid ;
int par ;
int i ;
M_WCHAR *wc_elt;
wc_elt = MakeWideCharString(elt);
if (! (eltid = m_packedlook(m_entree, wc_elt)))
{
m_free(wc_elt,"wide character string");
return(M_NULLVAL) ;
}
m_free(wc_elt,"wide character string");
/* A parameter name specified */
if (param)
{
for (par = m_element[eltid - 1].parptr, i = 1 ;
i <= m_element[eltid - 1].parcount ;
par++, i++)
if (!m_wcmbupstrcmp(&m_pname[m_parameter[par - 1].paramname], param))
return(i) ;
return(M_NULLVAL) ;
}
/* No parameter name specified */
/* First check is it a valid keyword? */
for (par = m_element[eltid - 1].parptr, i = 1 ;
i <= m_element[eltid - 1].parcount ;
par++, i++)
if (m_parameter[par - 1].type == M_KEYWORD)
if (m_partype(par, value)) return(i) ;
/* It wasn't a keyword. Check for valid value for some other parameter.*/
for (par = m_element[eltid - 1].parptr, i = 1 ;
i <= m_element[eltid - 1].parcount ;
par++, i++)
{
if (m_parameter[par - 1].type == M_KEYWORD) continue ;
if (m_partype(par, value)) return(i) ;
}
/* Not a valid value for any parameter */
return(M_NULLVAL) ;
}

View File

@@ -0,0 +1,13 @@
/* $XConsortium: getc.c /main/3 1995/11/08 10:52:46 rswiston $ */
/* Copyright 1988, 1989 Hewlett-Packard Co. */
/* Default get-char procedure */
#include "userinc.h"
#include "globdec.h"
int m_getc(m_ptr)
void *m_ptr ;
{
return(getc((FILE*) m_ptr)) ;
}

View File

@@ -0,0 +1,20 @@
/* $XConsortium: getsign.c /main/3 1995/11/08 10:53:02 rswiston $ */
/*
Copyright 1988, 1989 Hewlett-Packard Co.
*/
/* Issue interface-generated sign-on message */
#include <stdio.h>
#include "basic.h"
#include "trie.h"
#include "dtdext.h"
#include "parser.h"
#include "signonx.h"
void m_getsignon(M_NOPAR)
{
m_errline(m_signon) ;
}

View File

@@ -0,0 +1,49 @@
/* $XConsortium: ifdata.c /main/3 1995/11/08 10:53:18 rswiston $ */
/* Copyright 1988, 1989 Hewlett-Packard Co. */
/* Ifdata.c contains functions used by the interface to access the
single item of interface-determined data stored on the parse stack. */
#include <stdio.h>
#include "basic.h"
#include "trie.h"
#include "dtdext.h"
#include "parser.h"
/* Retrieve the interface data stored with the current element's nth parent */
void *m_getdata(n, flag)
int n ;
LOGICAL *flag ;
{
M_PARSE *stackptr ;
for (stackptr = m_stacktop ;
stackptr->oldtop && n >= 0 ;
stackptr = stackptr->oldtop, n--) {
if (! n) {
*flag = TRUE ;
return(stackptr->ifdata) ;
}
}
*flag = FALSE ;
return(NULL) ;
}
/* Store interface data for the current element's nth parent */
LOGICAL m_putdata(data, n)
void *data ;
int n ;
{
M_PARSE *stackptr ;
for (stackptr = m_stacktop ;
stackptr->oldtop && n >= 0 ;
stackptr = stackptr->oldtop, n--) {
if (! n) {
stackptr->ifdata = data ;
return(TRUE) ;
}
}
return(FALSE) ;
}

View File

@@ -0,0 +1,140 @@
/* $XConsortium: input.c /main/3 1995/11/08 10:53:34 rswiston $ */
/*
Copyright 1986 Tandem Computers Incorporated.
This product and information is proprietary of Tandem Computers Incorporated.
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
*/
/* Input.c contains procedures that deal with the interface between the
scanner and parser for PARSER */
#include <stdio.h>
#include "basic.h"
#include "trie.h"
#include "dtdext.h"
#include "delim.h"
#include "context.h"
#include "parser.h"
/* M_etcomplete is called when a complete end-tag has been read */
void m_etcomplete(M_NOPAR)
{
if (! m_scanel) {
M_WCHAR *wc_etago, *wc_tagc;
wc_etago = MakeWideCharString(m_etago);
wc_tagc = MakeWideCharString(m_tagc);
m_err3("%s%s%s ignored: element undefined", wc_etago, m_name, wc_tagc) ;
m_free(wc_etago,"multi-byte string");
m_free(wc_tagc,"multi-byte string");
}
else
if (! m_ckend(m_scanel, FALSE)) {
m_err1("End tag for %s unexpected", m_nameofelt(m_scanel)) ;
m_expecting() ;
m_showcurelt() ;
if (m_element[m_stacktop->element - 1].content == M_CDATA ||
m_element[m_stacktop->element - 1].content == M_RCDATA)
m_ckend(m_stacktop->element, FALSE) ;
m_frcend(m_scanel) ;
}
}
/* M_frcend is called after a syntax error to end element VAL even
if more content for that element is expected */
void m_frcend(val)
M_ELEMENT val ;
{
M_PARSE *stackptr ;
M_ELEMENT poppedval ;
for (stackptr = m_stacktop ;
stackptr->oldtop && stackptr->element != val ;
stackptr = stackptr->oldtop) ;
if (! stackptr->oldtop) {
m_err1("No %s element currently opened", m_nameofelt(val)) ;
if (m_stacktop->oldtop)
if (m_element[m_stacktop->element].content == M_CDATA ||
m_element[m_stacktop->element].content == M_RCDATA)
m_ckend(m_stacktop->element, FALSE) ;
return ;
}
while (TRUE) {
poppedval = m_stacktop->element ;
m_endaction(m_stacktop->element) ;
m_pop() ;
if (poppedval == val) return ;
}
}
/* M_frcstart is called to force the start of an element when that element
cannot legally occur in the current context but does appear in the text*/
void m_frcstart(M_NOPAR)
{
m_push(m_scanel, m_element[m_scanel - 1].start, m_scannet) ;
if (m_scannet) m_netlevel++ ;
m_stacktop->contextual = FALSE ;
m_stkparams() ;
if (m_element[m_scanel - 1].content == M_CDATA ||
m_element[m_scanel - 1].content == M_RCDATA) {
m_stacktop->intext = TRUE ;
m_curcon = m_element[m_scanel - 1].content == M_CDATA ?
CDATAEL : RCDATAEL ;
m_stacktop->thisent = m_eopencnt ;
}
}
/* M_holdproc processes a RE that was saved to test if it was the last
RE in an element's content */
void m_holdproc(M_NOPAR)
{
if (m_stacktop->holdre) {
m_stacktop->holdre = FALSE ;
if (m_stacktop->intext) m_textaction(M_RE) ;
else {
m_strtcdata((int) M_RE) ;
if (m_curcon == NETDATACON) m_curcon = NETCDATA ;
else if (m_curcon == DATACON) m_curcon = POUNDCDATA ;
}
}
}
/* M_stcomplete is called when a complete start tag has been recognized */
void m_stcomplete(M_NOPAR)
{
if (! m_scanel) return ;
if (m_strtproc(m_scanel))
m_stkparams() ;
else {
if (m_stacktop->holdre) m_holdproc() ;
/* M_strtproc should not return TRUE as long as #PCDATA is considered
optional, but this code should work if the standard is changed */
if (m_strtproc(m_scanel)) m_stkparams() ;
else {
if (m_stacktop->oldtop) {
m_err2("%s not allowed at this point in %s",
m_nameofelt(m_scanel),
m_nameofelt(m_stacktop->element)) ;
m_expecting() ;
m_showcurelt() ;
}
else if (! m_start) {
M_WCHAR *wc_stago, *wc_tagc;
wc_stago = MakeWideCharString(m_stago);
wc_tagc = MakeWideCharString(m_tagc);
m_err6("Expecting %s%s%s instead of %s%s%s to start document",
wc_stago,
m_nameofelt(1),
wc_tagc,
wc_stago,
m_nameofelt(m_scanel),
wc_tagc) ;
m_free(wc_stago,"multi-byte string");
m_free(wc_tagc,"multi-byte string");
}
m_frcstart() ;
}
}
if (m_element[m_scanel - 1].content == M_NONE) m_endtag(m_scanel) ;
}

View File

@@ -0,0 +1,39 @@
/* $XConsortium: level.c /main/3 1995/11/08 10:53:50 rswiston $ */
/*
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
*/
#include <stdio.h>
#include "basic.h"
#include "trie.h"
#include "dtdext.h"
#include "parser.h"
/* Procedure callable by interface designer. Returns number of occurrences
of element on parse stack */
int m_level(elt)
M_WCHAR *elt ;
{
int i = 0 ;
M_PARSE *stackptr ;
for (stackptr = m_stacktop ;
stackptr->oldtop ;
stackptr = stackptr->oldtop) {
if (! m_wcupstrcmp(elt, m_nameofelt(stackptr->element))) i++ ;
}
return(i) ;
}
int m_mblevel(elt)
char *elt ;
{
int retval;
M_WCHAR *wc_elt;
wc_elt = MakeWideCharString(elt);
retval = m_level(wc_elt);
m_free(wc_elt,"wide character string");
return(retval);
}

View File

@@ -0,0 +1,34 @@
/* $XConsortium: lookent.c /main/3 1995/11/08 10:54:08 rswiston $ */
/*
Copyright 1986 Tandem Computers Incorporated.
This product and information is proprietary of Tandem Computers Incorporated.
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
*/
/* Lookent.c contains procedure m_lookent(), callable by interface
designers, to return entity type and content. Useful for entity
parameters */
#include <stdio.h>
#include "basic.h"
#include "trie.h"
#include "dtdext.h"
#include "parser.h"
#include "entext.h"
LOGICAL m_lookent(name, type, content, wheredef)
M_WCHAR *name ;
unsigned char *type ;
M_WCHAR **content ;
unsigned char *wheredef ;
{
M_ENTITY *entity ;
if (entity = (M_ENTITY *) m_lookfortrie(name, m_enttrie)) {
*type = entity->type ;
*content = entity->content ;
*wheredef = entity->wheredef ;
return(TRUE) ;
}
else return(FALSE) ;
}

View File

@@ -0,0 +1,404 @@
/* $XConsortium: minim.c /main/3 1995/11/08 10:54:22 rswiston $ */
/*
Copyright 1986 Tandem Computers Incorporated.
This product and information is proprietary of Tandem Computers Incorporated.
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
*/
/* Minim.c contains procedures relevant to tag minimization */
#include <stdio.h>
#include <string.h>
#if defined(MSDOS)
#include <process.h>
#endif
#include "basic.h"
#include "trie.h"
#include "dtdext.h"
#include "parser.h"
#include "delim.h"
#include "context.h"
/* M_expecting reports to the user the possible valid content at a particular
state in the parse of the document */
void m_expecting(M_NOPAR)
{
LOGICAL expstart = TRUE ;
M_PARSE *stackptr ;
M_OPENFSA *fsastack ;
M_ANDLIST *usedand ;
M_ANDGROUP pand ;
LOGICAL required = FALSE ;
LOGICAL data = FALSE ;
m_expcount = 0 ;
if (m_stacktop->intext) m_expline(&expstart, &data, M_NULLVAL) ;
for (stackptr = m_stacktop ; stackptr ; stackptr = stackptr->oldtop) {
if (m_explimit && m_expcount > M_EXPLIMIT) return ;
if (m_start && ! stackptr->oldtop) return ;
/* First check for possible start-tags.
Begin by testing if at start of document or not within a
CDATA or RCDATA element. */
if (! stackptr->oldtop ||
m_element[stackptr->element - 1].content == M_REGEXP) {
/* Note the following statement, which checks the type of the
element at the top of the stack, is not a repeat of the previous
one, which checks the type of an element embedded in the stack.
The second comparison prevents traversing paths from
a parent of an RCDATA or CDATA element and still allows displaying
the end-tag of the parent */
if (! stackptr->oldtop ||
m_element[m_stacktop->element - 1].content == M_REGEXP)
for (fsastack = stackptr->fsastack ;
fsastack ;
fsastack = fsastack->oldtop) {
for (pand = fsastack->andgroup ;
pand ;
pand = m_andgroup[pand - 1].next) {
for (usedand = fsastack->usedand ;
usedand ;
usedand = usedand->next)
if (usedand->group == pand) break ;
if (! usedand)
m_expexpand(&expstart, m_andgroup[pand - 1].start, &required,
&data) ;
}
if (required) return ;
m_expexpand(&expstart, fsastack->current, &required, &data) ;
if (! m_state[fsastack->current - 1].final) return ;
}
}
else if (m_element[stackptr->element - 1].content == M_CDATA ||
m_element[stackptr->element - 1].content == M_RCDATA)
m_expline(&expstart, &data, M_NULLVAL) ;
if (m_explimit && m_expcount > M_EXPLIMIT) return ;
/* Now report the end-tag */
m_exptend(&expstart, stackptr) ;
if (! m_element[stackptr->element - 1].emin) return ;
}
}
/* Recursive procedure first called from expecting() to display
names of elements reachable from a particular node */
void m_expexpand(expstart, node, required, data)
LOGICAL *expstart ;
M_STATE node ;
LOGICAL *required ;
LOGICAL *data ;
{
M_ARC parc ;
M_ANDGROUP pand ;
for (parc = m_state[node - 1].first ;
parc ;
parc = m_arc[parc - 1].next) {
if (m_explimit && m_expcount > M_EXPLIMIT) return ;
if (m_arc[parc - 1].group)
for (pand = m_arc[parc - 1].group ;
pand ;
pand = m_andgroup[pand - 1].next)
m_expexpand(expstart, m_andgroup[pand - 1].start, required, data) ;
else {
if (! m_state[node - 1].final) *required = TRUE ;
m_expline(expstart, data, m_arc[parc - 1].label) ;
}
}
}
/* M_expline writes one line for m_expecting() */
void m_expline(expstart, data, label)
LOGICAL *expstart ;
LOGICAL *data ;
M_ELEMENT label ;
{
char buffer[M_NAMELEN + 2*MAXD + 1] ;
if (! label && *data) return ;
if (m_excluded(label)) return ;
if (*expstart) {
sprintf(buffer, "Expecting ") ;
m_errline(buffer) ;
*expstart = FALSE ;
}
else {
sprintf(buffer, " or ") ;
m_errline(buffer) ;
}
if (m_explimit && m_expcount == M_EXPLIMIT) {
sprintf(buffer, ". . .\n") ;
m_errline(buffer) ;
}
else if (label) {
char *mb_enptr;
mb_enptr = MakeMByteString(&m_ename[m_element[label - 1].enptr]);
sprintf(buffer, "%s%s%s\n", m_stago, mb_enptr, m_tagc) ;
m_free(mb_enptr,"multi-byte string");
m_errline(buffer) ;
}
else {
sprintf(buffer, "data characters\n") ;
m_errline(buffer) ;
*data = TRUE ;
}
m_expcount++ ;
}
/* M_exptend is called from m_expecting to inform the user after an
error if an end tag is permitted */
void m_exptend(expstart, stackptr)
LOGICAL *expstart ;
M_PARSE *stackptr ;
{
char buffer[M_NAMELEN + 2*MAXD + 1] ;
if (*expstart) {
sprintf(buffer, "Expecting ") ;
m_errline(buffer) ;
*expstart = FALSE ;
}
else {
sprintf(buffer, " or ") ;
m_errline(buffer) ;
}
if (m_explimit && m_expcount == M_EXPLIMIT) {
sprintf(buffer, ". . .\n") ;
m_errline(buffer) ;
}
else if (stackptr->neednet) {
sprintf(buffer, "%s\n", m_net) ;
m_errline(buffer) ;
}
else {
char *mb_enptr;
mb_enptr =
MakeMByteString(&m_ename[m_element[stackptr->element - 1].enptr]);
sprintf(buffer, "%s%s%s\n", m_etago, mb_enptr, m_tagc) ;
m_free(mb_enptr,"multi-byte string");
m_errline(buffer) ;
}
m_expcount++ ;
}
/* M_findunique is used to test for start tag minimization. If the current
parse state permits at least one element with explicit start-tag
minimization, the left-most such element to occur in the content model
is returned. Otherwise, the contextually-required element, if any,
is returned. Finally, if the parse state permits a unique valid element,
and the flag for conformance to ISO 8879 is not set, the unique valid
element is returned by m_findunique.
Before returning, m_findunique verifies that the element to be returned
permits start-tag minimization. If not, the value is returned only if
conformance to ISO 8879 is set.
Actually m_findunique returns 1 greater than the index of the unique
element, 1 if character data is expected, and 0 (FALSE) if there is
no unique element.
*/
M_ELEMENT m_findunique(from, newleft)
M_STATE from ;
int *newleft ;
{
M_ARC parc ;
M_ELEMENT cr = 0, minim = 0;
int leftmost = M_BIGINT ;
int testleft = M_BIGINT ;
int testminim ;
M_ANDGROUP pand ;
for (parc = m_state[from - 1].first ;
parc ;
parc = m_arc[parc - 1].next) {
if (m_arc[parc - 1].group) {
if (! m_conform)
for (pand = m_arc[parc - 1].group ;
pand ;
pand = m_andgroup[pand - 1].next) {
testminim = m_findunique(m_andgroup[pand - 1].start, &testleft) ;
if (testminim && testleft < leftmost) {
minim = testminim ;
leftmost = testleft ;
}
}
}
else {
if (! m_conform) {
if (m_arc[parc - 1].minim &&
m_arc[parc - 1].minim < leftmost &&
! m_excluded(m_arc[parc - 1].label)) {
/* Save the explicitly minimizable element plus its position
in the content model */
leftmost = m_arc[parc - 1].minim ;
minim = m_arc[parc - 1].label + 1 ;
} /* End arc.minim > leftmost */
else if (m_arc[parc - 1].optional &&
parc == m_state[from - 1].first &&
! m_arc[parc - 1].next &&
m_element[m_arc[parc - 1].label -1].smin &&
! m_excluded(m_arc[parc - 1].label))
/* Save the only element that can occur */
cr = m_arc[parc - 1].label ;
} /* End if (! m_conform) */
/* Save the contextually-required element */
if (! m_arc[parc - 1].optional && ! m_excluded(m_arc[parc - 1].label))
cr = m_arc[parc - 1].label ;
} /* End if (! group) */
} /* End for parc */
*newleft = leftmost ;
if (minim) return(minim) ;
if (cr) return(cr + 1) ;
return(FALSE) ;
}
/* M_nullendtag is called when a null end tag is encountered; i.e., at the
end of a short element */
void m_nullendtag(M_NOPAR)
{
LOGICAL foundnet ;
while (m_stacktop->oldtop) {
foundnet = m_stacktop->neednet ;
if (! foundnet && ! m_element[m_stacktop->element - 1].emin) {
m_err1("Missing end tag for %s",
m_nameofelt(m_stacktop->element)) ;
m_showcurelt() ;
}
if (! m_ckend(m_stacktop->element, foundnet)) {
M_WCHAR *wc_found;
wc_found = MakeWideCharString(foundnet ? "Null" : "Implied");
m_err2("%s end tag for %s unexpected",
wc_found,
m_nameofelt(m_stacktop->element)) ;
m_free(wc_found,"wide character string");
m_expecting() ;
m_showcurelt() ;
m_frcend(m_stacktop->element) ;
}
if (foundnet) return ;
}
m_error("Internal error: Invalid stack in Nullendtag") ;
m_exit(TRUE) ;
}
/* Tests to see if an end tag may have been omitted at this point in the
parse.*/
LOGICAL m_omitend(M_NOPAR)
{
M_ANDGROUP pand ;
M_OPENFSA *fsastack ;
M_ANDLIST *usedand ;
if (! m_stacktop->oldtop) return(FALSE) ;
if (m_element[m_stacktop->element - 1].content != M_REGEXP) return(TRUE) ;
for (fsastack = m_stacktop->fsastack ;
fsastack ;
fsastack = fsastack->oldtop) {
for (pand = fsastack->andgroup ;
pand ;
pand = m_andgroup[pand - 1].next) {
/* Doesn't matter if optional submodel of and-group has occurred */
if (m_state[m_andgroup[pand - 1].start - 1].final) continue ;
for (usedand = fsastack->usedand ;
usedand ;
usedand = usedand->next)
if (usedand->group == pand) break ;
/* Required submodel of and-group has not occurred */
if (! usedand) return(FALSE) ;
}
/* Current FSA not in final state */
if (! m_state[fsastack->current - 1].final) return(FALSE) ;
}
*m_nextme = (M_MIN *) m_malloc(sizeof(M_MIN), "end-tag minimization") ;
(*m_nextme)->val = m_stacktop->element ;
(*m_nextme)->next = NULL ;
m_nextme = &(*m_nextme)->next ;
return(TRUE) ;
}
/* Tests to see if a start tag may have been omitted at this point of
the parse. If so, saves the element name in the MINVAL array*/
LOGICAL m_omitstart()
{
M_ELEMENT c = M_NULLVAL ;
/* int par ; (used in commented-out code below) */
M_OPENFSA *fsastack ;
M_ANDLIST *usedand ;
M_ANDGROUP pand ;
int leftmost = M_BIGINT ;
int newleft = M_BIGINT ;
M_ELEMENT newc = M_NULLVAL ;
LOGICAL required = FALSE ;
M_MIN *min ;
/* Make sure are in an element that has a content model */
if (m_stacktop->oldtop &&
m_element[m_stacktop->element - 1].content != M_REGEXP)
return(FALSE) ;
/* Test for unique element expected, or only allowed token is #PCDATA */
for (fsastack = m_stacktop->fsastack ;
fsastack ;
fsastack = fsastack->oldtop) {
for (pand = fsastack->andgroup ;
pand ;
pand = m_andgroup[pand - 1].next) {
for (usedand = fsastack->usedand ;
usedand ;
usedand = usedand->next)
if (usedand->group == pand) break ;
if (! usedand) {
if (! m_state[m_andgroup[pand - 1].start - 1].final)
required = TRUE ;
newc = m_findunique(m_andgroup[pand - 1].start, &newleft) ;
if (newleft < leftmost) {
leftmost = newleft ;
c = newc ;
}
}
}
if (! required) {
newc = m_findunique(fsastack->current, &newleft) ;
if (newleft < leftmost) {
leftmost = newleft ;
c = newc ;
}
}
if (c > 1) break ;
if (fsastack == m_stacktop->fsastack && newc) {
c = newc ;
break ;
}
if (m_conform) return(FALSE) ;
if (! m_state[fsastack->current - 1].final) return(FALSE) ;
}
if (! c) return(FALSE) ;
/* Have found a unique element. Can its start-tag be omitted? */
c-- ;
if (m_element[c - 1].content == M_NONE) return(FALSE) ;
if (m_element[c - 1].content == M_CDATA) return(FALSE) ;
if (m_element[c - 1].content == M_RCDATA) return(FALSE) ;
/* Following code allows start-tag to be omitted only if all required
parameters are specified:
for (par = m_element[c - 1].parptr ; par ;
par = m_parameter[par - 1].next)
if (m_parameter[par - 1].deftype == M_REQUIRED) return(FALSE) ;
*/
/* Check for recursive sequences of omitted tags */
for (min = m_minstart ; min ; min = min->next)
if (c == min->val) return(FALSE) ;
m_push(c, m_element[c - 1].start, FALSE) ;
*m_nextms = (M_MIN *) m_malloc(sizeof(M_MIN), "start-tag minimization") ;
(*m_nextms)->val = m_stacktop->element ;
(*m_nextms)->next = NULL ;
m_nextms = &(*m_nextms)->next ;
return(TRUE) ;
}

View File

@@ -0,0 +1,14 @@
/* $XConsortium: openent.c /main/3 1995/11/08 10:54:37 rswiston $ */
/* Copyright 1988, 1989 Hewlett-Packard Co. */
/* Default open SYSTEM entity procedure */
#include "userinc.h"
#include "globdec.h"
void *m_openent(entcontent)
M_WCHAR *entcontent ;
{
return((void *) fopen(entcontent, "r")) ;
}

View File

@@ -0,0 +1,14 @@
/* $XConsortium: openfrst.c /main/3 1995/11/08 10:54:51 rswiston $ */
/* Copyright 1988, 1989 Hewlett-Packard Co. */
/* Default open SYSTEM entity procedure */
#include "userinc.h"
#include "globdec.h"
void *m_openfirst(M_NOPAR)
{
return((void *) stdin) ;
}

View File

@@ -0,0 +1,38 @@
/* $XConsortium: optstrg.c /main/3 1995/11/08 10:55:04 rswiston $ */
/*
Copyright 1988, 1989 Hewlett-Packard Co.
*/
#include <stdio.h>
#include <string.h>
#include "basic.h"
#include "trie.h"
#include "dtdext.h"
#include "parser.h"
/* Get program options from a string */
void m_optstring(p)
char *p ;
{
if (strchr(p, 'a')) m_malftrace = TRUE ;
if (strchr(p, 'c')) m_chtrace = TRUE ;
if (strchr(p, 'd')) m_cdtrace = TRUE ;
if (strchr(p, 'e')) m_entdupchk = FALSE ;
if (strchr(p, 'h')) m_heapchk = TRUE ;
if (strchr(p, 'l')) m_explimit = FALSE ;
if (strchr(p, 'm')) m_conform = TRUE ;
if (strchr(p, 's')) m_scantrace = TRUE ;
if (strchr(p, 't')) m_tagtrace = TRUE ;
if (strchr(p, 'w')) m_wholetag = TRUE ;
if (strchr(p, 'A')) m_malftrace = TRUE ;
if (strchr(p, 'C')) m_chtrace = TRUE ;
if (strchr(p, 'D')) m_cdtrace = TRUE ;
if (strchr(p, 'E')) m_entdupchk = FALSE ;
if (strchr(p, 'H')) m_heapchk = TRUE ;
if (strchr(p, 'L')) m_explimit = FALSE ;
if (strchr(p, 'M')) m_conform = TRUE ;
if (strchr(p, 'S')) m_scantrace = TRUE ;
if (strchr(p, 'T')) m_tagtrace = TRUE ;
if (strchr(p, 'W')) m_wholetag = TRUE ;
}

View File

@@ -0,0 +1,338 @@
/* $XConsortium: param.c /main/3 1995/11/08 10:55:19 rswiston $ */
/*
Copyright 1986 Tandem Computers Incorporated.
This product and information is proprietary of Tandem Computers Incorporated.
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
*/
/* Param.c has procedures relevant to parameters (attributes). */
#include <string.h>
#include <stdio.h>
#include <malloc.h>
#if defined(MSDOS)
#include <process.h>
#endif
#include "basic.h"
#include "trie.h"
#include "delim.h"
#include "context.h"
#include "dtdext.h"
#include "parser.h"
#include "entext.h"
/* Process the value for the parameter whose index number was previously
saved in m_ppsave */
void m_attval(string)
M_WCHAR *string ;
{
const M_WCHAR *p ;
if (p = m_partype(m_ppsave, string)) {
if (m_parameter[m_ppsave - 1].type == M_KEYWORD)
m_poccur[m_psave] = (M_WCHAR *) p ;
else {
m_poccur[m_psave] = (M_WCHAR *)
m_malloc(w_strlen(p) + 1, "parameter value") ;
w_strcpy(m_poccur[m_psave], p) ;
m_parupper(m_ppsave, m_poccur[m_psave]) ;
}
m_updatedefault(m_ppsave, p) ;
}
else m_err2("\"%s\" -- error in value for parameter %s",
string,
&m_pname[m_parameter[m_ppsave - 1].paramname]) ;
}
/* Process a string that is a parameter value not prefixed by the parameter
name and value indicator */
LOGICAL m_attvonly(string)
M_WCHAR *string ;
{
const M_WCHAR *p ;
int par, i ;
if (! m_scanel) {
m_error("Program error in m_attvonly") ;
m_exit(TRUE) ;
}
/* First check is it a valid keyword? */
for (par = m_element[m_scanel - 1].parptr, i = 0 ;
i < m_element[m_scanel - 1].parcount ;
par++, i++)
if (m_parameter[par - 1].type == M_KEYWORD)
if (p = m_partype(par, string)) {
if (m_poccur[i])
m_err2(
"Redefinition of parameter %s. Discarding old value '%s'.",
&m_pname[m_parameter[par - 1].paramname],
m_poccur[i]) ;
m_poccur[i] = (M_WCHAR *) p ;
m_updatedefault(par, p) ;
return(TRUE) ;
}
/* It wasn't a keyword. Check for valid value for some other
parameter whose value has not yet been specified. */
for (par = m_element[m_scanel - 1].parptr, i = 0 ;
i < m_element[m_scanel - 1].parcount ;
par++, i++)
if (! m_poccur[i]) {
m_poccur[i] = (M_WCHAR *) m_partype(par, string) ;
if (m_poccur[i]) {
m_parupper(par, string) ;
m_poccur[i] = (M_WCHAR *)
m_malloc(w_strlen(string) + 1, "parameter value") ;
w_strcpy(m_poccur[i], string) ;
m_updatedefault(par, m_poccur[i]) ;
return(TRUE) ;
}
}
m_err2("%s: impossible value for any parameters of %s",
string,
m_nameofelt(m_scanel)) ;
return(FALSE) ;
}
/* Check a name previously saved in m_saveatt to see if it is the name of
a valid parameter for the current start tag */
void m_findatt(M_NOPAR)
{
int par, i ;
if (! m_scanel) {
m_error("Program error in m_findatt") ;
m_exit(TRUE) ;
}
for (par = m_element[m_scanel - 1].parptr, i = 0 ;
i < m_element[m_scanel - 1].parcount ;
par++, i++)
if (! m_wcupstrcmp(&m_pname[m_parameter[par - 1].paramname],
m_saveatt)) {
if (m_poccur[i])
m_err2("Redefinition of parameter %s. Discarding old value '%s'.",
&m_pname[m_parameter[par - 1].paramname],
m_poccur[i]) ;
m_psave = i ;
m_ppsave = par ;
return ;
}
m_attvonly(m_saveatt) ;
if (! m_wholetag) {
M_WCHAR *wc_tagc;
wc_tagc = MakeWideCharString(m_tagc);
m_err3("No %s parameter for %s (possibly missing %s)",
m_saveatt,
m_nameofelt(m_scanel),
wc_tagc) ;
m_free(wc_tagc,"multi-byte string");
}
m_undodelim(m_dlmptr[M_VI - 1], TRUE) ;
m_stcomplete() ;
m_curcon = START ;
}
/* Free the parameter storage associated with an element on the parse stack */
void m_freeparam(stackelt)
M_PARSE *stackelt ;
{
int i ;
int par ;
if (stackelt->param) {
for (i = 0, par = m_element[stackelt->element - 1].parptr - 1 ;
i < m_element[stackelt->element - 1].parcount ; i++, par++)
if (m_parameter[par].type != M_KEYWORD)
if (m_parameter[par].deftype != M_NAMEDEF ||
stackelt->param[i] != m_parameter[par].defval)
if (stackelt->param[i])
m_free(stackelt->param[i], "parameter value") ;
m_free(stackelt->param, "parameter block") ;
}
}
/* Force a parameter value to uppercase, if appropriate for its type.
Also, if list-valued attribute, remove leading and trailing spaces,
and condense white-space sequences to a single blank*/
void m_parupper(par, string)
int par ;
M_WCHAR *string ;
{
M_WCHAR *p ;
M_WCHAR *q ;
int i ;
switch (m_parameter[par - 1].type) {
case M_ID:
case M_IDRF:
case M_NAMEPAR:
case M_NMTOKEN:
case M_NUTOKEN:
case M_ENTATT:
for ( ; *string ; string++)
*string = m_ctupper(*string) ;
return ;
case M_IDRFS:
case M_NAMES:
case M_NMSTOKEN:
case M_NUSTOKEN:
case M_NUMS:
for (p = string; *p ; p++)
if (! m_whitespace(*p)) break ;
w_strcpy(string, p) ;
for (p = string, i = 0 ; *p ; p++, i++)
*p = m_ctupper(*p) ;
if (m_whitespace(*p)) {
*p = M_SPACE ;
for (q = p + 1 ; m_whitespace(*q); q++) ;
w_strcpy(p + 1, q) ;
}
if (i && m_whitespace(string[i - 1])) string[i - 1] = M_EOS ;
return ;
default:
for ( ; *string ; string++)
if (*string == M_RE || *string == M_TAB) *string = M_SPACE ;
return ;
}
}
/* Set all parameters to their default values for an element included by
tag minimization */
void m_stkdefaultparams(M_NOPAR)
{
int i, par = 0 ;
m_stacktop->param = (M_WCHAR **)
m_malloc(
m_element[m_stacktop->element - 1].parcount * sizeof(M_WCHAR *),
"parameter block") ;
for (i = 0, par = m_element[m_stacktop->element - 1].parptr ;
i < m_element[m_stacktop->element - 1].parcount ;
i++, par++)
m_stkonedef(par, m_stacktop->element, m_stacktop->param, i) ;
m_strtaction(m_stacktop->element) ;
}
/* Stack one default parameter */
void m_stkonedef(par, scanel, poccur, i)
int par ;
M_ELEMENT scanel ;
M_WCHAR **poccur ;
int i ;
{
if (m_parameter[par - 1].deftype == M_REQUIRED ||
(m_parameter[par - 1].deftype == M_CURRENT &&
! m_parameter[par - 1].defval))
m_err2("Missing value for %s parameter of element %s",
&m_pname[m_parameter[par - 1].paramname],
m_nameofelt(scanel)) ;
poccur[i] = m_parameter[par - 1].defval ;
if (! m_parameter[par - 1].defval) return ;
if (m_parameter[par - 1].type == M_KEYWORD) return ;
/* If parameter is an entity name, the default is usable only if
the name is that of a defined entity */
if (m_parameter[par - 1].type == M_ENTATT)
if (! (M_ENTITY *)
m_lookfortrie(m_parameter[par - 1].defval, m_enttrie)) {
m_err1("Interface error: Default entity %s undefined", poccur[i]) ;
poccur[i] = NULL ;
return ;
}
/* Non-null, non-keyword current default must go on stack, since
default could change in a subelement */
if (m_parameter[par - 1].deftype != M_CURRENT &&
m_parameter[par - 1].deftype != M_CHANGEDCUR) return ;
poccur[i] = (M_WCHAR *)
m_malloc(w_strlen(poccur[i]) + 1, "parameter value") ;
w_strcpy(poccur[i], m_parameter[par - 1].defval) ;
}
/* Stack parameter values */
void m_stkparams(M_NOPAR)
{
int i, par ;
m_stacktop->param = (M_WCHAR **)
m_malloc(
m_element[m_stacktop->element - 1].parcount * sizeof(M_WCHAR *),
"parameter block") ;
for (i = 0, par = m_element[m_scanel - 1].parptr ;
i < m_element[m_scanel - 1].parcount ;
i++, par++) {
if (! m_poccur[i]) m_stkonedef(par, m_scanel, m_stacktop->param, i) ;
else m_stacktop->param[i] = m_poccur[i] ;
}
m_strtaction(m_stacktop->element) ;
}
/* Update the default of a parameter whose default is #CURRENT */
#if defined(M_PROTO)
void m_updatedefault(const int par , const M_WCHAR *string )
#else
void m_updatedefault(par, string)
int par ;
M_WCHAR *string ;
#endif /* M_PROTO */
{
if (m_parameter[par - 1].deftype != M_CURRENT &&
m_parameter[par - 1].deftype != M_CHANGEDCUR) return ;
/* For keyword parameters, the string is already saved in the
keyword array; for entities, it is saved with the entity structure */
/* In light of the above comment, why does the following if statement
not test for parameters of type entity? */
if (m_parameter[par - 1].type == M_KEYWORD)
m_parameter[par - 1].defval = (M_WCHAR *) string ;
/* Save value in allocated storage */
else {
if (m_parameter[par - 1].deftype == M_CHANGEDCUR)
m_free(m_parameter[par - 1].defval, "updateable default") ;
m_parameter[par - 1].defval = (M_WCHAR *)
m_malloc(w_strlen(string) + 1, "updateable default") ;
w_strcpy(m_parameter[par - 1].defval, string) ;
}
m_parameter[par - 1].deftype = M_CHANGEDCUR ;
}
/* Check to see if a string that occurs after the element name in a start
tag is a valid parameter name or value; if not, assume tag is ended */
LOGICAL m_validinpar(string)
M_WCHAR *string ;
{
int par ;
M_WCHAR *p ;
int i ;
M_WCHAR *wc_tagc;
if (! m_scanel) {
m_error("Program error in m_validinpar") ;
m_exit(TRUE) ;
}
for (par = m_element[m_scanel - 1].parptr, i = 0 ;
i < m_element[m_scanel - 1].parcount ;
par++, i++) {
/* Check if valid name of a parameter */
if (! m_wcupstrcmp(&m_pname[m_parameter[par - 1].paramname], string))
return(TRUE) ;
/* Check if possible value of a keyword parameter or of a non-keyword
parameter that has not yet occurred*/
if (m_partype(par, string) &&
(m_parameter[par - 1].type == M_KEYWORD || ! m_poccur[i]))
return(TRUE) ;
}
wc_tagc = MakeWideCharString(m_tagc);
if (! m_wholetag) m_err1("Invalid parameter or missing %s", wc_tagc) ;
m_free(wc_tagc,"wide character string");
m_stcomplete() ;
m_curcon = POUNDCDATA ;
for (p = string ; *p ; p++) ;
for (p-- ; p >= string ; p--) m_ungetachar((int) *p, M_NORMAL, TRUE) ;
return(FALSE) ;
}
#include "paramu.c"

View File

@@ -0,0 +1,22 @@
/* $XConsortium: parcount.c /main/3 1995/11/08 10:55:34 rswiston $ */
/*
Copyright 1989 Hewlett-Packard Co.
*/
#include <stdio.h>
#include "basic.h"
#include "trie.h"
#include "dtdext.h"
#include "parser.h"
/* Function callable by interface designers. Returns number of parameters
of specified element (-1 indicates error). */
int m_parcount(elt)
M_WCHAR *elt ;
{
M_ELEMENT eltid ;
if (! (eltid = m_packedlook(m_entree, elt))) return(-1) ;
return(m_element[eltid - 1].parcount) ;
}

View File

@@ -0,0 +1,39 @@
/* $XConsortium: pardef.c /main/3 1995/11/08 10:55:48 rswiston $ */
/*
Copyright 1989 Hewlett-Packard Co.
*/
#include <stdio.h>
#include "basic.h"
#include "trie.h"
#include "dtdext.h"
#include "parser.h"
/* Function callable by interface designers. Returns pointer to default
value of a parameter of an element. Type is set to indicate type of
default. Error indication is type is 0 and function returns NULL. */
M_WCHAR *m_pardefault(elt, param, type)
M_WCHAR *elt ;
M_WCHAR *param ;
unsigned char *type ;
{
M_ELEMENT eltid ;
int par ;
int i ;
*type = M_NULLVAL ;
if (! (eltid = m_packedlook(m_entree, elt))) return(NULL) ;
for (par = m_element[eltid - 1].parptr, i = 0 ;
i < m_element[eltid - 1].parcount ;
par++, i++)
if (! m_wcupstrcmp(&m_pname[m_parameter[par - 1].paramname], param)) {
*type = (unsigned char) m_parameter[par - 1].deftype ;
if (*type == M_REQUIRED || *type == M_NULLDEF) return(NULL) ;
return(m_parameter[par -1].defval) ;
}
/* Can't find the parameter */
return(NULL) ;
}

View File

@@ -0,0 +1,27 @@
/* $XConsortium: parent.c /main/3 1995/11/08 10:56:02 rswiston $ */
/*
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
*/
#include <stdio.h>
#include "basic.h"
#include "trie.h"
#include "dtdext.h"
#include "parser.h"
/* Procedure callable by interface designers. Returns pointer to name
of nth level parent of current element (0 is self, 1 is parent, 2
is grandparent, etc.) */
M_WCHAR *m_parent(n)
int n ;
{
M_PARSE *stackptr ;
for (stackptr = m_stacktop ;
stackptr->oldtop && n >= 0 ;
stackptr = stackptr->oldtop, n--) {
if (! n)
return(m_nameofelt(stackptr->element)) ;
}
return(NULL) ;
}

View File

@@ -0,0 +1,36 @@
/* $XConsortium: parname.c /main/3 1995/11/08 10:56:15 rswiston $ */
/*
Copyright 1989 Hewlett-Packard Co.
*/
#include <stdio.h>
#include "basic.h"
#include "trie.h"
#include "dtdext.h"
#include "parser.h"
/* Function callable by interface designers. Returns name of nth parameter
of specified element (NULL indicates error). */
M_WCHAR *m_parname(elt, n)
M_WCHAR *elt ;
int n ;
{
M_ELEMENT eltid ;
if (! (eltid = m_packedlook(m_entree, elt))) return(NULL) ;
if (n < 1 || n > m_element[eltid - 1].parcount) return(NULL) ;
return(&m_pname[m_parameter[(n - 1) + m_element[eltid - 1].parptr - 1].
paramname]) ;
}
M_WCHAR *m_mbparname(elt, n)
char *elt ;
int n ;
{
M_WCHAR *wc_elt, *retval;
wc_elt = MakeWideCharString(elt);
retval = m_parname(wc_elt, n);
m_free(wc_elt,"wide character string");
}

View File

@@ -0,0 +1,90 @@
/* $XConsortium: parser.c /main/3 1995/11/08 10:56:28 rswiston $ */
/* Parser.c contains the main procedure for program PARSER */
#include <string.h>
#include <stdio.h>
#include <malloc.h>
#include "basic.h"
#include "trie.h"
#include "dtdext.h"
#include "context.h"
#include "delim.h"
#include "parser.h"
#include "if.h"
#include "entext.h"
/* Main procedure */
void main(argc, argv)
int argc ;
char **argv ;
{
static char parserr[] = "\nM_token=%d, m_prevcon=%d, m_scanval=%d\n" ;
static char sopt[] =
"prevcon=%d,token=%d,curcon=%d,scanval='%c'(%d),line=%d,netlevel=%d\n" ;
static char name[] = "m_name = '%s'\n" ;
static char literal[] = "m_literal = '%s'\n" ;
#if defined(hpux) || defined(_AIX) || defined(sun) || defined(USL) || defined(__uxp__) || defined(__osf__)
char buffer[M_LITLEN + 80] ;
#else
#define max4(a,b,c,d) (a>b&&a>c&&a>d) ? a : ((b>c&&b>d) ? b : (c>d ? c : d))
M_WCHAR buffer[max4(sizeof(parserr) + 3,
sizeof(sopt) + 6,
sizeof(name) + M_NAMELEN - 2,
sizeof(literal) + M_LITLEN - 2)] ;
#endif
m_argc = argc ;
m_argv = argv ;
m_strtcase(1) ;
m_globss() ;
m_setoptions() ;
m_initialize() ;
while (TRUE) {
m_token = m_scan() ;
m_prevcon = m_curcon ;
m_curcon = m_newcon(m_prevcon - 1, m_token - 1) ;
if (! m_curcon) {
if (m_token != M_ENDFILE) {
m_error("Parsing table error") ;
sprintf(buffer, parserr, m_token, m_prevcon, m_scanval) ;
m_errline(buffer) ;
}
else {
m_error("Unexpected end of document") ;
m_showcurelt() ;
}
m_done() ;
}
if ((! m_stacktop->oldtop) &&
m_start &&
! m_aftereod &&
m_state[m_stacktop->fsastack->current - 1].final &&
(m_token != M_ENDFILE) &&
(m_token != M_TEXT || ! m_whitespace((M_WCHAR) m_scanval))
) {
m_error("Expecting end of document") ;
m_aftereod = TRUE ;
}
if (m_scantrace) {
sprintf(buffer, sopt,
m_prevcon, m_token, m_curcon, m_scanval ? m_scanval : ' ',
m_scanval, m_line[m_sysecnt], m_netlevel) ;
m_trace(buffer) ;
if (m_token == M_NAME) {
sprintf(buffer, name, m_name) ;
m_trace(buffer) ;
}
if (m_token == M_LITERAL) {
sprintf(buffer, literal, m_literal) ;
m_trace(buffer) ;
}
}
#include "case.c"
m_adjuststate() ;
if (m_token == M_ENDFILE) break ;
}
/* At EOF */
m_done() ;
}

View File

@@ -0,0 +1,435 @@
/* $XConsortium: parser.h /main/3 1995/11/08 10:56:42 rswiston $ */
/*
Copyright 1986 Tandem Computers Incorporated.
This product and information is proprietary of Tandem Computers Incorporated.
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
*/
/* Parser.h allocates global variables for PARSER */
#if defined(M_PARDEF)
#define M_PAREXTERN
#define M_PARINIT(a) = a
#else
#define M_PAREXTERN extern
#define M_PARINIT(a)
#endif
#include "common.h"
/* Stack of open entities and line number in each external file */
#define M_ENTLVL 16 /* Maximum number of open entities */
M_PAREXTERN M_ENTITY *m_opene[M_ENTLVL] ;
M_PAREXTERN int m_eopencnt M_PARINIT(0) ;
M_PAREXTERN void *m_sysent[M_ENTLVL + 1] ;
#define M_FIRSTLINE 1
M_PAREXTERN int m_line[M_ENTLVL + 1] M_PARINIT({M_FIRSTLINE}) ;
M_PAREXTERN int m_sysecnt M_PARINIT(0) ;
/* Possible states of a line -- no SGML characters yet processed, SGML
characters processed but no data character or contextual end tag,
data character or contextual end tag (i.e., end tag of a proper
subelement) has occurred. Note that linestat is stacked with each
element. If an element contains a line that
* is neither its first nor last line
* contains data characters within an included element
the status of the line should be M_SOMETHING not M_DCORCET because the data
characters belong to the inner element rather than the outer one.
Also note that "M_DCORCET" originally stood for "data character or contextual
end tag" when the Standard used the term "contextual element" to mean
an element allowed by a model rather than an inclusion and when
the rules for ignoring RE's referred to the occurrence of end tags of
such elements rather than the entire elements. Now the acronym can be
interpreted as "data character or contextual element".
*/
#define M_NOTHING 0
#define M_SOMETHING 1
#define M_DCORCET 2
/* Definitions for parse stack. The primary data structure of PARSER
is a stack containing one entry for each open element. Each entry
on the stack is described in an m_parse structure. Entries for
element's whose content is defined by a content model have a
pointer to a stack of open FSAs. These FSA stacks do not describe
the actual automata (which are coded in the data structures
generated by BUILD, but rather the current state in the active
automata. An element's FSA stack will have one entry for the
content model and an additional entry for each active and-group.
*/
typedef struct m_parse M_PARSE ;
typedef struct m_openfsa M_OPENFSA ;
typedef struct m_andlist M_ANDLIST ;
struct m_parse {
/* Pointer to preceding entry on stack */
M_PARSE *oldtop ;
/* Identifier of element this entry represents */
M_ELEMENT element ;
/* Pointer to table of parameter pointers for this instance of this
element */
M_WCHAR **param ;
/* Pointer to stack of open FSAs for this element */
M_OPENFSA *fsastack ;
/* For RCDATA elements to indicate the nesting level
of entities when the element opened, since net and etago
delimiters are not recognized except in the same entity
as the element began. */
int thisent ;
/* TRUE iff the element's start-tag ended with a NET so that a NET
is expected to end the element */
LOGICAL neednet ;
/* Has a Record End occurred in the element's content? */
LOGICAL firstre ;
/* Flag that indicates whether the element is contextual, i.e.,
whether it occurred because it was allowed in context by a
content model, or it was allowed by an inclusion exception or
occurred by error. (The term "contextual subelement" was used
in the Draft International Standard in the same sense as
"proper subelement" in the International Standard.) */
LOGICAL contextual ;
/* Whether character data is currently being processed. */
LOGICAL intext ;
/* Line status. Indicates whether anything has occurred after
the start-tag or most recent Record Start in this element */
char linestat ;
/* Flag indicating whether or not a Record End (carriage return)
has been scanned and is being held to see if there is more
content in the element. If there is, the RE will be processed
as a data character, otherwise it will be discarded. */
LOGICAL holdre ;
/* Pointer to the element's short reference map. The value is NULL
if there is no map. */
int *map ;
/* Index in actions for processing text characters encountered
in this element, and pointer to stack location where parameters
should be retrieved. */
int cdcase ;
M_PARSE *cdparam ;
/* Index in actions for processing processing instructions
encountered in this element, and pointer to stack location where
parameters should be retrieved. */
int picase ;
M_PARSE *piparam ;
/* Index in actions for processing start- and end-strings
encountered in this element, and pointer to stack location where
parameters should be retrieved. */
int stccase ;
M_PARSE *stparam ;
/* Pointer to name of input file in which the current element
began (NULL if primary input file). */
M_WCHAR *file ;
/* Line number where the current element began. */
int line ;
/* Interface-defined pointer stored on the stack */
void *ifdata ;
} ;
struct m_openfsa {
/* Pointer to preceding entry on FSA stack */
M_OPENFSA *oldtop ;
/* Current state in this FSA */
M_STATE current ;
/* Identifier of set of and-groups being processed and pointer to list of
and-groups that have occurred within this set. */
M_ANDGROUP andgroup ;
M_ANDLIST *usedand ;
} ;
struct m_andlist {
M_ANDGROUP group ;
M_ANDLIST *next ;
} ;
extern M_OPENFSA m_botfsa ;
/* Bottom marker of parse stack */
M_PAREXTERN M_PARSE m_stackbot
#if defined(M_PARDEF)
= {
/* M_PARSE *oldtop ;*/ NULL,
/* M_ELEMENT element ;*/ M_NULLVAL,
/* M_WCHAR **param ;*/ NULL,
/* M_OPENFSA *fsastack ;*/ &m_botfsa,
/* int thisent ;*/ 0,
/* LOGICAL neednet ;*/ FALSE,
/* LOGICAL firstre ; */ FALSE,
/* LOGICAL contextual ;*/ TRUE,
/* LOGICAL intext ;*/ FALSE,
/* int linestat ;*/ M_NOTHING,
/* LOGICAL holdre ;*/ FALSE,
/* int *map ;*/ NULL,
/* int cdcase ;*/ 1,
/* M_PARSE *cdparam ;*/ &m_stackbot,
/* int picase ;*/ 1,
/* M_PARSE *piparam ;*/ &m_stackbot,
/* int stccase ;*/ 1,
/* M_PARSE *stparam ;*/ &m_stackbot,
/* M_WCHAR *file ;*/ NULL,
/* int line ;*/ M_FIRSTLINE,
/* void *ifdata ;*/ NULL,
}
#endif
;
M_PAREXTERN M_OPENFSA m_botfsa
#if defined(M_PARDEF)
= {
/* M_OPENFSA *oldtop ;*/ NULL,
/* M_STATE current ;*/ 1,
/* M_ANDGROUP andgroup ;*/ M_NULLVAL,
/* M_ANDGROUP *usedand ;*/ NULL,
}
#endif
;
/* Index of current top of parse stack */
M_PAREXTERN M_PARSE *m_stacktop M_PARINIT(&m_stackbot) ;
/* Pointer to stack location where parameters for current code
segment are defined. Used for inherited code segments (text-code,
pi-code, string-code) */
M_PAREXTERN M_PARSE *m_stackpar ;
/* Type of characters */
typedef char M_HOLDTYPE ;
#if defined(M_PARDEF)
#include "chartype.h"
#else
extern M_CHARTYPE m_ctarray[M_CHARSETLEN] ;
#endif
/* Indicates a start tag is allowed by an inclusion exception */
#define M_NONCONTEXTUAL 2
/* Character used to delimit parameter names in start and end strings
entered as data to ELTDEF */
#define M_ESCAPECHAR '@'
/* Pointer to name of element */
#define m_nameofelt(x) &m_ename[m_element[x - 1].enptr]
/* Status of characters as read from input stream */
#define M_EE 0
#define M_NORMAL 1
#define M_CDCHAR 2
#define M_ENTNORMAL 3
/* State transition network generated by CONTEXT */
#include "sparse.h"
/* Maximum length of a sequence of blanks in a short reference delimiter */
#define M_BSEQLEN 100
/* #defines used in recognition of short reference delimiters */
#if defined(M_PARDEF)
#define M_HOLDSIZ M_MAXSR + M_BSEQLEN * M_MAXSEQ + 1
#else
#define M_HOLDSIZ
#endif
#define M_REGCHAR 1
#define M_SEQCHAR 2
#define M_BSCHAR 3
#define M_WSCHAR 4
#define M_RSCHAR 5
/* Number of allowable tokens to display after a syntax error */
#define M_EXPLIMIT 5
/* Status of T option output */
#define M_TOPTSTARTTAG 0
#define M_WHITESPACE 1
#define M_OTHER 2
/* Maximum length of processing instruction (not in a PI entity) */
#define M_PILEN 240
/* Storage for a name token just read by the scanner; and for a name read
while parsing parameters */
M_PAREXTERN M_WCHAR m_name[M_NAMELEN + 1] ;
M_PAREXTERN M_WCHAR m_saveatt[M_NAMELEN + 1] ;
/* M_curcon is current state of FSA that controls parser; m_prevcon is the
value of m_curcon before last character was scanned; m_token is the token
type returned by last call to scanner; and
m_scanval is index of element name just read within tag delimiters */
M_PAREXTERN int m_curcon M_PARINIT(PREAMBLE) ;
M_PAREXTERN int m_prevcon ;
M_PAREXTERN int m_token ;
M_PAREXTERN int m_scanval ;
/* Declarations for tentative list of omitted tags when checking for tag
MINimization */
typedef struct m_min M_MIN ;
struct m_min {
int val ;
M_MIN *next ;
} ;
M_PAREXTERN M_MIN *m_minstart ;
M_PAREXTERN M_MIN *m_minend ;
M_PAREXTERN M_MIN **m_nextms ;
M_PAREXTERN M_MIN **m_nextme ;
/* Count of the number of open elements expecting to be terminated with
a NET */
M_PAREXTERN int m_netlevel M_PARINIT(0) ;
/* Count of errors that have occurred */
M_PAREXTERN int m_errcnt M_PARINIT(0) ;
#define M_ERRLIM 100
M_PAREXTERN int m_errlim M_PARINIT(M_ERRLIM) ;
M_PAREXTERN int m_expcount ;
M_PAREXTERN LOGICAL m_errexit M_PARINIT(FALSE) ;
/* Flag to indicate whether processing of the text has begun */
M_PAREXTERN LOGICAL m_start M_PARINIT(FALSE) ;
/* Flag indicates whether current start tag is terminated by End-tag
indicator or by tag-close delimiter (or start of another tag) */
M_PAREXTERN LOGICAL m_scannet ;
/* Storage for literals */
M_PAREXTERN M_WCHAR m_literal[M_LITLEN + 1] ;
/* Buffer for sequence of white space that has been read before it is
determined whether or not the white space is significant */
#define M_WSPACELEN 100
M_PAREXTERN int m_wspace[M_WSPACELEN] ;
M_PAREXTERN int m_wscount M_PARINIT(0) ;
M_PAREXTERN int m_maxws M_PARINIT(0) ;
M_PAREXTERN int m_wsused ;
/* Temporary pointers to parameter values. Used while scanning start tag
before element is placed on parse stack.*/
M_PAREXTERN
#if defined M_PROTO
#endif
M_WCHAR *m_poccur[
#if defined(M_PARDEF)
M_MAXPAR ? M_MAXPAR : 1
#endif
] ;
/* Index of a particular parameter within the parameter list for a given
element */
M_PAREXTERN int m_psave ;
/* Index of a particular parameter within the list of all parameters for all
elements */
M_PAREXTERN int m_ppsave ;
/* Index of element of tag just scanned; may be result of short tag
minimization */
M_PAREXTERN M_ELEMENT m_scanel ;
/* Read-ahead buffer and number of characters currently in that buffer */
#define M_SAVECHAR 500
M_PAREXTERN int m_savechar[M_SAVECHAR] ;
M_PAREXTERN M_WCHAR m_savedchar[M_SAVECHAR] ;
M_PAREXTERN M_WCHAR m_oldlinestat[M_SAVECHAR] ;
M_PAREXTERN M_WCHAR m_oldatrs[M_SAVECHAR] ;
M_PAREXTERN int m_sourcefile[M_SAVECHAR] ;
M_PAREXTERN M_WCHAR m_atrs M_PARINIT(TRUE) ;
M_PAREXTERN int m_oldlsindex M_PARINIT(M_SAVECHAR - 1) ;
M_PAREXTERN int m_toundo M_PARINIT(0) ;
M_PAREXTERN int m_maxundo M_PARINIT(0) ;
#define M_LINELENGTH 80
M_PAREXTERN int m_saveline[M_LINELENGTH][M_ENTLVL + 1] ;
M_PAREXTERN int m_svlncnt[M_ENTLVL + 1] M_PARINIT({0}) ;
M_PAREXTERN LOGICAL m_svlnwrap[M_ENTLVL + 1] M_PARINIT({FALSE}) ;
/* Arrays used for short references */
M_PAREXTERN int m_hold[M_HOLDSIZ] ;
M_PAREXTERN M_HOLDTYPE m_dhold[M_HOLDSIZ] ;
M_PAREXTERN int m_delim[M_HOLDSIZ] ;
M_PAREXTERN char m_srefchartype[M_HOLDSIZ] ;
M_PAREXTERN int m_current[M_HOLDSIZ] ;
/* Options
A -- Trace of calls to m_malloc() and m_free()
B --
C -- Trace of calls to m_getachar(), putachar()
D -- Trace of encountered data characters
E -- Don't report duplicate entity declarations
F --
G --
H -- M_malloc and m_free check for valid heap
I --
J --
K --
L -- Don't limit number of possible tokens displayed by expecting()
M -- Determine start-tag minimization strictly according to the Standard
N --
O --
P --
Q --
R --
S -- Scanner trace
T -- Tag trace
U --
V --
W -- Missing tagc not considered an error
X --
Y --
Z --
*/
M_PAREXTERN LOGICAL m_malftrace M_PARINIT(FALSE) ;
M_PAREXTERN LOGICAL m_chtrace M_PARINIT(FALSE) ;
M_PAREXTERN LOGICAL m_cdtrace M_PARINIT(FALSE) ;
M_PAREXTERN LOGICAL m_entdupchk M_PARINIT(TRUE) ;
M_PAREXTERN LOGICAL m_heapchk M_PARINIT(FALSE) ;
M_PAREXTERN LOGICAL m_explimit M_PARINIT(TRUE) ;
M_PAREXTERN LOGICAL m_conform M_PARINIT(FALSE) ;
M_PAREXTERN LOGICAL m_scantrace M_PARINIT(FALSE) ;
M_PAREXTERN LOGICAL m_tagtrace M_PARINIT(FALSE) ;
M_PAREXTERN LOGICAL m_wholetag M_PARINIT(FALSE) ;
M_PAREXTERN int m_toptstat ;
/* Flag that indicates when unexpected content detected after document
appears to be complete */
M_PAREXTERN LOGICAL m_aftereod M_PARINIT(FALSE) ;
/* Save standard C main program arguments */
M_PAREXTERN int m_argc ;
M_PAREXTERN char **m_argv ;
/* PARSER output file */
M_PAREXTERN FILE *m_outfile M_PARINIT(stdout) ;
M_PAREXTERN FILE *m_errfile M_PARINIT(stderr) ;
/* Save processing instruction */
M_PAREXTERN M_WCHAR m_pi[M_PILEN + 1] ;
M_PAREXTERN int m_pilen M_PARINIT(0) ;
/* Entity being defined */
M_PAREXTERN M_ENTITY *m_entity ;
M_PAREXTERN int m_entclen ;
M_PAREXTERN M_WCHAR m_entcontent[M_LITLEN + 1] ;
/* Largest positive integer */
#define M_BIGINT 0x7FFF
/* Include function prototypes */
#include "proto.h"

View File

@@ -0,0 +1,118 @@
/* $XConsortium: parutil.c /main/3 1995/11/08 10:56:57 rswiston $ */
/*
Copyright 1986 Tandem Computers Incorporated.
This product and information is proprietary of Tandem Computers Incorporated.
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
*/
/* Parutil.c contains utility functions for program PARSER */
#include <string.h>
#include <stdio.h>
#include <malloc.h>
#include <locale.h>
#if defined(MSDOS)
#include <process.h>
#endif
#include "basic.h"
#include "trie.h"
#include "dtdext.h"
#include "delim.h"
#include "context.h"
#include "parser.h"
#include "entext.h"
#include "if.h"
#include "version.h"
/* Adjust parsing state after each token if necessary */
void m_adjuststate(M_NOPAR)
{
if (m_curcon == START) {
if (m_netlevel) {
if (m_stacktop->intext) m_curcon = NETCDATA ;
else if (m_textpermitted()) m_curcon = NETDATACON ;
else m_curcon = NETELCON ;
}
else {
if (m_stacktop->intext) m_curcon = POUNDCDATA ;
else if (m_textpermitted()) m_curcon = DATACON ;
else m_curcon = ELCON ;
}
}
else if (m_netlevel) switch(m_curcon) {
case POUNDCDATA:
m_curcon = NETCDATA ;
break ;
case CDATAEL:
if (m_stacktop->neednet) m_curcon = NETELCDATA ;
break ;
case RCDATAEL:
if (m_stacktop->neednet) m_curcon = NETRCDATA ;
break ;
default:
break ;
}
}
/* Tests whether the element named in a tag is defined; if so, returns its
index; otherwise return FALSE */
M_ELEMENT m_eltname(M_NOPAR)
{
M_ELEMENT eltid ;
if (eltid = m_packedlook(m_entree, m_name)) return(eltid) ;
else {
m_err1("Undefined element %s", m_name) ;
return(FALSE) ;
}
}
int get_mb_cur_max()
{
char *l;
int i;
l = getenv("LANG");
i = MB_CUR_MAX;
return i;
}
/* Program initialization */
void m_initialize(M_NOPAR)
{
char **mb_delims;
M_WCHAR **wc_delims;
m_signmsg(m_conform ?
"MARKUP PARSER " :
"MARKUP PARSER (with non-canonical SGML enhancements) ") ;
m_signmsg(M_VERSION) ;
m_signmsg("\n") ;
m_signmsg("(c) Copyright 1993, 1994, 1995 Hewlett-Packard Company\n");
m_signmsg("(c) Copyright 1993, 1994, 1995 International Business Machines Corp.\n");
m_signmsg("(c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.\n");
m_signmsg("(c) Copyright 1993, 1994, 1995 Unix System Labs, Inc., a subsidiary of Novell, Inc.\n");
/* commented out since date stamp interfers with testing -- bad reason
m_getsignon() ;
*/
if (! (m_sysent[m_sysecnt] = m_openfirst()))
{
m_error("Unable to open input file") ;
m_exit(TRUE) ;
}
setlocale(LC_ALL, "");
get_mb_cur_max();
mb_delims = mb_dlmptr;
wc_delims = m_dlmptr;
while (*mb_delims)
{
*wc_delims++ = MakeWideCharString(*mb_delims);
mb_delims++;
}
*wc_delims = 0;
}

View File

@@ -0,0 +1,39 @@
/* $XConsortium: parvalok.c /main/3 1995/11/08 10:57:12 rswiston $ */
/*
Copyright 1989 Hewlett-Packard Co.
*/
#include <stdio.h>
#include "basic.h"
#include "trie.h"
#include "dtdext.h"
#include "parser.h"
/* Function callable by interface designers. Returns TRUE if specified value
is a legal value for the indicated parameter of the given element,
FALSE otherwise. */
#if defined(M_PROTO)
LOGICAL m_parvalok( M_WCHAR *elt , M_WCHAR *param , const M_WCHAR *value )
#else
LOGICAL m_parvalok(elt, param, value)
M_WCHAR *elt ;
M_WCHAR *param ;
M_WCHAR *value ;
#endif /* M_PROTO */
{
M_ELEMENT eltid ;
int par ;
int i ;
if (! (eltid = m_packedlook(m_entree, elt))) return(FALSE) ;
for (par = m_element[eltid - 1].parptr, i = 1 ;
i <= m_element[eltid - 1].parcount ;
par++, i++)
if (! m_wcupstrcmp(&m_pname[m_parameter[par - 1].paramname], param))
if (m_partype(par, value)) return(TRUE) ;
else return(FALSE) ;
/* No such parameter */
return(FALSE) ;
}

View File

@@ -0,0 +1,27 @@
/* $XConsortium: pi.c /main/3 1995/11/08 10:57:26 rswiston $ */
/*
Copyright 1986 Tandem Computers Incorporated.
This product and information is proprietary of Tandem Computers Incorporated.
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
*/
/* Pi.c executes pi-code specified in the interface. */
#include "userinc.h"
#include "globdec.h"
/* Include generated code */
#include "pfile.c"
/* When a processing instruction or SDATA entity other than a CODE entity
occurs */
void m_piaction(m_pi, m_entname, m_enttype)
M_WCHAR *m_pi ;
M_WCHAR *m_entname ;
int m_enttype ;
{
m_stackpar = m_stacktop->piparam ;
(*m_ptable[m_stacktop->picase])(m_pi, m_entname, m_enttype) ;
}

View File

@@ -0,0 +1,17 @@
/* $XConsortium: procscmp.c /main/3 1995/11/08 10:57:41 rswiston $ */
/*
Copyright 1986 Tandem Computers Incorporated.
This product and information is proprietary of Tandem Computers Incorporated.
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
*/
/* Procscmp.c prefixes the interface's procs.c file with appropriate
declarations so it can be compiled. */
#include "userinc.h"
#include "globdec.h"
/* Include any procedures specified by the interface designer */
#include "procs.c"

View File

@@ -0,0 +1,825 @@
/* $XConsortium: proto.h /main/3 1995/11/08 10:57:56 rswiston $ */
int m_actgetc(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void m_adjuststate(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
LOGICAL m_allwhite(
#if defined(M_PROTO)
const M_WCHAR *string
#endif
) ;
void m_attval(
#if defined(M_PROTO)
M_WCHAR *string
#endif
) ;
LOGICAL m_attvonly(
#if defined(M_PROTO)
M_WCHAR *string
#endif
) ;
int m_checkstart(
#if defined(M_PROTO)
M_ELEMENT val
#endif
) ;
LOGICAL m_ckend(
#if defined(M_PROTO)
M_ELEMENT val, LOGICAL neednet
#endif
) ;
void m_ckmap(
#if defined(M_PROTO)
M_WCHAR *name, LOGICAL useoradd
#endif
) ;
void m_closent(
#if defined(M_PROTO)
void *m_ptr
#endif
) ;
void m_codeent(
#if defined(M_PROTO)
int m_ent
#endif
) ;
M_PARSE *m_copystackelt(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
M_WCHAR *m_cyclent(
#if defined(M_PROTO)
LOGICAL init, unsigned char *type, M_WCHAR **content,
unsigned char *wheredef
#endif
) ;
void m_dispcurelt(
#if defined(M_PROTO)
M_WCHAR *file, int line
#endif
) ;
void m_done(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void m_dumpline(
#if defined(M_PROTO)
M_WCHAR *file, int line
#endif
) ;
void m_eduptype(
#if defined(M_PROTO)
int type
#endif
) ;
M_ELEMENT m_eltname(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void m_endaction(
#if defined(M_PROTO)
M_ELEMENT m_elt
#endif
) ;
void m_endcase(
#if defined(M_PROTO)
int m_action
#endif
) ;
void m_endtag(
#if defined(M_PROTO)
M_ELEMENT c
#endif
) ;
void m_entexpand(
#if defined(M_PROTO)
M_ENTITY *openent
#endif
) ;
void m_eprefix(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void m_err1(
#if defined(M_PROTO)
const char *text, const M_WCHAR *arg
#endif
) ;
void m_err2(
#if defined(M_PROTO)
const char *text, const M_WCHAR *arg1, const M_WCHAR *arg2
#endif
) ;
void m_err3(
#if defined(M_PROTO)
char *text, M_WCHAR *arg1, M_WCHAR *arg2, M_WCHAR *arg3
#endif
) ;
void m_err4(
#if defined(M_PROTO)
char *text, M_WCHAR *arg1, M_WCHAR *arg2, M_WCHAR *arg3, M_WCHAR *arg4
#endif
) ;
void m_err5(
#if defined(M_PROTO)
char *text, M_WCHAR *arg1, M_WCHAR *arg2, M_WCHAR *arg3,
M_WCHAR *arg4, M_WCHAR *arg5
#endif
) ;
void m_err6(
#if defined(M_PROTO)
char *text, M_WCHAR *arg1, M_WCHAR *arg2, M_WCHAR *arg3,
M_WCHAR *arg4, M_WCHAR *arg5, M_WCHAR *arg6
#endif
) ;
void m_err7(
#if defined(M_PROTO)
char *text, M_WCHAR *arg1, M_WCHAR *arg2, M_WCHAR *arg3,
M_WCHAR *arg4, M_WCHAR *arg5, M_WCHAR *arg6, M_WCHAR *arg7
#endif
) ;
void m_errline(
#if defined(M_PROTO)
char *p
#endif
) ;
void m_error(
#if defined(M_PROTO)
char *text
#endif
) ;
void m_esuffix(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void m_exit(
#if defined(M_PROTO)
int status
#endif
) ;
void m_etcomplete(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
LOGICAL m_excluded(
#if defined(M_PROTO)
M_ELEMENT elt
#endif
) ;
void m_expecting(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void m_expexpand(
#if defined(M_PROTO)
LOGICAL *expstart, M_STATE node, LOGICAL *required, LOGICAL *data
#endif
) ;
void m_expline(
#if defined(M_PROTO)
LOGICAL *expstart, LOGICAL *data, M_ELEMENT label
#endif
) ;
void m_exptend(
#if defined(M_PROTO)
LOGICAL *expstart, M_PARSE *stackptr
#endif
) ;
int m_findact(
#if defined(M_PROTO)
M_ELEMENT elt, int *array
#endif
) ;
void m_findatt(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void m_findchain(
#if defined(M_PROTO)
M_PARSE *stackptr, int start, int chainin, int *chainout, int *index,
LOGICAL wild
#endif
) ;
int m_findpar(
#if defined(M_PROTO)
const char *elt, const char *param, const M_WCHAR *value
#endif
) ;
M_ELEMENT m_findunique(
#if defined(M_PROTO)
M_STATE from, int *newleft
#endif
) ;
void m_frcend(
#if defined(M_PROTO)
M_ELEMENT val
#endif
) ;
void m_frcstart(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void m_free(
#if defined(M_PROTO)
void *block, char *msg
#endif
) ;
void m_freeFSA(
#if defined(M_PROTO)
M_PARSE *stackelt
#endif
) ;
void m_freemin(
#if defined(M_PROTO)
M_MIN *min
, char *msg
#endif
) ;
void m_freeparam(
#if defined(M_PROTO)
M_PARSE *stackelt
#endif
) ;
LOGICAL m_gendelim(
#if defined(M_PROTO)
int srlen, int context
#endif
) ;
int m_getachar(
#if defined(M_PROTO)
M_HOLDTYPE *dchar
#endif
) ;
int m_getc(
#if defined(M_PROTO)
void *m_ptr
#endif
) ;
int mb_getwc(
#if defined(M_PROTO)
void *m_ptr
#endif
) ;
void *m_getdata(
#if defined(M_PROTO)
int n, LOGICAL *flag
#endif
) ;
void m_getline(
#if defined(M_PROTO)
M_WCHAR **file, int *line
#endif
) ;
void m_getname(
#if defined(M_PROTO)
M_WCHAR first
#endif
) ;
void m_getsignon(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
int m_gettoken(
#if defined(M_PROTO)
int *c, M_HOLDTYPE *dchar, int context
#endif
) ;
void m_globes(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void m_globss(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void m_holdproc(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void m_inctest(
#if defined(M_PROTO)
int *count, int limit, char *message
#endif
) ;
void m_initctype(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void m_initialize(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void m_lastchars(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
int m_level(
#if defined(M_PROTO)
M_WCHAR *elt
#endif
) ;
int m_mblevel(
#if defined(M_PROTO)
char *elt
#endif
) ;
void m_litproc(
#if defined(M_PROTO)
int delim
#endif
) ;
void m_longent(
#if defined(M_PROTO)
int context
#endif
) ;
LOGICAL m_lookent(
#if defined(M_PROTO)
M_WCHAR *name, unsigned char *type, M_WCHAR **content,
unsigned char *wheredef
#endif
) ;
void main(
#if defined(M_PROTO)
int argc, char **argv
#endif
) ;
void *m_malloc(
#if defined(M_PROTO)
int size, char *msg
#endif
) ;
void m_missingtagc(
#if defined(M_PROTO)
int c, M_HOLDTYPE dchar, LOGICAL start
#endif
) ;
LOGICAL m_nextand(
#if defined(M_PROTO)
M_OPENFSA *thisfsa, M_ELEMENT label
#endif
) ;
void m_nextdelimchar(
#if defined(M_PROTO)
int *n, int i, LOGICAL *linestart, LOGICAL newlinestart, LOGICAL skipblank,
unsigned char type
#endif
) ;
void m_ntrent(
#if defined(M_PROTO)
M_WCHAR *p
#endif
) ;
void m_nullendtag(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
LOGICAL m_omitend(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
LOGICAL m_omitstart(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void m_openchk(
#if defined(M_PROTO)
FILE **ptr, char *name, char *mode
#endif
) ;
void *m_openent(
#if defined(M_PROTO)
M_WCHAR *entcontent
#endif
) ;
void *m_openfirst(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void m_optstring(
#if defined(M_PROTO)
char *p
#endif
) ;
int m_packedlook(
#if defined(M_PROTO)
M_PTRIE *xptrie, M_WCHAR *name
#endif
) ;
int m_parcount(
#if defined(M_PROTO)
M_WCHAR *elt
#endif
) ;
M_WCHAR *m_pardefault(
#if defined(M_PROTO)
M_WCHAR *elt, M_WCHAR *param, unsigned char *type
#endif
) ;
M_WCHAR *m_parent(
#if defined(M_PROTO)
int n
#endif
) ;
M_WCHAR *m_parname(
#if defined(M_PROTO)
M_WCHAR *elt, int n
#endif
) ;
M_WCHAR *m_mbparname(
#if defined(M_PROTO)
char *elt, int n
#endif
) ;
const M_WCHAR *m_partype(
#if defined(M_PROTO)
const int par, const M_WCHAR *string
#endif
) ;
void m_parupper(
#if defined(M_PROTO)
int par, M_WCHAR *string
#endif
) ;
LOGICAL m_parvalok(
#if defined(M_PROTO)
M_WCHAR *elt, M_WCHAR *param, const M_WCHAR *value
#endif
) ;
void m_piaction(
#if defined(M_PROTO)
M_WCHAR *m_pi, M_WCHAR *m_entname, int m_enttype
#endif
) ;
void m_pop(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void m_push(
#if defined(M_PROTO)
M_ELEMENT elt, M_STATE current, LOGICAL need
#endif
) ;
LOGICAL m_putdata(
#if defined(M_PROTO)
void *data, int n
#endif
) ;
void m_readcomments(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void *m_realloc(
#if defined(M_PROTO)
void *ptr, int size, char *msg
#endif
) ;
int m_scan(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void m_setmap(
#if defined(M_PROTO)
int map, LOGICAL useoradd
#endif
) ;
void m_setoptions(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void m_setparam(
#if defined(M_PROTO)
M_WCHAR **cvar, int par
#endif
) ;
void m_shortref(
#if defined(M_PROTO)
int context
#endif
) ;
void m_showcurelt(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void m_signmsg(
#if defined(M_PROTO)
char *p
#endif
) ;
void m_sigre(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void m_startdoc(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void m_startmsg(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void m_stcaction(
#if defined(M_PROTO)
M_WCHAR *m_string, LOGICAL M_START, LOGICAL M_END
#endif
) ;
void m_stcomplete(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void m_stkdefaultparams(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void m_stkonedef(
#if defined(M_PROTO)
int par, M_ELEMENT scanel, M_WCHAR **poccur, int i
#endif
) ;
void m_stkparams(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void m_strtaction(
#if defined(M_PROTO)
M_ELEMENT m_elt
#endif
) ;
void m_strtcase(
#if defined(M_PROTO)
int m_action
#endif
) ;
void m_strtcdata(
#if defined(M_PROTO)
int scanval
#endif
) ;
LOGICAL m_strtproc(
#if defined(M_PROTO)
M_ELEMENT scanval
#endif
) ;
void m_strttag(
#if defined(M_PROTO)
M_ELEMENT val, LOGICAL net
#endif
) ;
void m_textaction(
#if defined(M_PROTO)
M_WCHAR m_textchar
#endif
) ;
void m_textout(
#if defined(M_PROTO)
char *format, LOGICAL start, LOGICAL end
#endif
) ;
LOGICAL m_textpermitted(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
M_WCHAR *m_thisfile(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
int m_thisline(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void m_trace(
#if defined(M_PROTO)
char *p
#endif
) ;
void m_wctrace(
#if defined(M_PROTO)
M_WCHAR *p
#endif
) ;
LOGICAL m_transition(
#if defined(M_PROTO)
M_ELEMENT label, LOGICAL recur
#endif
) ;
void m_undodelim(
#if defined(M_PROTO)
M_WCHAR *delim, LOGICAL flag
#endif
) ;
void m_ungetachar(
#if defined(M_PROTO)
int c, M_HOLDTYPE dchar, LOGICAL preread
#endif
) ;
void m_updatedefault(
#if defined(M_PROTO)
const int par, const M_WCHAR *string
#endif
) ;
int m_wcupstrcmp(
#if defined(M_PROTO)
const M_WCHAR *p, const M_WCHAR *q
#endif
) ;
int m_wcmbupstrcmp(
#if defined(M_PROTO)
const M_WCHAR *p, const char *q
#endif
) ;
int m_mbmbupstrcmp(
#if defined(M_PROTO)
const char *p, const char *q
#endif
) ;
LOGICAL m_validinpar(
#if defined(M_PROTO)
M_WCHAR *string
#endif
) ;
LOGICAL m_vldentref(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
LOGICAL m_whitespace(
#if defined(M_PROTO)
M_WCHAR c
#endif
) ;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,14 @@
/* $XConsortium: setopt.c /main/3 1995/11/08 10:58:30 rswiston $ */
/*
Copyright 1988, 1989 Hewlett-Packard Co.
*/
#include "userinc.h"
#include "globdec.h"
/* Set program options */
void m_setoptions(M_NOPAR)
{
if (m_argc > 1) m_optstring(m_argv[1]) ;
}

View File

@@ -0,0 +1,22 @@
/* $XConsortium: setpar.c /main/3 1995/11/08 10:58:44 rswiston $ */
/*
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
*/
/* Setparam.c is used by interfaces where code accesses an element's
attributes */
#include <stdio.h>
#include "basic.h"
#include "trie.h"
#include "dtdext.h"
#include "parser.h"
/* Set a user-defined C variable to the corresponding parameter value */
void m_setparam(cvar, par)
M_WCHAR **cvar ;
int par ;
{
*cvar = m_stackpar->param[par] ;
}

View File

@@ -0,0 +1,18 @@
/* $XConsortium: signmsg.c /main/3 1995/11/08 10:58:59 rswiston $ */
/*
Copyright 1988, 1989 Hewlett-Packard Co.
*/
#include "userinc.h"
#include "globdec.h"
/* Process signon message text */
void m_signmsg(p)
M_WCHAR *p ;
{
char mb_p;
mb_p = MakeMByteString(p);
m_errline(mb_p) ;
m_free(mb_p,"multi-byte string");
}

View File

@@ -0,0 +1,22 @@
/* $XConsortium: start.c /main/3 1995/11/08 10:59:13 rswiston $ */
/*
Copyright 1986 Tandem Computers Incorporated.
This product and information is proprietary of Tandem Computers Incorporated.
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
*/
/* Start.c executes start-code specified in the interface. */
#include "userinc.h"
#include "globdec.h"
/* Include generated file */
#include "sfile.c"
/* Perform the m_action-th start-code in the interface */
void m_strtcase(m_action)
int m_action ;
{
(*m_stable[m_action])() ;
}

View File

@@ -0,0 +1,17 @@
/* $XConsortium: startdoc.c /main/3 1995/11/08 10:59:27 rswiston $ */
/*
Copyright 1989 Hewlett-Packard Co.
*/
#include "userinc.h"
#include "globdec.h"
/* Default function called at start of document instance. Allows interface
control after all entity declarations have been processed. Not needed
in valid documents (when it is called just prior to global start-code),
but may be useful in some applications nevertheless. */
void m_startdoc(M_NOPAR)
{
}

View File

@@ -0,0 +1,23 @@
/* $XConsortium: string.c /main/3 1995/11/08 10:59:41 rswiston $ */
/* Copyright 1988, 1989 Hewlett-Packard Co. */
/* String.c executes string-code specified in the interface. */
#include "userinc.h"
#include "globdec.h"
/* Include generated code */
#include "stfile.c"
#if defined(M_PROTO)
void m_stcaction(M_WCHAR *m_string, LOGICAL M_START, LOGICAL M_END)
#else
void m_stcaction(m_string, M_START, M_END)
M_WCHAR *m_string ;
LOGICAL M_START ;
LOGICAL M_END ;
#endif
{
m_stackpar = m_stacktop->stparam ;
(*m_sttable[m_stacktop->stccase])(m_string, M_START, M_END) ;
}

View File

@@ -0,0 +1,755 @@
/* $XConsortium: struct.c /main/3 1995/11/08 10:59:57 rswiston $ */
/*
Copyright 1986 Tandem Computers Incorporated.
This product and information is proprietary of Tandem Computers Incorporated.
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
*/
/* Struct.c contains functions relevant to parsing document structure for
program PARSER */
#include <string.h>
#include <stdio.h>
#include <malloc.h>
#if defined(MSDOS)
#include <process.h>
#endif
#include "basic.h"
#include "trie.h"
#include "dtdext.h"
#include "delim.h"
#include "context.h"
#include "parser.h"
#include "entext.h"
#include "if.h"
/* M_checkstart tests to see if the element (or #PCDATA) indicated by VAL
is valid input. It returns TRUE, FALSE, or M_NONCONTEXTUAL respectively
if the element is allowed by content, not allowed, or allowed by an
inclusion exception. */
int m_checkstart(val)
M_ELEMENT val ;
{
M_PARSE *stackptr ;
int except ;
/* Check for applicable exclusions */
if (m_excluded(val)) return(FALSE) ;
/* Check for declared content in element currently at top of stack */
if (m_stacktop->oldtop) {
if (m_element[m_stacktop->element - 1].content == M_ANY) return(TRUE) ;
if (m_element[m_stacktop->element - 1].content == M_CDATA ||
m_element[m_stacktop->element - 1].content == M_RCDATA)
if (! val) return(TRUE) ;
else return(FALSE) ;
}
/* Check content model */
if (m_transition(val, TRUE)) return(TRUE) ;
/* Check for inclusions */
for (stackptr = m_stacktop ;
stackptr->oldtop ;
stackptr = stackptr->oldtop)
for (except = m_element[stackptr->element - 1].inptr ;
except ;
except = m_exception[except - 1].next)
if (m_exception[except - 1].element == val) return(M_NONCONTEXTUAL) ;
/* Nothing left to try, val is not allowed */
return(FALSE) ;
}
/* M_ckend verifies that element VAL can be legally ended at the
current state of the parse, by an end tag or NET as indicated by NEEDNET.
If VAL is not the element at the top of the parse stack, m_ckend
checks to see if the end of VAL can validly end nested
elements as well. */
#if defined(M_PROTO)
LOGICAL m_ckend(M_ELEMENT val, LOGICAL neednet)
#else
LOGICAL m_ckend(val, neednet)
M_ELEMENT val ;
LOGICAL neednet ;
#endif
{
M_PARSE *stackptr ;
M_OPENFSA *fsastack ;
M_ANDLIST *usedand ;
M_ANDGROUP pand ;
M_MIN *minend ;
M_MIN *discard ;
m_minend = NULL ;
m_nextme = &m_minend ;
/* Go down the stack, checking that each element can end until
element val occurs */
for (stackptr = m_stacktop ; stackptr ; stackptr = stackptr->oldtop) {
/* If the element at stackptr has a content model, make sure each
open fsa is in a final state and that all required submodels of
open and-groups have occurred */
for (fsastack = stackptr->fsastack ;
fsastack ;
fsastack = fsastack->oldtop) {
if (! m_state[fsastack->current - 1].final) {
m_freemin(m_minend, "end-tag minimization") ;
return(FALSE) ;
}
for (pand = fsastack->andgroup ;
pand ;
pand = m_andgroup[pand - 1].next) {
/* Don't bother checking if optional submodel of an and-group
has occurred */
if (m_state[m_andgroup[pand - 1].start - 1].final) continue ;
for (usedand = fsastack->usedand ;
usedand ;
usedand = usedand->next)
if (usedand->group == pand) break ;
if (! usedand) {
/* Didn't find a required submodel */
m_freemin(m_minend, "end-tag minimization") ;
return(FALSE) ;
}
} /* End for pand */
} /* End for fsastack */
/* Have confirmed that the element indicated by stackptr can end now */
if (stackptr->element == val) break ;
*m_nextme = (M_MIN *) m_malloc(sizeof(M_MIN), "end-tag minimization") ;
(*m_nextme)->next = NULL ;
(*m_nextme)->val = stackptr->element ;
m_nextme = &(*m_nextme)->next ;
} /* End for stackptr */
if (! stackptr) {
m_freemin(m_minend, "end-tag minimization") ;
return(FALSE) ;
}
for (minend = m_minend ; minend ; ) {
discard = minend ;
minend = minend->next ;
m_free(discard, "end-tag minimization") ;
if (m_stacktop->neednet && ! neednet) {
M_WCHAR *wc_net;
wc_net = MakeWideCharString(m_net);
m_err2("Expecting %s to end %s",
wc_net,
m_nameofelt(m_stacktop->element)) ;
m_free(wc_net,"wide character string");
m_showcurelt() ;
}
if (! m_element[m_stacktop->element - 1].emin) {
m_err1("Missing end tag for %s", m_nameofelt(m_stacktop->element)) ;
m_showcurelt() ;
}
m_endtag(m_stacktop->element) ;
}
if (m_stacktop->neednet != neednet) {
M_WCHAR *wc_etago, *wc_tagc, *wc_mnet, *wc_stago, *wc_net;
wc_etago = MakeWideCharString(m_etago);
wc_stago = MakeWideCharString(m_stago);
wc_tagc = MakeWideCharString(m_tagc);
wc_net = MakeWideCharString(m_net);
if (neednet)
m_err4("Expecting %s%s%s instead of %s",
wc_etago,
m_nameofelt(m_stacktop->element),
wc_tagc,
wc_net) ;
else
m_err4("Expecting %s to end %s%s%s",
wc_net,
wc_stago,
m_nameofelt(m_stacktop->element),
wc_tagc) ;
m_showcurelt() ;
m_free(wc_etago,"wide character string");
m_free(wc_stago,"wide character string");
m_free(wc_tagc,"wide character string");
m_free(wc_net,"wide character string");
}
m_endtag(val) ;
return(TRUE) ;
} /*end m_ckend*/
/* Make a copy of the stack entry at the top of the parse stack in a scratch
area */
M_PARSE *m_copystackelt(M_NOPAR)
{
M_OPENFSA *oldfsa ;
M_OPENFSA **newfsa ;
M_ANDLIST *oldand ;
M_ANDLIST **newand ;
M_PARSE *copy ;
copy = (M_PARSE *) m_malloc(sizeof(M_PARSE), "stack element") ;
memcpy((char *) copy, (char *) m_stacktop, sizeof(M_PARSE)) ;
copy->param = NULL ;
for (oldfsa = m_stacktop->fsastack, newfsa = &copy->fsastack ;
oldfsa ;
oldfsa = oldfsa->oldtop, newfsa = &(*newfsa)->oldtop) {
*newfsa = (M_OPENFSA *) m_malloc(sizeof(M_OPENFSA), "FSA") ;
memcpy((char *) *newfsa, (char *) oldfsa, sizeof(M_OPENFSA)) ;
for (oldand = oldfsa->usedand, newand = &(*newfsa)->usedand ;
oldand ;
oldand = oldand->next, newand = &(*newand)->next) {
*newand = (M_ANDLIST *) m_malloc(sizeof(M_ANDLIST), "and list") ;
(*newand)->group = oldand->group ;
(*newand)->next = NULL ;
}
}
return(copy) ;
}
/* End of document */
void m_done(M_NOPAR)
{
M_ELEMENT lastelt ;
while (m_stacktop->oldtop) {
lastelt = m_stacktop->element ;
if (! m_ckend(m_stacktop->element, FALSE)) {
m_err1("More content expected in element %s at end of document",
m_nameofelt(m_stacktop->element)) ;
m_expecting() ;
m_showcurelt() ;
m_frcend(m_stacktop->element) ;
}
else if (! m_element[lastelt - 1].emin)
m_err1("Missing end tag for %s", m_nameofelt(lastelt)) ;
}
m_endcase(1) ;
m_globes() ;
m_exit(m_errexit) ;
}
/* Process the endtag (implied, abbreviated, or explicit) for element C*/
void m_endtag(c)
M_ELEMENT c ;
{
m_endaction(c) ;
m_pop() ;
if (m_stacktop->intext) {
m_curcon = POUNDCDATA ;
if (m_netlevel) m_curcon = NETCDATA ;
}
}
/* Check that the identified element is not prohibited in the current context
by an exclusion exception */
LOGICAL m_excluded(elt)
M_ELEMENT elt ;
{
M_PARSE *stackptr ;
int except ;
if (! elt) return(FALSE) ;
for (stackptr = m_stacktop ;
stackptr->oldtop ;
stackptr = stackptr->oldtop)
for (except = m_element[stackptr->element - 1].exptr ;
except ;
except = m_exception[except - 1].next)
if (m_exception[except - 1].element == elt) return(TRUE) ;
return(FALSE) ;
}
/* Free the OPEN FSA substructures associated with an element on
the parse stack */
void m_freeFSA(stackelt)
M_PARSE *stackelt ;
{
M_OPENFSA *fsastack ;
M_ANDLIST *usedand ;
while (stackelt->fsastack) {
fsastack = stackelt->fsastack ;
if (fsastack == &m_botfsa) return ;
while (fsastack->usedand) {
usedand = fsastack->usedand ;
fsastack->usedand = usedand->next ;
m_free(usedand, "and list") ;
}
stackelt->fsastack = fsastack->oldtop ;
m_free(fsastack, "FSA") ;
}
}
/* Free storage used for tentative chain of tag minimizations */
void m_freemin(min, msg)
M_MIN *min ;
char *msg ;
{
M_MIN *discard ;
for ( ; min ;) {
discard = min ;
min = min->next ;
m_free(discard, msg) ;
}
}
/* M_nextand returns TRUE iff element label is allowed at the current point
in the current content model by starting a new submodel of the and-group
indicated by fsastack, or (if the and-group is within a seq-group) by
continuing past the and-group */
LOGICAL m_nextand(thisfsa, label)
M_OPENFSA *thisfsa ;
M_ELEMENT label ;
{
M_ANDLIST *newgroup ;
M_ANDGROUP pand ;
M_ANDLIST *plist ;
M_OPENFSA *savefsa ;
M_OPENFSA *fsa ;
LOGICAL required = FALSE ;
LOGICAL last ;
/* Verify currently within an and-group and in final state of this
branch */
if (! m_state[thisfsa->current - 1].final) return(FALSE) ;
if (! thisfsa->oldtop) return(FALSE) ;
savefsa = m_stacktop->fsastack ;
/* Check possibility of starting a new branch*/
m_stacktop->fsastack =
(M_OPENFSA *) m_malloc(sizeof(M_OPENFSA), "FSA") ;
m_stacktop->fsastack->oldtop = thisfsa->oldtop ;
m_stacktop->fsastack->andgroup = M_NULLVAL ;
m_stacktop->fsastack->usedand = NULL ;
newgroup = (M_ANDLIST *) m_malloc(sizeof(M_ANDLIST), "and list") ;
newgroup->next = thisfsa->oldtop->usedand ;
thisfsa->oldtop->usedand = newgroup ;
for (pand = thisfsa->oldtop->andgroup ;
pand ;
pand = m_andgroup[pand - 1].next) {
for (plist = newgroup->next ; plist ; plist = plist->next)
if (pand == plist->group) break ;
if (! plist) {
newgroup->group = pand ;
m_stacktop->fsastack->current = m_andgroup[pand - 1].start ;
if (! m_state[m_stacktop->fsastack->current - 1].final)
required = TRUE ;
if (m_transition(label, FALSE)) {
for (fsa = savefsa ; TRUE ; fsa = fsa->oldtop) {
for (plist = fsa->usedand ; plist ; plist = plist->next)
m_free(plist, "and list") ;
if (fsa == thisfsa) {
m_free(fsa, "FSA") ;
break;
}
m_free(fsa, "FSA") ;
}
return(TRUE) ;
}
}
}
/* Couldn't start a new branch. Restore parse stack */
thisfsa->oldtop->usedand = newgroup->next ;
m_free(newgroup, "and list") ;
m_free(m_stacktop->fsastack, "FSA") ;
m_stacktop->fsastack = savefsa ;
/* Have all required branches occurred? */
if (required) return(FALSE) ;
/* Can we continue past this and-group in a containing seq-group? */
m_stacktop->fsastack =
(M_OPENFSA *) m_malloc(sizeof(M_OPENFSA), "FSA") ;
m_stacktop->fsastack->oldtop = thisfsa->oldtop->oldtop ;
m_stacktop->fsastack->andgroup = M_NULLVAL ;
m_stacktop->fsastack->usedand = NULL ;
m_stacktop->fsastack->current = thisfsa->oldtop->current ;
if (m_transition(label, FALSE)) {
/* Free temporary FSA storage used to test transition */
for (fsa = savefsa, last = FALSE ; TRUE ; fsa = fsa->oldtop) {
for (plist = fsa->usedand ; plist ; plist = plist->next)
m_free(plist, "and list") ;
m_free(fsa, "FSA") ;
if (last) break ;
if (fsa == thisfsa) last = TRUE ;
}
return(TRUE) ;
}
m_free(m_stacktop->fsastack, "FSA") ;
m_stacktop->fsastack = savefsa ;
/* Can we continue in a containing and-group? */
if (m_nextand(thisfsa->oldtop, label)) return(TRUE) ;
return(FALSE) ;
}
/* Pops the parse stack*/
void m_pop(M_NOPAR)
{
M_PARSE *stackelt ;
if (! m_stacktop->oldtop) {
m_error("Program error: attempt to pop empty stack") ;
m_exit(TRUE) ;
}
if (m_stacktop->map && m_stacktop->map != m_stacktop->oldtop->map)
m_free(m_stacktop->map, "short reference map") ;
m_freeparam(m_stacktop) ;
m_freeFSA(m_stacktop) ;
if (m_stacktop->neednet) m_netlevel-- ;
stackelt = m_stacktop ;
m_stacktop = stackelt->oldtop ;
m_free(stackelt, "stack element") ;
}
/* Pushes a new item onto the parse stack, setting its element, current,
and neednet fields as indicated by the parameters*/
#if defined(M_PROTO)
void m_push(M_ELEMENT elt, M_STATE current, LOGICAL need)
#else
void m_push(elt, current, need)
M_ELEMENT elt ;
M_STATE current ;
LOGICAL need ;
#endif
{
M_PARSE *newstack ;
m_aftereod = FALSE ;
newstack = (M_PARSE *) m_malloc(sizeof(M_PARSE), "stack element") ;
newstack->oldtop = m_stacktop ;
newstack->element = elt ;
newstack->param = NULL ;
if (m_element[elt - 1].content == M_REGEXP) {
newstack->fsastack = (M_OPENFSA *) m_malloc(sizeof(M_OPENFSA), "FSA") ;
newstack->fsastack->oldtop = NULL ;
newstack->fsastack->current = current ;
newstack->fsastack->andgroup = M_NULLVAL ;
newstack->fsastack->usedand = NULL ;
}
else newstack->fsastack = NULL ;
newstack->thisent = 0 ;
newstack->neednet = need ;
newstack->firstre = FALSE ;
newstack->contextual = TRUE ;
newstack->intext = FALSE ;
newstack->linestat = M_NOTHING ;
newstack->holdre = FALSE ;
newstack->map = m_stacktop->map ;
newstack->cdcase = m_stacktop->cdcase ;
newstack->picase = m_stacktop->picase ;
newstack->stccase = m_stacktop->stccase ;
newstack->cdparam = m_stacktop->cdparam ;
newstack->piparam = m_stacktop->piparam ;
newstack->stparam = m_stacktop->stparam ;
newstack->file = m_stacktop->file ;
newstack->line = m_stacktop->line ;
newstack->ifdata = NULL ;
m_stacktop = newstack ;
if (m_element[elt - 1].srefptr)
m_setmap(m_element[elt - 1].srefptr,
(LOGICAL) m_element[elt - 1].useoradd) ;
}
/* Process first character of a segment of character data. The first
character is treated differently so that if character data is not
allowed in the current context, an error message is issued with the
first character only and not with every character. */
void m_strtcdata(scanval)
int scanval ;
{
if (! m_strtproc(M_NULLVAL))
if (m_whitespace((M_WCHAR) scanval)) {
m_curcon = m_prevcon ;
return ;
}
else {
if (m_stacktop->oldtop) {
m_err1("Data characters not allowed at this point in %s",
m_nameofelt(m_stacktop->element)) ;
m_expecting() ;
m_showcurelt() ;
}
else if (! m_start) {
m_error("Document may not start with data characters") ;
m_expecting() ;
}
}
m_start = TRUE ;
m_textaction((M_WCHAR) scanval) ;
m_stacktop->firstre = TRUE ;
m_stacktop->intext = TRUE ;
}
/* M_strtproc checks that the next starttag or beginning of the next
#PCDATA segment is valid, processing omitted start and endtags as needed.
(Since m_endtag may reset the current context if the stack is popped down
to an element that was within #PCDATA, m_strtproc saves the current context
and restores it after returning from the last call to m_endtag.)
*/
LOGICAL m_strtproc(scanval)
M_ELEMENT scanval ;
{
int check ;
M_PARSE *original ;
int savecontext ;
int savenet ;
M_PARSE *savestack ;
M_PARSE *starttagomit ;
M_MIN *min ;
M_MIN *discard ;
/* The algorithms used here involve making a copy of the stack entry
at the top of the stack before testing for the possibility of
start-tag omission. Values of cdparam, piparam, and stparam
are not used while testing for markup minimization and therefore
are not set. However, the original entry and the copy may differ
in the accuracy of these values, so care must be taken to keep
the version in which they are correct when the stack is manipulated
for the final time */
/* Is scanval allowed without tag omission? */
savestack = m_stacktop ;
original = m_stacktop ;
m_stacktop = m_copystackelt() ;
if (check = m_checkstart(scanval)) {
if (scanval && m_stacktop->holdre && check != M_NONCONTEXTUAL) {
m_freeFSA(m_stacktop) ;
m_free(m_stacktop, "stack element") ;
m_stacktop = original ;
m_holdproc() ;
return(m_strtproc(scanval)) ;
}
m_freeFSA(m_stacktop) ;
m_free(m_stacktop, "stack element") ;
m_stacktop = original ;
if (scanval && check != M_NONCONTEXTUAL) {
m_stacktop->linestat = M_DCORCET ;
m_stacktop->firstre = TRUE ;
}
m_strttag(scanval, m_scannet) ;
if (check == M_NONCONTEXTUAL) m_stacktop->contextual = FALSE ;
else if (scanval) m_stacktop->oldtop->intext = FALSE ;
return(TRUE) ;
}
/* Check for start- and end-tag omission */
savecontext = m_curcon ;
savenet = m_netlevel ;
m_minstart = m_minend = NULL ;
m_nextms = &m_minstart ;
m_nextme = &m_minend ;
starttagomit = m_stacktop ;
while (TRUE) {
if (m_omitstart()) {
if (check = m_checkstart(scanval)) break ;
else continue ;
}
m_freemin(m_minstart, "start-tag minimization") ;
m_minstart = NULL ;
m_nextms = &m_minstart ;
while (m_stacktop != starttagomit) m_pop() ;
m_freeFSA(m_stacktop) ;
m_free(m_stacktop, "stack element") ;
m_stacktop = original ;
if (m_omitend()) {
original = m_stacktop->oldtop ;
m_stacktop = m_stacktop->oldtop ;
m_stacktop = m_copystackelt() ;
starttagomit = m_stacktop ;
if (check = m_checkstart(scanval)) break ;
else continue ;
}
m_freemin(m_minend, "end-tag minimization") ;
m_freemin(m_minstart, "start-tag minimization") ;
m_stacktop = savestack ;
m_netlevel = savenet ;
m_curcon = savecontext ;
return(FALSE) ;
}
/* Have determined a sequence of omitted tags. Process them */
/* Undo all stack changes that were made tentatively, so they can
be redone with invocation of interface as appropriate */
while (m_stacktop != starttagomit) m_pop() ;
m_freeFSA(m_stacktop) ;
m_free(m_stacktop, "stack element") ;
m_stacktop = savestack ;
m_netlevel = savenet ;
if (m_minend) m_stacktop->holdre = FALSE ;
else if (m_stacktop->holdre && check != M_NONCONTEXTUAL) {
m_freemin(m_minstart, "start-tag minimization") ;
m_holdproc() ;
if (scanval) return(m_strtproc(scanval)) ;
else return(TRUE) ;
}
for (min = m_minend ; min ;) {
if (m_stacktop->neednet) {
M_WCHAR *wc_net;
wc_net = MakeWideCharString(m_net);
m_err2("Expecting %s to end %s",
wc_net,
m_nameofelt(m_stacktop->element)) ;
m_free(wc_net,"wide character string");
m_showcurelt() ;
}
if (! m_element[m_stacktop->element - 1].emin) {
m_err1("Missing end tag for %s", m_nameofelt(m_stacktop->element)) ;
m_showcurelt() ;
}
m_endtag(min->val) ;
discard = min ;
min = min->next ;
m_free(discard, "end-tag minimization") ;
}
for (min = m_minstart ; min ;) {
m_checkstart(min->val) ;
m_strttag(min->val, FALSE) ;
if (! m_element[min->val - 1].smin)
m_err1("Missing start tag for %s", m_nameofelt(min->val)) ;
m_stkdefaultparams() ;
discard = min ;
min = min->next ;
m_free(discard, "start-tag minimization") ;
}
check = m_checkstart(scanval) ;
if (scanval && check != M_NONCONTEXTUAL) {
m_stacktop->linestat = M_DCORCET ;
m_stacktop->firstre = TRUE ;
}
m_strttag(scanval, m_scannet) ;
if (check == M_NONCONTEXTUAL) m_stacktop->contextual = FALSE ;
else if (scanval) m_stacktop->oldtop->intext = FALSE ;
m_curcon = savecontext ;
if (m_element[m_stacktop->element - 1].content == M_CDATA)
m_curcon = CDATAEL ;
if (m_element[m_stacktop->element - 1].content == M_RCDATA) {
m_curcon = RCDATAEL ;
m_stacktop->thisent = m_eopencnt ;
}
return(TRUE) ;
}
/* Processes explicit or implied start tag*/
#if defined(M_PROTO)
void m_strttag(M_ELEMENT val, LOGICAL net)
#else
void m_strttag(val, net)
M_ELEMENT val ;
LOGICAL net ;
#endif
{
m_transition(val, TRUE) ;
if (val) {
m_push(val, m_element[val - 1].start, net) ;
if (net) m_netlevel++ ;
if (m_element[val - 1].content == M_CDATA ||
m_element[val - 1].content == M_RCDATA) {
m_stacktop->intext = TRUE ;
m_curcon = m_element[val - 1].content == M_CDATA ?
CDATAEL : RCDATAEL ;
}
}
}
/* Returns indication of whether or not parsed data characters are allowed
(without tag minimization) in the current context. Used to distinguish
mixed content from element content. (Assuming the definition of
mixed content is a context where #PCDATA can occur, not that the current
content model contains #PCDATA at some point. The former definition
makes more sense, is used by MARKUP, and is under consideration by the
Standards committee; the latter is the current definition in the Standard
*/
LOGICAL m_textpermitted(M_NOPAR)
{
M_ANDGROUP pand ;
M_OPENFSA *fsastack ;
M_ANDLIST *usedand ;
LOGICAL morebranches = FALSE ;
if (! m_stacktop->oldtop) return(FALSE) ;
/* If element has declared content (other than EMPTY), data is allowed.
But EMPTY elements don't stay on the stack long enough to call this
function */
if (m_element[m_stacktop->element - 1].content != M_REGEXP) return(TRUE) ;
/* If within #PCDATA, more text can be entered */
if (m_stacktop->intext) return(TRUE) ;
/* If current state emits an arc labelled #PCDATA, text can be
entered */
for (fsastack = m_stacktop->fsastack ;
fsastack ;
fsastack = fsastack->oldtop) {
for (pand = fsastack->andgroup ;
pand ;
pand = m_andgroup[pand - 1].next) {
for (usedand = fsastack->usedand ;
usedand ;
usedand = usedand->next)
if (usedand->group == pand) break ;
if (! usedand) {
if (m_state[m_andgroup[pand - 1].start - 1].datacontent)
return(TRUE) ;
if (! m_state[m_andgroup[pand - 1].start - 1].final)
morebranches = TRUE ;
}
}
if (morebranches) return(FALSE) ;
if (m_state[fsastack->current - 1].datacontent) return(TRUE) ;
if (! m_state[fsastack->current - 1].final) return(FALSE) ;
}
return(FALSE) ;
} /* End m_textpermitted() */
/* Returns TRUE iff LABEL allowed in the current state of the current
element (without expanding any minimization). May result in changes
to the stack of FSA's for this element if and-groups open or close. */
#if defined(M_PROTO)
LOGICAL m_transition(M_ELEMENT label, LOGICAL recur)
#else
LOGICAL m_transition(label, recur)
M_ELEMENT label ;
LOGICAL recur ;
#endif
{
M_ARC parc ;
M_OPENFSA *newfsa ;
M_ANDGROUP pand ;
if (m_stacktop->oldtop &&
m_element[m_stacktop->element - 1].content != M_REGEXP)
return(FALSE) ;
for (parc = m_state[m_stacktop->fsastack->current - 1].first ;
parc ;
parc = m_arc[parc - 1].next) {
if (m_arc[parc - 1].group) {
newfsa = (M_OPENFSA *) m_malloc(sizeof(M_OPENFSA), "FSA") ;
newfsa->oldtop = m_stacktop->fsastack ;
newfsa->andgroup = M_NULLVAL ;
newfsa->usedand = NULL ;
m_stacktop->fsastack = newfsa ;
for (pand = m_arc[parc - 1].group ; pand ;
pand = m_andgroup[pand - 1].next) {
newfsa->current = m_andgroup[pand - 1].start ;
if (m_transition(label, FALSE)) {
newfsa->oldtop->andgroup = m_arc[parc - 1].group ;
newfsa->oldtop->usedand =
(M_ANDLIST *) m_malloc(sizeof(M_ANDLIST), "and list") ;
newfsa->oldtop->usedand->group = pand ;
newfsa->oldtop->usedand->next = NULL ;
newfsa->oldtop->current = m_arc[parc - 1].to ;
return(TRUE) ;
}
}
m_stacktop->fsastack = newfsa->oldtop ;
m_free(newfsa, "FSA") ;
}
else if (label == m_arc[parc - 1].label) {
m_stacktop->fsastack->current = m_arc[parc - 1].to ;
return(TRUE) ;
}
} /* End for parc */
if (recur && m_nextand(m_stacktop->fsastack, label)) return(TRUE) ;
return(FALSE) ;
} /* End transition */

View File

@@ -0,0 +1,266 @@
/* $XConsortium: tex.h /main/3 1995/11/08 11:00:13 rswiston $ */
EXTERN char *special[256]
#if defined(DEFINE)
= {
/* Char Name TeX Expansion */
/* */
/* 0: ^@ NUL */ 0,
/* 1: ^A SOH */ 0,
/* 2: ^B STX */ 0,
/* 3: ^C ETX */ 0,
/* 4: ^D EOT */ 0,
/* 5: ^E ENQ */ 0,
/* 6: ^F ACK */ 0,
/* 7: ^G BEL */ 0,
/* 8: ^H BS */ 0,
/* 9: ^I HT */ 0,
/* 10: ^J LF */ 0,
/* 11: ^K VT */ 0,
/* 12: ^L FF */ 0,
/* 13: ^M CR */ 0,
/* 14: ^N SO */ 0,
/* 15: ^O SI */ 0,
/* 16: ^P DLE */ 0,
/* 17: ^Q DC1 */ 0,
/* 18: ^R DC2 */ 0,
/* 19: ^S DC3 */ 0,
/* 20: ^T DC4 */ 0,
/* 21: ^U NAK */ 0,
/* 22: ^V SYN */ 0,
/* 23: ^W ETB */ 0,
/* 24: ^X CAN */ 0,
/* 25: ^Y EM */ 0,
/* 26: ^Z SUB */ 0,
/* 27: ^[ ESC */ 0,
/* 28: ^\ FS */ 0,
/* 29: ^] GS */ 0,
/* 30: ^^ RS */ 0,
/* 31: ^_ US */ 0,
/* 32: SP */ 0,
/* 33: ! */ 0,
/* 34: " */ 0,
/* 35: # */ "\\#",
/* 36: $ */ "{\\dollar}",
/* 37: % */ "\\%",
/* 38: & */ "\\&",
/* 39: ' */ "{'}",
/* 40: ( */ 0,
/* 41: ) */ 0,
/* 42: * */ 0,
/* 43: + */ 0,
/* 44: , */ 0,
/* 45: - */ "{-}",
/* 46: . */ 0,
/* 47: / */ 0,
/* 48: 0 */ 0,
/* 49: 1 */ 0,
/* 50: 2 */ 0,
/* 51: 3 */ 0,
/* 52: 4 */ 0,
/* 53: 5 */ 0,
/* 54: 6 */ 0,
/* 55: 7 */ 0,
/* 56: 8 */ 0,
/* 57: 9 */ 0,
/* 58: : */ 0,
/* 59: ; */ 0,
/* 60: < */ "{\\lthan}",
/* 61: = */ 0,
/* 62: > */ "{\\gthan}",
/* 63: ? */ 0,
/* 64: @ */ 0,
/* 65: A */ 0,
/* 66: B */ 0,
/* 67: C */ 0,
/* 68: D */ 0,
/* 69: E */ 0,
/* 70: F */ 0,
/* 71: G */ 0,
/* 72: H */ 0,
/* 73: I */ 0,
/* 74: J */ 0,
/* 75: K */ 0,
/* 76: L */ 0,
/* 77: M */ 0,
/* 78: N */ 0,
/* 79: O */ 0,
/* 80: P */ 0,
/* 81: Q */ 0,
/* 82: R */ 0,
/* 83: S */ 0,
/* 84: T */ 0,
/* 85: U */ 0,
/* 86: V */ 0,
/* 87: W */ 0,
/* 88: X */ 0,
/* 89: Y */ 0,
/* 90: Z */ 0,
/* 91: [ */ 0,
/* 92: \\ */ "{\\bslash}",
/* 93: ] */ 0,
/* 94: ^ */ "\\string^",
/* 95: _ */ "{\\under}",
/* 96: ` */ "{`}",
/* 97: a */ 0,
/* 98: b */ 0,
/* 99: c */ 0,
/* 100: d */ 0,
/* 101: e */ 0,
/* 102: f */ 0,
/* 103: g */ 0,
/* 104: h */ 0,
/* 105: i */ 0,
/* 106: j */ 0,
/* 107: k */ 0,
/* 108: l */ 0,
/* 109: m */ 0,
/* 110: n */ 0,
/* 111: o */ 0,
/* 112: p */ 0,
/* 113: q */ 0,
/* 114: r */ 0,
/* 115: s */ 0,
/* 116: t */ 0,
/* 117: u */ 0,
/* 118: v */ 0,
/* 119: w */ 0,
/* 120: x */ 0,
/* 121: y */ 0,
/* 122: z */ 0,
/* 123: { */ "{\\lbrac}",
/* 124: | */ "{\\vbar}",
/* 125: } */ "{\\rbrac}",
/* 126: ~ */ "\\string~",
/* 127: DEL */ 0,
/* 128: undefined */ 0,
/* 129: undefined */ 0,
/* 130: undefined */ 0,
/* 131: undefined */ 0,
/* 132: undefined */ 0,
/* 133: undefined */ 0,
/* 134: undefined */ 0,
/* 135: undefined */ 0,
/* 136: undefined */ 0,
/* 137: undefined */ 0,
/* 138: undefined */ 0,
/* 139: undefined */ 0,
/* 140: undefined */ 0,
/* 141: undefined */ 0,
/* 142: undefined */ 0,
/* 143: undefined */ 0,
/* 144: undefined */ 0,
/* 145: undefined */ 0,
/* 146: undefined */ 0,
/* 147: undefined */ 0,
/* 148: undefined */ 0,
/* 149: undefined */ 0,
/* 150: undefined */ 0,
/* 151: undefined */ 0,
/* 152: undefined */ 0,
/* 153: undefined */ 0,
/* 154: undefined */ 0,
/* 155: undefined */ 0,
/* 156: undefined */ 0,
/* 157: undefined */ 0,
/* 158: undefined */ 0,
/* 159: undefined */ 0,
/* 160: undefined */ 0,
/* 161: A grave */ "\\`A",
/* 162: A circumflex */ "\\^A",
/* 163: E grave */ "\\`E",
/* 164: E circumflex */ "\\^E",
/* 165: E dieresis */ "\\\042E",
/* 166: I circumflex */ "\\^I",
/* 167: I dieresis */ "\\\042I",
/* 168: acute accent */ "\\'{ }",
/* 169: grave accent */ "\\`{ }",
/* 170: circumflex */ "\\^{ }",
/* 171: dieresis */ "\\\042{ }",
/* 172: tilde */ "\\~{ }",
/* 173: U grave */ "\\`U",
/* 174: U circumflex */ "\\^U",
/* 175: Italian Lira */ 0,
/* 176: overbar */ 0,
/* 177: Y acute */ "\\'Y",
/* 178: y acute */ "\\'y",
/* 179: degree */ 0,
/* 180: C cedilla */ "\\c{C}",
/* 181: c cedilla */ "\\c{c}",
/* 182: N tilde */ "\\~N",
/* 183: n tilde */ "\\~n",
/* 184: inverted exclamation mark */ "{!`}",
/* 185: inverted question mark */ "{?`}",
/* 186: currency sign */ 0,
/* 187: pound sterling */ 0,
/* 188: Yen */ 0,
/* 189: Section sign */ 0,
/* 190: florin */ 0,
/* 191: Cent sign */ 0,
/* 192: a circumflex */ "\\^a",
/* 193: e circumflex */ "\\^e",
/* 194: o circumflex */ "\\^o",
/* 195: u circumflex */ "\\^u",
/* 196: a acute */ "\\'a",
/* 197: e acute */ "\\'e",
/* 198: o acute */ "\\'o",
/* 199: u acute */ "\\'u",
/* 200: a grave */ "\\`a",
/* 201: e grave */ "\\`e",
/* 202: o grave */ "\\`o",
/* 203: u grave */ "\\`u",
/* 204: a dieresis */ "\\\042a",
/* 205: e dieresis */ "\\\042e",
/* 206: o dieresis */ "\\\042o",
/* 207: u dieresis */ "\\\042u",
/* 208: A angstrom */ "{\\AA}",
/* 209: i circumflex */ "{\\^\\i}",
/* 210: O slash */ "{\\O}",
/* 211: AE ligature */ "{\\AE}",
/* 212: a angstrom */ "{\\aa}",
/* 213: i acute */ "{\\'\\i}",
/* 214: o slash */ "{\\o}",
/* 215: ae ligature */ "{\\ae}",
/* 216: A dieresis */ "\\\042A",
/* 217: i grave */ "{\\`\\i}",
/* 218: O dieresis */ "\\\042O",
/* 219: U dieresis */ "\\\042U",
/* 220: E acute */ "\\'E",
/* 221: i dieresis */ "{\\\042\\i}",
/* 222: SS ligature */ "{\\ss}",
/* 223: O circumflex */ "\\^O",
/* 224: A acute */ "\\'A",
/* 225: A tilde */ "\\~A",
/* 226: a tilde */ "\\~a",
/* 227: Eth */ 0,
/* 228: eth */ 0,
/* 229: I acute */ "\\'I",
/* 230: I grave */ "\\`I",
/* 231: O acute */ "\\'O",
/* 232: O grave */ "\\`O",
/* 233: O tilde */ "\\~O",
/* 234: o tilde */ "\\~o",
/* 235: S caron */ "\\v{S}",
/* 236: s caron */ "\\v{s}",
/* 237: U acute */ "\\'U",
/* 238: Y dieresis */ "\\\042Y",
/* 239: y dieresis */ "\\\042y",
/* 240: Thorn */ 0,
/* 241: thorn */ 0,
/* 242: undefined */ 0,
/* 243: mu */ 0,
/* 244: paragraph sign */ 0,
/* 245: fraction 3/4 */ 0,
/* 246: long dash */ 0,
/* 247: fraction 1/4 */ 0,
/* 248: fraction 1/2 */ 0,
/* 249: Female ordinal */ 0,
/* 250: Male ordinal */ 0,
/* 251: French double open quote */ 0,
/* 252: Solid square */ 0,
/* 253: French double close quote */ 0,
/* 254: Plus over minus sign */ 0,
/* 255: undefined */ 0
}
#endif
;

View File

@@ -0,0 +1,53 @@
/* $XConsortium: text.c /main/3 1995/11/08 11:00:29 rswiston $ */
/*
Copyright 1986 Tandem Computers Incorporated.
This product and information is proprietary of Tandem Computers Incorporated.
Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
*/
/* Text.c executes text-code specified in the interface. */
#include "userinc.h"
#include "globdec.h"
/* Include generated file */
#include "tfile.c"
/* When a text character occurs */
#if defined(M_PROTO)
void m_textaction(M_WCHAR m_textchar)
#else
void m_textaction(m_textchar)
M_WCHAR m_textchar ;
#endif
{
char buffer[10] ;
char mb_re;
M_WCHAR wc_re;
mb_re = M_RE;
mbtowc(&wc_re, &mb_re, 1);
if (m_stacktop->holdre) {
m_stacktop->holdre = FALSE ;
m_textaction(wc_re) ;
}
if (m_cdtrace) {
m_trace("Text character '") ;
buffer[0] = m_textchar ;
buffer[1] = M_EOS ;
m_trace(buffer) ;
m_trace("' (") ;
sprintf(buffer, "%d", m_textchar) ;
m_trace(buffer) ;
m_trace(")\n") ;
}
if (m_tagtrace)
m_toptstat = m_textchar == M_SPACE || m_textchar == M_TAB ?
M_WHITESPACE : M_OTHER ;
if (m_textchar != wc_re) m_stacktop->linestat = M_DCORCET ;
m_stackpar = m_stacktop->cdparam ;
(*m_ttable[m_stacktop->cdcase])(m_textchar) ;
}

View File

@@ -0,0 +1,24 @@
/* $XConsortium: trace.c /main/3 1995/11/08 11:00:43 rswiston $ */
/*
Copyright 1988, 1989 Hewlett-Packard Co.
*/
#include "userinc.h"
#include "globdec.h"
/* Write debugging trace information */
void m_wctrace(p)
M_WCHAR *p ;
{
char *mb_p;
mb_p = MakeMByteString(p);
fputs(mb_p, m_outfile) ;
m_free(mb_p,"multi-byte string");
}
void m_trace(p)
char *p ;
{
fputs(p, m_outfile);
}

View File

@@ -0,0 +1,15 @@
/* $XConsortium: userinc.h /main/3 1995/11/08 11:00:58 rswiston $ */
/* Copyright 1988, 1989 Hewlett-Packard Co. */
/* Header files for interface code files */
#include <stdio.h>
#include "basic.h"
#include "trie.h"
#include "dtdext.h"
#include "parser.h"
#include "delim.h"
#include "entext.h"
#include "signonx.h"
#include "pval.h"
#include "version.h"