summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2003-06-30 21:47:22 +0000
committerMarc Espie <espie@cvs.openbsd.org>2003-06-30 21:47:22 +0000
commit06c9ed6564f8bbc0056658a983d379052179aa86 (patch)
treee2c1a9ac42503c1580f5acf99ef39fea3d6c8df4 /usr.bin
parent6947789365296ced45fe71914dfebf93e2dd8934 (diff)
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@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/m4/eval.c8
-rw-r--r--usr.bin/m4/extern.h4
-rw-r--r--usr.bin/m4/gnum4.c7
-rw-r--r--usr.bin/m4/main.c12
-rw-r--r--usr.bin/m4/mdef.h9
-rw-r--r--usr.bin/m4/trace.c4
6 files changed, 25 insertions, 19 deletions
diff --git a/usr.bin/m4/eval.c b/usr.bin/m4/eval.c
index 4d427b8c94d..8e06bc9468f 100644
--- a/usr.bin/m4/eval.c
+++ b/usr.bin/m4/eval.c
@@ -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);
diff --git a/usr.bin/m4/extern.h b/usr.bin/m4/extern.h
index a00dad4b057..d7477cdff94 100644
--- a/usr.bin/m4/extern.h
+++ b/usr.bin/m4/extern.h
@@ -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;
diff --git a/usr.bin/m4/gnum4.c b/usr.bin/m4/gnum4.c
index 8a2c7977212..4b39253c042 100644
--- a/usr.bin/m4/gnum4.c
+++ b/usr.bin/m4/gnum4.c
@@ -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]);
}
diff --git a/usr.bin/m4/main.c b/usr.bin/m4/main.c
index d0e0e64286c..5a814d2e46c 100644
--- a/usr.bin/m4/main.c
+++ b/usr.bin/m4/main.c
@@ -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.. */
diff --git a/usr.bin/m4/mdef.h b/usr.bin/m4/mdef.h
index 5e3ca2d33ee..8ba892dc3e4 100644
--- a/usr.bin/m4/mdef.h
+++ b/usr.bin/m4/mdef.h
@@ -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)
diff --git a/usr.bin/m4/trace.c b/usr.bin/m4/trace.c
index 7d3ef6022d2..5d53d4f71c7 100644
--- a/usr.bin/m4/trace.c
+++ b/usr.bin/m4/trace.c
@@ -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;
}