Post-ansification changes for usr.bin/lex
authorNick Downing <downing.nick@gmail.com>
Tue, 31 Jan 2017 12:56:22 +0000 (23:56 +1100)
committerNick Downing <downing.nick@gmail.com>
Tue, 31 Jan 2017 13:45:37 +0000 (00:45 +1100)
21 files changed:
.gitignore
lib/libc/gen/Makefile
n.sh
scripts/make.sh
usr.bin/Makefile
usr.bin/lex/groups.txt [new file with mode: 0644]
usr.bin/lex/header.c
usr.bin/lex/ldefs.h
usr.bin/lex/lmain.c
usr.bin/lex/parser.y
usr.bin/lex/sub1.c
usr.bin/lex/sub2.c
usr.bin/lex/uniqify.sed [new file with mode: 0644]
usr.bin/lex/y.tab.c [deleted file]
usr.bin/x_install.sh [new file with mode: 0644]
usr.bin/x_lorder.sh [new symlink]
usr.bin/x_nohup.sh [new symlink]
usr.bin/yacc/Makefile
usr.bin/yacc/x_yaccpar [new file with mode: 0644]
usr.bin/yacc/yaccpar
xify/xify.sh

index ebab920..adae24d 100644 (file)
@@ -125,6 +125,8 @@ usr.bin/file
 usr.bin/find/bigram
 usr.bin/find/code
 usr.bin/find/find
+usr.bin/lex/lex
+usr.bin/lex/y.tab.c
 usr.bin/join
 usr.bin/look
 usr.bin/mesg
index 96534cf..9545a1a 100644 (file)
@@ -26,13 +26,14 @@ OBJS=       abort.o abs.o alarm.o atof.o atoi.o atol.o bcmp.o bcopy.o bzero.o \
        getgrent.o getgrgid.o getgrnam.o getlogin.o getpass.o getpwent.o \
        getpwnamuid.o getttyent.o getttynam.o getusershell.o getwd.o index.o \
        initgroups.o insque.o ldexp.o malloc.o mkstemp.o mktemp.o modf.o \
-       ndbm.o nlist.o opendir.o perror.o psignal.o qsort.o random.o \
+       ndbm.o opendir.o perror.o psignal.o qsort.o random.o \
        readdir.o regex.o remque.o rindex.o scandir.o seekdir.o setegid.o \
-       seteuid.o setgid.o _setjmp.o setjmp.o setjmperr.o setrgid.o setruid.o \
+       seteuid.o setgid.o setjmperr.o setrgid.o setruid.o \
        setuid.o siginterrupt.o siglist.o signal.o sleep.o strcat.o strcmp.o \
        strcpy.o strlen.o strncat.o strncmp.o strncpy.o swab.o syslog.o \
        system.o telldir.o time.o timezone.o ttyname.o ttyslot.o ualarm.o \
        usleep.o valloc.o
+#nlist.o _setjmp.o setjmp.o
 CFLAGS=        -O ${DEFS}
 TAGSFILE=tags
 
diff --git a/n.sh b/n.sh
index 5d080c0..06d5285 100755 (executable)
--- a/n.sh
+++ b/n.sh
@@ -27,7 +27,9 @@ mkdir -p lib/libc/ns/profiled
 mkdir -p lib/libc/stdio/profiled
 mkdir -p lib/libc/sys/profiled
 (cd lib/libc && make.sh clean && make.sh && make.sh install)
-(cd bin && make.sh clean && make.sh SUBDIR="as csh diff sed sh tp" NSTD= KMEM= && make.sh SUBDIR="as csh diff sed sh tp" NSTD= KMEM= install)
-(cd usr.bin && make.sh clean && make.sh SUBDIR="find yacc" NSTD= KMEM= && make.sh SUBDIR="find yacc" NSTD= KMEM= install)
 
-#(cd test && make clean && make)
+(cd usr.bin/yacc && make.sh clean && make.sh && make.sh install)
+(cd usr.bin/lex && make.sh clean && make.sh && make.sh install)
+
+(cd bin && make.sh clean && make.sh SUBDIR="as csh diff sed sh tp" NSTD= KMEM= && make.sh SUBDIR="as csh diff sed sh tp" NSTD= KMEM= install)
+(cd usr.bin && make.sh clean && make.sh SUBDIR=find NSTD= KMEM= && make.sh SUBDIR=find NSTD= KMEM= install)
index 9dab6a4..beea003 100755 (executable)
@@ -1,4 +1,4 @@
 #!/bin/sh
 ROOT=`dirname $0`/..
 ROOT=`cd $ROOT && pwd`
-make CC="$ROOT/cross/bin/hostcc -Dunix -Dvax" LD="$ROOT/cross/bin/hostld" DESTDIR="$ROOT/cross" $@
+make X_="x_" CC="$ROOT/cross/bin/hostcc -Dunix -Dvax" LD="$ROOT/cross/bin/hostld" YACC="$ROOT/cross/usr/bin/yacc" LEX="$ROOT/cross/usr/bin/lex" DESTDIR="$ROOT/cross" "$@"
index ce37e9b..6512be5 100644 (file)
@@ -51,12 +51,12 @@ install:
        -for i in ${SUBDIR}; do \
                (cd $$i; make ${MFLAGS} DESTDIR=${DESTDIR} install); done
        -for i in ${SCRIPT}; do \
-               (install -c -m 555 $$i.sh ${DESTDIR}/usr/bin/$$i); done
+               (install -c -m 555 ${X_}$$i.sh ${DESTDIR}/usr/bin/$$i); done
        -for i in ${STD} ${NSTD}; do \
                (install -s $$i ${DESTDIR}/usr/bin/$$i); done
        -for i in ${KMEM}; do \
                (install -s -g kmem -m 2755 $$i ${DESTDIR}/usr/bin/$$i); done
-       install -c units.lib ${DESTDIR}/usr/lib/units
+       install -c -m 644 units.lib ${DESTDIR}/usr/lib/units
 
 clean:
        rm -f a.out core *.s *.o y.tab.c
diff --git a/usr.bin/lex/groups.txt b/usr.bin/lex/groups.txt
new file mode 100644 (file)
index 0000000..944e54f
--- /dev/null
@@ -0,0 +1,5 @@
+header.c ldefs.h
+lmain.c ldefs.h
+sub1.c ldefs.h
+sub2.c ldefs.h
+y.tab.c ldefs.h
index f7ecd8f..7918904 100644 (file)
@@ -5,11 +5,14 @@
 static char sccsid[] = "@(#)header.c   4.1 (Berkeley) 8/11/83";
 #endif
 /*# include "ldefs.h"*/
-int phead1() {
-       ratfor ? rhd1() : chd1();
+void phead1() {
+       if (ratfor)
+               rhd1();
+       else
+               chd1();
        }
 
-int chd1() {
+void chd1() {
        fprintf(fout,"# include \"stdio.h\"\n");
        if (ZCH>NCH)
        fprintf(fout, "# define U(x) ((x)&0377)\n");
@@ -50,7 +53,7 @@ int chd1() {
        fprintf(fout,"extern struct yysvf yysvec[], *yybgin;\n");
        }
 
-int rhd1() {
+void rhd1() {
        fprintf(fout,"integer function yylex(dummy)\n");
        fprintf(fout,"define YYLMAX 200\n");
        fprintf(fout,"define ECHO call yyecho(yytext,yyleng)\n");
@@ -69,24 +72,27 @@ int rhd1() {
        fprintf(fout,"\t\telse goto 30998\n");
        }
 
-int phead2() {
+void phead2() {
        if(!ratfor)chd2();
        }
 
-int chd2() {
+void chd2() {
        fprintf(fout,"while((nstr = yylook()) >= 0)\n");
        fprintf(fout,"yyfussy: switch(nstr){\n");
        fprintf(fout,"case 0:\n");
        fprintf(fout,"if(yywrap()) return(0); break;\n");
        }
 
-int ptail() {
+void ptail() {
        if(!pflag)
-               ratfor ? rtail() : ctail();
+               if (ratfor)
+                       rtail();
+               else
+                       ctail();
        pflag = 1;
        }
 
-int ctail() {
+void ctail() {
        fprintf(fout,"case -1:\nbreak;\n");             /* for reject */
        fprintf(fout,"default:\n");
        fprintf(fout,"fprintf(yyout,\"bad switch yylook %%d\",nstr);\n");
@@ -94,7 +100,7 @@ int ctail() {
        fprintf(fout,"/* end of yylex */\n");
        }
 
-int rtail() {
+void rtail() {
        register int i;
        fprintf(fout,"\n30998 if(nstr .lt. 0 .or. nstr .gt. %d)goto 30999\n",casecount);
        fprintf(fout,"nstr = nstr + 1\n");
@@ -105,7 +111,7 @@ int rtail() {
        fprintf(fout,"30997 continue\n");
        fprintf(fout,"}\nend\n");
        }
-int statistics() {
+void statistics() {
        fprintf(errorf,"%d/%d nodes(%%e), %d/%d positions(%%p), %d/%d (%%n), %ld transitions\n",
                tptr, treesize, nxtpos-positions, maxpos, stnum+1, nstates, rcount);
        fprintf(errorf, ", %d/%d packed char classes(%%k)", pcptr-pchar, pchlen);
index 56b9970..c1ee817 100644 (file)
@@ -3,6 +3,12 @@
 
 #include <stdio.h>
 
+#ifdef __STDC__
+#include <stdint.h>
+#else
+typedef int intptr_t;
+#endif
+
 /*     ldefs.c 4.1     83/08/11        */
 
 /*# include <stdio.h>*/
@@ -115,8 +121,8 @@ extern int prev;    /* previous input character */
 extern int pres;       /* present input character */
 extern int peek;       /* next input character */
 extern int *name;
-extern int *left;
-extern int *right;
+extern intptr_t *left;
+extern intptr_t *right;
 extern int *parent;
 extern char *nullstr;
 extern int tptr;
@@ -175,54 +181,62 @@ extern char *psave;
 #endif
 #endif
 
+#ifndef NORETURN
+#ifdef __GNUC__
+#define NORETURN __attribute__ ((__noreturn__))
+#else
+#define NORETURN
+#endif
+#endif
+
 /* header.c */
-int phead1 __P((void));
-int chd1 __P((void));
-int rhd1 __P((void));
-int phead2 __P((void));
-int chd2 __P((void));
-int ptail __P((void));
-int ctail __P((void));
-int rtail __P((void));
-int statistics __P((void));
+void phead1 __P((void));
+void chd1 __P((void));
+void rhd1 __P((void));
+void phead2 __P((void));
+void chd2 __P((void));
+void ptail __P((void));
+void ctail __P((void));
+void rtail __P((void));
+void statistics __P((void));
 
 /* lmain.c */
 int main __P((int argc, char **argv));
-int get1core __P((void));
-int free1core __P((void));
-int get2core __P((void));
-int free2core __P((void));
-int get3core __P((void));
+void get1core __P((void));
+void free1core __P((void));
+void get2core __P((void));
+void free2core __P((void));
+void get3core __P((void));
 int free3core __P((void));
 char *myalloc __P((int a, int b));
 int buserr __P((void));
 int segviol __P((void));
-int yyerror __P((char *s));
+void yyerror __P((char *s));
 
 /* sub1.c */
 char *getl __P((char *p));
 int space __P((int ch));
 int digit __P((int c));
-int error __P((char *s, ...));
-int warning __P((char *s, ...));
+void error __P((char *s, ...)) NORETURN;
+void warning __P((char *s, ...));
 int _index __P((int a, char *s));
 int alpha __P((int c));
 int printable __P((int c));
-int lgate __P((void));
-int scopy __P((char *s, char *t));
+void lgate __P((void));
+void scopy __P((char *s, char *t));
 int siconv __P((char *t));
 int slength __P((char *s));
 int scomp __P((char *x, char *y));
 int ctrans __P((char **ss));
-int cclinter __P((int sw));
+void cclinter __P((int sw));
 int usescape __P((int c));
 int lookup __P((char *s, char **t));
 int cpyact __P((void));
 int gch __P((void));
 int mn2 __P((int a, int d, int c));
-int mn1 __P((int a, int d));
+int mn1 __P((int a, intptr_t d));
 int mn0 __P((int a));
-int munput __P((int t, char *p));
+void munput __P((int t, intptr_t p));
 int dupl __P((int n));
 int allprint __P((int c));
 int strpt __P((char *s));
@@ -231,27 +245,27 @@ int sect2dump __P((void));
 int treedump __P((void));
 
 /* sub2.c */
-int cfoll __P((int v));
+void cfoll __P((int v));
 int pfoll __P((void));
-int add __P((int **array, int n));
-int follow __P((int v));
-int first __P((int v));
-int cgoto __P((void));
-int nextstate __P((int s, int c));
+void add __P((int **array, int n));
+void follow __P((int v));
+void first __P((int v));
+void cgoto __P((void));
+void nextstate __P((int s, int c));
 int notin __P((int n));
-int packtrans __P((int st, char *tch, int *tst, int cnt, int tryit));
+void packtrans __P((int st, char *tch, int *tst, int cnt, int tryit));
 int pstate __P((int s));
 int member __P((int d, char *t));
 int stprt __P((int i));
-int acompute __P((int s));
+void acompute __P((int s));
 int pccl __P((void));
-int mkmatch __P((void));
-int layout __P((void));
-int rprint __P((int *a, char *s, int n));
-int shiftr __P((int *a, int n));
-int upone __P((int *a, int n));
-int bprint __P((char *a, char *s, int n));
-int padd __P((int **array, int n));
+void mkmatch __P((void));
+void layout __P((void));
+void rprint __P((int *a, char *s, int n));
+void shiftr __P((int *a, int n));
+void upone __P((int *a, int n));
+void bprint __P((char *a, char *s, int n));
+void padd __P((int **array, int n));
 
 /* y.tab.c */
 int yylex __P((void));
index 100cf05..f65358a 100644 (file)
@@ -104,8 +104,8 @@ int chset;  /* 1 = char set modified */
 FILE *fin, *fother;
 int fptr;
 int *name;
-int *left;
-int *right;
+intptr_t *left;
+intptr_t *right;
 int *parent;
 char *nullstr;
 int tptr;
@@ -251,9 +251,7 @@ int main(argc, argv) int argc; char **argv; {
        fclose(stderr);
        exit(0);        /* success return code */
        }
-int get1core() {
-       register int i, val;
-       register char *p;
+void get1core() {
 ccptr =        ccl = myalloc(CCLSIZE,sizeof(*ccl));
 pcptr = pchar = myalloc(pchlen, sizeof(*pchar));
        def = (char **) myalloc(DEFSIZE,sizeof(*def));
@@ -264,14 +262,13 @@ sp =      schar = myalloc(STARTCHAR,sizeof(*schar));
        if(ccl == 0 || def == 0 || subs == 0 || dchar == 0 || sname == 0 || schar == 0)
                error("Too little core to begin");
        }
-int free1core() {
+void free1core() {
        free(def);
        free(subs);
        free(dchar);
        }
-int get2core() {
-       register int i, val;
-       register char *p;
+void get2core() {
+       register int i;
        gotof = (int *) myalloc(nstates,sizeof(*gotof));
        nexts = (int *) myalloc(ntrans,sizeof(*nexts));
        nchar = myalloc(ntrans,sizeof(*nchar));
@@ -287,7 +284,7 @@ nxtpos = positions = (int *) myalloc(maxpos,sizeof(*positions));
                error("Too little core for state generation");
        for(i=0;i<=tptr;i++)foll[i] = 0;
        }
-int free2core() {
+void free2core() {
        free(positions);
        free(tmpstat);
        free(foll);
@@ -301,9 +298,7 @@ int free2core() {
        free(schar);
        free(ccl);
        }
-int get3core() {
-       register int i, val;
-       register char *p;
+void get3core() {
        verify = (int *) myalloc(outsize,sizeof(*verify));
        advance = (int *) myalloc(outsize,sizeof(*advance));
        stoff = (int *) myalloc(stnum+2,sizeof(*stoff));
@@ -355,7 +350,7 @@ int segviol() {
        }
 # endif
 
-int yyerror(s) char *s; {
+void yyerror(s) char *s; {
        fprintf(stderr, "\"%s\", line %d: %s\n",
                fptr > 0 ? sargv[fptr] : "<stdin>", yyline, s);
 }
index 0cd87f5..ac02607 100644 (file)
@@ -8,11 +8,18 @@
 %left '*' '+' '?'
 
 %{
-#ifndef lint
+#include <gen.h>
+/*#include <stdio.h> ldefs.h*/
+/*#include <strings.h> gen.h*/
+#include "ldefs.h"
+
+#define YYSTYPE intptr_t
+
+#if defined(DOSCCS) && !defined(lint)
 static char sccsid[] = "@(#)parser.y   4.1 (Berkeley) 8/11/83";
 #endif
 
-# include "ldefs.h"
+/*# include "ldefs.h"*/
 %}
 %%
 %{
@@ -46,14 +53,14 @@ lexinput:   defns delim prods end
        ;
 end:           delim | ;
 defns: defns STR STR
-       ={      scopy($2,dp);
+       ={      scopy((char *)$2,dp);
                def[dptr] = dp;
-               dp += slength($2) + 1;
-               scopy($3,dp);
+               dp += slength((char *)$2) + 1;
+               scopy((char *)$3,dp);
                subs[dptr++] = dp;
                if(dptr >= DEFSIZE)
                        error("Too many definitions");
-               dp += slength($3) + 1;
+               dp += slength((char *)$3) + 1;
                if(dp >= dchar+DEFCHAR)
                        error("Definitions too long");
                subs[dptr]=def[dptr]=0; /* for lookup - require ending null */
@@ -93,7 +100,7 @@ r:   CHAR
        ={      $$ = mn0($1); }
        | STR
        ={
-               p = $1;
+               p = (char *)$1;
                i = mn0(*p++);
                while(*p)
                        i = mn2(RSTR,i,*p++);
@@ -118,7 +125,7 @@ r:  CHAR
                        }
                else
                        p = psave;
-               $$ = mn1(RCCL,p);
+               $$ = mn1(RCCL, (intptr_t)p);
                cclinter(1);
                }
        | CCL
@@ -213,7 +220,7 @@ r:  CHAR
        ={      $$ = mn0(RNULLS); }
        ;
 %%
-yylex(){
+int yylex() {
        register char *p;
        register int c, i;
        char  *t, *xp;
@@ -241,16 +248,15 @@ yylex(){
                                                sectbegin = TRUE;
                                                i = treesize*(sizeof(*name)+sizeof(*left)+
                                                        sizeof(*right)+sizeof(*nullstr)+sizeof(*parent))+ALITTLEEXTRA;
-                                               c = myalloc(i,1);
-                                               if(c == 0)
+                                               p = myalloc(i,1);
+                                               if(p == 0)
                                                        error("Too little core for parse tree");
-                                               p = c;
                                                free(p);
-                                               name = myalloc(treesize,sizeof(*name));
-                                               left = myalloc(treesize,sizeof(*left));
-                                               right = myalloc(treesize,sizeof(*right));
+                                               name = (int *)myalloc(treesize,sizeof(*name));
+                                               left = (intptr_t *)myalloc(treesize,sizeof(*left));
+                                               right = (intptr_t *)myalloc(treesize,sizeof(*right));
                                                nullstr = myalloc(treesize,sizeof(*nullstr));
-                                               parent = myalloc(treesize,sizeof(*parent));
+                                               parent = (int *)myalloc(treesize,sizeof(*parent));
                                                if(name == 0 || left == 0 || right == 0 || parent == 0 || nullstr == 0)
                                                        error("Too little core for parse tree");
                                                return(freturn(DELIM));
@@ -361,12 +367,12 @@ yylex(){
                                                error("Premature eof");
                                        case 's': case 'S':             /* start conditions */
                                                lgate();
-                                               while(*p && index(*p," \t,") < 0) p++;
+                                               while(*p && _index(*p," \t,") < 0) p++;
                                                n = TRUE;
                                                while(n){
-                                                       while(*p && index(*p," \t,") >= 0) p++;
+                                                       while(*p && _index(*p," \t,") >= 0) p++;
                                                        t = p;
-                                                       while(*p && index(*p," \t,") < 0)p++;
+                                                       while(*p && _index(*p," \t,") < 0)p++;
                                                        if(!*p) n = FALSE;
                                                        *p++ = 0;
                                                        if (*t == 0) continue;
@@ -398,7 +404,7 @@ yylex(){
                                        prev = *p;
                                        *p = 0;
                                        bptr = p+1;
-                                       yylval = buf;
+                                       yylval = (intptr_t)buf;
                                        if(digit(buf[0]))
                                                warning("Substitution strings may not begin with digits");
                                        return(freturn(STR));
@@ -411,7 +417,7 @@ yylex(){
                                if(*p == 0)
                                        warning("No translation given - null string assumed");
                                scopy(p,token);
-                               yylval = token;
+                               yylval = (intptr_t)token;
                                prev = '\n';
                                return(freturn(STR));
                                }
@@ -522,7 +528,7 @@ yylex(){
                                        if(i < 0)
                                                warning("Definition %s not found",token);
                                        else
-                                               munput('s',subs[i]);
+                                               munput('s', (intptr_t)subs[i]);
                                        continue;
                                        }
                        case '<':               /* start condition ? */
@@ -562,7 +568,7 @@ yylex(){
                                        }
                                if(slptr > slist+STARTSIZE)             /* note not packed ! */
                                        error("Too many start conditions used");
-                               yylval = t;
+                               yylval = (intptr_t)t;
                                x = SCON;
                                break;
                        case '"':
@@ -588,7 +594,7 @@ yylex(){
                                        x = CHAR;
                                        }
                                else {
-                                       yylval = token;
+                                       yylval = (intptr_t)token;
                                        x = STR;
                                        }
                                break;
@@ -632,9 +638,9 @@ yylex(){
                                        while(p <ccptr && scomp(token,p) != 0)p++;
                                        }
                                if(p < ccptr)   /* found it */
-                                       yylval = p;
+                                       yylval = (intptr_t)p;
                                else {
-                                       yylval = ccptr;
+                                       yylval = (intptr_t)ccptr;
                                        scopy(token,ccptr);
                                        ccptr += slength(token) + 1;
                                        if(ccptr >= ccl+CCLSIZE)
@@ -653,12 +659,12 @@ yylex(){
                                        }
                                if(alpha(peek)){
                                        i = 0;
-                                       yylval = token;
+                                       yylval = (intptr_t)token;
                                        token[i++] = c;
                                        while(alpha(peek))
                                                token[i++] = gch();
                                        if(peek == '?' || peek == '*' || peek == '+')
-                                               munput('c',token[--i]);
+                                               munput('c', (intptr_t)token[--i]);
                                        token[i] = 0;
                                        if(i == 1){
                                                yylval = token[0];
@@ -689,8 +695,7 @@ yylex(){
        }
 /* end of yylex */
 # ifdef DEBUG
-freturn(i)
-  int i; {
+int freturn(i) int i; {
        if(yydebug) {
                printf("now return ");
                if(i < NCH) allprint(i);
index d73426e..b966f22 100644 (file)
@@ -41,16 +41,16 @@ int digit(c) int c; {
        return(c>='0' && c <= '9');
 }
 #ifdef __STDC__
-int error(char *s, ...)
+void error(char *s, ...)
 #else
-int error(s, va_alist) char *s; va_dcl
+void error(s, va_alist) char *s; va_dcl
 #endif
 {
        va_list argp;
 
        fprintf(errorf,"\"%s\", line %d: (Error) ",
                fptr > 0 ? sargv[fptr] : "<stdin>", yyline);
-       _va_start(argp, fmt);
+       _va_start(argp, s);
        vfprintf(errorf,s,argp);
        va_end(argp);
        putc('\n',errorf);
@@ -69,16 +69,16 @@ int error(s, va_alist) char *s; va_dcl
        }
 
 #ifdef __STDC__
-int warning(char *s, ...)
+void warning(char *s, ...)
 #else
-int warning(s, va_alist) char *s; va_dcl
+void warning(s, va_alist) char *s; va_dcl
 #endif
 {
        va_list argp;
 
        fprintf(errorf,"\"%s\", line %d: (Warning) ",
                fptr > 0 ? sargv[fptr] : "<stdin>", yyline);
-       _va_start(argp, fmt);
+       _va_start(argp, s);
        vfprintf(errorf,s,argp);
        va_end(argp);
        putc('\n',errorf);
@@ -110,7 +110,7 @@ return( c>040 && c < 0177);
 return(_index(c, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,;:><+*)('&%!-=\"")>=0);
 # endif
 }
-int lgate() {
+void lgate() {
        char fname[20];
        if (lgatflg) return;
        lgatflg=1;
@@ -124,7 +124,7 @@ int lgate() {
        }
 /* scopy(ptr to str, ptr to str) - copy first arg str to second */
 /* returns ptr to second arg */
-int scopy(s, t) char *s; char *t; {
+void scopy(s, t) char *s; char *t; {
        register char *i;
        i = t;
        while(*i++ = *s++);
@@ -193,7 +193,7 @@ int ctrans(ss) char **ss; {
        }
        return(c);
 }
-int cclinter(sw) int sw; {
+void cclinter(sw) int sw; {
                /* sw = 1 ==> ccl */
        register int i, j, k;
        int m;
@@ -436,7 +436,7 @@ int mn2(a, d, c) int a; int d; int c; {
                error("Parse tree too big %s",(treesize == TREESIZE?"\nTry using %e num":""));
        return(tptr++);
        }
-int mn1(a, d) int a; int d; {
+int mn1(a, d) int a; intptr_t d; {
        name[tptr] = a;
        left[tptr] = d;
        parent[tptr] = 0;
@@ -444,7 +444,7 @@ int mn1(a, d) int a; int d; {
        switch(a){
        case RCCL:
        case RNCCL:
-               if(slength(d) == 0) nullstr[tptr] = TRUE;
+               if(slength((char *)d) == 0) nullstr[tptr] = TRUE;
                break;
        case STAR:
        case QUEST:
@@ -471,7 +471,8 @@ int mn1(a, d) int a; int d; {
        if(tptr > treesize)
                error("Parse tree too big %s",(treesize == TREESIZE?"\nTry using %e num":""));
        return(tptr++);
-       }
+}
+
 int mn0(a) int a; {
        name[tptr] = a;
        parent[tptr] = 0;
@@ -488,18 +489,18 @@ int mn0(a) int a; {
                error("Parse tree too big %s",(treesize == TREESIZE?"\nTry using %e num":""));
        return(tptr++);
        }
-int munput(t, p)       /* implementation dependent */ int t; char *p; {
+void munput(t, p)      /* implementation dependent */ int t; intptr_t p; {
        register int i,j;
        if(t == 'c'){
                *pushptr++ = peek;              /* watch out for this */
-               peek = p;
+               peek = (int)p;
                }
        else if(t == 's'){
                *pushptr++ = peek;
-               peek = p[0];
-               i = slength(p);
+               peek = ((char *)p)[0];
+               i = slength((char *)p);
                for(j = i-1; j>=1; j--)
-                       *pushptr++ = p[j];
+                       *pushptr++ = ((char *)p)[j];
                }
 # ifdef DEBUG
        else error("Unrecognized munput option %c",t);
@@ -557,7 +558,7 @@ int allprint(c) int c; {
                default:
                        if(!printable(c)){
                                printf("\\%-3o",c);
-                               charc =+ 3;
+                               charc += 3;
                                }
                        else 
                                putchar(c);
index dc8ac4d..b9a6304 100644 (file)
@@ -7,7 +7,7 @@ static char sccsid[] = "@(#)sub2.c      4.1 (Berkeley) 8/11/83";
 #endif
 
 /*# include "ldefs.h"*/
-int cfoll(v) int v; {
+void cfoll(v) int v; {
        register int i,j,k;
        char *p;
        i = name[v];
@@ -28,7 +28,7 @@ int cfoll(v) int v; {
                        else if(i == RCCL || i == RNCCL){       /* compress ccl list */
                                for(j=1; j<NCH;j++)
                                        symbol[j] = (i==RNCCL);
-                               p = left[v];
+                               p = (char *)left[v];
                                while(*p)
                                        symbol[*p++] = (i == RCCL);
                                p = pcptr;
@@ -42,7 +42,7 @@ int cfoll(v) int v; {
                                *pcptr++ = 0;
                                if(pcptr > pchar + pchlen)
                                        error("Too many packed character classes");
-                               left[v] = p;
+                               left[v] = (intptr_t)p;
                                name[v] = RCCL; /* RNCCL eliminated */
 # ifdef DEBUG
                                if(debug && *p){
@@ -94,7 +94,7 @@ int pfoll() {
        return;
        }
 # endif
-int add(array, n) int **array; int n; {
+void add(array, n) int **array; int n; {
        register int i, *temp;
        register char *ctemp;
        temp = nxtpos;
@@ -109,7 +109,7 @@ int add(array, n) int **array; int n; {
                error("Too many positions %s",(maxpos== MAXPOS?"\nTry using %p num":""));
        return;
        }
-int follow(v) int v; {
+void follow(v) int v; {
        register int p;
        if(v >= tptr-1)return;
        p = parent[v];
@@ -147,7 +147,7 @@ int follow(v) int v; {
                }
        return;
        }
-int first(v)   /* calculate set of positions with v as root which can be active initially */ int v; {
+void first(v)  /* calculate set of positions with v as root which can be active initially */ int v; {
        register int i;
        register char *p;
        i = name[v];
@@ -169,7 +169,7 @@ int first(v)        /* calculate set of positions with v as root which can be active in
                        break;
                case RSCON:
                        i = stnum/2 +1;
-                       p = right[v];
+                       p = (char *)right[v];
                        while(*p)
                                if(*p++ == i){
                                        first(left[v]);
@@ -191,7 +191,7 @@ int first(v)        /* calculate set of positions with v as root which can be active in
                }
        return;
        }
-int cgoto() {
+void cgoto() {
        register int i, j, s;
        int npos, curpos, n;
        int tryit;
@@ -237,7 +237,7 @@ int cgoto() {
                        else switch(name[curpos]){
                        case RCCL:
                                tryit = TRUE;
-                               q = left[curpos];
+                               q = (char *)left[curpos];
                                while(*q){
                                        for(j=1;j<NCH;j++)
                                                if(cindex[j] == *q)
@@ -308,7 +308,7 @@ int cgoto() {
        }
        /*      Beware -- 70% of total CPU time is spent in this subroutine -
                if you don't believe me - try it yourself ! */
-int nextstate(s, c) int s; int c; {
+void nextstate(s, c) int s; int c; {
        register int j, *newpos;
        register char *temp, *tz;
        int *pos, i, *f, num, curpos, number;
@@ -321,7 +321,7 @@ int nextstate(s, c) int s; int c; {
                j = name[curpos];
                if(j < NCH && j == c
                || j == RSTR && c == right[curpos]
-               || j == RCCL && member(c,left[curpos])){
+               || j == RCCL && member(c, (char *)left[curpos])){
                        f = foll[curpos];
                        number = *f;
                        newpos = f+1;
@@ -340,7 +340,8 @@ int nextstate(s, c) int s; int c; {
                }
        count = j;
        return;
-       }
+}
+
 int notin(n) int n; {  /* see if tmpstat occurs previously */
        register int *j,k;
        register char *temp;
@@ -359,7 +360,7 @@ int notin(n) int n; {       /* see if tmpstat occurs previously */
                }
        return(-1);
        }
-int packtrans(st, tch, tst, cnt, tryit) int st; char *tch; int *tst; int cnt; int tryit; {
+void packtrans(st, tch, tst, cnt, tryit) int st; char *tch; int *tst; int cnt; int tryit; {
        /* pack transitions into nchar, nexts */
        /* nchar is terminated by '\0', nexts uses cnt, followed by elements */
        /* gotof[st] = _index into nchr, nexts for state st */
@@ -577,7 +578,7 @@ int stprt(i) int i; {
        return;
        }
 # endif
-int acompute(s)        /* compute action list = set of poss. actions */ int s; {
+void acompute(s)       /* compute action list = set of poss. actions */ int s; {
        register int *p, i, j;
        int cnt, m;
        int temp[300], k, neg[300], n;
@@ -672,7 +673,7 @@ int pccl() {
        return;
        }
 # endif
-int mkmatch() {
+void mkmatch() {
        register int i;
        char tab[NCH];
        for(i=0; i<ccount; i++)
@@ -685,7 +686,7 @@ int mkmatch() {
                match[i] = tab[cindex[i]];
        return;
        }
-int layout() {
+void layout() {
        /* format and output final program's tables */
        register int i, j, k;
        int  top, bot, startup, omin;
@@ -835,7 +836,7 @@ int layout() {
                        }
                else {
                        int *fbarr;
-                       fbarr = myalloc(2*NCH, sizeof(*fbarr));
+                       fbarr = (int *)myalloc(2*NCH, sizeof(*fbarr));
                        if (fbarr==0)
                                error("No space for char table reverse",0);
                        for(i=0; i<ZCH; i++)
@@ -862,7 +863,7 @@ int layout() {
        fprintf(fout,"0};\n");
        return;
        }
-int rprint(a, s, n) int *a; char *s; int n; {
+void rprint(a, s, n) int *a; char *s; int n; {
        register int i;
        fprintf(fout,"block data\n");
        fprintf(fout,"common /L%s/ %s\n",s,s);
@@ -875,17 +876,17 @@ int rprint(a, s, n) int *a; char *s; int n; {
                }
        fprintf(fout,"end\n");
        }
-int shiftr(a, n) int *a; int n; {
+void shiftr(a, n) int *a; int n; {
 int i;
 for(i=n; i>=0; i--)
        a[i+1]=a[i];
 }
-int upone(a, n) int *a; int n; {
+void upone(a, n) int *a; int n; {
 int i;
 for(i=0; i<=n ; i++)
        a[i]++;
 }
-int bprint(a, s, n) char *a; char *s; int n; {
+void bprint(a, s, n) char *a; char *s; int n; {
        register int i, j, k;
        fprintf(fout,"block data\n");
        fprintf(fout,"common /L%s/ %s\n",s,s);
@@ -902,7 +903,7 @@ int bprint(a, s, n) char *a; char *s; int n; {
        fprintf(fout,"end\n");
        }
 # ifdef PP
-int padd(array, n) int **array; int n; {
+void padd(array, n) int **array; int n; {
        register int i, *j, k;
        array[n] = nxtpos;
        if(count == 0){
diff --git a/usr.bin/lex/uniqify.sed b/usr.bin/lex/uniqify.sed
new file mode 100644 (file)
index 0000000..b67ab71
--- /dev/null
@@ -0,0 +1,9 @@
+s/@/ATSIGN/g
+s/^/@/
+s/$/@/
+s/[^A-Za-z0-9_]\+/@&@/g
+
+s/@index@/@_index@/
+
+s/@//g
+s/ATSIGN/@/g
diff --git a/usr.bin/lex/y.tab.c b/usr.bin/lex/y.tab.c
deleted file mode 100644 (file)
index ff7ed7d..0000000
+++ /dev/null
@@ -1,974 +0,0 @@
-#include <gen.h>
-/*#include <stdio.h> ldefs.h*/
-/*#include <strings.h> gen.h*/
-#include "ldefs.h"
-
-# define CHAR 257
-# define CCL 258
-# define NCCL 259
-# define STR 260
-# define DELIM 261
-# define SCON 262
-# define ITER 263
-# define NEWE 264
-# define NULLS 265
-# define CAT 266
-
-# line 11 "parser.y"
-#if defined(DOSCCS) && !defined(lint)
-static char sccsid[] = "@(#)parser.y   4.1 (Berkeley) 8/11/83";
-#endif
-
-/*# include "ldefs.h"*/
-#define yyclearin yychar = -1
-#define yyerrok yyerrflag = 0
-extern int yychar;
-extern short yyerrflag;
-#ifndef YYMAXDEPTH
-#define YYMAXDEPTH 150
-#endif
-#ifndef YYSTYPE
-#define YYSTYPE int
-#endif
-YYSTYPE yylval, yyval;
-
-# line 19 "parser.y"
-int i;
-int j,k;
-int g;
-char *p;
-# define YYERRCODE 256
-
-# line 215 "parser.y"
-
-int yylex() {
-       register char *p;
-       register int c, i;
-       char  *t, *xp;
-       int n, j, k, x;
-       static int sectbegin;
-       static char token[TOKENSIZE];
-       static int iter;
-
-# ifdef DEBUG
-       yylval = 0;
-# endif
-
-       if(sect == DEFSECTION) {                /* definitions section */
-               while(!eof) {
-                       if(prev == '\n'){               /* next char is at beginning of line */
-                               getl(p=buf);
-                               switch(*p){
-                               case '%':
-                                       switch(c= *(p+1)){
-                                       case '%':
-                                               lgate();
-                                               if(!ratfor)fprintf(fout,"# ");
-                                               fprintf(fout,"define YYNEWLINE %d\n",ctable['\n']);
-                                               if(!ratfor)fprintf(fout,"yylex(){\nint nstr; extern int yyprevious;\n");
-                                               sectbegin = TRUE;
-                                               i = treesize*(sizeof(*name)+sizeof(*left)+
-                                                       sizeof(*right)+sizeof(*nullstr)+sizeof(*parent))+ALITTLEEXTRA;
-                                               c = myalloc(i,1);
-                                               if(c == 0)
-                                                       error("Too little core for parse tree");
-                                               p = c;
-                                               free(p);
-                                               name = myalloc(treesize,sizeof(*name));
-                                               left = myalloc(treesize,sizeof(*left));
-                                               right = myalloc(treesize,sizeof(*right));
-                                               nullstr = myalloc(treesize,sizeof(*nullstr));
-                                               parent = myalloc(treesize,sizeof(*parent));
-                                               if(name == 0 || left == 0 || right == 0 || parent == 0 || nullstr == 0)
-                                                       error("Too little core for parse tree");
-                                               return(freturn(DELIM));
-                                       case 'p': case 'P':     /* has overridden number of positions */
-                                               while(*p && !digit(*p))p++;
-                                               maxpos = siconv(p);
-# ifdef DEBUG
-                                               if (debug) printf("positions (%%p) now %d\n",maxpos);
-# endif
-                                               if(report == 2)report = 1;
-                                               continue;
-                                       case 'n': case 'N':     /* has overridden number of states */
-                                               while(*p && !digit(*p))p++;
-                                               nstates = siconv(p);
-# ifdef DEBUG
-                                               if(debug)printf( " no. states (%%n) now %d\n",nstates);
-# endif
-                                               if(report == 2)report = 1;
-                                               continue;
-                                       case 'e': case 'E':             /* has overridden number of tree nodes */
-                                               while(*p && !digit(*p))p++;
-                                               treesize = siconv(p);
-# ifdef DEBUG
-                                               if (debug) printf("treesize (%%e) now %d\n",treesize);
-# endif
-                                               if(report == 2)report = 1;
-                                               continue;
-                                       case 'o': case 'O':
-                                               while (*p && !digit(*p))p++;
-                                               outsize = siconv(p);
-                                               if (report ==2) report=1;
-                                               continue;
-                                       case 'a': case 'A':             /* has overridden number of transitions */
-                                               while(*p && !digit(*p))p++;
-                                               if(report == 2)report = 1;
-                                               ntrans = siconv(p);
-# ifdef DEBUG
-                                               if (debug)printf("N. trans (%%a) now %d\n",ntrans);
-# endif
-                                               continue;
-                                       case 'k': case 'K': /* overriden packed char classes */
-                                               while (*p && !digit(*p))p++;
-                                               if (report==2) report=1;
-                                               free(pchar);
-                                               pchlen = siconv(p);
-# ifdef DEBUG
-                                               if (debug) printf( "Size classes (%%k) now %d\n",pchlen);
-# endif
-                                               pchar=pcptr=myalloc(pchlen, sizeof(*pchar));
-                                               continue;
-                                       case 't': case 'T':     /* character set specifier */
-                                               ZCH = atoi(p+2);
-                                               if (ZCH < NCH) ZCH = NCH;
-                                               if (ZCH > 2*NCH) error("ch table needs redeclaration");
-                                               chset = TRUE;
-                                               for(i = 0; i<ZCH; i++)
-                                                       ctable[i] = 0;
-                                               while(getl(p) && scomp(p,"%T") != 0 && scomp(p,"%t") != 0){
-                                                       if((n = siconv(p)) <= 0 || n > ZCH){
-                                                               warning("Character value %d out of range",n);
-                                                               continue;
-                                                               }
-                                                       while(!space(*p) && *p) p++;
-                                                       while(space(*p)) p++;
-                                                       t = p;
-                                                       while(*t){
-                                                               c = ctrans(&t);
-                                                               if(ctable[c]){
-                                                                       if (printable(c))
-                                                                               warning("Character '%c' used twice",c);
-                                                                       else
-                                                                               warning("Character %o used twice",c);
-                                                                       }
-                                                               else ctable[c] = n;
-                                                               t++;
-                                                               }
-                                                       p = buf;
-                                                       } {
-                                               char chused[2*NCH]; int kr;
-                                               for(i=0; i<ZCH; i++)
-                                                       chused[i]=0;
-                                               for(i=0; i<NCH; i++)
-                                                       chused[ctable[i]]=1;
-                                               for(kr=i=1; i<NCH; i++)
-                                                       if (ctable[i]==0) {
-                                                               while (chused[kr] == 0)
-                                                                       kr++;
-                                                               ctable[i]=kr;
-                                                               chused[kr]=1;
-                                                               }
-                                               }
-                                               lgate();
-                                               continue;
-                                       case 'r': case 'R':
-                                               c = 'r';
-                                       case 'c': case 'C':
-                                               if(lgatflg)
-                                                       error("Too late for language specifier");
-                                               ratfor = (c == 'r');
-                                               continue;
-                                       case '{':
-                                               lgate();
-                                               while(getl(p) && scomp(p,"%}") != 0)
-                                                       fprintf(fout, "%s\n",p);
-                                               if(p[0] == '%') continue;
-                                               error("Premature eof");
-                                       case 's': case 'S':             /* start conditions */
-                                               lgate();
-                                               while(*p && _index(*p," \t,") < 0) p++;
-                                               n = TRUE;
-                                               while(n){
-                                                       while(*p && _index(*p," \t,") >= 0) p++;
-                                                       t = p;
-                                                       while(*p && _index(*p," \t,") < 0)p++;
-                                                       if(!*p) n = FALSE;
-                                                       *p++ = 0;
-                                                       if (*t == 0) continue;
-                                                       i = sptr*2;
-                                                       if(!ratfor)fprintf(fout,"# ");
-                                                       fprintf(fout,"define %s %d\n",t,i);
-                                                       scopy(t,sp);
-                                                       sname[sptr++] = sp;
-                                                       sname[sptr] = 0;        /* required by lookup */
-                                                       if(sptr >= STARTSIZE)
-                                                               error("Too many start conditions");
-                                                       sp += slength(sp) + 1;
-                                                       if(sp >= schar+STARTCHAR)
-                                                               error("Start conditions too long");
-                                                       }
-                                               continue;
-                                       default:
-                                               warning("Invalid request %s",p);
-                                               continue;
-                                               }       /* end of switch after seeing '%' */
-                               case ' ': case '\t':            /* must be code */
-                                       lgate();
-                                       fprintf(fout, "%s\n",p);
-                                       continue;
-                               default:                /* definition */
-                                       while(*p && !space(*p)) p++;
-                                       if(*p == 0)
-                                               continue;
-                                       prev = *p;
-                                       *p = 0;
-                                       bptr = p+1;
-                                       yylval = buf;
-                                       if(digit(buf[0]))
-                                               warning("Substitution strings may not begin with digits");
-                                       return(freturn(STR));
-                                       }
-                               }
-                       /* still sect 1, but prev != '\n' */
-                       else {
-                               p = bptr;
-                               while(*p && space(*p)) p++;
-                               if(*p == 0)
-                                       warning("No translation given - null string assumed");
-                               scopy(p,token);
-                               yylval = token;
-                               prev = '\n';
-                               return(freturn(STR));
-                               }
-                       }
-               /* end of section one processing */
-               }
-       else if(sect == RULESECTION){           /* rules and actions */
-               while(!eof){
-                       switch(c=gch()){
-                       case '\0':
-                               return(freturn(0));
-                       case '\n':
-                               if(prev == '\n') continue;
-                               x = NEWE;
-                               break;
-                       case ' ':
-                       case '\t':
-                               if(sectbegin == TRUE){
-                                       cpyact();
-                                       while((c=gch()) && c != '\n');
-                                       continue;
-                                       }
-                               if(!funcflag)phead2();
-                               funcflag = TRUE;
-                               if(ratfor)fprintf(fout,"%d\n",30000+casecount);
-                               else fprintf(fout,"case %d:\n",casecount);
-                               if(cpyact()){
-                                       if(ratfor)fprintf(fout,"goto 30997\n");
-                                       else fprintf(fout,"break;\n");
-                                       }
-                               while((c=gch()) && c != '\n');
-                               if(peek == ' ' || peek == '\t' || sectbegin == TRUE){
-                                       warning("Executable statements should occur right after %%");
-                                       continue;
-                                       }
-                               x = NEWE;
-                               break;
-                       case '%':
-                               if(prev != '\n') goto character;
-                               if(peek == '{'){        /* included code */
-                                       getl(buf);
-                                       while(!eof && getl(buf) && scomp("%}",buf) != 0)
-                                               fprintf(fout,"%s\n",buf);
-                                       continue;
-                                       }
-                               if(peek == '%'){
-                                       c = gch();
-                                       c = gch();
-                                       x = DELIM;
-                                       break;
-                                       }
-                               goto character;
-                       case '|':
-                               if(peek == ' ' || peek == '\t' || peek == '\n'){
-                                       if(ratfor)fprintf(fout,"%d\n",30000+casecount++);
-                                       else fprintf(fout,"case %d:\n",casecount++);
-                                       continue;
-                                       }
-                               x = '|';
-                               break;
-                       case '$':
-                               if(peek == '\n' || peek == ' ' || peek == '\t' || peek == '|' || peek == '/'){
-                                       x = c;
-                                       break;
-                                       }
-                               goto character;
-                       case '^':
-                               if(prev != '\n' && scon != TRUE) goto character;        /* valid only at line begin */
-                               x = c;
-                               break;
-                       case '?':
-                       case '+':
-                       case '.':
-                       case '*':
-                       case '(':
-                       case ')':
-                       case ',':
-                       case '/':
-                               x = c;
-                               break;
-                       case '}':
-                               iter = FALSE;
-                               x = c;
-                               break;
-                       case '{':       /* either iteration or definition */
-                               if(digit(c=gch())){     /* iteration */
-                                       iter = TRUE;
-                               ieval:
-                                       i = 0;
-                                       while(digit(c)){
-                                               token[i++] = c;
-                                               c = gch();
-                                               }
-                                       token[i] = 0;
-                                       yylval = siconv(token);
-                                       munput('c',c);
-                                       x = ITER;
-                                       break;
-                                       }
-                               else {          /* definition */
-                                       i = 0;
-                                       while(c && c!='}'){
-                                               token[i++] = c;
-                                               c = gch();
-                                               }
-                                       token[i] = 0;
-                                       i = lookup(token,def);
-                                       if(i < 0)
-                                               warning("Definition %s not found",token);
-                                       else
-                                               munput('s',subs[i]);
-                                       continue;
-                                       }
-                       case '<':               /* start condition ? */
-                               if(prev != '\n')                /* not at line begin, not start */
-                                       goto character;
-                               t = slptr;
-                               do {
-                                       i = 0;
-                                       c = gch();
-                                       while(c != ',' && c && c != '>'){
-                                               token[i++] = c;
-                                               c = gch();
-                                               }
-                                       token[i] = 0;
-                                       if(i == 0)
-                                               goto character;
-                                       i = lookup(token,sname);
-                                       if(i < 0) {
-                                               warning("Undefined start condition %s",token);
-                                               continue;
-                                               }
-                                       *slptr++ = i+1;
-                                       } while(c && c != '>');
-                               *slptr++ = 0;
-                               /* check if previous value re-usable */
-                               for (xp=slist; xp<t; ) {
-                                       if (strcmp(xp, t)==0)
-                                               break;
-                                       while (*xp++);
-                                       }
-                               if (xp<t) {
-                                       /* re-use previous pointer to string */
-                                       slptr=t;
-                                       t=xp;
-                                       }
-                               if(slptr > slist+STARTSIZE)             /* note not packed ! */
-                                       error("Too many start conditions used");
-                               yylval = t;
-                               x = SCON;
-                               break;
-                       case '"':
-                               i = 0;
-                               while((c=gch()) && c != '"' && c != '\n'){
-                                       if(c == '\\') c = usescape(c=gch());
-                                       token[i++] = c;
-                                       if(i > TOKENSIZE){
-                                               warning("String too long");
-                                               i = TOKENSIZE-1;
-                                               break;
-                                               }
-                                       }
-                               if(c == '\n') {
-                                       yyline--;
-                                       warning("Non-terminated string");
-                                       yyline++;
-                                       }
-                               token[i] = 0;
-                               if(i == 0)x = NULLS;
-                               else if(i == 1){
-                                       yylval = token[0];
-                                       x = CHAR;
-                                       }
-                               else {
-                                       yylval = token;
-                                       x = STR;
-                                       }
-                               break;
-                       case '[':
-                               for(i=1;i<NCH;i++) symbol[i] = 0;
-                               x = CCL;
-                               if((c = gch()) == '^'){
-                                       x = NCCL;
-                                       c = gch();
-                                       }
-                               while(c != ']' && c){
-                                       if(c == '\\') c = usescape(c=gch());
-                                       symbol[c] = 1;
-                                       j = c;
-                                       if((c=gch()) == '-' && peek != ']'){            /* range specified */
-                                               c = gch();
-                                               if(c == '\\') c = usescape(c=gch());
-                                               k = c;
-                                               if(j > k) {
-                                                       n = j;
-                                                       j = k;
-                                                       k = n;
-                                                       }
-                                               if(!(('A' <= j && k <= 'Z') ||
-                                                    ('a' <= j && k <= 'z') ||
-                                                    ('0' <= j && k <= '9')))
-                                                       warning("Non-portable Character Class");
-                                               for(n=j+1;n<=k;n++)
-                                                       symbol[n] = 1;          /* implementation dependent */
-                                               c = gch();
-                                               }
-                                       }
-                               /* try to pack ccl's */
-                               i = 0;
-                               for(j=0;j<NCH;j++)
-                                       if(symbol[j])token[i++] = j;
-                               token[i] = 0;
-                               p = ccptr;
-                               if(optim){
-                                       p = ccl;
-                                       while(p <ccptr && scomp(token,p) != 0)p++;
-                                       }
-                               if(p < ccptr)   /* found it */
-                                       yylval = p;
-                               else {
-                                       yylval = ccptr;
-                                       scopy(token,ccptr);
-                                       ccptr += slength(token) + 1;
-                                       if(ccptr >= ccl+CCLSIZE)
-                                               error("Too many large character classes");
-                                       }
-                               cclinter(x==CCL);
-                               break;
-                       case '\\':
-                               c = usescape(c=gch());
-                       default:
-                       character:
-                               if(iter){       /* second part of an iteration */
-                                       iter = FALSE;
-                                       if('0' <= c && c <= '9')
-                                               goto ieval;
-                                       }
-                               if(alpha(peek)){
-                                       i = 0;
-                                       yylval = token;
-                                       token[i++] = c;
-                                       while(alpha(peek))
-                                               token[i++] = gch();
-                                       if(peek == '?' || peek == '*' || peek == '+')
-                                               munput('c',token[--i]);
-                                       token[i] = 0;
-                                       if(i == 1){
-                                               yylval = token[0];
-                                               x = CHAR;
-                                               }
-                                       else x = STR;
-                                       }
-                               else {
-                                       yylval = c;
-                                       x = CHAR;
-                                       }
-                               }
-                       scon = FALSE;
-                       if(x == SCON)scon = TRUE;
-                       sectbegin = FALSE;
-                       return(freturn(x));
-                       }
-               }
-       /* section three */
-       ptail();
-# ifdef DEBUG
-       if(debug)
-               fprintf(fout,"\n/*this comes from section three - debug */\n");
-# endif
-       while(getl(buf) && !eof)
-               fprintf(fout,"%s\n",buf);
-       return(freturn(0));
-       }
-/* end of yylex */
-# ifdef DEBUG
-int XXXfreturn(i) int i; {
-       if(yydebug) {
-               printf("now return ");
-               if(i < NCH) allprint(i);
-               else printf("%d",i);
-               printf("   yylval = ");
-               switch(i){
-                       case STR: case CCL: case NCCL:
-                               strpt(yylval);
-                               break;
-                       case CHAR:
-                               allprint(yylval);
-                               break;
-                       default:
-                               printf("%d",yylval);
-                               break;
-                       }
-               putchar('\n');
-               }
-       return(i);
-       }
-# endif
-short yyexca[] ={
--1, 1,
-       0, -1,
-       -2, 0,
-       };
-# define YYNPROD 33
-# define YYLAST 291
-short yyact[]={
-
-  34,  45,  35,  23,  21,  43,  27,  28,   4,  34,
-  16,  32,  41,  21,  46,  27,  28,  10,  34,  16,
-  32,   8,  21,   9,  27,  28,  25,  29,  16,   6,
-   7,   3,  24,  34,  27,  28,  29,  21,  11,  27,
-  28,   2,   5,  16,   1,  29,  21,   0,  27,  28,
-   0,   0,  16,   0,   0,  29,  21,   0,  20,   0,
-  29,   0,  16,   0,   0,  21,   0,  20,   0,  29,
-   0,  16,   0,   0,  31,   0,  20,   0,   0,   0,
-  12,   0,   0,  12,   0,   0,   0,   0,  30,   0,
-   0,  20,   0,  42,  36,  37,  38,  30,   0,   0,
-   0,   0,   0,   0,   0,  39,  30,  40,   0,   0,
-  20,   0,   0,   0,   0,   0,   0,   0,   0,  20,
-   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-   0,   0,   0,   0,   0,   0,   0,   0,   0,  44,
-   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-   0,  14,  17,  18,  15,   0,  19,  33,   0,  22,
-  14,  17,  18,  15,   0,  19,  33,  26,  22,  14,
-  17,  18,  15,   0,   0,  33,   0,  22,   0,   0,
-   0,   0,   0,   0,  14,  17,  18,  15,   0,   0,
-  33,   0,  22,  14,  17,  18,  15,   0,   0,  33,
-   0,  22,  13,  14,  17,  18,  15,   7,  19,   0,
-   0,  22,  14,  17,  18,  15,   0,  19,   0,   0,
-  22 };
-short yypact[]={
-
--248,-1000,-1000,-231,-1000,  16,-257,-1000,  16,-1000,
--1000,-1000, -27,-262,-1000,-1000,-1000,-1000,-1000,  25,
-  25,  25,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,
-  25,  -8,  25, -32,-1000,-1000, -18,   6, -36,  -3,
- -18,-124,-1000,-1000,-111,-1000,-1000 };
-short yypgo[]={
-
-   0,  44,  41,  31,  38,  21,  23,  17,  74 };
-short yyr1[]={
-
-   0,   1,   2,   2,   2,   6,   6,   3,   3,   4,
-   5,   5,   7,   7,   8,   8,   8,   8,   8,   8,
-   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,
-   8,   8,   8 };
-short yyr2[]={
-
-   0,   1,   4,   3,   1,   1,   0,   3,   0,   1,
-   2,   1,   2,   2,   1,   1,   1,   1,   1,   2,
-   2,   2,   3,   2,   3,   5,   3,   4,   2,   2,
-   2,   3,   1 };
-short yychk[]={
-
--1000,  -1,  -2,  -3, 256,  -4, 260, 261,  -5,  -6,
-  -7,  -4,  -8, 256, 257, 260,  46, 258, 259, 262,
-  94,  40, 265, 260,  -6,  -7, 264,  42,  43,  63,
- 124,  -8,  47, 263,  36, 264,  -8,  -8,  -8,  -8,
-  -8,  44, 125,  41, 263, 125, 125 };
-short yydef[]={
-
-   8,  -2,   1,   0,   4,   6,   0,   9,   6,   3,
-  11,   5,   0,   0,  14,  15,  16,  17,  18,   0,
-   0,   0,  32,   7,   2,  10,  12,  19,  20,  21,
-   0,  23,   0,   0,  30,  13,  28,  29,   0,  22,
-  24,   0,  26,  31,   0,  27,  25 };
-#ifndef lint
-static char yaccpar_sccsid[] = "@(#)yaccpar    4.1     (Berkeley)      2/11/83";
-#endif
-
-#
-# define YYFLAG -1000
-# define YYERROR goto yyerrlab
-# define YYACCEPT return(0)
-# define YYABORT return(1)
-
-/*     parser for yacc output  */
-
-#ifdef YYDEBUG
-int yydebug = 0; /* 1 for debugging */
-#endif
-YYSTYPE yyv[YYMAXDEPTH]; /* where the values are stored */
-int yychar = -1; /* current input token number */
-int yynerrs = 0;  /* number of errors */
-short yyerrflag = 0;  /* error recovery flag */
-
-int yyparse() {
-
-       short yys[YYMAXDEPTH];
-       short yyj, yym;
-       register YYSTYPE *yypvt;
-       register short yystate, *yyps, yyn;
-       register YYSTYPE *yypv;
-       register short *yyxi;
-
-       yystate = 0;
-       yychar = -1;
-       yynerrs = 0;
-       yyerrflag = 0;
-       yyps= &yys[-1];
-       yypv= &yyv[-1];
-
- yystack:    /* put a state and value onto the stack */
-
-#ifdef YYDEBUG
-       if( yydebug  ) printf( "state %d, char 0%o\n", yystate, yychar );
-#endif
-               if( ++yyps> &yys[YYMAXDEPTH] ) { yyerror( "yacc stack overflow" ); return(1); }
-               *yyps = yystate;
-               ++yypv;
-               *yypv = yyval;
-
- yynewstate:
-
-       yyn = yypact[yystate];
-
-       if( yyn<= YYFLAG ) goto yydefault; /* simple state */
-
-       if( yychar<0 ) if( (yychar=yylex())<0 ) yychar=0;
-       if( (yyn += yychar)<0 || yyn >= YYLAST ) goto yydefault;
-
-       if( yychk[ yyn=yyact[ yyn ] ] == yychar ){ /* valid shift */
-               yychar = -1;
-               yyval = yylval;
-               yystate = yyn;
-               if( yyerrflag > 0 ) --yyerrflag;
-               goto yystack;
-               }
-
- yydefault:
-       /* default state action */
-
-       if( (yyn=yydef[yystate]) == -2 ) {
-               if( yychar<0 ) if( (yychar=yylex())<0 ) yychar = 0;
-               /* look through exception table */
-
-               for( yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate) ; yyxi += 2 ) ; /* VOID */
-
-               while( *(yyxi+=2) >= 0 ){
-                       if( *yyxi == yychar ) break;
-                       }
-               if( (yyn = yyxi[1]) < 0 ) return(0);   /* accept */
-               }
-
-       if( yyn == 0 ){ /* error */
-               /* error ... attempt to resume parsing */
-
-               switch( yyerrflag ){
-
-               case 0:   /* brand new error */
-
-                       yyerror( "syntax error" );
-               yyerrlab:
-                       ++yynerrs;
-
-               case 1:
-               case 2: /* incompletely recovered error ... try again */
-
-                       yyerrflag = 3;
-
-                       /* find a state where "error" is a legal shift action */
-
-                       while ( yyps >= yys ) {
-                          yyn = yypact[*yyps] + YYERRCODE;
-                          if( yyn>= 0 && yyn < YYLAST && yychk[yyact[yyn]] == YYERRCODE ){
-                             yystate = yyact[yyn];  /* simulate a shift of "error" */
-                             goto yystack;
-                             }
-                          yyn = yypact[*yyps];
-
-                          /* the current yyps has no shift onn "error", pop stack */
-
-#ifdef YYDEBUG
-                          if( yydebug ) printf( "error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1] );
-#endif
-                          --yyps;
-                          --yypv;
-                          }
-
-                       /* there is no state on the stack with an error shift ... abort */
-
-       yyabort:
-                       return(1);
-
-               case 3:  /* no shift yet; clobber input char */
-
-#ifdef YYDEBUG
-                       if( yydebug ) printf( "error recovery discards char %d\n", yychar );
-#endif
-
-                       if( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */
-                       yychar = -1;
-                       goto yynewstate;   /* try again in the same state */
-
-                       }
-
-               }
-
-       /* reduction by production yyn */
-
-#ifdef YYDEBUG
-               if( yydebug ) printf("reduce %d\n",yyn);
-#endif
-               yyps -= yyr2[yyn];
-               yypvt = yypv;
-               yypv -= yyr2[yyn];
-               yyval = yypv[1];
-               yym=yyn;
-                       /* consult goto table to find next state */
-               yyn = yyr1[yyn];
-               yyj = yypgo[yyn] + *yyps + 1;
-               if( yyj>=YYLAST || yychk[ yystate = yyact[yyj] ] != -yyn ) yystate = yyact[yypgo[yyn]];
-               switch(yym){
-                       
-case 1:
-# line 25 "parser.y"
-{      
-# ifdef DEBUG
-               if(debug) sect2dump();
-# endif
-       } break;
-case 3:
-# line 33 "parser.y"
-{
-               if(!funcflag)phead2();
-               funcflag = TRUE;
-       } break;
-case 4:
-# line 38 "parser.y"
-{
-# ifdef DEBUG
-               if(debug) {
-                       sect1dump();
-                       sect2dump();
-                       }
-# endif
-               } break;
-case 7:
-# line 49 "parser.y"
-{      scopy(yypvt[-1],dp);
-               def[dptr] = dp;
-               dp += slength(yypvt[-1]) + 1;
-               scopy(yypvt[-0],dp);
-               subs[dptr++] = dp;
-               if(dptr >= DEFSIZE)
-                       error("Too many definitions");
-               dp += slength(yypvt[-0]) + 1;
-               if(dp >= dchar+DEFCHAR)
-                       error("Definitions too long");
-               subs[dptr]=def[dptr]=0; /* for lookup - require ending null */
-       } break;
-case 9:
-# line 64 "parser.y"
-{
-# ifdef DEBUG
-               if(sect == DEFSECTION && debug) sect1dump();
-# endif
-               sect++;
-               } break;
-case 10:
-# line 72 "parser.y"
-{      yyval = mn2(RNEWE,yypvt[-1],yypvt[-0]);
-               } break;
-case 11:
-# line 75 "parser.y"
-{      yyval = yypvt[-0];} break;
-case 12:
-# line 78 "parser.y"
-{
-               if(divflg == TRUE)
-                       i = mn1(S1FINAL,casecount);
-               else i = mn1(FINAL,casecount);
-               yyval = mn2(RCAT,yypvt[-1],i);
-               divflg = FALSE;
-               casecount++;
-               } break;
-case 13:
-# line 87 "parser.y"
-{
-# ifdef DEBUG
-               if(debug) sect2dump();
-# endif
-               } break;
-case 14:
-# line 93 "parser.y"
-{      yyval = mn0(yypvt[-0]); } break;
-case 15:
-# line 95 "parser.y"
-{
-               p = yypvt[-0];
-               i = mn0(*p++);
-               while(*p)
-                       i = mn2(RSTR,i,*p++);
-               yyval = i;
-               } break;
-case 16:
-# line 103 "parser.y"
-{      symbol['\n'] = 0;
-               if(psave == FALSE){
-                       p = ccptr;
-                       psave = ccptr;
-                       for(i=1;i<'\n';i++){
-                               symbol[i] = 1;
-                               *ccptr++ = i;
-                               }
-                       for(i='\n'+1;i<NCH;i++){
-                               symbol[i] = 1;
-                               *ccptr++ = i;
-                               }
-                       *ccptr++ = 0;
-                       if(ccptr > ccl+CCLSIZE)
-                               error("Too many large character classes");
-                       }
-               else
-                       p = psave;
-               yyval = mn1(RCCL,p);
-               cclinter(1);
-               } break;
-case 17:
-# line 125 "parser.y"
-{      yyval = mn1(RCCL,yypvt[-0]); } break;
-case 18:
-# line 127 "parser.y"
-{      yyval = mn1(RNCCL,yypvt[-0]); } break;
-case 19:
-# line 129 "parser.y"
-{      yyval = mn1(STAR,yypvt[-1]); } break;
-case 20:
-# line 131 "parser.y"
-{      yyval = mn1(PLUS,yypvt[-1]); } break;
-case 21:
-# line 133 "parser.y"
-{      yyval = mn1(QUEST,yypvt[-1]); } break;
-case 22:
-# line 135 "parser.y"
-{      yyval = mn2(BAR,yypvt[-2],yypvt[-0]); } break;
-case 23:
-# line 137 "parser.y"
-{      yyval = mn2(RCAT,yypvt[-1],yypvt[-0]); } break;
-case 24:
-# line 139 "parser.y"
-{      if(!divflg){
-                       j = mn1(S2FINAL,-casecount);
-                       i = mn2(RCAT,yypvt[-2],j);
-                       yyval = mn2(DIV,i,yypvt[-0]);
-                       }
-               else {
-                       yyval = mn2(RCAT,yypvt[-2],yypvt[-0]);
-                       warning("Extra slash removed");
-                       }
-               divflg = TRUE;
-               } break;
-case 25:
-# line 151 "parser.y"
-{      if(yypvt[-3] > yypvt[-1]){
-                       i = yypvt[-3];
-                       yypvt[-3] = yypvt[-1];
-                       yypvt[-1] = i;
-                       }
-               if(yypvt[-1] <= 0)
-                       warning("Iteration range must be positive");
-               else {
-                       j = yypvt[-4];
-                       for(k = 2; k<=yypvt[-3];k++)
-                               j = mn2(RCAT,j,dupl(yypvt[-4]));
-                       for(i = yypvt[-3]+1; i<=yypvt[-1]; i++){
-                               g = dupl(yypvt[-4]);
-                               for(k=2;k<=i;k++)
-                                       g = mn2(RCAT,g,dupl(yypvt[-4]));
-                               j = mn2(BAR,j,g);
-                               }
-                       yyval = j;
-                       }
-       } break;
-case 26:
-# line 172 "parser.y"
-{
-               if(yypvt[-1] < 0)warning("Can't have negative iteration");
-               else if(yypvt[-1] == 0) yyval = mn0(RNULLS);
-               else {
-                       j = yypvt[-2];
-                       for(k=2;k<=yypvt[-1];k++)
-                               j = mn2(RCAT,j,dupl(yypvt[-2]));
-                       yyval = j;
-                       }
-               } break;
-case 27:
-# line 183 "parser.y"
-{
-                               /* from n to infinity */
-               if(yypvt[-2] < 0)warning("Can't have negative iteration");
-               else if(yypvt[-2] == 0) yyval = mn1(STAR,yypvt[-3]);
-               else if(yypvt[-2] == 1)yyval = mn1(PLUS,yypvt[-3]);
-               else {          /* >= 2 iterations minimum */
-                       j = yypvt[-3];
-                       for(k=2;k<yypvt[-2];k++)
-                               j = mn2(RCAT,j,dupl(yypvt[-3]));
-                       k = mn1(PLUS,dupl(yypvt[-3]));
-                       yyval = mn2(RCAT,j,k);
-                       }
-               } break;
-case 28:
-# line 197 "parser.y"
-{      yyval = mn2(RSCON,yypvt[-0],yypvt[-1]); } break;
-case 29:
-# line 199 "parser.y"
-{      yyval = mn1(CARAT,yypvt[-0]); } break;
-case 30:
-# line 201 "parser.y"
-{      i = mn0('\n');
-               if(!divflg){
-                       j = mn1(S2FINAL,-casecount);
-                       k = mn2(RCAT,yypvt[-1],j);
-                       yyval = mn2(DIV,k,i);
-                       }
-               else yyval = mn2(RCAT,yypvt[-1],i);
-               divflg = TRUE;
-               } break;
-case 31:
-# line 211 "parser.y"
-{      yyval = yypvt[-1]; } break;
-case 32:
-# line 213 "parser.y"
-{      yyval = mn0(RNULLS); } break;
-               }
-               goto yystack;  /* stack new state and value */
-
-       }
diff --git a/usr.bin/x_install.sh b/usr.bin/x_install.sh
new file mode 100644 (file)
index 0000000..e297515
--- /dev/null
@@ -0,0 +1,80 @@
+#! /bin/sh
+ROOT="`basename $0`/../.."
+#
+#      @(#)install.sh  4.8     (Berkeley)      3/6/86
+#
+cmd=""
+stripbefore=""
+stripafter=""
+chmod="$ROOT/bin/chmod -f 755"
+chown="$ROOT/etc/chown -f root"
+chgrp="$ROOT/bin/chgrp -f staff"
+while true ; do
+       case $1 in
+               -s )    if [ $cmd ]
+                       then    stripafter="$ROOT/bin/strip"
+                       else    stripbefore="$ROOT/bin/strip"
+                       fi
+                       shift
+                       ;;
+               -c )    if [ $cmd ]
+                       then    echo "install: multiple specifications of -c"
+                               exit 1
+                       fi
+                       cmd="$ROOT/bin/cp"
+                       stripafter=$stripbefore
+                       stripbefore=""
+                       shift
+                       ;;
+               -m )    chmod="$ROOT/bin/chmod -f $2"
+                       shift
+                       shift
+                       ;;
+               -o )    chown="$ROOT/etc/chown -f $2"
+                       shift
+                       shift
+                       ;;
+               -g )    chgrp="$ROOT/bin/chgrp -f $2"
+                       shift
+                       shift
+                       ;;
+               * )     break
+                       ;;
+       esac
+done
+if [ $cmd ]
+then true
+else cmd="$ROOT/bin/mv"
+fi
+
+if [ ! ${2-""} ]
+then   echo "install: no destination specified"
+       exit 1
+fi
+if [ ${3-""} ]
+then   echo "install: too many files specified -> $*"
+       exit 1
+fi
+if [ $1 = $2 -o $2 = . ]
+then   echo "install: can't move $1 onto itself"
+       exit 1
+fi
+if [ '!' -f $1 ]
+then   echo "install: can't open $1"
+       exit 1
+fi
+if [ -d $2 ]
+then   file=$2/`basename $1`
+else   file=$2
+fi
+/bin/rm -f $file
+if [ $stripbefore ]
+then   $stripbefore $1
+fi
+$cmd $1 $file
+if [ $stripafter ]
+then   $stripafter $file
+fi
+$chown $file
+$chgrp $file
+$chmod $file
diff --git a/usr.bin/x_lorder.sh b/usr.bin/x_lorder.sh
new file mode 120000 (symlink)
index 0000000..9b655d7
--- /dev/null
@@ -0,0 +1 @@
+lorder.sh
\ No newline at end of file
diff --git a/usr.bin/x_nohup.sh b/usr.bin/x_nohup.sh
new file mode 120000 (symlink)
index 0000000..3434e16
--- /dev/null
@@ -0,0 +1 @@
+nohup.sh
\ No newline at end of file
index 7f86b18..db1d207 100644 (file)
@@ -14,7 +14,8 @@ yacc: y1.o y2.o y3.o y4.o
 y1.o y2.o y3.o y4.o: dextern.h files.h
 install:
        install -s yacc $(DESTDIR)/usr/bin
-       install -c -m 644 yaccpar $(DESTDIR)/usr/lib
+#      install -c -m 644 ${X_}yaccpar $(DESTDIR)/usr/lib
+       install -c -m 644 ${X_}yaccpar $(DESTDIR)/usr/lib/yaccpar
 clean :
        -rm -f *.o yacc
 
diff --git a/usr.bin/yacc/x_yaccpar b/usr.bin/yacc/x_yaccpar
new file mode 100644 (file)
index 0000000..0a2b8e0
--- /dev/null
@@ -0,0 +1,157 @@
+#if defined(DOSCCS) && !defined(lint)
+static char yaccpar_sccsid[] = "@(#)yaccpar    4.1     (Berkeley)      2/11/83";
+#endif
+
+#ifdef __GNUC__
+#pragma nox_GCC nox_diagnostic nox_ignored "-Wunused-label"
+#endif
+
+#
+# define YYFLAG -1000
+# define YYERROR goto yyerrlab
+# define YYACCEPT return(0)
+# define YYABORT return(1)
+
+/*     parser for yacc output  */
+
+#ifdef YYDEBUG
+int yydebug = 0; /* 1 for debugging */
+#endif
+YYSTYPE yyv[YYMAXDEPTH]; /* where the values are stored */
+int yychar = -1; /* current input token number */
+int yynerrs = 0;  /* number of errors */
+short yyerrflag = 0;  /* error recovery flag */
+
+int yyparse() {
+
+       short yys[YYMAXDEPTH];
+       short yyj, yym;
+       register YYSTYPE *yypvt;
+       register short yystate, *yyps, yyn;
+       register YYSTYPE *yypv;
+       register short *yyxi;
+
+       yystate = 0;
+       yychar = -1;
+       yynerrs = 0;
+       yyerrflag = 0;
+       yyps= &yys[-1];
+       yypv= &yyv[-1];
+
+ yystack:    /* put a state and value onto the stack */
+
+#ifdef YYDEBUG
+       if( yydebug  ) printf( "state %d, char 0%o\n", yystate, yychar );
+#endif
+               if( ++yyps> &yys[YYMAXDEPTH] ) { yyerror( "yacc stack overflow" ); return(1); }
+               *yyps = yystate;
+               ++yypv;
+               *yypv = yyval;
+
+ yynewstate:
+
+       yyn = yypact[yystate];
+
+       if( yyn<= YYFLAG ) goto yydefault; /* simple state */
+
+       if( yychar<0 ) if( (yychar=yylex())<0 ) yychar=0;
+       if( (yyn += yychar)<0 || yyn >= YYLAST ) goto yydefault;
+
+       if( yychk[ yyn=yyact[ yyn ] ] == yychar ){ /* valid shift */
+               yychar = -1;
+               yyval = yylval;
+               yystate = yyn;
+               if( yyerrflag > 0 ) --yyerrflag;
+               goto yystack;
+               }
+
+ yydefault:
+       /* default state action */
+
+       if( (yyn=yydef[yystate]) == -2 ) {
+               if( yychar<0 ) if( (yychar=yylex())<0 ) yychar = 0;
+               /* look through exception table */
+
+               for( yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate) ; yyxi += 2 ) ; /* VOID */
+
+               while( *(yyxi+=2) >= 0 ){
+                       if( *yyxi == yychar ) break;
+                       }
+               if( (yyn = yyxi[1]) < 0 ) return(0);   /* accept */
+               }
+
+       if( yyn == 0 ){ /* error */
+               /* error ... attempt to resume parsing */
+
+               switch( yyerrflag ){
+
+               case 0:   /* brand new error */
+
+                       yyerror( "syntax error" );
+               yyerrlab:
+                       ++yynerrs;
+
+               case 1:
+               case 2: /* incompletely recovered error ... try again */
+
+                       yyerrflag = 3;
+
+                       /* find a state where "error" is a legal shift action */
+
+                       while ( yyps >= yys ) {
+                          yyn = yypact[*yyps] + YYERRCODE;
+                          if( yyn>= 0 && yyn < YYLAST && yychk[yyact[yyn]] == YYERRCODE ){
+                             yystate = yyact[yyn];  /* simulate a shift of "error" */
+                             goto yystack;
+                             }
+                          yyn = yypact[*yyps];
+
+                          /* the current yyps has no shift onn "error", pop stack */
+
+#ifdef YYDEBUG
+                          if( yydebug ) printf( "error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1] );
+#endif
+                          --yyps;
+                          --yypv;
+                          }
+
+                       /* there is no state on the stack with an error shift ... abort */
+
+       yyabort:
+                       return(1);
+
+
+               case 3:  /* no shift yet; clobber input char */
+
+#ifdef YYDEBUG
+                       if( yydebug ) printf( "error recovery discards char %d\n", yychar );
+#endif
+
+                       if( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */
+                       yychar = -1;
+                       goto yynewstate;   /* try again in the same state */
+
+                       }
+
+               }
+
+       /* reduction by production yyn */
+
+#ifdef YYDEBUG
+               if( yydebug ) printf("reduce %d\n",yyn);
+#endif
+               yyps -= yyr2[yyn];
+               yypvt = yypv;
+               yypv -= yyr2[yyn];
+               yyval = yypv[1];
+               yym=yyn;
+                       /* consult goto table to find next state */
+               yyn = yyr1[yyn];
+               yyj = yypgo[yyn] + *yyps + 1;
+               if( yyj>=YYLAST || yychk[ yystate = yyact[yyj] ] != -yyn ) yystate = yyact[yypgo[yyn]];
+               switch(yym){
+                       $A
+               }
+               goto yystack;  /* stack new state and value */
+
+       }
index a3c3e6a..e58c57d 100644 (file)
@@ -1,6 +1,6 @@
-#ifndef lint
+#if defined(DOSCCS) && !defined(lint)
 static char yaccpar_sccsid[] = "@(#)yaccpar    4.1     (Berkeley)      2/11/83";
-#endif not lint
+#endif
 
 #
 # define YYFLAG -1000
@@ -18,7 +18,7 @@ int yychar = -1; /* current input token number */
 int yynerrs = 0;  /* number of errors */
 short yyerrflag = 0;  /* error recovery flag */
 
-yyparse() {
+int yyparse() {
 
        short yys[YYMAXDEPTH];
        short yyj, yym;
index bf950ae..3f46cf2 100755 (executable)
@@ -22,5 +22,5 @@ typedef uint32_t x_unsigned_long;
 
 #endif
 EOF
-  "`dirname "$0"`/xifyfilt" <$1 2>$3 |sed -e 's/\(extern\|register\|static\) x_int\([   ]\+\(int\|long\|short\|unsigned\|x_Bignum\|x_Iptr\|x_bytetoktype\|x_bool\|x_caddr_t\|x_chptr\|x_datum\|x_inttoktype\|x_lgtype\|x_off_t\|x_time_t\|x_u_char\|x_u_int\|x_u_short\|x_u_long\)\)/\1\2/g; s/va_arg(x_argp, x_\(unsigned_\)\?\(short\|int\|long\))/_va_arg_\1\2(x_argp)/g'
+  "`dirname "$0"`/xifyfilt" <$1 2>$3 |sed -e 's/\(extern\|register\|static\) x_int\([   ]\+\(int\|long\|short\|unsigned\|x_Bignum\|x_Iptr\|x_YYSTYPE\|x_bytetoktype\|x_bool\|x_caddr_t\|x_chptr\|x_datum\|x_inttoktype\|x_lgtype\|x_off_t\|x_time_t\|x_u_char\|x_u_int\|x_u_short\|x_u_long\)\)/\1\2/g; s/va_arg(x_argp, x_\(unsigned_\)\?\(short\|int\|long\))/_va_arg_\1\2(x_argp)/g'
 ) >$2