version 1.29, 2008/06/04 14:04:42 |
version 1.30, 2008/10/06 20:38:33 |
|
|
} |
} |
*/ |
*/ |
|
|
#ifdef _NFILE |
/* do we really need these? */ |
#ifndef FOPEN_MAX |
/* #ifdef _NFILE */ |
#define FOPEN_MAX _NFILE |
/* #ifndef FOPEN_MAX */ |
#endif |
/* #define FOPEN_MAX _NFILE */ |
#endif |
/* #endif */ |
|
/* #endif */ |
|
/* */ |
|
/* #ifndef FOPEN_MAX */ |
|
/* #define FOPEN_MAX 40 */ /* max number of open files */ |
|
/* #endif */ |
|
/* */ |
|
/* #ifndef RAND_MAX */ |
|
/* #define RAND_MAX 32767 */ /* all that ansi guarantees */ |
|
/* #endif */ |
|
|
#ifndef FOPEN_MAX |
|
#define FOPEN_MAX 40 /* max number of open files */ |
|
#endif |
|
|
|
#ifndef RAND_MAX |
|
#define RAND_MAX 32767 /* all that ansi guarantees */ |
|
#endif |
|
|
|
jmp_buf env; |
jmp_buf env; |
int use_arc4 = 1; |
int use_arc4 = 1; |
extern int pairstack[]; |
extern int pairstack[]; |
|
|
if (rminlen) |
if (rminlen) |
minlen += quantum - rminlen; |
minlen += quantum - rminlen; |
tbuf = (char *) realloc(*pbuf, minlen); |
tbuf = (char *) realloc(*pbuf, minlen); |
|
dprintf( ("adjbuf %s: %d %d (pbuf=%p, tbuf=%p)\n", whatrtn, *psiz, minlen, *pbuf, tbuf) ); |
if (tbuf == NULL) { |
if (tbuf == NULL) { |
if (whatrtn) |
if (whatrtn) |
FATAL("out of memory in %s", whatrtn); |
FATAL("out of memory in %s", whatrtn); |
|
|
for (np = a[1]; np; np = np->nnext) { |
for (np = a[1]; np; np = np->nnext) { |
y = execute(np); /* subscript */ |
y = execute(np); /* subscript */ |
s = getsval(y); |
s = getsval(y); |
if (!adjbuf(&buf, &bufsz, strlen(buf)+strlen(s)+nsub+1, recsize, 0, 0)) |
if (!adjbuf(&buf, &bufsz, strlen(buf)+strlen(s)+nsub+1, recsize, 0, "array")) |
FATAL("out of memory for %s[%s...]", x->nval, buf); |
FATAL("out of memory for %s[%s...]", x->nval, buf); |
strlcat(buf, s, bufsz); |
strlcat(buf, s, bufsz); |
if (np->nnext) |
if (np->nnext) |
|
|
for (np = a[1]; np; np = np->nnext) { |
for (np = a[1]; np; np = np->nnext) { |
y = execute(np); /* subscript */ |
y = execute(np); /* subscript */ |
s = getsval(y); |
s = getsval(y); |
if (!adjbuf(&buf, &bufsz, strlen(buf)+strlen(s)+nsub+1, recsize, 0, 0)) |
if (!adjbuf(&buf, &bufsz, strlen(buf)+strlen(s)+nsub+1, recsize, 0, "awkdelete")) |
FATAL("out of memory deleting %s[%s...]", x->nval, buf); |
FATAL("out of memory deleting %s[%s...]", x->nval, buf); |
strlcat(buf, s, bufsz); |
strlcat(buf, s, bufsz); |
if (np->nnext) |
if (np->nnext) |
|
|
for (p = a[0]; p; p = p->nnext) { |
for (p = a[0]; p; p = p->nnext) { |
x = execute(p); /* expr */ |
x = execute(p); /* expr */ |
s = getsval(x); |
s = getsval(x); |
if (!adjbuf(&buf, &bufsz, strlen(buf)+strlen(s)+nsub+1, recsize, 0, 0)) |
if (!adjbuf(&buf, &bufsz, strlen(buf)+strlen(s)+nsub+1, recsize, 0, "intest")) |
FATAL("out of memory deleting %s[%s...]", x->nval, buf); |
FATAL("out of memory deleting %s[%s...]", x->nval, buf); |
strlcat(buf, s, bufsz); |
strlcat(buf, s, bufsz); |
tempfree(x); |
tempfree(x); |
|
|
if ((fmt = (char *) malloc(fmtsz)) == NULL) |
if ((fmt = (char *) malloc(fmtsz)) == NULL) |
FATAL("out of memory in format()"); |
FATAL("out of memory in format()"); |
while (*s) { |
while (*s) { |
adjbuf(&buf, &bufsize, MAXNUMSIZE+1+p-buf, recsize, &p, "format"); |
adjbuf(&buf, &bufsize, MAXNUMSIZE+1+p-buf, recsize, &p, "format1"); |
if (*s != '%') { |
if (*s != '%') { |
*p++ = *s++; |
*p++ = *s++; |
continue; |
continue; |
|
|
fmtwd = atoi(s+1); |
fmtwd = atoi(s+1); |
if (fmtwd < 0) |
if (fmtwd < 0) |
fmtwd = -fmtwd; |
fmtwd = -fmtwd; |
adjbuf(&buf, &bufsize, fmtwd+1+p-buf, recsize, &p, "format"); |
adjbuf(&buf, &bufsize, fmtwd+1+p-buf, recsize, &p, "format2"); |
for (t = fmt; (*t++ = *s) != '\0'; s++) { |
for (t = fmt; (*t++ = *s) != '\0'; s++) { |
if (!adjbuf(&fmt, &fmtsz, MAXNUMSIZE+1+t-fmt, recsize, &t, 0)) |
if (!adjbuf(&fmt, &fmtsz, MAXNUMSIZE+1+t-fmt, recsize, &t, "format3")) |
FATAL("format item %.30s... ran format() out of memory", os); |
FATAL("format item %.30s... ran format() out of memory", os); |
if (isalpha((uschar)*s) && *s != 'l' && *s != 'h' && *s != 'L') |
if (isalpha((uschar)*s) && *s != 'l' && *s != 'h' && *s != 'L') |
break; /* the ansi panoply */ |
break; /* the ansi panoply */ |
|
|
*t = '\0'; |
*t = '\0'; |
if (fmtwd < 0) |
if (fmtwd < 0) |
fmtwd = -fmtwd; |
fmtwd = -fmtwd; |
adjbuf(&buf, &bufsize, fmtwd+1+p-buf, recsize, &p, "format"); |
adjbuf(&buf, &bufsize, fmtwd+1+p-buf, recsize, &p, "format4"); |
|
|
switch (*s) { |
switch (*s) { |
case 'f': case 'e': case 'g': case 'E': case 'G': |
case 'f': case 'e': case 'g': case 'E': case 'G': |
|
|
n = MAXNUMSIZE; |
n = MAXNUMSIZE; |
if (fmtwd > n) |
if (fmtwd > n) |
n = fmtwd; |
n = fmtwd; |
adjbuf(&buf, &bufsize, 1+n+p-buf, recsize, &p, "format"); |
adjbuf(&buf, &bufsize, 1+n+p-buf, recsize, &p, "format5"); |
switch (flag) { |
switch (flag) { |
case '?': /* unknown, so dump it too */ |
case '?': /* unknown, so dump it too */ |
snprintf(p, buf + bufsize - p, "%s", fmt); |
snprintf(p, buf + bufsize - p, "%s", fmt); |
|
|
n = strlen(t); |
n = strlen(t); |
if (fmtwd > n) |
if (fmtwd > n) |
n = fmtwd; |
n = fmtwd; |
adjbuf(&buf, &bufsize, 1+strlen(p)+n+p-buf, recsize, &p, "format"); |
adjbuf(&buf, &bufsize, 1+strlen(p)+n+p-buf, recsize, &p, "format6"); |
p += strlen(p); |
p += strlen(p); |
snprintf(p, buf + bufsize - p, "%s", t); |
snprintf(p, buf + bufsize - p, "%s", t); |
break; |
break; |
|
|
n = strlen(t); |
n = strlen(t); |
if (fmtwd > n) |
if (fmtwd > n) |
n = fmtwd; |
n = fmtwd; |
if (!adjbuf(&buf, &bufsize, 1+n+p-buf, recsize, &p, 0)) |
if (!adjbuf(&buf, &bufsize, 1+n+p-buf, recsize, &p, "format7")) |
FATAL("huge string/format (%d chars) in printf %.30s... ran format() out of memory", n, t); |
FATAL("huge string/format (%d chars) in printf %.30s... ran format() out of memory", n, t); |
snprintf(p, buf + bufsize - p, fmt, t); |
snprintf(p, buf + bufsize - p, fmt, t); |
break; |
break; |