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,86 @@
XCOMM $XConsortium: Imakefile /main/3 1995/11/08 10:04:07 rswiston $
/* eltdef Imakefile */
ARCCMD = arc u
UNARCCMD = arc x
ARCDELCMD = arc d
HELPTAG = ..
HELPTAGSRC = $(HELPTAG)/helptag
HELPPARSERSRC = $(HELPTAG)/parser
HELPELTDEFSRC = $(HELPTAG)/eltdef
HELPDTDFILE = $(HELPTAGSRC)/hptag.dtd
HELPUTILSRC = $(HELPTAG)/util
HELPBUILDSRC = $(HELPTAG)/build
HELPUTILLIB = $(HELPTAG)/util/libutil.a
HELPIFFILE = $(HELPTAGSRC)/help.if
HELPTSSFILE = $(HELPTAGSRC)/htag.tss
INCLUDES = -I. -I$(HELPUTILSRC) -I$(HELPBUILDSRC)
SRCS = eltdef.c eltutil.c entity.c scan.c
OBJS = eltdef.o eltutil.o entity.o scan.o
CCPRODS = case.c
ECPRODS = efile.c entfile.c pfile.c sfile.c stfile.c tfile.c
CHPRODS = context.h delim.h
EHPRODS = entity2.h globdec.h globdef.h if.h pval.h signon.h signonx.h
CPRODS = $(CCPRODS) $(CHPRODS)
EPRODS = $(ECPRODS) $(EHPRODS)
CTRASH = delim.dat error
ETRASH = estring.h error
TRASH = delim.dat estring.h error
PRODUCTS = $(CPRODS) $(EPRODS)
LOCAL_LIBRARIES = $(HELPUTILLIB)
/* Don't use shared libs for hp */
#ifdef HPArchitecture
#if OSMajorVersion > 7
EXTRA_LOAD_FLAGS = -Wl,-a archive
#endif
#endif
#ifdef SunArchitecture
.NO_PARALLEL:
#endif
all:: $(PRODUCTS)
NormalLibraryObjectRule()
NormalProgramTarget(eltdef,$(OBJS),delim.h $(LOCAL_LIBRARIES),$(LOCAL_LIBRARIES),)
$(EPRODS): eltdef $(HELPIFFILE) $(HELPTSSFILE)
$(RM) $(EPRODS) $(ETRASH)
./eltdef $(HELPIFFILE)
$(CPRODS): $(HELPUTILSRC)/context $(HELPTAGSRC)/delim.elt context.dat
$(RM) $(CPRODS) $(CTRASH)
/* get application-specific delim.dat */
$(CP) $(HELPTAGSRC)/delim.elt delim.dat
$(HELPUTILSRC)/context
$(HELPUTILSRC)/context:
cd $(HELPUTILSRC); make context
arc package :
if exist util.arc $(CP) build.arc old.arc
$(ARCCMD) util.arc *.c *.h makefile
unarc dearc :
$(UNARCCMD) util.arc
clean::
$(RM) $(PRODUCTS) $(TRASH)
depend::
includes:: $(PRODUCTS)
DependTarget()

View File

@@ -0,0 +1,722 @@
startcomment
comcon:comcon {
/* $XConsortium: context.dat /main/3 1995/07/17 18:50:09 lehors $ */
/*
Copyright 1986 Tandem Computers Incorporated.
This product and information is proprietary of Tandem Computers Incorporated.
Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co.
Context.dat defines the state transitions for program ELTDEF.
*/
}
;
endcomment
incom:incom
;
entstart
start:entdec
error:entdec
;
entsystem
entval:typedec {enttype(M_SYSTEM) ;}
;
entst
entval:typedec {enttype(M_STARTTAG) ;}
;
entet
entval:typedec {enttype(M_ENDTAG) ;}
;
entmd
entval:typedec {enttype(M_MD) ;}
;
entpi
entval:piorsdata {enttype(M_PI) ;}
;
entsdata
entval:piorsdata {enttype(M_SDATA) ;}
;
entcdata
entval:typedec {enttype(M_CDATAENT) ;}
;
typecode
piorsdata:codetagc {
entity->wheredef = M_DELTDEF ;
enttype(entity->type == M_PI ? M_CODEPI : M_CODESDATA) ;
entity->codeindex = ++codeent ;
}
;
endofcode
inentc:start
;
lit
value:value,
litcon:litcon
;
lita
value:value,
litcon:litcon
;
entlit
entval:declitent,
piorsdata:declitent,
typedec:declitent {entclen = 0 ;}
declitent:postent,
edeclitent:postent {
entcontent[entclen] = M_EOS ;
entity->content =
(M_WCHAR *) m_malloc(entclen + 1, "entity content") ;
w_strcpy(entity->content, entcontent) ;
entity->wheredef = M_DELTDEF ;
}
;
entlita
entval:declitaent,
piorsdata:declitaent,
typedec:declitaent {entclen = 0 ;}
declitaent:postent,
edclitaent:postent {
entcontent[entclen] = M_EOS ;
entity->content =
(M_WCHAR *) m_malloc(entclen + 1, "entity content") ;
w_strcpy(entity->content, entcontent) ;
entity->wheredef = M_DELTDEF ;
}
;
cro
litcon:litcon
;
litrs
litcon:litcon
;
litrsc
litcon:litcon
;
litre
litcon:litcon
;
litrec
litcon:litcon
;
littab
litcon:litcon
;
littabc
litcon:litcon
;
litspace
litcon:litcon
;
litcspace
litcon:litcon
;
refc
charent:charent
;
signon
start:insignon {restart = RSIGNON ;}
error:insignon
;
gdef
start:globdef,
insignon:globdef {
endsignon() ;
restart = RGLOBDEF ;
/* fprintf(globdef, "#line %d \"%s\"\n", m_line, iffile) ; */
}
error:globdef {
endsignon() ;
/* fprintf(globdef, "#line %d \"%s\"\n", m_line, iffile) ; */
}
;
gdec
start:globdec,
insignon:globdec {
endsignon() ;
restart = RGLOBDEC ;
/* fprintf(globdec, "#line %d \"%s\"\n", m_line, iffile) ; */
}
globdef:globdec {
restart = RGLOBDEC ;
/* fprintf(globdec, "#line %d \"%s\"\n", m_line, iffile) ; */
}
error:globdec {
if (! signonend) endsignon() ;
restart = RGLOBDEC ;
/* fprintf(globdec, "#line %d \"%s\"\n", m_line, iffile) ; */
}
;
inisstring
start:iniss,
insignon:iniss {
endsignon() ;
gss = stringcnt ;
instring = TRUE ;
}
inies:iniss {
endstring() ;
gss = stringcnt ;
if (gss)
m_error("Multiple specification of global start string") ;
instring = TRUE ;
}
inisc:iniss,
iniec:iniss,
initc:iniss,
inipc:iniss,
inistc:iniss {
if (gss)
m_error("Multiple specification of global start string") ;
gss = stringcnt ;
instring = TRUE ;
}
globdef:iniss,
globdec:iniss {
gss = stringcnt ;
instring = TRUE ;
}
;
iniestring
start:inies,
insignon:inies {
endsignon() ;
ges = stringcnt ;
instring = TRUE ;
}
iniss:inies {
if (ges)
m_error("Multiple specification of global end string") ;
endstring() ;
ges = stringcnt ;
instring = TRUE ;
}
inisc:inies,
iniec:inies,
initc:inies,
inipc:inies,
inistc:inies {
if (ges)
m_error("Multiple specification of global end string") ;
ges = stringcnt ;
instring = TRUE ;
}
globdef:inies,
globdec:inies {
ges = stringcnt ;
instring = TRUE ;
}
;
inistring
start:inistc,
insignon:inistc {
endsignon() ;
/* fprintf(stfile, "#line %d \"%s\"\n", m_line, iffile) ; */
finistc = FALSE ;
}
iniss:inistc,
inies:inistc {
finistc = FALSE ;
endstring() ;
if (! finistc)
m_error("Multiple specification of global string code") ;
}
iniec:inistc,
initc:inistc,
inipc:inistc,
inisc:inistc {
if (! finistc)
m_error("Multiple specification of global string code") ;
/* fprintf(stfile, "#line %d \"%s\"\n", m_line, iffile) ; */
finistc = FALSE ;
}
globdef:inistc,
globdec:inistc {
finistc = FALSE ;
/* fprintf(stfile, "#line %d \"%s\"\n", m_line, iffile) ; */
}
;
inistart
start:inisc,
insignon:inisc {
endsignon() ;
/* fprintf(sfile, "#line %d \"%s\"\n", m_line, iffile) ; */
}
iniss:inisc,
inies:inisc {endstring() ;}
iniec:inisc,
initc:inisc,
inipc:inisc,
inistc:inisc,
globdef:inisc,
globdec:inisc {
/* fprintf(sfile, "#line %d \"%s\"\n", m_line, iffile) ; */
}
;
iniend
start:iniec,
insignon:iniec {
endsignon() ;
/* fprintf(efile, "#line %d \"%s\"\n", m_line, iffile) ; */
}
iniss:iniec,
inies:iniec {endstring() ;}
inisc:iniec,
initc:iniec,
inipc:iniec,
inistc:iniec,
globdef:iniec,
globdec:iniec {
/* fprintf(efile, "#line %d \"%s\"\n", m_line, iffile) ; */
}
;
initext
start:initc,
insignon:initc {
endsignon() ;
/* fprintf(tfile, "#line %d \"%s\"\n", m_line, iffile) ; */
finitext = FALSE ;
}
iniss:initc,
inies:initc {endstring() ;}
inisc:initc,
iniec:initc,
inipc:initc,
inistc:initc,
globdef:initc,
globdec:initc {
/* fprintf(tfile, "#line %d \"%s\"\n", m_line, iffile) ; */
finitext = FALSE ;
}
;
initpi
start:inipc,
insignon:inipc {
endsignon() ;
/* fprintf(pfile, "#line %d \"%s\"\n", m_line, iffile) ; */
finipi = FALSE ;
}
iniss:inipc,
inies:inipc {endstring() ;}
inisc:inipc,
iniec:inipc,
initc:inipc,
inistc:inipc,
globdef:inipc,
globdec:inipc {
/* fprintf(pfile, "#line %d \"%s\"\n", m_line, iffile) ; */
finipi = FALSE ;
}
;
elt
start:needn,
insignon:needn {
endsignon() ;
endini() ;
}
inelt:needn
globdef:needn,
globdec:needn,
inisc:needn,
iniec:needn,
initc:needn,
inipc:needn {endini() ;}
inss:needn,
ines:needn {endstring() ;}
insc:needn
inec:needn
intc:needn
inpc:needn
instc:needn
inparam:needn
preparam:needn
error:needn
;
tagc
postent:start
codetagc:inentc {
startcode(entity->codeindex, &inent, entfile,
"c", nopar, nopar, "") ;
}
close:preparam
sschain:inss {
*getaction(starray) = stringcnt ;
instring = TRUE ;
}
eschain:ines {
*getaction(etarray) = stringcnt ;
instring = TRUE ;
}
pcchain:inpc {
*getaction(pcarray) = ++pactions ;
startcode(pactions, &inpc, pfile, "p", pproto, pformal, pftype) ;
}
tcchain:intc {
*getaction(tcarray) = ++tactions ;
startcode(tactions, &intext, tfile, "t", tproto, tformal,
tftype) ;
}
scchain:insc {
*getaction(scarray) = ++sactions ;
startcode(sactions, &insc, sfile, "s", nopar, nopar, "") ;
}
ecchain:inec {
*getaction(ecarray) = ++eactions ;
startcode(eactions, &inec, efile, "e", nopar, nopar, "") ;
}
stcchain:instc {
*getaction(stcarray) = ++stactions ;
startcode(stactions, &instc, stfile, "st", stproto, stformal,
stft) ;
}
;
sep
sschain:sschain {*getaction(starray) = stringcnt ;}
eschain:eschain {*getaction(etarray) = stringcnt ;}
pcchain:pcchain {*getaction(pcarray) = pactions + 1 ;}
tcchain:tcchain {*getaction(tcarray) = tactions + 1 ;}
scchain:scchain {*getaction(scarray) = sactions + 1 ;}
ecchain:ecchain {*getaction(ecarray) = eactions + 1 ;}
stcchain:stcchain {*getaction(stcarray) = stactions + 1 ;}
postvalue:invalue
;
param
preparam:inparam
;
vi
cvar:pname
cvalue:value
;
rend
postpname:inparam
;
grpo
postpname:invalue
;
grpc
invalue:postpname
postvalue:postpname
;
sss
inelt:sschain
inss:sschain,
ines:sschain {endstring() ;}
inpc:sschain
intc:sschain
insc:sschain
inec:sschain
instc:sschain
inparam:sschain
preparam:sschain
;
ess
iniss:inisc,
inss:inelt {endstring() ;}
;
ses
inelt:eschain
inss:eschain,
ines:eschain {endstring() ;}
inpc:eschain
intc:eschain
insc:eschain
inec:eschain
instc:eschain
inparam:eschain
preparam:eschain
;
ees
inies:inisc,
ines:inelt {endstring() ;}
;
scode
inss:scchain,
ines:scchain {endstring() ;}
inparam:scchain
inelt:scchain
inpc:scchain
intc:scchain
insc:scchain
inec:scchain
instc:scchain
preparam:scchain
;
ecode
inss:ecchain,
ines:ecchain {endstring() ;}
insc:ecchain
inparam:ecchain
inelt:ecchain
inec:ecchain
intc:ecchain
inpc:ecchain
instc:eschain
preparam:ecchain
;
tcode
inss:tcchain,
ines:tcchain {endstring() ;}
insc:tcchain
inec:tcchain
inparam:tcchain
inelt:tcchain
preparam:tcchain
inpc:tcchain
intc:tcchain
instc:tcchain
;
pcode
inelt:pcchain
preparam:pcchain
inparam:pcchain
inss:pcchain,
ines:pcchain {endstring() ;}
inpc:pcchain
intc:pcchain
insc:pcchain
inec:pcchain
instc:pcchain
;
stcode
inelt:stcchain
preparam:stcchain
inparam:stcchain
inss:stcchain,
ines:stcchain {endstring() ;}
inpc:stcchain
intc:stcchain
insc:stcchain
inec:stcchain
instc:stcchain
;
endfile
start:finish,
insignon:finish {
endsignon() ;
endini() ;
}
globdef:finish,
globdec:finish,
inistc:finish,
inisc:finish,
iniec:finish,
initc:finish,
inipc:finish {endini() ;}
;
wildcard
stcchain:stcchain,
sschain:sschain,
eschain:eschain,
scchain:scchain,
ecchain:ecchain,
tcchain:tcchain,
pcchain:pcchain {
*nextchain = (CHAIN *) m_malloc(sizeof(CHAIN), "chain") ;
(*nextchain)->elt = 1 ;
(*nextchain)->next = NULL ;
nextchain = &(*nextchain)->next ;
}
;
literal
value:postvalue {value(literal) ;}
;
name
needn:close {startelement() ;}
inparam:cvar {storecvar() ;}
pname:postpname {storepname() ;}
invalue:cvalue {cvalue() ;}
value:postvalue {value(name) ;}
entdec:entval {addent() ;}
stcchain:stcchain,
sschain:sschain,
eschain:eschain,
scchain:scchain,
ecchain:ecchain,
tcchain:tcchain,
pcchain:pcchain {
*nextchain = (CHAIN *) m_malloc(sizeof(CHAIN), "chain") ;
(*nextchain)->next = NULL ;
if ((*nextchain)->elt = m_packedlook(m_entree, name))
(*nextchain)->elt++ ;
else
m_err1("Undefined element: %s", name) ;
nextchain = &(*nextchain)->next ;
}
;
text
declitent:declitent {
if (entclen >= M_LITLEN) {
curcon = EDECLITENT ;
m_error("Entity content too long") ;
}
else entcontent[entclen++] = textchar ;
}
declitaent:declitaent {
if (entclen >= M_LITLEN) {
curcon = EDCLITAENT ;
m_error("Entity content too long") ;
}
else entcontent[entclen++] = textchar ;
}
edeclitent:edeclitent
edclitaent:edclitaent
insignon:insignon {
socr = (LOGICAL) (textchar == '\n') ;
signonmsg[sochar++] = textchar ;
if (sochar >= SOCHAR) {
m_error("Exceeded buffer for sign-on message") ;
exit(TRUE) ;
}
}
globdef:globdef {
fprintf(globdef, "%c", textchar) ;
/* if (textchar == '\n') fprintf(globdef, "#line %d \"%s\"\n",
m_line, iffile) ; */
}
globdec:globdec {
fprintf(globdec, "%c", textchar) ;
/* if (textchar == '\n') fprintf(globdec, "#line %d \"%s\"\n",
m_line, iffile) ; */
}
iniss:iniss,
inss:inss {
if (! stringstart) fprintf(string, ",\n") ;
fprintf(string, " %d", textchar) ;
stringstart = FALSE ;
stringcnt++ ;
}
inies:inies,
ines:ines {
if (! stringstart) fprintf(string, ",\n") ;
fprintf(string, " %d", textchar) ;
stringstart = FALSE ;
stringcnt++ ;
}
inisc:inisc,
insc:insc {
fprintf(sfile, "%c", textchar) ;
/* if (textchar == '\n') fprintf(sfile, "#line %d \"%s\"\n",
m_line, iffile) ; */
}
iniec:iniec,
inec:inec {
fprintf(efile, "%c", textchar) ;
/* if (textchar == '\n') fprintf(efile, "#line %d \"%s\"\n",
m_line, iffile) ; */
}
initc:initc,
intc:intc {
fprintf(tfile, "%c", textchar) ;
/* if (textchar == '\n') fprintf(tfile, "#line %d \"%s\"\n",
m_line, iffile) ; */
}
inipc:inipc,
inpc:inpc {
fprintf(pfile, "%c", textchar) ;
/* if (textchar == '\n') fprintf(pfile, "#line %d \"%s\"\n",
m_line, iffile) ; */
}
inistc:inistc,
instc:instc {
fprintf(stfile, "%c", textchar) ;
/* if (textchar == '\n') fprintf(stfile, "#line %d \"%s\"\n",
m_line, iffile) ; */
}
inentc:inentc {
fprintf(entfile, "%c", textchar) ;
/* if (textchar == '\n') fprintf(entfile, "#line %d \"%s\"\n",
m_line, iffile) ; */
}
;

View File

@@ -0,0 +1,74 @@
/* $XConsortium: eltdef.c /main/3 1995/11/08 10:04:23 rswiston $ */
/*
Copyright 1986 Tandem Computers Incorporated.
This product and information is proprietary of Tandem Computers Incorporated.
Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co.
*/
/* Eltdef.c contains the main program for ELTDEF */
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#if defined(MSDOS)
#include <process.h>
#endif
#include "basic.h"
#include "trie.h"
#define M_DTDDEF
#include "dtd.h"
#include "context.h"
#include "delim.h"
#define ELTDEF
#include "eltdef.h"
#define M_ENTDEF
#include "entity.h"
/* Main program */
void main(argc, argv)
int argc ;
char **argv ;
{
int m_token ;
if (argc > 2)
if (*argv[2] == '-') {
if (strchr(argv[2], 'a')) m_malftrace = TRUE ;
if (strchr(argv[2], 'A')) m_malftrace = TRUE ;
if (strchr(argv[2], 'd')) debug = TRUE ;
if (strchr(argv[2], 'D')) debug = TRUE ;
if (strchr(argv[2], 'h')) m_heapchk = TRUE ;
if (strchr(argv[2], 'H')) m_heapchk = TRUE ;
if (strchr(argv[2], 's')) scantrace = TRUE ;
if (strchr(argv[2], 'S')) scantrace = TRUE ;
}
else
fprintf(stderr,
"****Starting with MARKUP 2.0, ELTDEF no longer writes a statistics file"
) ;
if (argc < 2) {
fprintf(stderr, "**** Specify interface file ****\n") ;
exit(TRUE) ;
}
strncpy(iffile, argv[1], IFLEN) ;
initialize() ;
while (TRUE) {
m_token = scan() ;
if (m_token == ELT) restart = RELEMENT ;
m_prevcon = curcon ;
curcon = m_newcon(m_prevcon - 1, m_token - 1) ;
if (scantrace)
printf(
"Main: m_prevcon=%d,m_token=%d,curcon=%d,textchar='%c'(%d), line=%d\n",
m_prevcon, m_token, curcon, textchar, textchar, m_line) ;
#include "case.c"
if (m_token == ENDFILE) break ;
if (! curcon) {
m_error("Parsing table error") ;
break ;
}
}
done() ;
}

View File

@@ -0,0 +1,219 @@
/* $XConsortium: eltdef.h /main/3 1995/11/08 10:04:40 rswiston $ */
/*
Copyright 1986 Tandem Computers Incorporated.
This product and information is proprietary of Tandem Computers Incorporated.
Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co.
*/
/* Eltdef.h is the include file for allocating global variables in ELTDEF */
#if defined(ELTDEF)
#define ELTEXTERN
#define ELTINIT(a) = a
#else
#define ELTEXTERN extern
#define ELTINIT(a)
#endif
#include "common.h"
/* Error recovery status */
#define RENTITY 0
#define RSIGNON 1
#define RGLOBDEC 2
#define RGLOBDEF 3
#define RELEMENT 4
/* State transition network generated by CONTEXT */
#include "sparse.h"
/* Indicates whether, and if so where, each character can appear in
a name */
#if defined(ELTDEF)
#include "chartype.h"
#else
extern M_CHARTYPE m_ctarray[M_CHARSETLEN] ;
#endif
/* Scanned name or literal */
ELTEXTERN M_WCHAR name[M_NAMELEN + 1] ;
ELTEXTERN M_WCHAR literal[M_LITLEN + 1] ;
/* Associates a C variable with a particular parameter */
typedef struct cvarstruct CVARSTRUCT ;
struct cvarstruct {
int param ;
M_WCHAR *cvarptr ;
CVARSTRUCT *next ;
} ;
ELTEXTERN CVARSTRUCT *cvarlist ;
/* Current and previous context (state) of transition system
controlling ELTDEF */
ELTEXTERN int curcon ELTINIT(START) ;
ELTEXTERN int m_prevcon ;
/* Character read-ahead buffer */
ELTEXTERN int toundo ELTINIT(0) ;
ELTEXTERN int maxundo ELTINIT(0) ;
#define SAVECHAR 50
ELTEXTERN int savechar[SAVECHAR] ;
/* Chain of elements named in pseudo-tag */
typedef struct chain CHAIN ;
struct chain {
M_ELEMENT elt ;
CHAIN *next ;
} ;
ELTEXTERN CHAIN *firstchain ELTINIT(NULL) ;
ELTEXTERN CHAIN **nextchain ELTINIT(&firstchain) ;
/* Text character returned from scanner */
ELTEXTERN M_WCHAR textchar ;
/* Identifying index of element currently being processed */
ELTEXTERN M_ELEMENT openelt ELTINIT(M_NULLVAL) ;
/* Output files */
ELTEXTERN FILE *globdec, *globdef, *string,
*pfile, *tfile, *sfile, *efile, *entfile, *ifile, *stfile, *ifh, *pvalh ;
/* Flags indicating whether currently in the middle of processing
an action */
ELTEXTERN LOGICAL intext ELTINIT(FALSE),
inent ELTINIT(FALSE),
inpc ELTINIT(FALSE),
insc ELTINIT(FALSE),
inec ELTINIT(FALSE),
instc ELTINIT(FALSE),
instring ELTINIT(FALSE) ;
/* Location of global start-string and end-string, if any */
ELTEXTERN int gss ELTINIT(0),
ges ELTINIT(0) ;
/* Flags indicating whether default code setments are to be used */
ELTEXTERN LOGICAL finitext ELTINIT(TRUE),
finipi ELTINIT(TRUE),
finistc ELTINIT(TRUE) ;
/* Whether have finished the sign-on message */
ELTEXTERN LOGICAL signonend ELTINIT(FALSE) ;
/* Whether errors have occurred */
ELTEXTERN LOGICAL errexit ELTINIT(FALSE) ;
/* Number of characters currently written to stext.h and etext.h */
ELTEXTERN int stringcnt ELTINIT(1) ;
/* Number of actions so far written to code files */
ELTEXTERN int sactions ELTINIT(1),
eactions ELTINIT(1),
tactions ELTINIT(1),
pactions ELTINIT(1),
stactions ELTINIT(1) ;
/* Pool of ponters for associating a chain of elements with an action string
or code */
typedef struct action ACTION ;
struct action {
int data ;
M_ELEMENT element ;
int count ;
ACTION *son ;
ACTION *next ;
ACTION *nextact ;
} ;
ELTEXTERN int actlen ELTINIT(0) ;
ELTEXTERN ACTION *firstact ELTINIT(NULL) ;
ELTEXTERN ACTION **nextact ELTINIT(&firstact) ;
/* Number of elements defined in the document type */
#if defined(M_DTDDEF)
#define ELCOUNT sizeof(m_element)/sizeof(m_element[0])
#else
#define ELCOUNT
#endif
/* Action arrays, indexed by the element in which they occur. Each element
is a linked list for actions qualified by the context in which they
occur. */
ELTEXTERN ACTION *starray[ELCOUNT],
*etarray[ELCOUNT],
*scarray[ELCOUNT],
*ecarray[ELCOUNT],
*tcarray[ELCOUNT],
*pcarray[ELCOUNT],
*stcarray[ELCOUNT] ;
/* Store the sign-on message */
#define SOCHAR 512
ELTEXTERN char signonmsg[SOCHAR] ;
ELTEXTERN int sochar ELTINIT(0) ;
/* Indicates which elements have been processed at a particular time */
ELTEXTERN LOGICAL processed[ELCOUNT] ;
/* Flags to indicate whether data has yet been written to various files */
ELTEXTERN LOGICAL stringstart ELTINIT(TRUE) ;
/* Flag indicating whether a carriage return was the last character of
the signon message */
ELTEXTERN LOGICAL socr ELTINIT(FALSE) ;
/* Number of current input line */
ELTEXTERN int m_line ELTINIT(1) ;
/* Pointer to file error for error messages */
ELTEXTERN FILE *m_errfile ;
/* Name of interface file */
#define IFLEN 512
ELTEXTERN char iffile[IFLEN] ;
/* Pointer to current entity */
ELTEXTERN M_ENTITY *entity ;
/* Count of code entities defined */
ELTEXTERN int codeent ELTINIT(0) ;
/* Content of entity being defined */
ELTEXTERN int entclen ;
ELTEXTERN M_WCHAR entcontent[M_LITLEN + 1] ;
/* Error recovery status */
ELTEXTERN int restart ELTINIT(RENTITY) ;
/* Strings to write to generated files */
#define pproto "M_WCHAR *m_pi, M_WCHAR *m_entname, int m_enttype"
#define pformal "m_pi, m_entname, m_enttype"
#define pftype " M_WCHAR *m_pi ;\n M_WCHAR *m_entname ;\n int m_enttype ;"
#define tproto "M_WCHAR m_textchar"
#define tformal "m_textchar"
#define tftype " M_WCHAR m_textchar ;\n"
#define stproto "M_WCHAR *m_string, LOGICAL M_START, LOGICAL M_END"
#define stformal "m_string, M_START, M_END"
#define stft " M_WCHAR *m_string ;\n LOGICAL M_START ;\n LOGICAL M_END ;\n"
#define nopar "M_NOPAR"
/* Structures for generating defines for parameter values */
ELTEXTERN M_TRIE parval ;
typedef struct {
M_WCHAR *cname ;
M_WCHAR *value ;
int line ;
} PARVAL ;
ELTEXTERN PARVAL *pval ;
/* Function prototypes */
#include "proto.h"
/* Flag to open fewer files for convenience of debugging with
CodeView */
ELTEXTERN LOGICAL debug ELTINIT(FALSE) ;
/* Scanner trace for debugging */
ELTEXTERN LOGICAL scantrace ELTINIT(FALSE) ;
/* Test validity of heap in calls to malloc/free */
ELTEXTERN LOGICAL m_heapchk ELTINIT(FALSE) ;
/* Trace calls to malloc/free */
ELTEXTERN LOGICAL m_malftrace ELTINIT(FALSE) ;

View File

@@ -0,0 +1,675 @@
/* $XConsortium: eltutil.c /main/3 1995/11/08 10:04:56 rswiston $ */
/*
Copyright 1986 Tandem Computers Incorporated.
This product and information is proprietary of Tandem Computers Incorporated.
Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co.
*/
/* Eltutil.c contains procedures for program ELTDEF */
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#if defined(MSDOS)
#include <process.h>
#endif
#include "basic.h"
#include "trie.h"
#include "dtdext.h"
#include "eltdef.h"
#include "delim.h"
#include "context.h"
#include "entext.h"
#include "version.h"
/* Output indicated action pointer array to if.h */
void actptrout(array, name)
ACTION **array;
char *name;
{
int i;
fprintf(ifh, "M_IFEXTERN int %s[%d]\n#if defined(M_IFDEF)\n = {\n",
name, m_elcount);
for (i = 0 ; i < m_elcount ; i++) {
if (i > 0) fprintf(ifh, ",\n");
fprintf(ifh, " %d", array[i] ? array[i]->count : M_NULLVAL);
}
fprintf(ifh, "}\n#endif\n ;\n");
}
/* Close a code file and write jump table at the end */
#if defined(M_PROTO)
void closeiffile(LOGICAL flag, FILE *file, int count, char *table, char *proto)
#else
void closeiffile(flag, file, count, table, proto)
LOGICAL flag;
FILE *file;
int count;
char *table;
char *proto;
#endif
{
int i;
endcode(flag, file);
if (count) {
fprintf(file,
"void (*m_%stable[])(\n#if defined(M_PROTO)\n %s\n#endif\n ) = {\n",
table, proto);
fprintf(file, " m_%s1, /* Place holder for 1-based indexing */\n",
table);
for (i = 1 ; i <= count ; i++) {
fprintf(file, " m_%s%d", table, i);
if (i != count) fputs(",\n", file);
}
fputs("} ;\n", file);
}
else
fprintf(file,
"void (*m_%stable[1])(\n#if defined(M_PROTO)\n %s\n#endif\n ) ;\n",
table, proto);
fclose(file);
}
/* Called when the C identifier to be #define'd to a parameter value is
scanned */
void cvalue(M_NOPAR)
{
PARVAL *new;
new = (PARVAL *) m_malloc(sizeof(PARVAL), "parameter value");
if (pval = (PARVAL *) m_ntrtrie(name, &parval, (M_TRIE *) new))
m_free(new, "parameter value");
else {
new->line = 0;
new->value = NULL;
new->cname = (M_WCHAR *) m_malloc(w_strlen(name) + 1, "C name");
w_strcpy(new->cname, name);
pval = new;
}
}
/* Called after last input character is read to place closing punctuation
at end of output files and close them */
void done(M_NOPAR)
{
M_ENTITY *ent;
ACTION *actp;
LOGICAL first;
int i;
closeiffile(inent, entfile, codeent, "c", nopar);
closeiffile(intext, tfile, tactions, "t", tproto);
closeiffile(inpc, pfile, pactions, "p", pproto);
closeiffile(insc, sfile, sactions, "s", nopar);
closeiffile(inec, efile, eactions, "e", nopar);
closeiffile(instc, stfile, stactions, "st", stproto);
endstring();
fclose(string);
/* Write if.h (which was opened for sign-on message) */
fprintf(ifh, "M_IFEXTERN int m_gss M_IFINIT(%d) ;\n", gss);
fprintf(ifh, "M_IFEXTERN int m_ges M_IFINIT(%d) ;\n", ges);
fputs("M_IFEXTERN struct {\n", ifh);
fputs(" int data ;\n", ifh);
fputs(" M_ELEMENT element ;\n", ifh);
fputs(" int son ;\n", ifh);
fputs(" int next ;\n", ifh);
if (actlen) {
fprintf(ifh,
" } m_action[%d]\n#if defined(M_IFDEF)\n = {\n",
actlen);
first = TRUE;
for (actp = firstact ; actp ; actp = actp->nextact) {
if (first) first = FALSE;
else fprintf(ifh, ",\n");
fprintf(ifh, " %d, %d, %d, %d",
actp->data, actp->element,
actp->son ? actp->son->count : M_NULLVAL,
actp->next ? actp->next->count : M_NULLVAL);
}
fprintf(ifh, "}\n#endif\n ;\n");
}
else fputs(" } m_action[1] ;\n", ifh);
actptrout(starray, "m_starray");
actptrout(etarray, "m_etarray");
actptrout(scarray, "m_scarray");
actptrout(ecarray, "m_ecarray");
actptrout(tcarray, "m_tcarray");
actptrout(pcarray, "m_pcarray");
actptrout(stcarray, "m_stcarray");
outstring();
m_openchk(&pvalh, "pval.h", "w");
fputs("/* Parameter values specified in the interface */\n", pvalh);
if (parval.data) outpval(parval.data);
fclose(ifh);
/* Report any elements and entities left undefined */
for (i = 0 ; i < m_elcount ; i++)
if (! processed[i])
warning1("Warning: No specification for element %s",
&m_ename[m_element[i].enptr]);
for (ent = firstent ; ent ; ent = ent->next)
if (! ent->wheredef)
warning1("Warning: Entity %s undefined", ent->name);
entout("entity2");
exit(errexit);
}
/* Called when finished reading a section of code from the input file */
#if defined(M_PROTO)
void endcode(LOGICAL flag, FILE *file)
#else
void endcode(flag, file)
LOGICAL flag;
FILE *file;
#endif
{
if (flag) fprintf(file, "}}\n\n");
}
/* Called at the end of all initial fields in the interface definition */
void endini(M_NOPAR)
{
if (finitext)
fputs(" putc(m_textchar, m_outfile);\n", tfile);
if (finipi)
fputs(" fputs(m_pi, m_outfile) ;\n", pfile);
if (finistc)
{
fputs(" {\n", stfile);
fputs(" char *mb_string;\n", stfile);
fputs(" mb_string = MakeMByteString(m_string);\n", stfile);
fputs(" fputs(mb_string, m_outfile) ;\n", stfile);
fputs(" m_free(mb_string,\"multi-byte string\");;\n", stfile);
fputs(" }\n", stfile);
}
}
/* End the sign-on message */
#include <time.h>
void endsignon(M_NOPAR)
{
time_t storetime;
char *p;
char *timeofday;
static char signon1[] = "Interface generated from ";
static char signon2[] = " on ";
int i;
int len;
FILE *sgfile;
signonend = TRUE;
/* Discard a trailing carriage return in the sign-on message */
if (socr) sochar--;
time(&storetime);
timeofday = ctime(&storetime);
len =
sochar+strlen(signon1)+strlen(signon2)+strlen(iffile)+strlen(timeofday)
/* a byte for end of string marker */
+ 1
/* a byte for a carriage return after any user-supplied message */
+ (sochar ? 1 : 0);
m_openchk(&sgfile, "signonx.h", "w");
fprintf(sgfile, "extern char m_signon[%d] ;\n", len);
fclose(sgfile);
m_openchk(&sgfile, "signon.h", "w");
fprintf(sgfile, "char m_signon[%d] = {\n", len);
for (i = 0 ; i <sochar ; i++)
fprintf(sgfile, " %d,\n", signonmsg[i]);
if (sochar) fputs(" 10,\n", sgfile);
for (p = signon1 ; *p ; p++)
fprintf(sgfile, " %d,\n", *p);
for (p = iffile ; *p ; p++)
fprintf(sgfile, " %d,\n", *p);
for (p = signon2 ; *p ; p++)
fprintf(sgfile, " %d,\n", *p);
for (p = timeofday ; *p ; p++)
fprintf(sgfile, " %d,\n", *p);
fputs(" 0} ;\n", sgfile);
fclose(sgfile);
}
/* Closes a start-string or end-string */
void endstring(M_NOPAR)
{
if (instring) {
if (stringstart) stringstart = FALSE;
else fprintf(string, ",\n");
stringcnt++;
instring = FALSE;
fprintf(string, " 0");
}
/* If called after ENDFILE, ensure at least one character in output file*/
else if (stringstart) fprintf(string, " 0");
}
/* Set the type of an entity and check if different than declaration in
BUILD */
void enttype(type)
int type;
{
if ((entity->type == M_PI && type == M_CODEPI) ||
(entity->type == M_SDATA && type == M_CODESDATA));
else if (entity->type != M_GENERAL &&
entity->type != (unsigned char) type)
warning1("Redefining type of entity %s", name);
entity->type = (unsigned char) type;
}
/* Free storage used for a context-specification chain */
void freechain(M_NOPAR)
{
CHAIN *chainp, *dchainp;
for (chainp = firstchain ; chainp ;) {
dchainp = chainp;
chainp = chainp->next;
m_free(dchainp, "chain");
}
firstchain = NULL;
nextchain = &firstchain;
}
/* Returns pointer to data field in action node for current chain of
elements */
int *getaction(array)
ACTION **array;
{
ACTION *start, *node;
CHAIN *chainp;
if (! array[openelt - 1]) {
array[openelt - 1] = getactstruct();
array[openelt - 1]->element = openelt + 1;
}
start = array[openelt - 1];
for (chainp = firstchain ; chainp ; chainp = chainp->next) {
if (! start->son) {
for ( ; chainp ; chainp = chainp->next) {
start->son = getactstruct();
start->son->element = chainp->elt;
start = start->son;
}
freechain();
return(&start->data);
}
for (node = start->son ; node ; start = node, node = node->next)
if (node->element == chainp->elt) break;
if (! node) {
start->next = getactstruct();
start->next->element = chainp->elt;
start = start->next;
}
else start = node;
}
if (start->data) m_error("Duplicate specification");
freechain();
return(&start->data);
}
/* Allocate new action structure */
ACTION *getactstruct(M_NOPAR)
{
ACTION *new;
new = (ACTION *) m_malloc(sizeof(ACTION), "action");
new->count = ++actlen;
new->data = M_NULLVAL;
new->son = new->next = new->nextact = NULL;
*nextact = new;
nextact = &new->nextact;
return(new);
}
/* Program initialization */
void initialize(M_NOPAR)
{
char **mb_delims;
M_WCHAR **wc_delims;
fprintf(stderr, "MARKUP System - ELTDEF %s\n", M_VERSION);
fprintf(stderr, "Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co.\n");
m_openchk(&ifh, "if.h", "w");
m_openchk(&globdef, "globdef.h", "w");
m_openchk(&globdec, "globdec.h", "w");
m_openchk(&pfile, "pfile.c", "w");
/* ELTDEF opens too many files for use with CodeView debugger. If
this option is set, all code segments are written to one file */
if (debug)
{
tfile =
sfile =
efile =
stfile =
entfile =
pfile;
}
else
{
m_openchk(&tfile, "tfile.c", "w");
m_openchk(&sfile, "sfile.c", "w");
m_openchk(&efile, "efile.c", "w");
m_openchk(&stfile, "stfile.c", "w");
m_openchk(&entfile, "entfile.c", "w");
}
m_openchk(&string, "estring.h", "w");
m_openchk(&m_errfile, "error", "w");
m_openchk(&ifile, iffile, "r");
mb_delims = mb_dlmptr;
wc_delims = m_dlmptr;
while (*mb_delims)
{
*wc_delims++ = MakeWideCharString(*mb_delims);
mb_delims++;
}
*wc_delims = 0;
/* Start array for sign-on message on globals.h. Also,
make sure there is at least one line in globals.h, because
DOS copy does not copy an empty file */
fputs("/* Global definitions specified by interface designer*/\n",
globdef);
fputs("/* Global declarations specified by interface designer*/\n",
globdec);
fputs("#if defined(M_IFDEF)\n", ifh);
fputs("#define M_IFEXTERN\n", ifh);
fputs("#define M_IFINIT(a) = a\n", ifh);
fputs("#else\n", ifh);
fputs("#define M_IFEXTERN extern\n", ifh);
fputs("#define M_IFINIT(a)\n", ifh);
fputs("#endif\n", ifh);
startcode(pactions, &inpc, pfile, "p", pproto, pformal, pftype);
startcode(tactions, &intext, tfile, "t", tproto, tformal, tftype);
startcode(sactions, &insc, sfile, "s", nopar, nopar, "");
startcode(eactions, &inec, efile, "e", nopar, nopar, "");
startcode(stactions, &instc, stfile, "st", stproto, stformal, stft);
}
/* Output definitions for strings */
void outstring(M_NOPAR)
{
int c;
m_openchk(&string, "estring.h", "r");
fprintf(ifh, "M_IFEXTERN char m_string[%d]\n",
stringcnt > 1 ? stringcnt - 1 : 1);
if (stringcnt - 1) {
fputs("#if defined(M_IFDEF)\n = {\n", ifh);
while ((c = getc(string)) != EOF) putc(c, ifh);
fputs("}\n#endif\n", ifh);
}
fputs(" ;\n", ifh);
fclose(string);
}
/* Output #define's for parameter values */
void outpval(p)
M_TRIE *p;
{
M_WCHAR *q;
for ( ; p ; p = p->next)
if (p->symbol) outpval(p->data);
else
{
char *mb_cname;
mb_cname = MakeMByteString(((PARVAL *) p->data)->cname);
fprintf(pvalh,
"/* line %d \"%s\" */\n",
((PARVAL *) p->data)->line,
iffile);
fprintf(pvalh, "#define %s \"", mb_cname);
m_free(mb_cname,"multi-byte string");
if (q = ((PARVAL *) p->data)->value)
for ( ; *q ; q++)
{
char mbq[32]; /* larger than largest possible mbyte char */
int length;
length = wctomb(mbq, *q);
if (length == 1)
switch (*mbq)
{
case '\n':
fputs("\\n", pvalh);
break;
case '"':
fputs("\\\"", pvalh);
break;
default:
putc(*mbq, pvalh);
break;
}
else
fputs(mbq, pvalh);
}
fputs("\"\n", pvalh);
}
}
/* Skip rest of statement after an error */
void skiptoend(M_NOPAR)
{
int i;
static errlev = 0;
CVARSTRUCT *cvarp, *dvarp;
for (cvarp = cvarlist ; cvarp ;) {
dvarp = cvarp;
m_free(cvarp->cvarptr, "C variable name");
cvarp = cvarp->next;
m_free(dvarp, "C variable");
}
cvarlist = NULL;
freechain();
if (! errlev++) {
curcon = ERROR;
while (TRUE) {
i = scan();
if (i == ENDFILE) break;
else if (i == ELT) {
if (restart <= RSIGNON) endsignon();
restart = RELEMENT;
curcon = NEEDN;
break;
}
else if (i == GDEF && restart < RGLOBDEF) {
if (restart <= RSIGNON) endsignon();
restart = RGLOBDEF;
curcon = GLOBDEF;
break;
}
else if (i == GDEC && restart < RGLOBDEC) {
if (restart <= RSIGNON) endsignon();
restart = RGLOBDEC;
curcon = GLOBDEC;
break;
}
else if (i == SIGNON && restart < RSIGNON) {
curcon = INSIGNON;
restart = RSIGNON;
break;
}
else if (i == ENTSTART && restart == RENTITY) {
curcon = ENTDEC;
break;
}
curcon = ERROR;
} /* end while */
} /* end if ! errlev */
errlev--;
}
/* Starts processing a code segment from the input file */
void startcode(caseno, flag, file, prefix, proto, formal, formtype)
int caseno;
LOGICAL *flag;
FILE *file;
char *prefix;
char *proto;
char *formal;
char *formtype;
{
CVARSTRUCT *cvarp;
endcode(*flag, file);
*flag = TRUE;
/* protoype */
fprintf(file,
"void m_%s%d(\n#if defined(M_PROTO)\n %s\n#endif\n ) ;\n",
prefix,
caseno,
proto);
/* ANSI defines */
fputs("#if defined(M_PROTO)\n", file);
fprintf(file, "void m_%s%d(%s)\n", prefix, caseno, proto);
fputs("#else\n", file);
fprintf(file,
"void m_%s%d(%s)\n%s\n#endif\n {\n", /* balance the "}" */
prefix,
caseno,
formal,
formtype);
for (cvarp = cvarlist ; cvarp ; cvarp = cvarp->next)
{
char *mb_cvarptr;
mb_cvarptr = MakeMByteString(cvarp->cvarptr);
fprintf(file, " M_WCHAR *%s ;\n", mb_cvarptr);
m_free(mb_cvarptr,"multi-byte string");
}
for (cvarp = cvarlist ; cvarp ; cvarp = cvarp->next)
{
char *mb_cvarptr;
mb_cvarptr = MakeMByteString(cvarp->cvarptr);
fprintf(file,
" m_setparam(&%s, %d) ;\n",
mb_cvarptr,
cvarp->param);
m_free(mb_cvarptr,"multi-byte string");
}
fprintf(file, "{\n/* line %d \"%s\" */\n", m_line, iffile); /* balance "}" */
}
/* Begins processing a new element */
void startelement(M_NOPAR)
{
CVARSTRUCT *cvarp;
CVARSTRUCT *discard;
for (cvarp = cvarlist ; cvarp ; ) {
discard = cvarp;
m_free(cvarp->cvarptr, "C variable name");
cvarp = cvarp->next;
m_free(discard, "C variable");
}
cvarlist = NULL;
if (openelt = m_packedlook(m_entree, name)) {
if (processed[openelt - 1])
warning1("Warning: Element %s already processed", name);
processed[openelt - 1] = TRUE;
}
else m_err1("Undefined element: %s", name);
}
/* Stores the name of a C variable read from the input file */
void storecvar(M_NOPAR)
{
CVARSTRUCT *new;
new = (CVARSTRUCT *) m_malloc(sizeof(CVARSTRUCT), "C variable");
new->cvarptr = (M_WCHAR *) m_malloc(w_strlen(name) + 1,
"C variable name");
w_strcpy(new->cvarptr, name);
new->next = cvarlist;
cvarlist = new;
}
/* Compares the parameter name associated with a C variable in the input
file with the names of all parameters of the current element. Stores
result for later output with code segments */
void storepname(M_NOPAR)
{
int i, par;
for (i = 0, par = m_element[openelt - 1].parptr;
i < m_element[openelt - 1].parcount;
i++, par++)
if (! w_strcmp(&m_pname[m_parameter[par - 1].paramname], name))
break;
if (i >= m_element[openelt - 1].parcount) {
m_err2("%s: No such parameter for element %s", name,
&m_ename[m_element[openelt - 1].enptr]);
return;
}
cvarlist->param = i;
}
/* Called when a possible parameter value to be defined is encountered */
void value(p)
M_WCHAR *p;
{
char buffer[5];
if (m_partype(cvarlist->param + m_element[openelt - 1].parptr, p))
{
if (pval->line)
{
if (w_strcmp(pval->value, p))
{
M_WCHAR *w_buffer;
sprintf(buffer, "%d", pval->line);
w_buffer = MakeWideCharString(buffer);
m_err5("Can't #define %s to %s. %s #define'd to %s on line %s",
pval->cname,
p,
pval->cname,
pval->value,
w_buffer);
m_free(w_buffer, "wide character string");
}
}
else {
pval->value = (M_WCHAR *) m_malloc(w_strlen(p) + 1, "pval value");
w_strcpy(pval->value, p);
pval->line = m_line;
}
}
else m_err3("\"%s\" illegal value for parameter %s of %s",
p,
&m_pname[m_parameter[cvarlist->param +
m_element[openelt - 1].parptr - 1].paramname],
&m_ename[m_element[openelt-1].enptr]);
}
#include "paramu.c"

View File

@@ -0,0 +1,51 @@
/* $XConsortium: entity.c /main/3 1995/11/08 10:05:17 rswiston $ */
/* Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co. */
/* Entity.c has ELTDEF procedures relevant to entities */
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include "basic.h"
#include "trie.h"
#include "dtdext.h"
#include "eltdef.h"
#include "entext.h"
/* Add an entity */
void addent(M_NOPAR)
{
M_ENTITY *new ;
new = (M_ENTITY *) m_malloc(sizeof(M_ENTITY), "entity") ;
if (entity = (M_ENTITY *) m_ntrtrie(name, m_enttrie, (M_TRIE *) new)) {
m_free(new, "entity") ;
if (! entity->wheredef) return ;
if (entity->wheredef == M_DBUILD) {
warning1("Redefining %s: entity defined in BUILD", entity->name) ;
entity->type = M_GENERAL ;
entity->wheredef = FALSE ;
entity->content = NULL ;
return ;
}
else
m_err1("Attempt to redefine %s", entity->name) ;
return ;
}
entity = new ;
if (lastent) lastent->next = entity ;
else firstent = entity ;
lastent = entity ;
entity->type = M_GENERAL ;
entity->wheredef = FALSE ;
entity->content = NULL ;
entity->name =
(M_WCHAR *) m_malloc(w_strlen(name) + 1, "entity name") ;
entity->index = ++m_entcnt ;
entity->codeindex = M_NULLVAL ;
entity->next = NULL ;
w_strcpy(entity->name, name) ;
return ;
}
#include "entout.c"

View File

@@ -0,0 +1,339 @@
/* $XConsortium: proto.h /main/3 1995/11/08 10:05:39 rswiston $ */
/*
Copyright (c) 1988, 1989 Hewlett-Packard Co.
*/
/* Proto.h contains function prototypes for program ELTDEF. */
void actptrout(
#if defined(M_PROTO)
ACTION **array, char *name
#endif
) ;
void addent(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
LOGICAL m_allwhite(
#if defined(M_PROTO)
const M_WCHAR *string
#endif
) ;
void closeiffile(
#if defined(M_PROTO)
LOGICAL flag, FILE *file, int count, char *table, char *proto
#endif
) ;
void countdown(
#if defined(M_PROTO)
M_TRIE *parent, int *count
#endif
) ;
void cvalue(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void done(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void m_dumptrie(
#if defined(M_PROTO)
FILE *file,
M_TRIE *xtrie,
char *extname,
int *count,
void (*proc)(M_ENTITY *)
#endif
) ;
void endcode(
#if defined(M_PROTO)
LOGICAL flag, FILE *file
#endif
) ;
void endini(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void endsignon(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void endstring(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void entout(
#if defined(M_PROTO)
char *fname
#endif
) ;
void enttype(
#if defined(M_PROTO)
int type
#endif
) ;
void m_error(
#if defined(M_PROTO)
char *text
#endif
) ;
void m_err1(
#if defined(M_PROTO)
const char *text, const M_WCHAR *arg
#endif
) ;
void m_mberr1(
#if defined(M_PROTO)
char *text, const char *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_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_exit(
#if defined(M_PROTO)
int status
#endif
) ;
void m_free(
#if defined(M_PROTO)
void *block, char *msg
#endif
) ;
void freechain(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
int getachar(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
int *getaction(
#if defined(M_PROTO)
ACTION **array
#endif
) ;
ACTION *getactstruct(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void getname(
#if defined(M_PROTO)
int first
#endif
) ;
int gettoken(
#if defined(M_PROTO)
int *c, int context
#endif
) ;
void m_initctype(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void initialize(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
LOGICAL m_letter(
#if defined(M_PROTO)
M_WCHAR c
#endif
) ;
LOGICAL litproc(
#if defined(M_PROTO)
int delim
#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_openchk(
#if defined(M_PROTO)
FILE **ptr, char *name, char *mode
#endif
) ;
void outpval(
#if defined(M_PROTO)
M_TRIE *p
#endif
) ;
void outstring(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
int m_packedlook(
#if defined(M_PROTO)
M_PTRIE *xptrie, M_WCHAR *name
#endif
) ;
const M_WCHAR *m_partype(
#if defined(M_PROTO)
const int par, const M_WCHAR *string
#endif
) ;
int scan(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void skiptoend(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void startcode(
#if defined(M_PROTO)
int caseno, LOGICAL *flag, FILE *file, char *prefix, char *proto,
char *formal, char *formtype
#endif
) ;
void startelement(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void storecvar(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void storepname(
#if defined(M_PROTO)
M_NOPAR
#endif
) ;
void undodelim(
#if defined(M_PROTO)
M_WCHAR *delim
#endif
) ;
void ungetachar(
#if defined(M_PROTO)
int c
#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
) ;
void value(
#if defined(M_PROTO)
M_WCHAR *p
#endif
) ;
void warning(
#if defined(M_PROTO)
char *text
#endif
) ;
void warning1(
#if defined(M_PROTO)
char *text, M_WCHAR *arg
#endif
) ;
LOGICAL m_whitespace(
#if defined(M_PROTO)
M_WCHAR c
#endif
) ;

View File

@@ -0,0 +1,143 @@
/* $XConsortium: scan.c /main/3 1995/11/08 10:05:59 rswiston $ */
/*
Copyright 1986 Tandem Computers Incorporated.
This product and information is proprietary of Tandem Computers Incorporated.
Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co.
*/
/* Scan.c contains scanner procedures for program ELTDEF */
#include <stdio.h>
#include <string.h>
#if defined(MSDOS)
#include <process.h>
#endif
#include "basic.h"
#include "trie.h"
#include "dtdext.h"
#include "eltdef.h"
#define M_CONDEF
#include "context.h"
#define M_DELIMDEF
#include "delim.h"
/* Reads a name token */
void getname(first)
int first;
{
M_WCHAR *p, wus;
int c, cttype;
LOGICAL cname;
mbtowc(&wus, "_", 1);
cname = (LOGICAL) (curcon == INPARAM || curcon == INVALUE);
*(p = name) = (M_WCHAR) first;
if (! cname) *p = m_ctupper(*p);
while (TRUE)
{
c = getachar();
if (c == EOF) break;
*++p = (M_WCHAR) c;
cttype = m_cttype(*p);
if (! cname)
{
if (cttype == M_NONNAME) break;
}
else
{
if ((cttype != M_NMSTART) && (cttype != M_DIGIT) && (*p != wus))
break;
}
if (p >= name + M_NAMELEN)
{
*(name + M_NAMELEN) = M_EOS;
m_error("Element name too long");
}
if (! cname) *p = m_ctupper(*p);
}
ungetachar(c);
*p = M_EOS;
}
/* Reads the next token and returns it to the main procedure */
int scan(M_NOPAR)
{
int c;
int n;
static char unexp[] = "c";
M_WCHAR wus;
mbtowc(&wus, "_", 1);
while (TRUE)
{
while ((n = gettoken(&c, COMCON)) == STARTCOMMENT)
while ((n = gettoken(&c, INCOM)) != ENDCOMMENT)
if (c == EOF)
{
m_error("EOF occurred within comment");
done();
exit(TRUE);
}
ungetachar(c);
n = gettoken(&c, curcon);
if (n)
{
if (n != LIT && n != LITA) return(n);
if (litproc(n))
{
if (scantrace)
{
char *mbyte;
mbyte = MakeMByteString(literal);
printf("literal '%s'\n", mbyte);
m_free(mbyte, "multi-byte string");
}
return(LITERAL);
}
}
if (c == EOF) return(ENDFILE);
if (m_newcon(curcon - 1, TEXT - 1))
{
textchar = (M_WCHAR) c;
return(TEXT);
}
if (m_whitespace((M_WCHAR) c)) continue;
if (m_newcon(curcon - 1, NAME - 1))
{
if (curcon == INPARAM || curcon == INVALUE)
{
/* Check for C identifier */
if (m_letter((M_WCHAR) c) || c == wus)
{
getname(c);
return(NAME);
}
}
else
{
/* Check for SGML name */
if ((m_cttype(c) == M_NMSTART) ||
(m_cttype(c) != M_NONNAME && curcon == VALUE))
{
getname(c);
return(NAME);
}
}
}
if (curcon != ERROR)
{
m_mberr1("Unexpected character: '%s'", unexp);
}
} /* End while */
} /* End scan */
#include "scanutil.c"
#if defined(sparse)
#include "sparse.c"
#endif