version 1.50, 2020/06/10 21:02:19 |
version 1.51, 2020/06/10 21:02:33 |
|
|
} |
} |
if (!isarr(x)) |
if (!isarr(x)) |
return True; |
return True; |
if (a[1] == 0) { /* delete the elements, not the table */ |
if (a[1] == NULL) { /* delete the elements, not the table */ |
freesymtab(x); |
freesymtab(x); |
x->tval &= ~STR; |
x->tval &= ~STR; |
x->tval |= ARR; |
x->tval |= ARR; |
|
|
} |
} |
x = execute(a[1]); /* a[1] = target text */ |
x = execute(a[1]); /* a[1] = target text */ |
s = getsval(x); |
s = getsval(x); |
if (a[0] == 0) /* a[1] == 0: already-compiled reg expr */ |
if (a[0] == NULL) /* a[1] == 0: already-compiled reg expr */ |
i = (*mf)((fa *) a[2], s); |
i = (*mf)((fa *) a[2], s); |
else { |
else { |
y = execute(a[2]); /* a[2] = regular expr */ |
y = execute(a[2]); /* a[2] = regular expr */ |
|
|
FATAL("out of space for temporaries"); |
FATAL("out of space for temporaries"); |
for(i = 1; i < 100; i++) |
for(i = 1; i < 100; i++) |
tmps[i-1].cnext = &tmps[i]; |
tmps[i-1].cnext = &tmps[i]; |
tmps[i-1].cnext = 0; |
tmps[i-1].cnext = NULL; |
} |
} |
x = tmps; |
x = tmps; |
tmps = x->cnext; |
tmps = x->cnext; |
|
|
int k, m, n; |
int k, m, n; |
char *s; |
char *s; |
int temp; |
int temp; |
Cell *x, *y, *z = 0; |
Cell *x, *y, *z = NULL; |
|
|
x = execute(a[0]); |
x = execute(a[0]); |
y = execute(a[1]); |
y = execute(a[1]); |
if (a[2] != 0) |
if (a[2] != NULL) |
z = execute(a[2]); |
z = execute(a[2]); |
s = getsval(x); |
s = getsval(x); |
k = strlen(s) + 1; |
k = strlen(s) + 1; |
if (k <= 1) { |
if (k <= 1) { |
tempfree(x); |
tempfree(x); |
tempfree(y); |
tempfree(y); |
if (a[2] != 0) { |
if (a[2] != NULL) { |
tempfree(z); |
tempfree(z); |
} |
} |
x = gettemp(); |
x = gettemp(); |
|
|
else if (m > k) |
else if (m > k) |
m = k; |
m = k; |
tempfree(y); |
tempfree(y); |
if (a[2] != 0) { |
if (a[2] != NULL) { |
n = (int) getfval(z); |
n = (int) getfval(z); |
tempfree(z); |
tempfree(z); |
} else |
} else |
|
|
{ |
{ |
Cell *x; |
Cell *x; |
|
|
if (a[0] == 0) |
if (a[0] == NULL) |
x = execute(a[1]); |
x = execute(a[1]); |
else { |
else { |
x = execute(a[0]); |
x = execute(a[0]); |
|
|
|
|
Cell *split(Node **a, int nnn) /* split(a[0], a[1], a[2]); a[3] is type */ |
Cell *split(Node **a, int nnn) /* split(a[0], a[1], a[2]); a[3] is type */ |
{ |
{ |
Cell *x = 0, *y, *ap; |
Cell *x = NULL, *y, *ap; |
char *s, *origs; |
char *s, *origs; |
char *fs, *origfs = NULL; |
char *fs = NULL, *origfs = NULL; |
int sep; |
int sep; |
char *t, temp, num[50]; |
char *t, temp, num[50]; |
int n, tempstat, arg3type; |
int n, tempstat, arg3type; |
|
|
if (s == NULL) |
if (s == NULL) |
FATAL("out of space in split"); |
FATAL("out of space in split"); |
arg3type = ptoi(a[3]); |
arg3type = ptoi(a[3]); |
if (a[2] == 0) /* fs string */ |
if (a[2] == NULL) /* fs string */ |
fs = getsval(fsloc); |
fs = getsval(fsloc); |
else if (arg3type == STRING) { /* split(str,arr,"string") */ |
else if (arg3type == STRING) { /* split(str,arr,"string") */ |
x = execute(a[2]); |
x = execute(a[2]); |
|
|
if (istrue(x)) { |
if (istrue(x)) { |
tempfree(x); |
tempfree(x); |
x = execute(a[1]); |
x = execute(a[1]); |
} else if (a[2] != 0) { |
} else if (a[2] != NULL) { |
tempfree(x); |
tempfree(x); |
x = execute(a[2]); |
x = execute(a[2]); |
} |
} |
|
|
x = execute(a[0]); |
x = execute(a[0]); |
tempfree(x); |
tempfree(x); |
for (;;) { |
for (;;) { |
if (a[1]!=0) { |
if (a[1]!=NULL) { |
x = execute(a[1]); |
x = execute(a[1]); |
if (!istrue(x)) return(x); |
if (!istrue(x)) return(x); |
else tempfree(x); |
else tempfree(x); |
|
|
case FCOS: |
case FCOS: |
u = cos(getfval(x)); break; |
u = cos(getfval(x)); break; |
case FATAN: |
case FATAN: |
if (nextarg == 0) { |
if (nextarg == NULL) { |
WARNING("atan2 requires two arguments; returning 1.0"); |
WARNING("atan2 requires two arguments; returning 1.0"); |
u = 1.0; |
u = 1.0; |
} else { |
} else { |
|
|
} |
} |
break; |
break; |
case FRAND: |
case FRAND: |
u = (Awkfloat) (random() & RAND_MAX) / ((u_int)RAND_MAX + 1); |
/* random() returns numbers in [0..2^31-1] |
|
* in order to get a number in [0, 1), divide it by 2^31 |
|
*/ |
|
u = (Awkfloat) random() / (0x7fffffffL + 0x1UL); |
break; |
break; |
case FSRAND: |
case FSRAND: |
if (isrec(x)) { /* no argument provided */ |
if (isrec(x)) { /* no argument provided */ |
|
|
tempfree(x); |
tempfree(x); |
x = gettemp(); |
x = gettemp(); |
setfval(x, u); |
setfval(x, u); |
if (nextarg != 0) { |
if (nextarg != NULL) { |
WARNING("warning: function has too many arguments"); |
WARNING("warning: function has too many arguments"); |
for ( ; nextarg; nextarg = nextarg->nnext) |
for ( ; nextarg; nextarg = nextarg->nnext) |
execute(nextarg); |
execute(nextarg); |
|
|
Cell *y; |
Cell *y; |
FILE *fp; |
FILE *fp; |
|
|
if (a[1] == 0) /* a[1] is redirection operator, a[2] is file */ |
if (a[1] == NULL) /* a[1] is redirection operator, a[2] is file */ |
fp = stdout; |
fp = stdout; |
else |
else |
fp = redirect(ptoi(a[1]), a[2]); |
fp = redirect(ptoi(a[1]), a[2]); |
|
|
else |
else |
fputs(getsval(ofsloc), fp); |
fputs(getsval(ofsloc), fp); |
} |
} |
if (a[1] != 0) |
if (a[1] != NULL) |
fflush(fp); |
fflush(fp); |
if (ferror(fp)) |
if (ferror(fp)) |
FATAL("write error on %s", filename(fp)); |
FATAL("write error on %s", filename(fp)); |
|
|
{ |
{ |
const char *s = us; |
const char *s = us; |
int i, m; |
int i, m; |
FILE *fp = 0; |
FILE *fp = NULL; |
|
|
if (*s == '\0') |
if (*s == '\0') |
FATAL("null file name in print or getline"); |
FATAL("null file name in print or getline"); |
|
|
return NULL; |
return NULL; |
|
|
for (i=0; i < nfiles; i++) |
for (i=0; i < nfiles; i++) |
if (files[i].fp == 0) |
if (files[i].fp == NULL) |
break; |
break; |
if (i >= nfiles) { |
if (i >= nfiles) { |
struct files *nf; |
struct files *nf; |
|
|
FATAL("out of memory in sub"); |
FATAL("out of memory in sub"); |
x = execute(a[3]); /* target string */ |
x = execute(a[3]); /* target string */ |
t = getsval(x); |
t = getsval(x); |
if (a[0] == 0) /* 0 => a[1] is already-compiled regexpr */ |
if (a[0] == NULL) /* 0 => a[1] is already-compiled regexpr */ |
pfa = (fa *) a[1]; /* regular expression */ |
pfa = (fa *) a[1]; /* regular expression */ |
else { |
else { |
y = execute(a[1]); |
y = execute(a[1]); |
|
|
num = 0; |
num = 0; |
x = execute(a[3]); /* target string */ |
x = execute(a[3]); /* target string */ |
t = getsval(x); |
t = getsval(x); |
if (a[0] == 0) /* 0 => a[1] is already-compiled regexpr */ |
if (a[0] == NULL) /* 0 => a[1] is already-compiled regexpr */ |
pfa = (fa *) a[1]; /* regular expression */ |
pfa = (fa *) a[1]; /* regular expression */ |
else { |
else { |
y = execute(a[1]); |
y = execute(a[1]); |