version 1.24, 2004/05/08 22:08:51 |
version 1.25, 2004/12/30 01:52:48 |
|
|
#include <stdio.h> |
#include <stdio.h> |
#include <ctype.h> |
#include <ctype.h> |
#include <setjmp.h> |
#include <setjmp.h> |
|
#include <limits.h> |
#include <math.h> |
#include <math.h> |
#include <string.h> |
#include <string.h> |
#include <stdlib.h> |
#include <stdlib.h> |
|
|
{ |
{ |
static Cell newcopycell = { OCELL, CCOPY, 0, "", 0.0, NUM|STR|DONTFREE }; |
static Cell newcopycell = { OCELL, CCOPY, 0, "", 0.0, NUM|STR|DONTFREE }; |
int i, ncall, ndef; |
int i, ncall, ndef; |
|
int freed = 0; /* handles potential double freeing when fcn & param share a tempcell */ |
Node *x; |
Node *x; |
Cell *args[NARGS], *oargs[NARGS]; /* BUG: fixed size arrays */ |
Cell *args[NARGS], *oargs[NARGS]; /* BUG: fixed size arrays */ |
Cell *y, *z, *fcn; |
Cell *y, *z, *fcn; |
|
|
} else if (t != y) { /* kludge to prevent freeing twice */ |
} else if (t != y) { /* kludge to prevent freeing twice */ |
t->csub = CTEMP; |
t->csub = CTEMP; |
tempfree(t); |
tempfree(t); |
|
} else if (t == y && t->csub == CCOPY) { |
|
t->csub = CTEMP; |
|
tempfree(t); |
|
freed = 1; |
} |
} |
} |
} |
tempfree(fcn); |
tempfree(fcn); |
if (isexit(y) || isnext(y)) |
if (isexit(y) || isnext(y)) |
return y; |
return y; |
tempfree(y); /* this can free twice! */ |
if (freed == 0) { |
|
tempfree(y); /* don't free twice! */ |
|
} |
z = fp->retval; /* return value */ |
z = fp->retval; /* return value */ |
dprintf( ("%s returns %g |%s| %o\n", s, getfval(z), getsval(z), z->tval) ); |
dprintf( ("%s returns %g |%s| %o\n", s, getfval(z), getsval(z), z->tval) ); |
fp--; |
fp--; |
|
|
|
|
Cell *indirect(Node **a, int n) /* $( a[0] ) */ |
Cell *indirect(Node **a, int n) /* $( a[0] ) */ |
{ |
{ |
|
Awkfloat val; |
Cell *x; |
Cell *x; |
int m; |
int m; |
char *s; |
char *s; |
|
|
x = execute(a[0]); |
x = execute(a[0]); |
m = (int) getfval(x); |
val = getfval(x); /* freebsd: defend against super large field numbers */ |
|
if ((Awkfloat)INT_MAX < val) |
|
FATAL("trying to access out of range field %s", x->nval); |
|
m = (int) val; |
if (m == 0 && !is_number(s = getsval(x))) /* suspicion! */ |
if (m == 0 && !is_number(s = getsval(x))) /* suspicion! */ |
FATAL("illegal field $(%s), name \"%s\"", s, x->nval); |
FATAL("illegal field $(%s), name \"%s\"", s, x->nval); |
/* BUG: can x->nval ever be null??? */ |
/* BUG: can x->nval ever be null??? */ |
|
|
ap->sval = (char *) makesymtab(NSYMTAB); |
ap->sval = (char *) makesymtab(NSYMTAB); |
|
|
n = 0; |
n = 0; |
if ((*s != '\0' && strlen(fs) > 1) || arg3type == REGEXPR) { /* reg expr */ |
if (*s != '\0' && (strlen(fs) > 1 || arg3type == REGEXPR)) { /* reg expr */ |
fa *pfa; |
fa *pfa; |
if (arg3type == REGEXPR) { /* it's ready already */ |
if (arg3type == REGEXPR) { /* it's ready already */ |
pfa = (fa *) a[2]; |
pfa = (fa *) a[2]; |
|
|
goto spdone; |
goto spdone; |
} |
} |
} while (nematch(pfa,s)); |
} while (nematch(pfa,s)); |
|
pfa->initstat = tempstat; /* bwk: has to be here to reset */ |
|
/* cf gsub and refldbld */ |
} |
} |
n++; |
n++; |
snprintf(num, sizeof num, "%d", n); |
snprintf(num, sizeof num, "%d", n); |
|
|
if (t == FTOUPPER) { |
if (t == FTOUPPER) { |
for (p = buf; *p; p++) |
for (p = buf; *p; p++) |
if (islower((uschar) *p)) |
if (islower((uschar) *p)) |
*p = toupper(*p); |
*p = toupper((uschar)*p); |
} else { |
} else { |
for (p = buf; *p; p++) |
for (p = buf; *p; p++) |
if (isupper((uschar) *p)) |
if (isupper((uschar) *p)) |
*p = tolower(*p); |
*p = tolower((uschar)*p); |
} |
} |
tempfree(x); |
tempfree(x); |
x = gettemp(); |
x = gettemp(); |