diff options
author | Zack Weinberg <zack@gcc.gnu.org> | 2000-03-28 21:45:02 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2000-03-28 21:45:02 +0000 |
commit | 29a72a4f09d8606f1414e5380c5eeb2ad5fc6737 (patch) | |
tree | ed8035556cbbe82211a22a58d3beaeef00e865d0 /gcc/cppfiles.c | |
parent | 1e9d75e87b82126fc5249149e5e85f2f1f308eea (diff) | |
download | gcc-29a72a4f09d8606f1414e5380c5eeb2ad5fc6737.zip gcc-29a72a4f09d8606f1414e5380c5eeb2ad5fc6737.tar.gz gcc-29a72a4f09d8606f1414e5380c5eeb2ad5fc6737.tar.bz2 |
cppfiles.c (hash_IHASH): Just return i->hash.
2000-03-28 Zack Weinberg <zack@wolery.cumb.org>
* cppfiles.c (hash_IHASH): Just return i->hash.
(cpp_included): Set dummy.hash using _cpp_calc_hash. Use
htab_find_with_hash.
(cpp_read_file): Likewise.
(find_include_file): Likewise. Properly initialize
ih->nshort. Share ih->name and ih->nshort if possible.
* cpphash.c (_cpp_calc_hash): New function.
(hash_HASHNODE): Just return h->hash.
(_cpp_lookup): Set dummy.hash using _cpp_calc_hash. Use
htab_find_with_hash.
* cpphash.h: Prototype _cpp_calc_hash.
* cppinit.c (initialize_builtins): Provide a valid hash
to _cpp_make_hashnode, using _cpp_calc_hash.
* cpphash.c (collect_expansion): # is not a special character
in object-like macros. In -traditional mode, /**/ is not
token paste at the beginning or end of the line.
* cpplib.c (do_include, do_import, do_include_next): If
parse_include fails, return immediately.
From-SVN: r32792
Diffstat (limited to 'gcc/cppfiles.c')
-rw-r--r-- | gcc/cppfiles.c | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/gcc/cppfiles.c b/gcc/cppfiles.c index bc137a9..f46052e 100644 --- a/gcc/cppfiles.c +++ b/gcc/cppfiles.c @@ -66,18 +66,8 @@ static unsigned int hash_IHASH (x) const void *x; { - IHASH *i = (IHASH *)x; - unsigned int r = 0, len = 0; - const U_CHAR *s = i->nshort; - - if (i->hash != (unsigned long)-1) - return i->hash; - - do - len++, r = r * 67 + (*s++ - 113); - while (*s && *s != '.'); - i->hash = r + len; - return r + len; + const IHASH *i = (const IHASH *)x; + return i->hash; } /* Compare an existing IHASH structure with a potential one. */ @@ -158,8 +148,9 @@ cpp_included (pfile, fname) { IHASH dummy, *ptr; dummy.nshort = fname; - dummy.hash = -1; - ptr = htab_find (pfile->all_include_files, (const void *)&dummy); + dummy.hash = _cpp_calc_hash (fname, strlen (fname)); + ptr = htab_find_with_hash (pfile->all_include_files, + (const void *)&dummy, dummy.hash); return (ptr != NULL); } @@ -219,11 +210,12 @@ find_include_file (pfile, fname, search_start, ihash, before) int f; char *name; - dummy.hash = -1; dummy.nshort = fname; + dummy.hash = _cpp_calc_hash (fname, strlen (fname)); path = (fname[0] == '/') ? ABSOLUTE_PATH : search_start; - slot = (IHASH **) htab_find_slot (pfile->all_include_files, - (const void *)&dummy, 1); + slot = (IHASH **) htab_find_slot_with_hash (pfile->all_include_files, + (const void *)&dummy, + dummy.hash, 1); if (*slot && (ih = redundant_include_p (pfile, *slot, path))) { @@ -280,10 +272,20 @@ find_include_file (pfile, fname, search_start, ihash, before) } else { - ih = (IHASH *) xmalloc (sizeof (IHASH) + strlen (name) - + strlen (fname) + 1); - ih->nshort = ih->name + strlen (fname) + 1; - strcpy ((char *)ih->nshort, fname); + char *s; + + if ((s = strstr (name, fname)) != NULL) + { + ih = (IHASH *) xmalloc (sizeof (IHASH) + strlen (name)); + ih->nshort = ih->name + (s - name); + } + else + { + ih = (IHASH *) xmalloc (sizeof (IHASH) + strlen (name) + + strlen (fname) + 1); + ih->nshort = ih->name + strlen (name) + 1; + strcpy ((char *)ih->nshort, fname); + } } strcpy ((char *)ih->name, name); ih->foundhere = path; @@ -620,10 +622,11 @@ cpp_read_file (pfile, fname) if (fname == NULL) fname = ""; - dummy.hash = -1; dummy.nshort = fname; - slot = (IHASH **) htab_find_slot (pfile->all_include_files, - (const void *) &dummy, 1); + dummy.hash = _cpp_calc_hash (fname, strlen (fname)); + slot = (IHASH **) htab_find_slot_with_hash (pfile->all_include_files, + (const void *) &dummy, + dummy.hash, 1); if (*slot && (ih = redundant_include_p (pfile, *slot, ABSOLUTE_PATH))) { if (ih == (IHASH *)-1) |