Deleted Added
full compact
run.c (146299) run.c (170331)
1/****************************************************************
2Copyright (C) Lucent Technologies 1997
3All Rights Reserved
4
5Permission to use, copy, modify, and distribute this software and
6its documentation for any purpose and without fee is hereby
7granted, provided that the above copyright notice appear in all
8copies and that both that the copyright notice and this

--- 35 unchanged lines hidden (view full) ---

44 WARNING("bad csub %d in Cell %d %s",
45 p->csub, p->ctype, p->sval);
46 }
47 if (istemp(p))
48 tfree(p);
49}
50*/
51
1/****************************************************************
2Copyright (C) Lucent Technologies 1997
3All Rights Reserved
4
5Permission to use, copy, modify, and distribute this software and
6its documentation for any purpose and without fee is hereby
7granted, provided that the above copyright notice appear in all
8copies and that both that the copyright notice and this

--- 35 unchanged lines hidden (view full) ---

44 WARNING("bad csub %d in Cell %d %s",
45 p->csub, p->ctype, p->sval);
46 }
47 if (istemp(p))
48 tfree(p);
49}
50*/
51
52#ifdef _NFILE
53#ifndef FOPEN_MAX
54#define FOPEN_MAX _NFILE
55#endif
56#endif
52/* do we really need these? */
53/* #ifdef _NFILE */
54/* #ifndef FOPEN_MAX */
55/* #define FOPEN_MAX _NFILE */
56/* #endif */
57/* #endif */
58/* */
59/* #ifndef FOPEN_MAX */
60/* #define FOPEN_MAX 40 */ /* max number of open files */
61/* #endif */
62/* */
63/* #ifndef RAND_MAX */
64/* #define RAND_MAX 32767 */ /* all that ansi guarantees */
65/* #endif */
57
66
58#ifndef FOPEN_MAX
59#define FOPEN_MAX 40 /* max number of open files */
60#endif
61
62#ifndef RAND_MAX
63#define RAND_MAX 32767 /* all that ansi guarantees */
64#endif
65
66jmp_buf env;
67extern int pairstack[];
68
69Node *winner = NULL; /* root of parse tree */
70Cell *tmps; /* free temporary cells for execution */
71
72static Cell truecell ={ OBOOL, BTRUE, 0, 0, 1.0, NUM };
73Cell *True = &truecell;

--- 31 unchanged lines hidden (view full) ---

105 if (minlen > *psiz) {
106 char *tbuf;
107 int rminlen = quantum ? minlen % quantum : 0;
108 int boff = pbptr ? *pbptr - *pbuf : 0;
109 /* round up to next multiple of quantum */
110 if (rminlen)
111 minlen += quantum - rminlen;
112 tbuf = (char *) realloc(*pbuf, minlen);
67jmp_buf env;
68extern int pairstack[];
69
70Node *winner = NULL; /* root of parse tree */
71Cell *tmps; /* free temporary cells for execution */
72
73static Cell truecell ={ OBOOL, BTRUE, 0, 0, 1.0, NUM };
74Cell *True = &truecell;

--- 31 unchanged lines hidden (view full) ---

106 if (minlen > *psiz) {
107 char *tbuf;
108 int rminlen = quantum ? minlen % quantum : 0;
109 int boff = pbptr ? *pbptr - *pbuf : 0;
110 /* round up to next multiple of quantum */
111 if (rminlen)
112 minlen += quantum - rminlen;
113 tbuf = (char *) realloc(*pbuf, minlen);
114 dprintf( ("adjbuf %s: %d %d (pbuf=%p, tbuf=%p)\n", whatrtn, *psiz, minlen, *pbuf, tbuf) );
113 if (tbuf == NULL) {
114 if (whatrtn)
115 FATAL("out of memory in %s", whatrtn);
116 return 0;
117 }
118 *pbuf = tbuf;
119 *psiz = minlen;
120 if (pbptr)

--- 337 unchanged lines hidden (view full) ---

458 if ((buf = (char *) malloc(bufsz)) == NULL)
459 FATAL("out of memory in array");
460
461 x = execute(a[0]); /* Cell* for symbol table */
462 buf[0] = 0;
463 for (np = a[1]; np; np = np->nnext) {
464 y = execute(np); /* subscript */
465 s = getsval(y);
115 if (tbuf == NULL) {
116 if (whatrtn)
117 FATAL("out of memory in %s", whatrtn);
118 return 0;
119 }
120 *pbuf = tbuf;
121 *psiz = minlen;
122 if (pbptr)

--- 337 unchanged lines hidden (view full) ---

460 if ((buf = (char *) malloc(bufsz)) == NULL)
461 FATAL("out of memory in array");
462
463 x = execute(a[0]); /* Cell* for symbol table */
464 buf[0] = 0;
465 for (np = a[1]; np; np = np->nnext) {
466 y = execute(np); /* subscript */
467 s = getsval(y);
466 if (!adjbuf(&buf, &bufsz, strlen(buf)+strlen(s)+nsub+1, recsize, 0, 0))
468 if (!adjbuf(&buf, &bufsz, strlen(buf)+strlen(s)+nsub+1, recsize, 0, "array"))
467 FATAL("out of memory for %s[%s...]", x->nval, buf);
468 strcat(buf, s);
469 if (np->nnext)
470 strcat(buf, *SUBSEP);
471 tempfree(y);
472 }
473 if (!isarr(x)) {
474 dprintf( ("making %s into an array\n", NN(x->nval)) );

--- 30 unchanged lines hidden (view full) ---

505 int bufsz = recsize;
506 char *buf;
507 if ((buf = (char *) malloc(bufsz)) == NULL)
508 FATAL("out of memory in adelete");
509 buf[0] = 0;
510 for (np = a[1]; np; np = np->nnext) {
511 y = execute(np); /* subscript */
512 s = getsval(y);
469 FATAL("out of memory for %s[%s...]", x->nval, buf);
470 strcat(buf, s);
471 if (np->nnext)
472 strcat(buf, *SUBSEP);
473 tempfree(y);
474 }
475 if (!isarr(x)) {
476 dprintf( ("making %s into an array\n", NN(x->nval)) );

--- 30 unchanged lines hidden (view full) ---

507 int bufsz = recsize;
508 char *buf;
509 if ((buf = (char *) malloc(bufsz)) == NULL)
510 FATAL("out of memory in adelete");
511 buf[0] = 0;
512 for (np = a[1]; np; np = np->nnext) {
513 y = execute(np); /* subscript */
514 s = getsval(y);
513 if (!adjbuf(&buf, &bufsz, strlen(buf)+strlen(s)+nsub+1, recsize, 0, 0))
515 if (!adjbuf(&buf, &bufsz, strlen(buf)+strlen(s)+nsub+1, recsize, 0, "awkdelete"))
514 FATAL("out of memory deleting %s[%s...]", x->nval, buf);
515 strcat(buf, s);
516 if (np->nnext)
517 strcat(buf, *SUBSEP);
518 tempfree(y);
519 }
520 freeelem(x, buf);
521 free(buf);

--- 22 unchanged lines hidden (view full) ---

544 }
545 if ((buf = (char *) malloc(bufsz)) == NULL) {
546 FATAL("out of memory in intest");
547 }
548 buf[0] = 0;
549 for (p = a[0]; p; p = p->nnext) {
550 x = execute(p); /* expr */
551 s = getsval(x);
516 FATAL("out of memory deleting %s[%s...]", x->nval, buf);
517 strcat(buf, s);
518 if (np->nnext)
519 strcat(buf, *SUBSEP);
520 tempfree(y);
521 }
522 freeelem(x, buf);
523 free(buf);

--- 22 unchanged lines hidden (view full) ---

546 }
547 if ((buf = (char *) malloc(bufsz)) == NULL) {
548 FATAL("out of memory in intest");
549 }
550 buf[0] = 0;
551 for (p = a[0]; p; p = p->nnext) {
552 x = execute(p); /* expr */
553 s = getsval(x);
552 if (!adjbuf(&buf, &bufsz, strlen(buf)+strlen(s)+nsub+1, recsize, 0, 0))
554 if (!adjbuf(&buf, &bufsz, strlen(buf)+strlen(s)+nsub+1, recsize, 0, "intest"))
553 FATAL("out of memory deleting %s[%s...]", x->nval, buf);
554 strcat(buf, s);
555 tempfree(x);
556 if (p->nnext)
557 strcat(buf, *SUBSEP);
558 }
559 k = lookup(buf, (Array *) ap->sval);
560 tempfree(ap);

--- 253 unchanged lines hidden (view full) ---

814 char *buf = *pbuf;
815 int bufsize = *pbufsize;
816
817 os = s;
818 p = buf;
819 if ((fmt = (char *) malloc(fmtsz)) == NULL)
820 FATAL("out of memory in format()");
821 while (*s) {
555 FATAL("out of memory deleting %s[%s...]", x->nval, buf);
556 strcat(buf, s);
557 tempfree(x);
558 if (p->nnext)
559 strcat(buf, *SUBSEP);
560 }
561 k = lookup(buf, (Array *) ap->sval);
562 tempfree(ap);

--- 253 unchanged lines hidden (view full) ---

816 char *buf = *pbuf;
817 int bufsize = *pbufsize;
818
819 os = s;
820 p = buf;
821 if ((fmt = (char *) malloc(fmtsz)) == NULL)
822 FATAL("out of memory in format()");
823 while (*s) {
822 adjbuf(&buf, &bufsize, MAXNUMSIZE+1+p-buf, recsize, &p, "format");
824 adjbuf(&buf, &bufsize, MAXNUMSIZE+1+p-buf, recsize, &p, "format1");
823 if (*s != '%') {
824 *p++ = *s++;
825 continue;
826 }
827 if (*(s+1) == '%') {
828 *p++ = '%';
829 s += 2;
830 continue;
831 }
832 /* have to be real careful in case this is a huge number, eg, %100000d */
833 fmtwd = atoi(s+1);
834 if (fmtwd < 0)
835 fmtwd = -fmtwd;
825 if (*s != '%') {
826 *p++ = *s++;
827 continue;
828 }
829 if (*(s+1) == '%') {
830 *p++ = '%';
831 s += 2;
832 continue;
833 }
834 /* have to be real careful in case this is a huge number, eg, %100000d */
835 fmtwd = atoi(s+1);
836 if (fmtwd < 0)
837 fmtwd = -fmtwd;
836 adjbuf(&buf, &bufsize, fmtwd+1+p-buf, recsize, &p, "format");
838 adjbuf(&buf, &bufsize, fmtwd+1+p-buf, recsize, &p, "format2");
837 for (t = fmt; (*t++ = *s) != '\0'; s++) {
839 for (t = fmt; (*t++ = *s) != '\0'; s++) {
838 if (!adjbuf(&fmt, &fmtsz, MAXNUMSIZE+1+t-fmt, recsize, &t, 0))
840 if (!adjbuf(&fmt, &fmtsz, MAXNUMSIZE+1+t-fmt, recsize, &t, "format3"))
839 FATAL("format item %.30s... ran format() out of memory", os);
840 if (isalpha((uschar)*s) && *s != 'l' && *s != 'h' && *s != 'L')
841 break; /* the ansi panoply */
842 if (*s == '*') {
843 x = execute(a);
844 a = a->nnext;
845 sprintf(t-1, "%d", fmtwd=(int) getfval(x));
846 if (fmtwd < 0)
847 fmtwd = -fmtwd;
848 adjbuf(&buf, &bufsize, fmtwd+1+p-buf, recsize, &p, "format");
849 t = fmt + strlen(fmt);
850 tempfree(x);
851 }
852 }
853 *t = '\0';
854 if (fmtwd < 0)
855 fmtwd = -fmtwd;
841 FATAL("format item %.30s... ran format() out of memory", os);
842 if (isalpha((uschar)*s) && *s != 'l' && *s != 'h' && *s != 'L')
843 break; /* the ansi panoply */
844 if (*s == '*') {
845 x = execute(a);
846 a = a->nnext;
847 sprintf(t-1, "%d", fmtwd=(int) getfval(x));
848 if (fmtwd < 0)
849 fmtwd = -fmtwd;
850 adjbuf(&buf, &bufsize, fmtwd+1+p-buf, recsize, &p, "format");
851 t = fmt + strlen(fmt);
852 tempfree(x);
853 }
854 }
855 *t = '\0';
856 if (fmtwd < 0)
857 fmtwd = -fmtwd;
856 adjbuf(&buf, &bufsize, fmtwd+1+p-buf, recsize, &p, "format");
858 adjbuf(&buf, &bufsize, fmtwd+1+p-buf, recsize, &p, "format4");
857
858 switch (*s) {
859 case 'f': case 'e': case 'g': case 'E': case 'G':
860 flag = 'f';
861 break;
862 case 'd': case 'i':
863 flag = 'd';
864 if(*(s-1) == 'l') break;

--- 17 unchanged lines hidden (view full) ---

882 }
883 if (a == NULL)
884 FATAL("not enough args in printf(%s)", os);
885 x = execute(a);
886 a = a->nnext;
887 n = MAXNUMSIZE;
888 if (fmtwd > n)
889 n = fmtwd;
859
860 switch (*s) {
861 case 'f': case 'e': case 'g': case 'E': case 'G':
862 flag = 'f';
863 break;
864 case 'd': case 'i':
865 flag = 'd';
866 if(*(s-1) == 'l') break;

--- 17 unchanged lines hidden (view full) ---

884 }
885 if (a == NULL)
886 FATAL("not enough args in printf(%s)", os);
887 x = execute(a);
888 a = a->nnext;
889 n = MAXNUMSIZE;
890 if (fmtwd > n)
891 n = fmtwd;
890 adjbuf(&buf, &bufsize, 1+n+p-buf, recsize, &p, "format");
892 adjbuf(&buf, &bufsize, 1+n+p-buf, recsize, &p, "format5");
891 switch (flag) {
892 case '?': sprintf(p, "%s", fmt); /* unknown, so dump it too */
893 t = getsval(x);
894 n = strlen(t);
895 if (fmtwd > n)
896 n = fmtwd;
893 switch (flag) {
894 case '?': sprintf(p, "%s", fmt); /* unknown, so dump it too */
895 t = getsval(x);
896 n = strlen(t);
897 if (fmtwd > n)
898 n = fmtwd;
897 adjbuf(&buf, &bufsize, 1+strlen(p)+n+p-buf, recsize, &p, "format");
899 adjbuf(&buf, &bufsize, 1+strlen(p)+n+p-buf, recsize, &p, "format6");
898 p += strlen(p);
899 sprintf(p, "%s", t);
900 break;
901 case 'f': sprintf(p, fmt, getfval(x)); break;
902 case 'd': sprintf(p, fmt, (long) getfval(x)); break;
903 case 'u': sprintf(p, fmt, (int) getfval(x)); break;
904 case 's':
905 t = getsval(x);
906 n = strlen(t);
907 if (fmtwd > n)
908 n = fmtwd;
900 p += strlen(p);
901 sprintf(p, "%s", t);
902 break;
903 case 'f': sprintf(p, fmt, getfval(x)); break;
904 case 'd': sprintf(p, fmt, (long) getfval(x)); break;
905 case 'u': sprintf(p, fmt, (int) getfval(x)); break;
906 case 's':
907 t = getsval(x);
908 n = strlen(t);
909 if (fmtwd > n)
910 n = fmtwd;
909 if (!adjbuf(&buf, &bufsize, 1+n+p-buf, recsize, &p, 0))
911 if (!adjbuf(&buf, &bufsize, 1+n+p-buf, recsize, &p, "format7"))
910 FATAL("huge string/format (%d chars) in printf %.30s... ran format() out of memory", n, t);
911 sprintf(p, fmt, t);
912 break;
913 case 'c':
914 if (isnum(x)) {
915 if (getfval(x))
916 sprintf(p, fmt, (int) getfval(x));
917 else {

--- 1010 unchanged lines hidden ---
912 FATAL("huge string/format (%d chars) in printf %.30s... ran format() out of memory", n, t);
913 sprintf(p, fmt, t);
914 break;
915 case 'c':
916 if (isnum(x)) {
917 if (getfval(x))
918 sprintf(p, fmt, (int) getfval(x));
919 else {

--- 1010 unchanged lines hidden ---