version 1.21, 2009/10/14 17:23:17 |
version 1.22, 2010/09/07 19:58:09 |
|
|
static void *hash_alloc(size_t, void *); |
static void *hash_alloc(size_t, void *); |
static void hash_free(void *, size_t, void *); |
static void hash_free(void *, size_t, void *); |
static void *element_alloc(size_t, void *); |
static void *element_alloc(size_t, void *); |
static void setup_definition(struct macro_definition *, const char *, |
static void setup_definition(struct macro_definition *, const char *, |
const char *); |
const char *); |
|
|
static struct ohash_info macro_info = { |
static struct ohash_info macro_info = { |
|
|
void * |
void * |
hash_alloc(s, u) |
hash_alloc(s, u) |
size_t s; |
size_t s; |
void *u UNUSED; |
void *u UNUSED; |
{ |
{ |
void *storage = xalloc(s, "hash alloc"); |
void *storage = xalloc(s, "hash alloc"); |
if (storage) |
if (storage) |
|
|
hash_free(p, s, u) |
hash_free(p, s, u) |
void *p; |
void *p; |
size_t s UNUSED; |
size_t s UNUSED; |
void *u UNUSED; |
void *u UNUSED; |
{ |
{ |
free(p); |
free(p); |
} |
} |
|
|
void * |
void * |
element_alloc(s, u) |
element_alloc(s, u) |
size_t s; |
size_t s; |
void *u UNUSED; |
void *u UNUSED; |
{ |
{ |
return xalloc(s, "element alloc"); |
return xalloc(s, "element alloc"); |
} |
} |
|
|
/* |
/* |
* find name in the hash table |
* find name in the hash table |
*/ |
*/ |
ndptr |
ndptr |
lookup(const char *name) |
lookup(const char *name) |
{ |
{ |
return ohash_find(¯os, ohash_qlookup(¯os, name)); |
return ohash_find(¯os, ohash_qlookup(¯os, name)); |
|
|
return NULL; |
return NULL; |
} |
} |
|
|
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) |
{ |
{ |
ndptr p; |
ndptr p; |
|
|
{ |
{ |
ndptr n; |
ndptr n; |
struct macro_definition *d; |
struct macro_definition *d; |
|
|
n = create_entry(name); |
n = create_entry(name); |
d = xalloc(sizeof(struct macro_definition), NULL); |
d = xalloc(sizeof(struct macro_definition), NULL); |
d->next = n->d; |
d->next = n->d; |
|
|
ndptr n; |
ndptr n; |
unsigned int i; |
unsigned int i; |
|
|
for (n = ohash_first(¯os, &i); n != NULL; |
for (n = ohash_first(¯os, &i); n != NULL; |
n = ohash_next(¯os, &i)) |
n = ohash_next(¯os, &i)) |
if (n->d != NULL) |
if (n->d != NULL) |
f(n->name, n->d); |
f(n->name, n->d); |
} |
} |
|
|
void |
void |
setup_builtin(const char *name, unsigned int type) |
setup_builtin(const char *name, unsigned int type) |
{ |
{ |
ndptr n; |
ndptr n; |
|
|
trace_flags |= TRACE_ALL; |
trace_flags |= TRACE_ALL; |
else |
else |
trace_flags &= ~TRACE_ALL; |
trace_flags &= ~TRACE_ALL; |
for (p = ohash_first(¯os, &i); p != NULL; |
for (p = ohash_first(¯os, &i); p != NULL; |
p = ohash_next(¯os, &i)) |
p = ohash_next(¯os, &i)) |
p->trace_flags = FLAG_NO_TRACE; |
p->trace_flags = FLAG_NO_TRACE; |
} else { |
} else { |
p = create_entry(name); |
p = create_entry(name); |
p->trace_flags = on; |
p->trace_flags = on; |
} |
} |
} |
} |
|
|
ndptr |
ndptr |
macro_getbuiltin(const char *name) |
macro_getbuiltin(const char *name) |
{ |
{ |
ndptr p; |
ndptr p; |
|
|
else |
else |
return p; |
return p; |
} |
} |
|
|