Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site yetti.UUCP Path: utzoo!utcs!mnetor!yetti!oz From: oz@yetti.UUCP (Ozan Yigit) Newsgroups: net.sources Subject: PROFF - Portable ROFF (3 of 5) Message-ID: <300@yetti.UUCP> Date: Tue, 14-Jan-86 00:00:13 EST Article-I.D.: yetti.300 Posted: Tue Jan 14 00:00:13 1986 Date-Received: Tue, 14-Jan-86 08:47:02 EST Reply-To: oz@yetti.UUCP (Ozan Yigit) Organization: York University Computer Science Lines: 1209 #!/bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #!/bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # debug.h # defs.h # dostuff2.c # eval.c # look.c # lookup.c # lookup.h # ltb.c # makefile # map.c # This archive created: Mon Jan 13 23:53:32 1986 export PATH; PATH=/bin:$PATH echo shar: extracting "'debug.h'" '(126 characters)' if test -f 'debug.h' then echo shar: over-writing existing file "'debug.h'" fi sed 's/^X//' << \SHAR_EOF > 'debug.h' X X X X/* X#define DEBUG X#define PROFILE X*/ X X#ifdef PROFILE X#define dprintf(str) printf((str)); X#else X#define dprintf(str) X#endif X SHAR_EOF if test 126 -ne "`wc -c 'debug.h'`" then echo shar: error transmitting "'debug.h'" '(should have been 126 characters)' fi echo shar: extracting "'defs.h'" '(1580 characters)' if test -f 'defs.h' then echo shar: over-writing existing file "'defs.h'" fi sed 's/^X//' << \SHAR_EOF > 'defs.h' X X/* X * defs.h X * X * #define rainbow - rainbow CP/M-86 version X * #define vms - vms version (predefined by VAX11C compiler) X * #define unix - unix version X */ X X/* X * Synonyms for ASCII control characters X * X */ X X#define BACKSPACE 8 X#define BEL 7 X#define BELL 7 X#define BLANK 32 X#define CARRIAGE_RETURN 13 X#define NEWLINE 10 X#define RUBOUT 127 X#define TAB 9 X X/* X * misc. definitions X * X */ X X#define EOS 0 X#define HUGE 30000 X#define NO 0 X#define OK 0 X#define YES 1 X#define FALSE 0 X#define TRUE 1 X#define FILENAMESIZE 50 X#define MAXCHARS 20 X#define MAXLINE 256 X#define MAXTOK 80 X#define ARB MAXLINE X X#define MAXCARD MAXLINE-1 X#define MAXNAME FILENAMESIZE X X#define NCHARS 33 X#define MAXOFILES 12 X X#define ARGFLAG '$' X#define INSIZE MAXLINE X#define MAXOUT 2*MAXLINE X#define MAXDEF 200 X#define NFILES MAXOFILES-4 X#define PAGENUM '#' X#define CURRENTDATE '%' X#define ESCAPE '@' X#define VESCAPE '$' X#define PAGEJECT 12 /* 12 is ASCII formfeed (control-L) */ X#define PAGEWIDTH 65 X#define PAGELEN 62 X#define BUFSIZE 512 /* push back buffer */ X/* X * lexical analyser values X * X * include lexical analyser return constants X * generated by ltb. X * X */ X#include "lextab.d" /* expended format & roff & runoff */ X X#define UNKNOWN 999 X#define MACRO 0 X#define NEGATED -1 X#define LEFT 1 X#define CENTER 2 X#define RIGHT 3 X X/* X * structure definition for contents linked list X * X */ X Xstruct clist { /* list struct for contents */ X char level; X char *str; X int page; X struct clist *nextc; X}; X X#undef putchar X#define putchar(c) putc((c),poutput); X SHAR_EOF if test 1580 -ne "`wc -c 'defs.h'`" then echo shar: error transmitting "'defs.h'" '(should have been 1580 characters)' fi echo shar: extracting "'dostuff2.c'" '(2884 characters)' if test -f 'dostuff2.c' then echo shar: over-writing existing file "'dostuff2.c'" fi sed 's/^X//' << \SHAR_EOF > 'dostuff2.c' X X X X X#include X#include X#include "proff.h" X#include "debug.h" X X/* X * dodef - define a command macro (".de xx" is in buf.) X * X */ Xdodef(buf,fd) Xchar buf[]; Xint fd; X{ X char name[MAXNAME],defn[MAXDEF]; X int i,junk; X X dprintf("dodef "); X i = 0; X junk = getwrd(buf, &i, name); X i = getwrd(buf, &i, name); /* get the name */ X if (i == 0) X error("missing name in command def."); X i = 0; X while (ngetln(buf,fd) != NULL) { X if (buf[0] == cchar && buf[1] == 'e' && X buf[2] == 'n' && !isalnum(buf[3])) X break; X junk = addstr(buf, defn, &i, MAXDEF); X } X if (addset(EOS, defn, &i, MAXDEF) == NO) X error("definition too long.\n"); X if (install(name, defn, macrotab) == NULL) X fprintf(stderr,"no room for new definition.\n"); X#ifdef DEBUG X printf("dodef: %s (name) %s (defn)\n",name,defn); X#endif X} X X/* X * doesc - expand escapes in buf X * X */ Xdoesc(buf, tbuf, size) Xchar buf[]; Xchar tbuf[]; Xint size; X{ X int i,j; X X dprintf("doesc "); X j = 0; X for (i = 0; buf[i] != EOS && j < size-1; i++) X /* X * clean up generic escapes along the way. X */ X if (buf[i] == genesc) X tbuf[j++] = buf[++i]; X X else if (buf[i] != ESCAPE) { X tbuf[j] = buf[i]; X j++; X } X else if (buf[i+1] == 'n' && X (buf[i+2] >= 'a' && buf[i+2] <= 'z')) { X j += itoc(nr[buf[i+2] - 'a'], X &tbuf[j], size - j - 1); X i += 2; X } X else { X tbuf[j] = buf[i]; X j++; X } X tbuf[j] = EOS; X strcpy(buf, tbuf); X} X X/* X * dovar - expand variables in buf X * X */ Xdovar(tbuf, buf) Xchar *buf; Xchar *tbuf; X{ X register char *c, *p, t; X struct hashlist *xp; X X while (*buf != '\0') { X if (*buf == genesc) { X *tbuf++ = *buf++; X *tbuf++ = *buf; X } X else if (*buf != VESCAPE) X *tbuf++ = *buf; X else { X buf++; /* skip the ESCAPE */ X if (*buf == '{') X buf++; X p = buf; /* save the beginning address of variable */ X while (isalnum(*buf)) X buf++; X t = *buf; /* save the character*/ X *buf = '\0'; /* hack a null there */ X if ((xp = lookup(p,gentab)) != NULL) { X c = xp->def; /* point to def */ X while (*c != '\0') X *tbuf++ = *c++; X } X if (*(p-1) != '{') X *tbuf++ = t; X else if (t != '}') X fprintf(stderr, "missing \"}\" in %s\n",p); X } X buf++; X } X *tbuf = '\0'; X} X X X/* X * dotabs - expand tabs in buf X * X */ Xdotabs(buf,tbuf,size) Xchar buf[]; Xchar tbuf[]; Xint size; X{ X int i,j; X dprintf("dotabs "); X X j = 0; X for (i = 0; buf[i] != EOS && j < size - 1; i++) X if (buf[i] == '\t') X while (j < size - 1) { X tbuf[j] = ' '; X j++; X if (tabs[j] == YES || j > INSIZE) X break; X } X else { X tbuf[j] = buf[i]; X j++; X } X tbuf[j] = EOS; X strcpy(buf, tbuf); X} X X/* X * docline - produce a "contents" line. X * X */ Xdocline(str,width,cline,page) Xchar *str; Xint width; Xchar *cline; Xint page; X{ X int i; X X for (i = 0; i < width - 6 && cline[i] != '\0'; i++) X str[i] = cline[i]; X while (i < width - 6) X str[i++] = '.'; X sprintf(str+i,"%5d\n",page); X} X SHAR_EOF if test 2884 -ne "`wc -c 'dostuff2.c'`" then echo shar: error transmitting "'dostuff2.c'" '(should have been 2884 characters)' fi echo shar: extracting "'eval.c'" '(1298 characters)' if test -f 'eval.c' then echo shar: over-writing existing file "'eval.c'" fi sed 's/^X//' << \SHAR_EOF > 'eval.c' X X X#include X#include X#include "proff.h" X#include "debug.h" X X X/* X * eval - evaluate defined command (push back definition) X * X */ Xeval(buf,defn) Xchar buf[]; Xchar defn[]; X{ X register int j,k; X int i; X int argptr[10]; X X for (i = 0; i < 10 ; i++) X argptr[i] = 0; X X buf[0] = '\0'; /* buf[0] is cchar */ X dprintf(defn); X dprintf("eval "); X i = 1; X argptr[0] = 1; /* first parm is macro name */ X while (buf[i] != ' ' && buf[i] != '\t' && X buf[i] != '\n' && buf[i] != '\0') X i++; X buf[i++] = '\0'; /* EOS terminate */ X /* X * start scanning remaining macro parameters. X * delimiters are blanks or commas. Any string X * enclosed with double quotes are accepted as X * parameters as well X * X */ X for (j = 1; j < 10; j++) { X skipbl(buf, &i); X if (buf[i] == '\n' || buf[i] == '\0') X break; X argptr[j] = i; X while (buf[i] != ' ' && buf[i] != '\t' && X buf[i] != ',' && buf[i] != '\n' && buf[i] != '\0') X i++; X buf[i] = '\0'; X i++; X } X for (k = strlen(defn) - 1; k >= 0; k--) X if (defn[k-1] != ARGFLAG) X putbak(defn[k]); X else { X if (defn[k] < '0' || defn[k] > '9') X putbak(defn[k]); X else { X i = defn[k] - '0'; X i = argptr[i]; X pbstr(&buf[i]); X k--; /* skip over $ */ X } X } X if (k = 0) /* do the last character */ X putbak(defn[k]); X} X SHAR_EOF if test 1298 -ne "`wc -c 'eval.c'`" then echo shar: error transmitting "'eval.c'" '(should have been 1298 characters)' fi echo shar: extracting "'look.c'" '(2939 characters)' if test -f 'look.c' then echo shar: over-writing existing file "'look.c'" fi sed 's/^X//' << \SHAR_EOF > 'look.c' X X X X X/* X * from K&R "The C Programming language" X * Table lookup routines X * X */ X#include X#include "lookup.h" X/* X * hash - for a hash value for string s X * X */ Xhash(s) Xchar *s; X{ X int hashval; X X for (hashval = 0; *s != '\0';) X hashval += *s++; X return (hashval % HASHMAX); X} X X/* X * lookup - lookup for a string s in the hash table X * X */ Xstruct hashlist X*lookup(s, hashtab) Xchar *s; Xstruct hashlist *hashtab[]; X{ X struct hashlist *np; X X for (np = hashtab[hash(s)]; np != NULL; np = np->next) X if (strcmp(s, np->name) == 0) X return(np); /* found */ X return(NULL); /* not found */ X} X X/* X * install - install a string name in hashtable and its value def X * at a given hashtable. X */ Xstruct hashlist X*install(name,def,hashtab) Xchar *name; Xchar *def; Xstruct hashlist *hashtab[]; X{ X int hashval; X struct hashlist *np, *lookup(); X char *strsave(), *malloc(); X X if ((np = lookup(name, hashtab)) == NULL) { /* not found.. */ X np = (struct hashlist *) malloc(sizeof(*np)); X if (np == NULL) X return(NULL); X if ((np->name = strsave(name)) == NULL) X return(NULL); X hashval = hash(np->name); X np->next = hashtab[hashval]; X hashtab[hashval] = np; X } else /* found.. */ X free(np->def); /* free prev. */ X if ((np->def = strsave(def)) == NULL) X return(NULL); X return(np); X} X X/* X * strsave - save string s somewhere X * X */ Xchar X*strsave(s) Xchar *s; X{ X char *p, *malloc(); X register int n; X X n = strlen(s) + 1; X if ((p = malloc(n)) != NULL) X strcpy(p, s); X return(p); X} X X/* X * lexinstal - instal a string name in hashtable and its value X * used by lexical analyser to quickly match a token X * and return its lexical value. X * X */ Xstruct lexlist X*lexinstal(name,val,flag,lextable) Xchar *name; Xint val; Xint flag; Xstruct lexlist *lextable[]; X{ X int hashval; X struct lexlist *np,*lexlook(); X char *strsave(), *malloc(); X X if ((np = lexlook(name,lextable)) == NULL) { /* not found.. */ X np = (struct lexlist *) malloc(sizeof(*np)); X if (np == NULL) X return(NULL); X if ((np->name = strsave(name)) == NULL) X return(NULL); X hashval = hash(np->name); X np->link = lextable[hashval]; X lextable[hashval] = np; X } X np->val = val; /* replace prev */ X np->flag = flag; X return(np); X} X X/* X * lexlook - lookup for a string s in the hash table X * used by lexinstal only. X * X */ Xstruct lexlist X*lexlook(s,table) Xchar *s; Xstruct lexlist *table[]; X{ X struct lexlist *np; X X for (np = table[hash(s)]; np != NULL; np = np->link) X if (strcmp(s, np->name) == 0) X return(np); /* found */ X return(NULL); /* not found */ X} X X/* X * remove an item from the hash table forever X * X */ Xstruct lexlist X*remove(s, table) Xchar *s; Xstruct lexlist *table[]; X{ X struct lexlist *np, *xp; X X np = table[hash(s)]; X xp = np; X while (np != NULL) { X if (strcmp(s, np->name) == 0) { X xp->link = np->link; /* remove the link */ X return(np); /* return the lost */ X } X xp = np; X np = np->link; X } X return(NULL); X} X SHAR_EOF if test 2939 -ne "`wc -c 'look.c'`" then echo shar: error transmitting "'look.c'" '(should have been 2939 characters)' fi echo shar: extracting "'lookup.c'" '(3017 characters)' if test -f 'lookup.c' then echo shar: over-writing existing file "'lookup.c'" fi sed 's/^X//' << \SHAR_EOF > 'lookup.c' X X X X X/* X * from K&R "The C Programming language" X * Table lookup routines X * X */ X#include X#include "proff.h" X/* X * hash - for a hash value for string s X * X */ Xhash(s) Xchar *s; X{ X int hashval; X X for (hashval = 0; *s != '\0';) X hashval += *s++; X return (hashval % HASHMAX); X} X X/* X * lookup - lookup for a string s in the hash table X * X */ Xstruct hashlist X*lookup(s, hashtab) Xchar *s; Xstruct hashlist *hashtab[]; X{ X struct hashlist *np; X X for (np = hashtab[hash(s)]; np != NULL; np = np->next) X if (strcmp(s, np->name) == 0) X return(np); /* found */ X return(NULL); /* not found */ X} X X/* X * install - install a string name in hashtable and its value def X * at a given hashtable. X */ Xstruct hashlist X*install(name,def,hashtab) Xchar *name; Xchar *def; Xstruct hashlist *hashtab[]; X{ X int hashval; X struct hashlist *np, *lookup(); X char *strsave(), *malloc(); X X if ((np = lookup(name, hashtab)) == NULL) { /* not found.. */ X np = (struct hashlist *) malloc(sizeof(*np)); X p_memoryus += sizeof(*np); X if (np == NULL) X return(NULL); X if ((np->name = strsave(name)) == NULL) X return(NULL); X hashval = hash(np->name); X np->next = hashtab[hashval]; X hashtab[hashval] = np; X } else /* found.. */ X free(np->def); /* free prev. */ X if ((np->def = strsave(def)) == NULL) X return(NULL); X return(np); X} X X/* X * strsave - save string s somewhere X * X */ Xchar X*strsave(s) Xchar *s; X{ X char *p, *malloc(); X register int n; X X n = strlen(s) + 1; X if ((p = malloc(n)) != NULL) { X p_memoryus += n; X strcpy(p, s); X } X return(p); X} X X/* X * lexinstal - instal a string name in hashtable and its value X * used by lexical analyser to quickly match a token X * and return its lexical value. X * X */ Xstruct lexlist X*lexinstal(name,val,flag,lextable) Xchar *name; Xint val; Xint flag; Xstruct lexlist *lextable[]; X{ X int hashval; X struct lexlist *np,*lexlook(); X char *strsave(), *malloc(); X X if ((np = lexlook(name,lextable)) == NULL) { /* not found.. */ X np = (struct lexlist *) malloc(sizeof(*np)); X p_memoryus += sizeof(*np); X if (np == NULL) X return(NULL); X if ((np->name = strsave(name)) == NULL) X return(NULL); X hashval = hash(np->name); X np->link = lextable[hashval]; X lextable[hashval] = np; X } X np->val = val; /* replace prev */ X np->flag = flag; X return(np); X} X X/* X * lexlook - lookup for a string s in the hash table X * used by lexinstal only. X * X */ Xstruct lexlist X*lexlook(s,table) Xchar *s; Xstruct lexlist *table[]; X{ X struct lexlist *np; X X for (np = table[hash(s)]; np != NULL; np = np->link) X if (strcmp(s, np->name) == 0) X return(np); /* found */ X return(NULL); /* not found */ X} X X/* X * remove an item from the hash table forever X * X */ Xstruct lexlist X*remove(s, table) Xchar *s; Xstruct lexlist *table[]; X{ X struct lexlist *np, *xp; X X np = table[hash(s)]; X xp = np; X while (np != NULL) { X if (strcmp(s, np->name) == 0) { X xp->link = np->link; /* remove the link */ X return(np); /* return the lost */ X } X xp = np; X np = np->link; X } X return(NULL); X} X SHAR_EOF if test 3017 -ne "`wc -c 'lookup.c'`" then echo shar: error transmitting "'lookup.c'" '(should have been 3017 characters)' fi echo shar: extracting "'lookup.h'" '(553 characters)' if test -f 'lookup.h' then echo shar: over-writing existing file "'lookup.h'" fi sed 's/^X//' << \SHAR_EOF > 'lookup.h' X X X X/* X * from K&R "The C Programming language" X * Table lookup routines X * structure and definitions X * X */ X X /* basic table entry */ Xstruct hashlist { X char *name; X char *def; X struct hashlist *next; /* next in chain */ X}; X /* basic table entry */ Xstruct lexlist { X char *name; X int val; /* lexical value */ X int flag; /* optional flag val */ X struct lexlist *link; /* next in chain */ X}; X X X#define HASHMAX 100 /* size of hashtable */ X Xstruct Xlexlist (*(*lextable))[];/* global pointer for lexical analyser hash table */ X SHAR_EOF if test 553 -ne "`wc -c 'lookup.h'`" then echo shar: error transmitting "'lookup.h'" '(should have been 553 characters)' fi echo shar: extracting "'ltb.c'" '(6222 characters)' if test -f 'ltb.c' then echo shar: over-writing existing file "'ltb.c'" fi sed 's/^X//' << \SHAR_EOF > 'ltb.c' X/* X * ltb.c - Lexical Table Builder X * X * Functional description: X * X * This program builds a file containing the data X * structures of a compile-time-initialised hash table. X * This hash table may later be used for lexical analysis, X * where number of symbols to look up is sufficiently large X * to avoid a run-time table initialization. X * In order to guarantee the success of this setup, the X * hash routine, the lookup and install routines should be X * the same between ltb and the lexical analysis. X * X * synopsis: X * X * ltb [table name] X * X * input file format: X * X * [flag value] X * X * token: string of alphanumeric characters to be X * matched by the lexical analyser (no blanks). X * these token strings are "installed" to a hash X * table by ltb to avoid run-time overhead. X * value X * identifier: A constant name to be used internally by the X * lexical analyser in place of the actual X * token value. a "#define " X * is generated for each value identifier, where X * value is an odd and unique integer constant. If X * the value identifier is a `*' (star), then the X * previous value is repeated. Thus: X * X * token ident. flag X * X * sp SP 1 X * space * { inherits SP } X * blank * { inherits SP } X * . . . X * . . . X * X * flag value: An additional integer field to pass flags etc. to X * the lexical analyser. If not specified, set to X * 0. token value field must be present for this field X * to be obtained. X * X * outputs: X * X * ltb generates two C include files: X * X * [tablename].d: compile time lexical constants (defines) X * [tablename].h: initialised hash table. X * X * where [tablename] is the name of the hash table as specified X * in the command line of ltb. If not specified, "lextab" is used X * as a default. X * X * routines used by LTB: X * X * hash, lookup and a modified version of install routines, X * as defined in K&R, pp. 134 - 136. X * X * Application areas: X * X * Lexical analysers for compilers, interpreters, spelling X * checkers. X * X * Author: X * Ozan S. Yigit X * Dept. of Computer Science X * York University X * X */ X X#define MAXLINE 80 X#define MAXSYM 80 X X#include X#include X#include "lookup.h" X Xstatic struct lexlist *hashtab[HASHMAX]; Xstatic struct lexlist *defitab[HASHMAX]; X Xchar *tabnam; /* table name */ X Xmain(argc,argv) Xint argc; Xchar *argv[]; X{ X FILE *fp; X char line[MAXLINE]; X char sym[MAXSYM],def[MAXSYM]; X register int val; X register int prev, *p; X register char *ptr; X int flag; X struct lexlist *np, *lexlook(); X X if (argc <= 2) { X fprintf(stderr,"%s [-] [tablename]", X argv[0]); X exit(1); X } X X if (*argv[1] == '-') { X val = atoi(argv[1]+1); /* skip "-" and convert */ X val = (val & 1) ? val : val+1; X p = argv[2]; X } X else { X val = 1; X p = argv[1]; X } X X if (argc < 3) X tabnam = "lextab"; X else X tabnam = argv[argc-1]; X X if ((fp = fopen(p,"r")) == NULL) { X fprintf(stderr,"%s:cannot open.\n",argv[1]); X exit(1); X } X else { X prev = val; X while (fgets(line,MAXLINE,fp) != NULL) { X if (*line != '!') { X flag = 0; X def[0] = '\0'; X ptr = line; X while (isspace(*ptr)) X ptr++; X if (*ptr == '\0') X continue; X sscanf(line,"%s %s %d",sym,def,&flag); X if (!(def[0] == '*' && def[1] == '\0')) { X if ((np = lexlook(def,defitab)) == NULL) { X /* value define */ X lexinstal(def,val,0,defitab); X prev = val; X val += 2; X } X else X prev = np->val; X } X /* lexical token */ X lexinstal(sym,prev,flag,hashtab); X } X } X defgen(); X lexgen(); X } X} X/* X * lexgen - print out the hash table in static form X * X */ Xlexgen() X{ X register int i; X register struct lexlist *np; X char filebuf[12]; X char *file; X FILE *op; X X file = filebuf; X X strncpy(file,tabnam,8); X strcat(file,".h"); X X if ((op = fopen(file,"w")) == NULL) { X fprintf(stderr,"%s: cannot create.\n",file); X exit(1); X } X X fprintf(op,"#ifndef STRUC_DEFINED\n\n"); X fprintf(op,"\/\*\t%s\t\*\/\n\n%s\n%s\n%s\n%s\n%s\n",file, X "struct _lex_h { char *__s;", X " int __v;", X " int __f;", X " struct _lex_h *__l;", X "};"); X fprintf(op,"\n#define STRUC_DEFINED\n#endif\n"); X X /* X * generate the hash table entries. X * each entry is followed by the next entry in its X * chain. X * In the operating systems with memory paging, this X * should have the extra advantage of localized X * memory referances. X * X */ X X for (i=0; i < HASHMAX; i++) X if ((np = hashtab[i]) != NULL) X prnode(np,op); X /* X * At last, we generate the pointer array (hashtable). X * this table should be assigned to lextable global X * variable before using with lexlook() or lexinstal(). X * lextable is defined in lookup.h X * X */ X X fprintf(op,"\n\n\/\* Hash Table \*\/\n\n"); X fprintf(op,"struct _lex_h *%s[%d] = {\n\t",tabnam,HASHMAX); X for (i=0; i < HASHMAX - 1; i++) { X np = hashtab[i]; X if(np == NULL) X fprintf(op,"NULL,\t"); X else X fprintf(op,"\&__%s,\t", np->name); X if (i % 4 == 0) X fprintf(op,"\n\t"); X } X np = hashtab[i]; X if (np == NULL) X fprintf(op,"NULL };\n"); X else X fprintf(op,"\&__%s };\n", np->name); X X fclose(op); X} X X/* X * prnode - print the current node. This routine is X * recursive such that printing starts from X * the end of the given list X * X */ Xprnode(np,op) Xregister struct Xlexlist *np; XFILE *op; X{ X if (np->link != NULL) X prnode(np->link,op); X fprintf(op,"struct\n_lex_h __%s = { ", X np->name); X fprintf(op,"\"%s\",\n %6d,%6d,", X np->name, X np->val, X np->flag); X if (np->link != NULL) X fprintf(op,"\&__%s };\n", X (np->link)->name); X else X fprintf(op,"NULL };\n"); X} X X/* X * defgen - generate a file containing the lexical X * constants to be equated to lexical symbols X */ Xdefgen() X{ X register int i; X register struct lexlist *np; X char *file; X char filebuf[12]; X FILE *op; X X file = filebuf; X strncpy(file,tabnam,8); X strcat(file,".d"); X X if ((op = fopen(file,"w")) == NULL) { X fprintf(stderr,"%s: cannot create.\n",file); X exit(1); X } X for (i=0; i < HASHMAX; i++) { X for (np = defitab[i]; np != NULL; np = np->link) X fprintf(op,"\#define %s\t%d\n", X np->name, X np->val); X } X fclose(op); X} X SHAR_EOF if test 6222 -ne "`wc -c 'ltb.c'`" then echo shar: error transmitting "'ltb.c'" '(should have been 6222 characters)' fi echo shar: extracting "'makefile'" '(376 characters)' if test -f 'makefile' then echo shar: over-writing existing file "'makefile'" fi sed 's/^X//' << \SHAR_EOF > 'makefile' XCFLAGS=-O XOBJS= proff.o proff01.o proff02.o lookup.o pinit.o putwrd.o\ X pxlex.o pxxparse.o dostuff2.o eval.o stack.o map.o Xproff: $(OBJS) X cc -s -o proff $(OBJS) X X$(OBJS): lextab.h lextab.d X Xlextab.h lextab.d: proffsym.new ltb X ltb proffsym.new lextab X Xltb: ltb.o look.o X cc -s -o ltb ltb.o look.o Xclean: X rm proff *.o Xarch: X ./archc Makefile *.c *.h proffsym.new >proff.arc SHAR_EOF if test 376 -ne "`wc -c 'makefile'`" then echo shar: error transmitting "'makefile'" '(should have been 376 characters)' fi echo shar: extracting "'map.c'" '(1224 characters)' if test -f 'map.c' then echo shar: over-writing existing file "'map.c'" fi sed 's/^X//' << \SHAR_EOF > 'map.c' X X X#include X/* X * map map every character of s1 that is specified in s2 X * into s3 and replace in s. (source s1 remains untouched) X */ X Xmap(s,s1,s2,s3) Xregister char *s; Xregister char *s1; Xregister char *s2; Xregister char *s3; X{ X char *t, *t1; X if (*s1 != '\0') { X t = s; X t1 = s1; X strcpy(t,t1); X X while (*s2 != '\0' && *s3 != '\0') { X while (*t1 != '\0') { X if (*t1 == *s2) X *t = *s3; X t++; X t1++; X } X t = s; X t1 = s1; X s2++; X s3++; X } X } X else X *s = '\0'; X} X X/* X * roman - convert a numeric string into roman numerals X * X * icon version: X *procedure roman(n) X * local arabic, result X * static equiv X * initial equiv := ["","I","II","III","IV","V","VI","VII","VIII","IX"] X * integer(n) > 0 | fail X * result := "" X * every arabic := !n do X * result := map(result,"IVXLCDM","XLCDM**") || equiv[arabic+1] X * if find("*",result) then fail else return result X * end X * X */ Xint Xcvtroman(num,rom) Xchar *num; Xchar *rom; X{ X char tmp[20]; X Xstatic char *equiv_U[] = { "","I","II","III","IV","V","VI","VII","VIII","IX" }; X X *rom = NULL; X while (*num != '\0') { X map(tmp,rom,"IVXLCDM","XLCDM**"); X strcpy(rom,tmp); X strcat(rom,equiv_U[*num - '0']); X num++; X } X return(strlen(rom)); X} X SHAR_EOF if test 1224 -ne "`wc -c 'map.c'`" then echo shar: error transmitting "'map.c'" '(should have been 1224 characters)' fi # End of shell archive exit 0 -- Usenet: [decvax|allegra|linus|ihnp4]!utzoo!yetti!oz Bitnet: oz@[yusol|yuyetti] In the beginning, there was Word all right, except it wasn't fixed number of bits.