1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-10 06:47:55 -08:00

Make the trace status of a macro an actual argument that gets pushed

in the frame for the macro expansion.

(This will allow one single lookup to grab the macro definition and
the trace status)

okay millert@
This commit is contained in:
espie 2003-06-30 21:47:21 +00:00
parent 3509e8ffae
commit dde05c5fe1
6 changed files with 25 additions and 19 deletions

View File

@ -1,4 +1,4 @@
/* $OpenBSD: eval.c,v 1.49 2003/06/30 21:42:50 espie Exp $ */
/* $OpenBSD: eval.c,v 1.50 2003/06/30 21:47:21 espie Exp $ */
/* $NetBSD: eval.c,v 1.7 1996/11/10 21:21:29 pk Exp $ */
/*
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)eval.c 8.2 (Berkeley) 4/27/95";
#else
static char rcsid[] = "$OpenBSD: eval.c,v 1.49 2003/06/30 21:42:50 espie Exp $";
static char rcsid[] = "$OpenBSD: eval.c,v 1.50 2003/06/30 21:47:21 espie Exp $";
#endif
#endif /* not lint */
@ -103,7 +103,7 @@ unsigned long expansion_id;
* argc is 3 for macro-or-builtin() and 2 for macro-or-builtin
*/
void
eval(const char *argv[], int argc, int td)
eval(const char *argv[], int argc, int td, int is_traced)
{
ssize_t mark = -1;
@ -111,7 +111,7 @@ eval(const char *argv[], int argc, int td)
if (td & RECDEF)
errx(1, "%s at line %lu: expanding recursive definition for %s",
CURRENT_NAME, CURRENT_LINE, argv[1]);
if (traced_macros && is_traced(argv[1]))
if (is_traced)
mark = trace(argv, argc, infile+ilevel);
if (td == MACRTYPE)
expand_macro(argv, argc);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: extern.h,v 1.34 2003/06/30 21:42:50 espie Exp $ */
/* $OpenBSD: extern.h,v 1.35 2003/06/30 21:47:21 espie Exp $ */
/* $NetBSD: extern.h,v 1.3 1996/01/13 23:25:24 pk Exp $ */
/*-
@ -36,7 +36,7 @@
*/
/* eval.c */
extern void eval(const char *[], int, int);
extern void eval(const char *[], int, int, int);
extern void dodefine(const char *, const char *);
extern unsigned long expansion_id;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: gnum4.c,v 1.22 2003/06/30 21:42:50 espie Exp $ */
/* $OpenBSD: gnum4.c,v 1.23 2003/06/30 21:47:21 espie Exp $ */
/*
* Copyright (c) 1999 Marc Espie
@ -165,7 +165,8 @@ doindir(const char *argv[], int argc)
if (p == NULL)
errx(1, "undefined macro %s", argv[2]);
argv[1] = p->defn;
eval(argv+1, argc-1, p->type);
eval(argv+1, argc-1, p->type, traced_macros && is_traced(argv[2]));
}
void
@ -175,7 +176,7 @@ dobuiltin(const char *argv[], int argc)
argv[1] = NULL;
n = builtin_type(argv[2]);
if (n != -1)
eval(argv+1, argc-1, n);
eval(argv+1, argc-1, n, traced_macros && is_traced(argv[2]));
else
errx(1, "unknown builtin %s", argv[2]);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: main.c,v 1.59 2003/06/30 21:42:50 espie Exp $ */
/* $OpenBSD: main.c,v 1.60 2003/06/30 21:47:21 espie Exp $ */
/* $NetBSD: main.c,v 1.12 1997/02/08 23:54:49 cgd Exp $ */
/*-
@ -43,7 +43,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$OpenBSD: main.c,v 1.59 2003/06/30 21:42:50 espie Exp $";
static char rcsid[] = "$OpenBSD: main.c,v 1.60 2003/06/30 21:47:21 espie Exp $";
#endif
#endif /* not lint */
@ -328,6 +328,10 @@ macro(void)
*/
pushf(fp); /* previous call frm */
pushf(macro_getdef(p)->type); /* type of the call */
if (traced_macros && is_traced(macro_name(p)))
pushf(1);
else
pushf(0);
pushf(0); /* parenthesis level */
fp = sp; /* new frame pointer */
/*
@ -344,7 +348,7 @@ macro(void)
if (sp == STACKMAX)
errx(1, "internal stack overflow");
eval((const char **) mstack+fp+1, 2,
CALTYP);
CALTYP, TRACESTATUS);
ep = PREVEP; /* flush strspace */
sp = PREVSP; /* previous sp.. */
@ -443,7 +447,7 @@ macro(void)
errx(1, "internal stack overflow");
eval((const char **) mstack+fp+1, sp-fp,
CALTYP);
CALTYP, TRACESTATUS);
ep = PREVEP; /* flush strspace */
sp = PREVSP; /* previous sp.. */

View File

@ -1,4 +1,4 @@
/* $OpenBSD: mdef.h,v 1.25 2003/06/30 21:42:50 espie Exp $ */
/* $OpenBSD: mdef.h,v 1.26 2003/06/30 21:47:21 espie Exp $ */
/* $NetBSD: mdef.h,v 1.7 1996/01/13 23:25:27 pk Exp $ */
/*
@ -217,7 +217,8 @@ struct input_file {
*
*/
#define PARLEV (mstack[fp].sfra)
#define CALTYP (mstack[fp-1].sfra)
#define CALTYP (mstack[fp-2].sfra)
#define TRACESTATUS (mstack[fp-1].sfra)
#define PREVEP (mstack[fp+3].sstr)
#define PREVSP (fp-3)
#define PREVFP (mstack[fp-2].sfra)
#define PREVSP (fp-4)
#define PREVFP (mstack[fp-3].sfra)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: trace.c,v 1.7 2003/06/12 14:36:43 espie Exp $ */
/* $OpenBSD: trace.c,v 1.8 2003/06/30 21:47:21 espie Exp $ */
/*
* Copyright (c) 2001 Marc Espie.
*
@ -223,7 +223,7 @@ frame_level()
int framep;
for (framep = fp, level = 0; framep != 0;
level++,framep = mstack[framep-2].sfra)
level++,framep = mstack[framep-3].sfra)
;
return level;
}