version 1.5, 1999/04/20 17:31:31 |
version 1.6, 1999/12/08 23:09:46 |
|
|
ap = (Array *) malloc(sizeof(Array)); |
ap = (Array *) malloc(sizeof(Array)); |
tp = (Cell **) calloc(n, sizeof(Cell *)); |
tp = (Cell **) calloc(n, sizeof(Cell *)); |
if (ap == NULL || tp == NULL) |
if (ap == NULL || tp == NULL) |
ERROR "out of space in makesymtab" FATAL; |
FATAL("out of space in makesymtab"); |
ap->nelem = 0; |
ap->nelem = 0; |
ap->size = n; |
ap->size = n; |
ap->tab = tp; |
ap->tab = tp; |
|
|
} |
} |
p = (Cell *) malloc(sizeof(Cell)); |
p = (Cell *) malloc(sizeof(Cell)); |
if (p == NULL) |
if (p == NULL) |
ERROR "out of space for symbol table at %s", n FATAL; |
FATAL("out of space for symbol table at %s", n); |
p->nval = tostring(n); |
p->nval = tostring(n); |
p->sval = s ? tostring(s) : tostring(""); |
p->sval = s ? tostring(s) : tostring(""); |
p->fval = f; |
p->fval = f; |
|
|
void funnyvar(Cell *vp, char *rw) |
void funnyvar(Cell *vp, char *rw) |
{ |
{ |
if (isarr(vp)) |
if (isarr(vp)) |
ERROR "can't %s %s; it's an array name.", rw, vp->nval FATAL; |
FATAL("can't %s %s; it's an array name.", rw, vp->nval); |
if (vp->tval & FCN) |
if (vp->tval & FCN) |
ERROR "can't %s %s; it's a function.", rw, vp->nval FATAL; |
FATAL("can't %s %s; it's a function.", rw, vp->nval); |
ERROR "funny variable %p: n=%s s=\"%s\" f=%g t=%o", |
WARNING("funny variable %p: n=%s s=\"%s\" f=%g t=%o", |
vp, vp->nval, vp->sval, vp->fval, vp->tval WARNING; |
vp, vp->nval, vp->sval, vp->fval, vp->tval); |
} |
} |
|
|
char *setsval(Cell *vp, char *s) /* set string val of a Cell */ |
char *setsval(Cell *vp, char *s) /* set string val of a Cell */ |
|
|
|
|
p = (char *) malloc(strlen(s)+1); |
p = (char *) malloc(strlen(s)+1); |
if (p == NULL) |
if (p == NULL) |
ERROR "out of space in tostring on %s", s FATAL; |
FATAL("out of space in tostring on %s", s); |
strcpy(p, s); |
strcpy(p, s); |
return(p); |
return(p); |
} |
} |
|
|
char *qstring(char *s, int delim) /* collect string up to next delim */ |
char *qstring(char *s, int delim) /* collect string up to next delim */ |
{ |
{ |
|
char *os = s; |
int c, n; |
int c, n; |
char *buf = 0, *bp; |
char *buf, *bp; |
|
|
if ((buf = (char *) malloc(strlen(s)+3)) == NULL) |
if ((buf = (char *) malloc(strlen(s)+3)) == NULL) |
ERROR "out of space in qstring(%s)", s); |
FATAL( "out of space in qstring(%s)", s); |
for (bp = buf; (c = *s) != delim; s++) { |
for (bp = buf; (c = *s) != delim; s++) { |
if (c == '\n') |
if (c == '\n') |
ERROR "newline in string %.10s...", buf SYNTAX; |
SYNTAX( "newline in string %.20s...", os ); |
else if (c != '\\') |
else if (c != '\\') |
*bp++ = c; |
*bp++ = c; |
else { /* \something */ |
else { /* \something */ |
switch (c = *++s) { |
c = *++s; |
|
if (c == 0) { /* \ at end */ |
|
*bp++ = '\\'; |
|
break; /* for loop */ |
|
} |
|
switch (c) { |
case '\\': *bp++ = '\\'; break; |
case '\\': *bp++ = '\\'; break; |
case 'n': *bp++ = '\n'; break; |
case 'n': *bp++ = '\n'; break; |
case 't': *bp++ = '\t'; break; |
case 't': *bp++ = '\t'; break; |