version 1.13, 2003/06/30 22:10:21 |
version 1.14, 2003/06/30 22:11:38 |
|
|
#include "extern.h" |
#include "extern.h" |
|
|
struct ndblock { /* hashtable structure */ |
struct ndblock { /* hashtable structure */ |
|
unsigned int builtin_type; |
struct macro_definition *d; |
struct macro_definition *d; |
char name[1]; /* entry name.. */ |
char name[1]; /* entry name.. */ |
}; |
}; |
|
|
static void |
static void |
setup_definition(struct macro_definition *d, const char *defn, const char *name) |
setup_definition(struct macro_definition *d, const char *defn, const char *name) |
{ |
{ |
int n; |
ndptr p; |
|
|
if (strncmp(defn, BUILTIN_MARKER, sizeof(BUILTIN_MARKER)-1) == 0 && |
if (strncmp(defn, BUILTIN_MARKER, sizeof(BUILTIN_MARKER)-1) == 0 && |
(n = builtin_type(defn+sizeof(BUILTIN_MARKER)-1)) != -1) { |
(p = macro_getbuiltin(defn+sizeof(BUILTIN_MARKER)-1)) != NULL) { |
d->type = n & TYPEMASK; |
d->type = macro_builtin_type(p); |
if ((n & NOARGS) == 0) |
|
d->type |= NEEDARGS; |
|
d->defn = xstrdup(defn+sizeof(BUILTIN_MARKER)-1); |
d->defn = xstrdup(defn+sizeof(BUILTIN_MARKER)-1); |
} else { |
} else { |
if (!*defn) |
if (!*defn) |
|
|
if (n == NULL) { |
if (n == NULL) { |
n = ohash_create_entry(¯o_info, name, &end); |
n = ohash_create_entry(¯o_info, name, &end); |
ohash_insert(¯os, i, n); |
ohash_insert(¯os, i, n); |
|
n->builtin_type = MACRTYPE; |
n->d = NULL; |
n->d = NULL; |
} |
} |
return n; |
return n; |
|
|
ndptr n; |
ndptr n; |
|
|
n = create_entry(name); |
n = create_entry(name); |
|
n->builtin_type = type; |
n->d = xalloc(sizeof(struct macro_definition)); |
n->d = xalloc(sizeof(struct macro_definition)); |
n->d->defn = xstrdup(name); |
n->d->defn = xstrdup(name); |
n->d->type = type; |
n->d->type = type; |
|
|
{ |
{ |
return p->d; |
return p->d; |
} |
} |
|
|
|
ndptr |
|
macro_getbuiltin(const char *name) |
|
{ |
|
ndptr p; |
|
|
|
p = lookup(name); |
|
if (p == NULL || p->builtin_type == MACRTYPE) |
|
return NULL; |
|
else |
|
return p; |
|
} |
|
|
|
int |
|
macro_builtin_type(ndptr p) |
|
{ |
|
return p->builtin_type; |
|
} |
|
|