From 0a80cfdaca9588b24d0681caaa7e73524ce81761 Mon Sep 17 00:00:00 2001 From: millert Date: Mon, 7 Apr 1997 15:59:53 +0000 Subject: [PATCH] Back out last changes for now. They cause problems. --- usr.bin/awk/awk.h | 8 ++++---- usr.bin/awk/awkgram.y | 2 +- usr.bin/awk/b.c | 35 ++++++++++++++++---------------- usr.bin/awk/lexyy.c | 4 ++-- usr.bin/awk/run.c | 46 +++++++++++++++++++++---------------------- 5 files changed, 47 insertions(+), 48 deletions(-) diff --git a/usr.bin/awk/awk.h b/usr.bin/awk/awk.h index 23d1823c4ec..213e43302c8 100644 --- a/usr.bin/awk/awk.h +++ b/usr.bin/awk/awk.h @@ -193,7 +193,7 @@ extern Node *nullnode; #define NFIELD 4 -extern long pairstack[], paircnt; +extern int pairstack[], paircnt; #define notlegal(n) (n <= FIRSTTOKEN || n >= LASTTOKEN || proctab[n-FIRSTTOKEN] == nullproc) #define isvalue(n) ((n)->ntype == NVALUE) @@ -221,13 +221,13 @@ extern long pairstack[], paircnt; #define NSTATES 32 typedef struct rrow { - long ltype; + int ltype; union { int i; Node *np; char *up; } lval; /* because Al stores a pointer in it! */ - long *lfollow; + int *lfollow; } rrow; typedef struct fa { @@ -235,7 +235,7 @@ typedef struct fa { int anchor; int use; uschar gototab[NSTATES][NCHARS]; - long *posns[NSTATES]; + int *posns[NSTATES]; uschar out[NSTATES]; int initstat; int curstat; diff --git a/usr.bin/awk/awkgram.y b/usr.bin/awk/awkgram.y index 60ad49891c1..e1cb9f6e6fe 100644 --- a/usr.bin/awk/awkgram.y +++ b/usr.bin/awk/awkgram.y @@ -41,7 +41,7 @@ Node *arglist = 0; /* list of args for current function */ %union { Node *p; Cell *cp; - long i; + int i; char *s; } diff --git a/usr.bin/awk/b.c b/usr.bin/awk/b.c index 3ec883ee171..9952d94ed35 100644 --- a/usr.bin/awk/b.c +++ b/usr.bin/awk/b.c @@ -59,13 +59,13 @@ int *tmpset; int maxsetvec = 0; int rtok; /* next token in current re */ -long rlxval; +int rlxval; char *rlxstr; char *prestr; /* current position in current re */ char *lastre; /* origin of last re */ -static long setcnt; -static long poscnt; +static int setcnt; +static int poscnt; char *patbeg; int patlen; @@ -134,9 +134,9 @@ fa *mkdfa(char *s, int anchor) /* does the real work of making a dfa */ f->accept = poscnt-1; /* penter has computed number of positions in re */ cfoll(f, p1); /* set up follow sets */ freetr(p1); - if ((f->posns[0] = (long *) calloc(1, *(f->re[0].lfollow)*sizeof(int))) == NULL) + if ((f->posns[0] = (int *) calloc(1, *(f->re[0].lfollow)*sizeof(int))) == NULL) overflo("out of space in makedfa"); - if ((f->posns[1] = (long *) calloc(1, sizeof(int))) == NULL) + if ((f->posns[1] = (int *) calloc(1, sizeof(int))) == NULL) overflo("out of space in makedfa"); *f->posns[1] = 0; f->initstat = makeinit(f, anchor); @@ -154,7 +154,7 @@ int makeinit(fa *f, int anchor) f->reset = 0; k = *(f->re[0].lfollow); xfree(f->posns[2]); - if ((f->posns[2] = (long *) calloc(1, (k+1)*sizeof(int))) == NULL) + if ((f->posns[2] = (int *) calloc(1, (k+1)*sizeof(int))) == NULL) overflo("out of space in makeinit"); for (i=0; i <= k; i++) { (f->posns[2])[i] = (f->re[0].lfollow)[i]; @@ -329,12 +329,12 @@ void overflo(char *s) void cfoll(fa *f, Node *v) /* enter follow set of each leaf of vertex v into lfollow[leaf] */ { int i; - long *p; + int *p; switch (type(v)) { LEAF - f->re[(long) left(v)].ltype = type(v); - f->re[(long) left(v)].lval.np = right(v); + f->re[(int) left(v)].ltype = type(v); + f->re[(int) left(v)].lval.np = right(v); while (f->accept >= maxsetvec) { /* guessing here! */ maxsetvec *= 4; setvec = (int *) realloc(setvec, maxsetvec * sizeof(int)); @@ -347,9 +347,9 @@ void cfoll(fa *f, Node *v) /* enter follow set of each leaf of vertex v into lfo setvec[i] = 0; setcnt = 0; follow(v); /* computes setvec and setcnt */ - if ((p = (long *) calloc(1, (setcnt+1)*sizeof(int))) == NULL) + if ((p = (int *) calloc(1, (setcnt+1)*sizeof(int))) == NULL) overflo("out of space building follow set"); - f->re[(long) left(v)].lfollow = p; + f->re[(int) left(v)].lfollow = p; *p = setcnt; for (i = f->accept; i >= 0; i--) if (setvec[i] == 1) @@ -371,12 +371,11 @@ void cfoll(fa *f, Node *v) /* enter follow set of each leaf of vertex v into lfo int first(Node *p) /* collects initially active leaves of p into setvec */ /* returns 1 if p matches empty string */ { - int b; - long lp; + int b, lp; switch (type(p)) { LEAF - lp = (long) left(p); /* look for high-water mark of subscripts */ + lp = (int) left(p); /* look for high-water mark of subscripts */ while (setcnt >= maxsetvec || lp >= maxsetvec) { /* guessing here! */ maxsetvec *= 4; setvec = (int *) realloc(setvec, maxsetvec * sizeof(int)); @@ -508,7 +507,7 @@ int pmatch(fa *f, char *p0) /* longest match, for sub */ for (i = 2; i <= f->curstat; i++) xfree(f->posns[i]); k = *f->posns[0]; - if ((f->posns[2] = (long *) calloc(1, (k+1)*sizeof(int))) == NULL) + if ((f->posns[2] = (int *) calloc(1, (k+1)*sizeof(int))) == NULL) overflo("out of space in pmatch"); for (i = 0; i <= k; i++) (f->posns[2])[i] = (f->posns[0])[i]; @@ -558,7 +557,7 @@ int nematch(fa *f, char *p0) /* non-empty match, for sub */ for (i = 2; i <= f->curstat; i++) xfree(f->posns[i]); k = *f->posns[0]; - if ((f->posns[2] = (long *) calloc(1, (k+1)*sizeof(int))) == NULL) + if ((f->posns[2] = (int *) calloc(1, (k+1)*sizeof(int))) == NULL) overflo("out of state space"); for (i = 0; i <= k; i++) (f->posns[2])[i] = (f->posns[0])[i]; @@ -737,7 +736,7 @@ int relex(void) /* lexical analyzer for reparse */ int cgoto(fa *f, int s, int c) { int i, j, k; - long *p, *q; + int *p, *q; if (c < 0) ERROR "can't happen: neg char %d in cgoto", c FATAL; @@ -810,7 +809,7 @@ int cgoto(fa *f, int s, int c) for (i = 0; i < NCHARS; i++) f->gototab[f->curstat][i] = 0; xfree(f->posns[f->curstat]); - if ((p = (long *) calloc(1, (setcnt+1)*sizeof(int))) == NULL) + if ((p = (int *) calloc(1, (setcnt+1)*sizeof(int))) == NULL) overflo("out of space in cgoto"); f->posns[f->curstat] = p; diff --git a/usr.bin/awk/lexyy.c b/usr.bin/awk/lexyy.c index a2e74470d0d..e58761ae0f9 100644 --- a/usr.bin/awk/lexyy.c +++ b/usr.bin/awk/lexyy.c @@ -1902,7 +1902,7 @@ yylook(void){ } # endif yyr = yyt; - if ( (long)yyt > (long)yycrank){ + if ( (int)yyt > (int)yycrank){ yyt = yyr + yych; if (yyt <= yytop && yyt->verify+yysvec == yystate){ if(yyt->advance+yysvec == YYLERR) /* error transitions */ @@ -1912,7 +1912,7 @@ yylook(void){ } } # ifdef YYOPTIM - else if((long)yyt < (long)yycrank) { /* r < yycrank */ + else if((int)yyt < (int)yycrank) { /* r < yycrank */ yyt = yyr = yycrank+(yycrank-yyt); # ifdef LEXDEBUG if(debug)fprintf(yyout,"compressed state\n"); diff --git a/usr.bin/awk/run.c b/usr.bin/awk/run.c index 04ee33e603e..0cc0dc192bc 100644 --- a/usr.bin/awk/run.c +++ b/usr.bin/awk/run.c @@ -1,4 +1,4 @@ -/* $OpenBSD: run.c,v 1.11 1997/04/06 06:31:51 millert Exp $ */ +/* $OpenBSD: run.c,v 1.12 1997/04/07 15:59:56 millert Exp $ */ /**************************************************************** Copyright (C) AT&T and Lucent Technologies 1996 All Rights Reserved @@ -66,8 +66,8 @@ void tempfree(Cell *p) { jmp_buf env; #define PA2NUM 29 /* max number of pat,pat patterns allowed */ -long paircnt; /* number of them in use */ -long pairstack[PA2NUM]; /* state of each pat,pat */ +int paircnt; /* number of them in use */ +int pairstack[PA2NUM]; /* state of each pat,pat */ Node *winner = NULL; /* root of parse tree */ Cell *tmps; /* free temporary cells for execution */ @@ -201,7 +201,7 @@ Cell *call(Node **a, int n) /* function call. very kludgy and fragile */ } for (ncall = 0, x = a[1]; x != NULL; x = x->nnext) /* args in call */ ncall++; - ndef = (long) fcn->fval; /* args in defn */ + ndef = (int) fcn->fval; /* args in defn */ dprintf( ("calling %s, %d args (%d in defn), fp=%d\n", s, ncall, ndef, fp-frame) ); if (ncall > ndef) ERROR "function %s called with %d args, uses only %d", @@ -290,7 +290,7 @@ Cell *copycell(Cell *x) /* make a copy of a cell in a temp */ Cell *arg(Node **a, int n) /* nth argument of a function */ { - n = (long) a[0]; /* argument number, counting from 0 */ + n = (int) a[0]; /* argument number, counting from 0 */ dprintf( ("arg(%d), fp->nargs=%d\n", n, fp->nargs) ); if (n+1 > fp->nargs) ERROR "argument #%d of function %s was not supplied", @@ -352,9 +352,9 @@ Cell *getline(Node **a, int n) /* get next line from specific input */ r = gettemp(); if (a[1] != NULL) { /* getline < file */ x = execute(a[2]); /* filename */ - if ((long) a[1] == '|') /* input pipe */ + if ((int) a[1] == '|') /* input pipe */ a[1] = (Node *) LE; /* arbitrary flag */ - fp = openfile((long) a[1], getsval(x)); + fp = openfile((int) a[1], getsval(x)); tempfree(x); if (fp == NULL) n = -1; @@ -750,7 +750,7 @@ int format(char *buf, int bufsize, char *s, Node *a) if (*s == '*') { x = execute(a); a = a->nnext; - sprintf((char *)t-1, "%ld", (long) getfval(x)); + sprintf((char *)t-1, "%d", (int) getfval(x)); t = fmt + strlen(fmt); tempfree(x); } @@ -794,7 +794,7 @@ int format(char *buf, int bufsize, char *s, Node *a) break; case 1: sprintf((char *)p, (char *)fmt, getfval(x)); break; case 2: sprintf((char *)p, (char *)fmt, (long) getfval(x)); break; - case 3: sprintf((char *)p, (char *)fmt, (long) getfval(x)); break; + case 3: sprintf((char *)p, (char *)fmt, (int) getfval(x)); break; case 4: t = getsval(x); n = strlen(t); @@ -806,7 +806,7 @@ int format(char *buf, int bufsize, char *s, Node *a) case 5: isnum(x) ? (getfval(x) ? - sprintf((char *)p, (char *)fmt, (long) getfval(x)) + sprintf((char *)p, (char *)fmt, (int) getfval(x)) : (*p++ = '\0')) : sprintf((char *)p, (char *)fmt, getsval(x)[0]); break; @@ -818,7 +818,7 @@ int format(char *buf, int bufsize, char *s, Node *a) *p = '\0'; for ( ; a; a = a->nnext) /* evaluate any remaining args */ execute(a); - return ((long)(p - buf)); + return ((int)(p - buf)); } Cell *awksprintf(Node **a, int n) /* sprintf(a[0]) */ @@ -857,7 +857,7 @@ Cell *awkprintf(Node **a, int n) /* printf */ if (ferror(stdout)) ERROR "write error on stdout" FATAL; } else { - fp = redirect((long)a[1], a[2]); + fp = redirect((int)a[1], a[2]); fwrite(buf, len, 1, fp); fflush(fp); if (ferror(fp)) @@ -907,7 +907,7 @@ Cell *arith(Node **a, int n) /* a[0] + a[1], etc. also -a[0] */ break; case POWER: if (j >= 0 && modf(j, &v) == 0.0) /* pos integer exponent */ - i = ipow(i, (long) j); + i = ipow(i, (int) j); else i = errcheck(pow(i, j), "pow"); break; @@ -1001,7 +1001,7 @@ Cell *assign(Node **a, int n) /* a[0] = a[1], a[0] += a[1], etc. */ break; case POWEQ: if (yf >= 0 && modf(yf, &v) == 0.0) /* pos integer exponent */ - xf = ipow(xf, (long) yf); + xf = ipow(xf, (int) yf); else xf = errcheck(pow(xf, yf), "pow"); break; @@ -1061,7 +1061,7 @@ Cell *dopa2(Node **a, int n) /* a[0], a[1] { a[2] } */ Cell *x; int pair; - pair = (long) a[3]; + pair = (int) a[3]; if (pairstack[pair] == 0) { x = execute(a[0]); if (istrue(x)) @@ -1091,10 +1091,10 @@ Cell *split(Node **a, int nnn) /* split(a[0], a[1], a[2]); a[3] is type */ s = getsval(y); if (a[2] == 0) /* fs string */ fs = *FS; - else if ((long) a[3] == STRING) { /* split(str,arr,"string") */ + else if ((int) a[3] == STRING) { /* split(str,arr,"string") */ x = execute(a[2]); fs = getsval(x); - } else if ((long) a[3] == REGEXPR) + } else if ((int) a[3] == REGEXPR) fs = (char*) "(regexpr)"; /* split(str,arr,/regexpr/) */ else ERROR "illegal type of split()" FATAL; @@ -1107,9 +1107,9 @@ Cell *split(Node **a, int nnn) /* split(a[0], a[1], a[2]); a[3] is type */ ap->sval = (char *) makesymtab(NSYMTAB); n = 0; - if ((*s != '\0' && strlen(fs) > 1) || (long) a[3] == REGEXPR) { /* reg expr */ + if ((*s != '\0' && strlen(fs) > 1) || (int) a[3] == REGEXPR) { /* reg expr */ fa *pfa; - if ((long) a[3] == REGEXPR) { /* it's ready already */ + if ((int) a[3] == REGEXPR) { /* it's ready already */ pfa = (fa *) a[2]; } else { pfa = makedfa(fs, 1); @@ -1199,7 +1199,7 @@ Cell *split(Node **a, int nnn) /* split(a[0], a[1], a[2]); a[3] is type */ } tempfree(ap); tempfree(y); - if (a[2] != 0 && (long) a[3] == STRING) + if (a[2] != 0 && (int) a[3] == STRING) tempfree(x); x = gettemp(); x->tval = NUM; @@ -1395,7 +1395,7 @@ Cell *bltin(Node **a, int n) /* builtin functions. a[0] is type, a[1] is arg lis Node *nextarg; FILE *fp; - t = (long) a[0]; + t = (int) a[0]; x = execute(a[1]); nextarg = a[1]->nnext; switch (t) { @@ -1437,7 +1437,7 @@ Cell *bltin(Node **a, int n) /* builtin functions. a[0] is type, a[1] is arg lis u = time((time_t *)0); else u = getfval(x); - srand((long) u); u = (long) u; + srand((int) u); u = (int) u; break; case FTOUPPER: case FTOLOWER: @@ -1485,7 +1485,7 @@ Cell *printstat(Node **a, int n) /* print a[0] */ if (a[1] == 0) /* a[1] is redirection operator, a[2] is file */ fp = stdout; else - fp = redirect((long)a[1], a[2]); + fp = redirect((int)a[1], a[2]); for (x = a[0]; x != NULL; x = x->nnext) { y = execute(x); fputs((char *)getsval(y), fp); -- 2.20.1