summaryrefslogtreecommitdiff
path: root/usr.bin/m4/eval.c
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2001-09-18 14:05:15 +0000
committerMarc Espie <espie@cvs.openbsd.org>2001-09-18 14:05:15 +0000
commit779b7e3be33bf4c3f3cb805e8fa235bd673b3bcd (patch)
treef8743400a81b0b2f3a3dc566e6fb305b13692470 /usr.bin/m4/eval.c
parentee720c75bb5d9023ecb5904e05fd1c3308386f72 (diff)
let defn(builtin) work enough so that
define(`newmacro', defn(builtin)) will work, as it should.
Diffstat (limited to 'usr.bin/m4/eval.c')
-rw-r--r--usr.bin/m4/eval.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/usr.bin/m4/eval.c b/usr.bin/m4/eval.c
index c56d1c8bad1..ee4265f5d2e 100644
--- a/usr.bin/m4/eval.c
+++ b/usr.bin/m4/eval.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: eval.c,v 1.30 2001/09/18 13:52:58 espie Exp $ */
+/* $OpenBSD: eval.c,v 1.31 2001/09/18 14:05:14 espie Exp $ */
/* $NetBSD: eval.c,v 1.7 1996/11/10 21:21:29 pk Exp $ */
/*
@@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)eval.c 8.2 (Berkeley) 4/27/95";
#else
-static char rcsid[] = "$OpenBSD: eval.c,v 1.30 2001/09/18 13:52:58 espie Exp $";
+static char rcsid[] = "$OpenBSD: eval.c,v 1.31 2001/09/18 14:05:14 espie Exp $";
#endif
#endif /* not lint */
@@ -65,6 +65,8 @@ static char rcsid[] = "$OpenBSD: eval.c,v 1.30 2001/09/18 13:52:58 espie Exp $";
#include "extern.h"
#include "pathnames.h"
+#define BUILTIN_MARKER "__builtin_"
+
static void dodefn __P((const char *));
static void dopushdef __P((const char *, const char *));
static void dodump __P((const char *[], int));
@@ -544,6 +546,7 @@ dodefine(name, defn)
const char *defn;
{
ndptr p;
+ int n;
if (!*name)
errx(1, "%s at line %lu: null definition.", CURRENT_NAME,
@@ -552,6 +555,14 @@ dodefine(name, defn)
p = addent(name);
else if (p->defn != null)
free((char *) p->defn);
+ if (strncmp(defn, BUILTIN_MARKER, sizeof(BUILTIN_MARKER)-1) == 0) {
+ n = builtin_type(defn+sizeof(BUILTIN_MARKER)-1);
+ if (n != -1) {
+ p->type = n;
+ p->defn = null;
+ return;
+ }
+ }
if (!*defn)
p->defn = null;
else
@@ -570,11 +581,17 @@ dodefn(name)
const char *name;
{
ndptr p;
+ char *real;
- if ((p = lookup(name)) != nil && p->defn != null) {
+ if ((p = lookup(name)) != nil) {
+ if (p->defn != null) {
pbstr(rquote);
pbstr(p->defn);
pbstr(lquote);
+ } else if ((real = builtin_realname(p->type)) != NULL) {
+ pbstr(real);
+ pbstr(BUILTIN_MARKER);
+ }
}
}