Annotation of src/usr.bin/m4/main.c, Revision 1.79
1.79 ! marco 1: /* $OpenBSD: main.c,v 1.78 2010/03/22 20:40:44 espie Exp $ */
1.7 deraadt 2: /* $NetBSD: main.c,v 1.12 1997/02/08 23:54:49 cgd Exp $ */
1.1 deraadt 3:
4: /*-
5: * Copyright (c) 1989, 1993
6: * The Regents of the University of California. All rights reserved.
7: *
8: * This code is derived from software contributed to Berkeley by
9: * Ozan Yigit at York University.
10: *
11: * Redistribution and use in source and binary forms, with or without
12: * modification, are permitted provided that the following conditions
13: * are met:
14: * 1. Redistributions of source code must retain the above copyright
15: * notice, this list of conditions and the following disclaimer.
16: * 2. Redistributions in binary form must reproduce the above copyright
17: * notice, this list of conditions and the following disclaimer in the
18: * documentation and/or other materials provided with the distribution.
1.55 millert 19: * 3. Neither the name of the University nor the names of its contributors
1.1 deraadt 20: * may be used to endorse or promote products derived from this software
21: * without specific prior written permission.
22: *
23: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33: * SUCH DAMAGE.
34: */
35:
36: /*
37: * main.c
38: * Facility: m4 macro processor
39: * by: oz
40: */
41:
1.21 espie 42: #include <assert.h>
1.1 deraadt 43: #include <signal.h>
1.74 espie 44: #include <err.h>
1.1 deraadt 45: #include <errno.h>
46: #include <unistd.h>
47: #include <stdio.h>
48: #include <ctype.h>
49: #include <string.h>
1.13 espie 50: #include <stddef.h>
1.69 espie 51: #include <stdint.h>
1.34 espie 52: #include <stdlib.h>
1.63 espie 53: #include <ohash.h>
1.1 deraadt 54: #include "mdef.h"
55: #include "stdd.h"
56: #include "extern.h"
57: #include "pathnames.h"
58:
59: ndptr hashtab[HASHSIZE]; /* hash table for macros etc. */
1.79 ! marco 60: stae *mstack; /* stack of m4 machine */
! 61: char *sstack; /* shadow stack, for string space extension */
1.34 espie 62: static size_t STACKMAX; /* current maximum size of stack */
1.79 ! marco 63: int sp; /* current m4 stack pointer */
! 64: int fp; /* m4 call frame pointer */
1.26 espie 65: struct input_file infile[MAXINP];/* input file stack (0=stdin) */
1.36 espie 66: FILE **outfile; /* diversion array(0=bitbucket)*/
67: int maxout;
1.1 deraadt 68: FILE *active; /* active output file pointer */
1.79 ! marco 69: int ilevel = 0; /* input file stack pointer */
! 70: int oindex = 0; /* diversion index.. */
1.1 deraadt 71: char *null = ""; /* as it says.. just a null.. */
1.79 ! marco 72: char **m4wraps = NULL; /* m4wraps array. */
1.66 espie 73: int maxwraps = 0; /* size of m4wraps array */
74: int wrapindex = 0; /* current offset in m4wraps */
1.2 deraadt 75: char lquote[MAXCCHARS+1] = {LQUOTE}; /* left quote character (`) */
76: char rquote[MAXCCHARS+1] = {RQUOTE}; /* right quote character (') */
77: char scommt[MAXCCHARS+1] = {SCOMMT}; /* start character for comment */
78: char ecommt[MAXCCHARS+1] = {ECOMMT}; /* end character for comment */
1.54 espie 79: int synch_lines = 0; /* line synchronisation for C preprocessor */
1.77 sthen 80: int prefix_builtins = 0; /* -P option to prefix builtin keywords */
1.1 deraadt 81:
1.63 espie 82: struct keyblk {
83: char *knam; /* keyword name */
84: int ktyp; /* keyword type */
85: };
86:
1.1 deraadt 87: struct keyblk keywrds[] = { /* m4 keywords to be installed */
1.8 millert 88: { "include", INCLTYPE },
89: { "sinclude", SINCTYPE },
90: { "define", DEFITYPE },
91: { "defn", DEFNTYPE },
1.24 espie 92: { "divert", DIVRTYPE | NOARGS },
1.8 millert 93: { "expr", EXPRTYPE },
94: { "eval", EXPRTYPE },
95: { "substr", SUBSTYPE },
96: { "ifelse", IFELTYPE },
97: { "ifdef", IFDFTYPE },
98: { "len", LENGTYPE },
99: { "incr", INCRTYPE },
100: { "decr", DECRTYPE },
1.24 espie 101: { "dnl", DNLNTYPE | NOARGS },
102: { "changequote", CHNQTYPE | NOARGS },
103: { "changecom", CHNCTYPE | NOARGS },
1.8 millert 104: { "index", INDXTYPE },
1.1 deraadt 105: #ifdef EXTENDED
1.8 millert 106: { "paste", PASTTYPE },
107: { "spaste", SPASTYPE },
1.79 ! marco 108: /* Newer extensions, needed to handle gnu-m4 scripts */
1.31 espie 109: { "indir", INDIRTYPE},
110: { "builtin", BUILTINTYPE},
111: { "patsubst", PATSTYPE},
112: { "regexp", REGEXPTYPE},
1.35 espie 113: { "esyscmd", ESYSCMDTYPE},
1.31 espie 114: { "__file__", FILENAMETYPE | NOARGS},
115: { "__line__", LINETYPE | NOARGS},
1.1 deraadt 116: #endif
1.8 millert 117: { "popdef", POPDTYPE },
118: { "pushdef", PUSDTYPE },
1.24 espie 119: { "dumpdef", DUMPTYPE | NOARGS },
120: { "shift", SHIFTYPE | NOARGS },
1.8 millert 121: { "translit", TRNLTYPE },
122: { "undefine", UNDFTYPE },
1.24 espie 123: { "undivert", UNDVTYPE | NOARGS },
124: { "divnum", DIVNTYPE | NOARGS },
1.8 millert 125: { "maketemp", MKTMTYPE },
1.78 espie 126: { "mkstemp", MKTMTYPE },
1.24 espie 127: { "errprint", ERRPTYPE | NOARGS },
128: { "m4wrap", M4WRTYPE | NOARGS },
129: { "m4exit", EXITTYPE | NOARGS },
1.8 millert 130: { "syscmd", SYSCTYPE },
1.24 espie 131: { "sysval", SYSVTYPE | NOARGS },
1.49 espie 132: { "traceon", TRACEONTYPE | NOARGS },
133: { "traceoff", TRACEOFFTYPE | NOARGS },
1.1 deraadt 134:
1.79 ! marco 135: #if defined(unix) || defined(__unix__)
1.24 espie 136: { "unix", SELFTYPE | NOARGS },
1.1 deraadt 137: #else
138: #ifdef vms
1.24 espie 139: { "vms", SELFTYPE | NOARGS },
1.1 deraadt 140: #endif
141: #endif
142: };
143:
144: #define MAXKEYS (sizeof(keywrds)/sizeof(struct keyblk))
145:
146: extern int optind;
147: extern char *optarg;
148:
1.27 espie 149: #define MAXRECORD 50
150: static struct position {
151: char *name;
152: unsigned long line;
153: } quotes[MAXRECORD], paren[MAXRECORD];
154:
1.52 millert 155: static void record(struct position *, int);
156: static void dump_stack(struct position *, int);
1.27 espie 157:
1.52 millert 158: static void macro(void);
159: static void initkwds(void);
160: static ndptr inspect(int, char *);
161: static int do_look_ahead(int, const char *);
1.54 espie 162: static void reallyoutputstr(const char *);
163: static void reallyputchar(int);
1.18 espie 164:
1.52 millert 165: static void enlarge_stack(void);
1.34 espie 166:
1.52 millert 167: int main(int, char *[]);
1.1 deraadt 168:
169: int
1.53 espie 170: main(int argc, char *argv[])
1.1 deraadt 171: {
1.17 espie 172: int c;
173: int n;
1.1 deraadt 174: char *p;
175:
176: if (signal(SIGINT, SIG_IGN) != SIG_IGN)
177: signal(SIGINT, onintr);
178:
1.61 espie 179: init_macros();
1.14 espie 180: initspaces();
1.34 espie 181: STACKMAX = INITSTACKMAX;
182:
1.64 espie 183: mstack = (stae *)xalloc(sizeof(stae) * STACKMAX, NULL);
184: sstack = (char *)xalloc(STACKMAX, NULL);
1.1 deraadt 185:
1.36 espie 186: maxout = 0;
187: outfile = NULL;
188: resizedivs(MAXOUT);
189:
1.77 sthen 190: while ((c = getopt(argc, argv, "gst:d:D:U:o:I:P")) != -1)
1.1 deraadt 191: switch(c) {
192:
193: case 'D': /* define something..*/
194: for (p = optarg; *p; p++)
195: if (*p == '=')
196: break;
197: if (*p)
198: *p++ = EOS;
199: dodefine(optarg, p);
1.16 espie 200: break;
201: case 'I':
202: addtoincludepath(optarg);
1.1 deraadt 203: break;
1.77 sthen 204: case 'P':
205: prefix_builtins = 1;
206: break;
1.1 deraadt 207: case 'U': /* undefine... */
1.59 espie 208: macro_popdef(optarg);
1.32 espie 209: break;
210: case 'g':
211: mimic_gnu = 1;
1.1 deraadt 212: break;
1.46 espie 213: case 'd':
214: set_trace_flags(optarg);
1.47 espie 215: break;
1.54 espie 216: case 's':
217: synch_lines = 1;
218: break;
1.47 espie 219: case 't':
1.49 espie 220: mark_traced(optarg, 1);
1.46 espie 221: break;
1.38 aaron 222: case 'o':
1.46 espie 223: trace_file(optarg);
1.38 aaron 224: break;
1.1 deraadt 225: case '?':
226: usage();
227: }
228:
229: argc -= optind;
230: argv += optind;
1.77 sthen 231:
232: initkwds();
233: if (mimic_gnu)
234: setup_builtin("format", FORMATTYPE);
1.1 deraadt 235:
236: active = stdout; /* default active output */
237: bbase[0] = bufbase;
238: if (!argc) {
1.79 ! marco 239: sp = -1; /* stack pointer initialized */
! 240: fp = 0; /* frame pointer initialized */
1.26 espie 241: set_input(infile+0, stdin, "stdin");
242: /* default input (naturally) */
1.1 deraadt 243: macro();
244: } else
245: for (; argc--; ++argv) {
246: p = *argv;
1.13 espie 247: if (p[0] == '-' && p[1] == EOS)
1.26 espie 248: set_input(infile, stdin, "stdin");
249: else if (fopen_trypath(infile, p) == NULL)
1.11 espie 250: err(1, "%s", p);
1.1 deraadt 251: sp = -1;
1.79 ! marco 252: fp = 0;
1.1 deraadt 253: macro();
1.79 ! marco 254: release_input(infile);
1.1 deraadt 255: }
256:
1.66 espie 257: if (wrapindex) {
258: int i;
259:
1.1 deraadt 260: ilevel = 0; /* in case m4wrap includes.. */
261: bufbase = bp = buf; /* use the entire buffer */
1.66 espie 262: if (mimic_gnu) {
263: while (wrapindex != 0) {
264: for (i = 0; i < wrapindex; i++)
265: pbstr(m4wraps[i]);
266: wrapindex =0;
267: macro();
268: }
269: } else {
270: for (i = 0; i < wrapindex; i++) {
271: pbstr(m4wraps[i]);
272: macro();
1.79 ! marco 273: }
1.66 espie 274: }
1.1 deraadt 275: }
276:
277: if (active != stdout)
278: active = stdout; /* reset output just in case */
1.36 espie 279: for (n = 1; n < maxout; n++) /* default wrap-up: undivert */
1.1 deraadt 280: if (outfile[n] != NULL)
281: getdiv(n);
282: /* remove bitbucket if used */
283: if (outfile[0] != NULL) {
284: (void) fclose(outfile[0]);
285: }
286:
287: return 0;
288: }
289:
290: /*
1.21 espie 291: * Look ahead for `token'.
1.2 deraadt 292: * (on input `t == token[0]')
293: * Used for comment and quoting delimiters.
294: * Returns 1 if `token' present; copied to output.
295: * 0 if `token' not found; all characters pushed back
296: */
1.18 espie 297: static int
1.53 espie 298: do_look_ahead(int t, const char *token)
1.2 deraadt 299: {
300: int i;
301:
1.43 espie 302: assert((unsigned char)t == (unsigned char)token[0]);
1.2 deraadt 303:
304: for (i = 1; *++token; i++) {
305: t = gpbc();
1.43 espie 306: if (t == EOF || (unsigned char)t != (unsigned char)*token) {
1.68 espie 307: pushback(t);
1.2 deraadt 308: while (--i)
1.68 espie 309: pushback(*--token);
1.2 deraadt 310: return 0;
311: }
312: }
313: return 1;
314: }
315:
1.79 ! marco 316: #define LOOK_AHEAD(t, token) (t != EOF && \
! 317: (unsigned char)(t)==(unsigned char)(token)[0] && \
1.43 espie 318: do_look_ahead(t,token))
1.2 deraadt 319:
320: /*
1.1 deraadt 321: * macro - the work horse..
322: */
1.18 espie 323: static void
1.56 deraadt 324: macro(void)
1.17 espie 325: {
1.34 espie 326: char token[MAXTOK+1];
1.17 espie 327: int t, l;
328: ndptr p;
329: int nlpar;
1.1 deraadt 330:
331: cycle {
1.2 deraadt 332: t = gpbc();
1.68 espie 333:
334: if (LOOK_AHEAD(t,lquote)) { /* strip quotes */
335: nlpar = 0;
336: record(quotes, nlpar++);
337: /*
338: * Opening quote: scan forward until matching
339: * closing quote has been found.
340: */
341: do {
342:
343: l = gpbc();
344: if (LOOK_AHEAD(l,rquote)) {
345: if (--nlpar > 0)
346: outputstr(rquote);
347: } else if (LOOK_AHEAD(l,lquote)) {
348: record(quotes, nlpar++);
349: outputstr(lquote);
350: } else if (l == EOF) {
351: if (nlpar == 1)
352: warnx("unclosed quote:");
353: else
354: warnx("%d unclosed quotes:", nlpar);
355: dump_stack(quotes, nlpar);
356: exit(1);
357: } else {
358: if (nlpar > 0) {
359: if (sp < 0)
360: reallyputchar(l);
361: else
362: CHRSAVE(l);
363: }
364: }
365: }
366: while (nlpar != 0);
367: } else if (sp < 0 && LOOK_AHEAD(t, scommt)) {
368: reallyoutputstr(scommt);
369:
370: for(;;) {
371: t = gpbc();
372: if (LOOK_AHEAD(t, ecommt)) {
373: reallyoutputstr(ecommt);
374: break;
375: }
376: if (t == EOF)
377: break;
378: reallyputchar(t);
379: }
380: } else if (t == '_' || isalpha(t)) {
1.29 espie 381: p = inspect(t, token);
1.59 espie 382: if (p != NULL)
1.68 espie 383: pushback(l = gpbc());
1.79 ! marco 384: if (p == NULL || (l != LPAREN &&
1.59 espie 385: (macro_getdef(p)->type & NEEDARGS) != 0))
1.29 espie 386: outputstr(token);
1.1 deraadt 387: else {
388: /*
389: * real thing.. First build a call frame:
390: */
391: pushf(fp); /* previous call frm */
1.59 espie 392: pushf(macro_getdef(p)->type); /* type of the call */
1.63 espie 393: pushf(is_traced(p));
1.1 deraadt 394: pushf(0); /* parenthesis level */
395: fp = sp; /* new frame pointer */
396: /*
397: * now push the string arguments:
398: */
1.59 espie 399: pushs1(macro_getdef(p)->defn); /* defn string */
400: pushs1((char *)macro_name(p)); /* macro name */
1.79 ! marco 401: pushs(ep); /* start next..*/
1.1 deraadt 402:
1.79 ! marco 403: if (l != LPAREN && PARLEV == 0) {
1.41 espie 404: /* no bracks */
405: chrsave(EOS);
406:
407: if (sp == STACKMAX)
408: errx(1, "internal stack overflow");
1.79 ! marco 409: eval((const char **) mstack+fp+1, 2,
1.60 espie 410: CALTYP, TRACESTATUS);
1.41 espie 411:
412: ep = PREVEP; /* flush strspace */
413: sp = PREVSP; /* previous sp.. */
414: fp = PREVFP; /* rewind stack...*/
1.1 deraadt 415: }
416: }
1.41 espie 417: } else if (t == EOF) {
1.75 espie 418: if (sp > -1 && ilevel <= 0) {
1.27 espie 419: warnx( "unexpected end of input, unclosed parenthesis:");
420: dump_stack(paren, PARLEV);
421: exit(1);
422: }
1.1 deraadt 423: if (ilevel <= 0)
424: break; /* all done thanks.. */
1.26 espie 425: release_input(infile+ilevel--);
1.54 espie 426: emit_synchline();
1.1 deraadt 427: bufbase = bbase[ilevel];
428: continue;
1.68 espie 429: } else if (sp < 0) { /* not in a macro at all */
1.54 espie 430: reallyputchar(t); /* output directly.. */
1.1 deraadt 431: }
432:
433: else switch(t) {
434:
435: case LPAREN:
436: if (PARLEV > 0)
437: chrsave(t);
1.76 espie 438: while (isspace(l = gpbc())) /* skip blank, tab, nl.. */
439: if (PARLEV > 0)
440: chrsave(l);
1.68 espie 441: pushback(l);
1.27 espie 442: record(paren, PARLEV++);
1.1 deraadt 443: break;
444:
445: case RPAREN:
446: if (--PARLEV > 0)
447: chrsave(t);
448: else { /* end of argument list */
449: chrsave(EOS);
450:
451: if (sp == STACKMAX)
1.11 espie 452: errx(1, "internal stack overflow");
1.1 deraadt 453:
1.79 ! marco 454: eval((const char **) mstack+fp+1, sp-fp,
1.60 espie 455: CALTYP, TRACESTATUS);
1.1 deraadt 456:
457: ep = PREVEP; /* flush strspace */
458: sp = PREVSP; /* previous sp.. */
459: fp = PREVFP; /* rewind stack...*/
460: }
461: break;
462:
463: case COMMA:
464: if (PARLEV == 1) {
465: chrsave(EOS); /* new argument */
466: while (isspace(l = gpbc()))
467: ;
1.68 espie 468: pushback(l);
1.1 deraadt 469: pushs(ep);
470: } else
471: chrsave(t);
472: break;
473:
474: default:
1.22 espie 475: if (LOOK_AHEAD(t, scommt)) {
476: char *p;
477: for (p = scommt; *p; p++)
478: chrsave(*p);
479: for(;;) {
480: t = gpbc();
481: if (LOOK_AHEAD(t, ecommt)) {
482: for (p = ecommt; *p; p++)
483: chrsave(*p);
484: break;
485: }
486: if (t == EOF)
487: break;
1.48 espie 488: CHRSAVE(t);
1.22 espie 489: }
490: } else
1.48 espie 491: CHRSAVE(t); /* stack the char */
1.1 deraadt 492: break;
493: }
494: }
495: }
496:
1.79 ! marco 497: /*
! 498: * output string directly, without pushing it for reparses.
1.24 espie 499: */
500: void
1.53 espie 501: outputstr(const char *s)
1.24 espie 502: {
503: if (sp < 0)
1.54 espie 504: reallyoutputstr(s);
1.24 espie 505: else
506: while (*s)
1.48 espie 507: CHRSAVE(*s++);
1.24 espie 508: }
509:
1.54 espie 510: void
511: reallyoutputstr(const char *s)
512: {
513: if (synch_lines) {
514: while (*s) {
515: fputc(*s, active);
516: if (*s++ == '\n') {
517: infile[ilevel].synch_lineno++;
1.79 ! marco 518: if (infile[ilevel].synch_lineno !=
1.54 espie 519: infile[ilevel].lineno)
520: do_emit_synchline();
521: }
522: }
523: } else
524: fputs(s, active);
525: }
526:
527: void
528: reallyputchar(int c)
529: {
530: putc(c, active);
531: if (synch_lines && c == '\n') {
532: infile[ilevel].synch_lineno++;
533: if (infile[ilevel].synch_lineno != infile[ilevel].lineno)
534: do_emit_synchline();
535: }
536: }
537:
1.1 deraadt 538: /*
539: * build an input token..
1.79 ! marco 540: * consider only those starting with _ or A-Za-z.
1.1 deraadt 541: */
1.18 espie 542: static ndptr
1.79 ! marco 543: inspect(int c, char *tp)
1.1 deraadt 544: {
1.17 espie 545: char *name = tp;
546: char *etp = tp+MAXTOK;
547: ndptr p;
1.79 ! marco 548:
1.59 espie 549: *tp++ = c;
1.1 deraadt 550:
551: while ((isalnum(c = gpbc()) || c == '_') && tp < etp)
1.59 espie 552: *tp++ = c;
1.51 espie 553: if (c != EOF)
1.68 espie 554: PUSHBACK(c);
1.1 deraadt 555: *tp = EOS;
1.33 espie 556: /* token is too long, it won't match anything, but it can still
557: * be output. */
558: if (tp == ep) {
559: outputstr(name);
560: while (isalnum(c = gpbc()) || c == '_') {
561: if (sp < 0)
1.54 espie 562: reallyputchar(c);
1.33 espie 563: else
1.48 espie 564: CHRSAVE(c);
1.33 espie 565: }
566: *name = EOS;
1.59 espie 567: return NULL;
1.33 espie 568: }
1.1 deraadt 569:
1.63 espie 570: p = ohash_find(¯os, ohash_qlookupi(¯os, name, (const char **)&tp));
1.61 espie 571: if (p == NULL)
572: return NULL;
573: if (macro_getdef(p) == NULL)
574: return NULL;
575: return p;
1.1 deraadt 576: }
577:
578: /*
1.79 ! marco 579: * initkwds - initialise m4 keywords as fast as possible.
1.1 deraadt 580: * This very similar to install, but without certain overheads,
1.79 ! marco 581: * such as calling lookup. Malloc is not used for storing the
1.17 espie 582: * keyword strings, since we simply use the static pointers
1.1 deraadt 583: * within keywrds block.
584: */
1.18 espie 585: static void
1.56 deraadt 586: initkwds(void)
1.17 espie 587: {
1.59 espie 588: unsigned int type;
589: int i;
1.1 deraadt 590:
591: for (i = 0; i < MAXKEYS; i++) {
1.59 espie 592: type = keywrds[i].ktyp & TYPEMASK;
1.24 espie 593: if ((keywrds[i].ktyp & NOARGS) == 0)
1.59 espie 594: type |= NEEDARGS;
595: setup_builtin(keywrds[i].knam, type);
1.1 deraadt 596: }
1.45 espie 597: }
1.17 espie 598:
1.27 espie 599: static void
1.53 espie 600: record(struct position *t, int lev)
1.27 espie 601: {
602: if (lev < MAXRECORD) {
603: t[lev].name = CURRENT_NAME;
604: t[lev].line = CURRENT_LINE;
605: }
606: }
607:
608: static void
1.53 espie 609: dump_stack(struct position *t, int lev)
1.27 espie 610: {
611: int i;
612:
613: for (i = 0; i < lev; i++) {
614: if (i == MAXRECORD) {
615: fprintf(stderr, " ...\n");
616: break;
617: }
1.79 ! marco 618: fprintf(stderr, " %s at line %lu\n",
1.27 espie 619: t[i].name, t[i].line);
620: }
1.34 espie 621: }
622:
623:
1.79 ! marco 624: static void
1.56 deraadt 625: enlarge_stack(void)
1.34 espie 626: {
1.64 espie 627: STACKMAX += STACKMAX/2;
1.79 ! marco 628: mstack = xrealloc(mstack, sizeof(stae) * STACKMAX,
! 629: "Evaluation stack overflow (%lu)",
1.64 espie 630: (unsigned long)STACKMAX);
631: sstack = xrealloc(sstack, STACKMAX,
1.79 ! marco 632: "Evaluation stack overflow (%lu)",
1.64 espie 633: (unsigned long)STACKMAX);
1.27 espie 634: }