aboutsummaryrefslogtreecommitdiff
path: root/gcc/cpphash.c
diff options
context:
space:
mode:
authorZack Weinberg <zack@rabi.columbia.edu>1999-02-25 14:24:40 +0000
committerZack Weinberg <zack@gcc.gnu.org>1999-02-25 14:24:40 +0000
commit122ae89b144a0eaf31107f871f26ead27df8daad (patch)
tree6a70d45559c3b1a18fd0998b7705e78d86303259 /gcc/cpphash.c
parent9ab70a9bd7c8ee4fcf2f074459525e981ed1ca2e (diff)
downloadgcc-122ae89b144a0eaf31107f871f26ead27df8daad.zip
gcc-122ae89b144a0eaf31107f871f26ead27df8daad.tar.gz
gcc-122ae89b144a0eaf31107f871f26ead27df8daad.tar.bz2
cpphash.c (install): Rename to cpp_install, add cpp_reader* first argument.
1999-02-25 17:14 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cpphash.c (install): Rename to cpp_install, add cpp_reader* first argument. All callers changed. (hashtab): Removed. (cpp_lookup, cpp_install): Change all refs to hashtab to pfile->hashtab. (cpp_hash_cleanup): Removed. * cpphash.h: Adjust prototypes. * cpplib.h (struct cpp_reader): Add hashtab pointer. * cppinit.c (cpp_reader_init): Also allocate space for the hashtab. (cpp_cleanup): Delete all macros and free the hashtab. From-SVN: r25441
Diffstat (limited to 'gcc/cpphash.c')
-rw-r--r--gcc/cpphash.c29
1 files changed, 8 insertions, 21 deletions
diff --git a/gcc/cpphash.c b/gcc/cpphash.c
index a9061a9..0f95d8a 100644
--- a/gcc/cpphash.c
+++ b/gcc/cpphash.c
@@ -27,8 +27,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "cpplib.h"
#include "cpphash.h"
-static HASHNODE *hashtab[HASHSIZE];
-
static int comp_def_part PARAMS ((int, U_CHAR *, int, U_CHAR *,
int, int));
static int change_newlines PARAMS ((U_CHAR *, int));
@@ -104,7 +102,7 @@ hashf (name, len, hashsize)
}
/* Find the most recent hash node for name "name" (ending with first
- non-identifier char) installed by install
+ non-identifier char) installed by cpp_install
If LEN is >= 0, it is the length of the name.
Otherwise, compute the length by scanning the entire name.
@@ -131,7 +129,7 @@ cpp_lookup (pfile, name, len, hash)
if (hash < 0)
hash = hashf (name, len, HASHSIZE);
- bucket = hashtab[hash];
+ bucket = pfile->hashtab[hash];
while (bucket)
{
if (bucket->length == len && strncmp (bucket->name, name, len) == 0)
@@ -191,7 +189,7 @@ delete_macro (hp)
/* Install a name in the main hash table, even if it is already there.
Name stops with first non alphanumeric, except leading '#'.
Caller must check against redefinition if that is desired.
- delete_macro () removes things installed by install () in fifo order.
+ delete_macro () removes things installed by cpp_install () in fifo order.
this is important because of the `defined' special symbol used
in #if, and also if pushdef/popdef directives are ever implemented.
@@ -202,7 +200,8 @@ delete_macro (hp)
Otherwise, compute the hash code. */
HASHNODE *
-install (name, len, type, value, hash)
+cpp_install (pfile, name, len, type, value, hash)
+ cpp_reader *pfile;
U_CHAR *name;
int len;
enum node_type type;
@@ -227,9 +226,9 @@ install (name, len, type, value, hash)
i = sizeof (HASHNODE) + len + 1;
hp = (HASHNODE *) xmalloc (i);
bucket = hash;
- hp->bucket_hdr = &hashtab[bucket];
- hp->next = hashtab[bucket];
- hashtab[bucket] = hp;
+ hp->bucket_hdr = &pfile->hashtab[bucket];
+ hp->next = pfile->hashtab[bucket];
+ pfile->hashtab[bucket] = hp;
hp->prev = NULL;
if (hp->next != NULL)
hp->next->prev = hp;
@@ -242,18 +241,6 @@ install (name, len, type, value, hash)
return hp;
}
-void
-cpp_hash_cleanup (pfile)
- cpp_reader *pfile ATTRIBUTE_UNUSED;
-{
- register int i;
- for (i = HASHSIZE; --i >= 0;)
- {
- while (hashtab[i])
- delete_macro (hashtab[i]);
- }
-}
-
static int
macro_cleanup (pbuf, pfile)
cpp_buffer *pbuf;