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;
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);
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];
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));
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)
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));
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];
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];
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;
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;
-/* $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
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 */
}
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",
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",
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;
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);
}
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);
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;
*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]) */
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))
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;
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;
Cell *x;
int pair;
- pair = (long) a[3];
+ pair = (int) a[3];
if (pairstack[pair] == 0) {
x = execute(a[0]);
if (istrue(x))
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;
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);
}
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;
Node *nextarg;
FILE *fp;
- t = (long) a[0];
+ t = (int) a[0];
x = execute(a[1]);
nextarg = a[1]->nnext;
switch (t) {
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:
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);