diff options
author | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-10-14 23:04:13 +0000 |
---|---|---|
committer | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-10-14 23:04:13 +0000 |
commit | 5c43d212287dee84f71ab59d9c6438b643804f6d (patch) | |
tree | 14a7ba0c8a56918c072c9ebed2d40886baf5a592 | |
parent | c6f14ce52167542dfba3cae637d4db1cf2dae66a (diff) | |
download | gcc-5c43d212287dee84f71ab59d9c6438b643804f6d.tar.gz |
* cpplib.c (struct pragma_entry): Store the name as a hashnode.
(lookup_pragma_entry, insert_pragma_entry, do_pragma,
cpp_register_pragma): Update accordingly.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@46255 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cpplib.c | 46 |
2 files changed, 26 insertions, 26 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4bddb844139..d765745266d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2001-10-15 Neil Booth <neil@daikokuya.demon.co.uk> + + * cpplib.c (struct pragma_entry): Store the name as a hashnode. + (lookup_pragma_entry, insert_pragma_entry, do_pragma, + cpp_register_pragma): Update accordingly. + 2001-10-14 Neil Booth <neil@daikokuya.demon.co.uk> * c-pragma.h (cpp_register_pragma_space): Remove. diff --git a/gcc/cpplib.c b/gcc/cpplib.c index 9aab392c642..093c9dc806f 100644 --- a/gcc/cpplib.c +++ b/gcc/cpplib.c @@ -52,8 +52,7 @@ typedef void (*pragma_cb) PARAMS ((cpp_reader *)); struct pragma_entry { struct pragma_entry *next; - const char *name; - size_t len; + const cpp_hashnode *pragma; /* Name and length. */ int is_nspace; union { pragma_cb handler; @@ -111,9 +110,10 @@ static void do_diagnostic PARAMS ((cpp_reader *, enum error_type, int)); static cpp_hashnode *lex_macro_node PARAMS ((cpp_reader *)); static void do_include_common PARAMS ((cpp_reader *, enum include_type)); static struct pragma_entry *lookup_pragma_entry - PARAMS ((struct pragma_entry *, const char *pragma)); + PARAMS ((struct pragma_entry *, const cpp_hashnode *pragma)); static struct pragma_entry *insert_pragma_entry - PARAMS ((cpp_reader *, struct pragma_entry **, const char *, pragma_cb)); + PARAMS ((cpp_reader *, struct pragma_entry **, const cpp_hashnode *, + pragma_cb)); static void do_pragma_once PARAMS ((cpp_reader *)); static void do_pragma_poison PARAMS ((cpp_reader *)); static void do_pragma_system_header PARAMS ((cpp_reader *)); @@ -866,16 +866,10 @@ do_ident (pfile) static struct pragma_entry * lookup_pragma_entry (chain, pragma) struct pragma_entry *chain; - const char *pragma; + const cpp_hashnode *pragma; { - size_t len = strlen (pragma); - - while (chain) - { - if (chain->len == len && !memcmp (chain->name, pragma, len)) - break; - chain = chain->next; - } + while (chain && chain->pragma != pragma) + chain = chain->next; return chain; } @@ -884,18 +878,17 @@ lookup_pragma_entry (chain, pragma) singly-linked CHAIN. If handler is NULL, it is a namespace, otherwise it is a pragma and its handler. */ static struct pragma_entry * -insert_pragma_entry (pfile, chain, name, handler) +insert_pragma_entry (pfile, chain, pragma, handler) cpp_reader *pfile; struct pragma_entry **chain; - const char *name; + const cpp_hashnode *pragma; pragma_cb handler; { struct pragma_entry *new; new = (struct pragma_entry *) _cpp_aligned_alloc (pfile, sizeof (struct pragma_entry)); - new->name = name; - new->len = strlen (name); + new->pragma = pragma; if (handler) { new->is_nspace = 0; @@ -924,36 +917,39 @@ cpp_register_pragma (pfile, space, name, handler) { struct pragma_entry **chain = &pfile->pragmas; struct pragma_entry *entry; + const cpp_hashnode *node; if (!handler) abort (); if (space) { - entry = lookup_pragma_entry (*chain, space); + node = cpp_lookup (pfile, U space, strlen (space)); + entry = lookup_pragma_entry (*chain, node); if (!entry) - entry = insert_pragma_entry (pfile, chain, space, NULL); + entry = insert_pragma_entry (pfile, chain, node, NULL); else if (!entry->is_nspace) goto clash; chain = &entry->u.space; } /* Check for duplicates. */ - entry = lookup_pragma_entry (*chain, name); + node = cpp_lookup (pfile, U name, strlen (name)); + entry = lookup_pragma_entry (*chain, node); if (entry) { if (entry->is_nspace) clash: cpp_ice (pfile, "registering \"%s\" as both a pragma and a pragma namespace", - entry->name); + NODE_NAME (node)); else if (space) cpp_ice (pfile, "#pragma %s %s is already registered", space, name); else cpp_ice (pfile, "#pragma %s is already registered", name); } else - insert_pragma_entry (pfile, chain, name, handler); + insert_pragma_entry (pfile, chain, node, handler); } /* Register the pragmas the preprocessor itself handles. */ @@ -989,15 +985,13 @@ do_pragma (pfile) token = cpp_get_token (pfile); if (token->type == CPP_NAME) { - p = lookup_pragma_entry (pfile->pragmas, - (char *) NODE_NAME (token->val.node)); + p = lookup_pragma_entry (pfile->pragmas, token->val.node); if (p && p->is_nspace) { count = 2; token = cpp_get_token (pfile); if (token->type == CPP_NAME) - p = lookup_pragma_entry (p->u.space, - (char *) NODE_NAME (token->val.node)); + p = lookup_pragma_entry (p->u.space, token->val.node); else p = NULL; } |