mirror of
https://github.com/openbsd/src.git
synced 2025-01-10 06:47:55 -08:00
let defn(builtin) work enough so that
define(`newmacro', defn(builtin)) will work, as it should.
This commit is contained in:
parent
19a9603ec3
commit
f8b42d480d
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: extern.h,v 1.22 2001/09/18 13:52:58 espie Exp $ */
|
||||
/* $OpenBSD: extern.h,v 1.23 2001/09/18 14:05:14 espie Exp $ */
|
||||
/* $NetBSD: extern.h,v 1.3 1996/01/13 23:25:24 pk Exp $ */
|
||||
|
||||
/*-
|
||||
@ -69,6 +69,7 @@ extern void remhash __P((const char *, int));
|
||||
/* main.c */
|
||||
extern void outputstr __P((const char *));
|
||||
extern int builtin_type __P((const char *));
|
||||
extern char *builtin_realname __P((int));
|
||||
|
||||
/* misc.c */
|
||||
extern void chrsave __P((int));
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: main.c,v 1.44 2001/09/18 13:52:58 espie Exp $ */
|
||||
/* $OpenBSD: main.c,v 1.45 2001/09/18 14:05:14 espie Exp $ */
|
||||
/* $NetBSD: main.c,v 1.12 1997/02/08 23:54:49 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
@ -47,7 +47,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.44 2001/09/18 13:52:58 espie Exp $";
|
||||
static char rcsid[] = "$OpenBSD: main.c,v 1.45 2001/09/18 14:05:14 espie Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -574,6 +574,17 @@ builtin_type(key)
|
||||
return -1;
|
||||
}
|
||||
|
||||
char *
|
||||
builtin_realname(n)
|
||||
int n;
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i != MAXKEYS; i++)
|
||||
if (((keywrds[i].ktyp ^ n) & TYPEMASK) == 0)
|
||||
return keywrds[i].knam;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
record(t, lev)
|
||||
|
Loading…
Reference in New Issue
Block a user