aboutsummaryrefslogtreecommitdiff
path: root/libcpp/symtab.c
diff options
context:
space:
mode:
authorZack Weinberg <zack@gcc.gnu.org>2004-06-05 20:58:06 +0000
committerZack Weinberg <zack@gcc.gnu.org>2004-06-05 20:58:06 +0000
commitc6e8380069ff630939beec0b5872a37f5b710189 (patch)
treef9776b653c83d7c1faa17b330fe162333d109cc2 /libcpp/symtab.c
parentdbeff3e56d566719bb3f0c1ba29362d61fe3ff85 (diff)
downloadgcc-c6e8380069ff630939beec0b5872a37f5b710189.zip
gcc-c6e8380069ff630939beec0b5872a37f5b710189.tar.gz
gcc-c6e8380069ff630939beec0b5872a37f5b710189.tar.bz2
Makefile.am: Add makedepend.
libcpp: * Makefile.am: Add makedepend. * Makefile.in, aclocal.m4: Regenerate. * charset.c: Insert a space to avoid a warning. * directives.c: Include mkdeps.h. (_cpp_handle_directive): Reenable macro expander if appropriate. (undefine_macros): Inline body of _cpp_free_definition for speed. Do not call undef callback or _cpp_warn_if_unused_macro. (cpp_get_deps): New interface. * files.c (search_cache): Add pfile argument. Check for file that would be found by "" or <> search here... (_cpp_find_file): ...not here. Correct recorded start_dir of files found by directory-of-current-file search that would be found by "" or <> search. * init.c (cpp_add_dependency_target): Delete. * internal.h (struct lexer_state): Add discarding_output flag. * lex.c (lex_identifier): Compute hash function while scanning. * macro.c (cpp_scan_nooutput): Disable macro expansion outside directives. * makedepend.c: New file. * mkdeps.c (struct deps): Add vpath vector. (apply_vpath, deps_add_vpath): New function. (deps_free): Free vpath vector. (deps_add_dep, deps_add_target): Use apply_vpath. * symtab.c (calc_hash): Use HT_HASHSTEP and HT_FINISH. (ht_lookup_with_hash): New function. * cpplib.h, mkdeps.h: Update prototypes. * symtab.h: Update prototypes. (HT_HASHSTEP, HT_FINISH): New macros. gcc: * Makefile.in (MKDEPS_H): New shorthand. (c-opts.o): Update dependencies. * c-opts.c: Include mkdeps.h. (handle_deferred_opts): Use cpp_get_deps and deps_add_target, not cpp_add_dependency_target. From-SVN: r82654
Diffstat (limited to 'libcpp/symtab.c')
-rw-r--r--libcpp/symtab.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/libcpp/symtab.c b/libcpp/symtab.c
index c80dfa2..9b2e0f1 100644
--- a/libcpp/symtab.c
+++ b/libcpp/symtab.c
@@ -41,13 +41,11 @@ calc_hash (const unsigned char *str, size_t len)
{
size_t n = len;
unsigned int r = 0;
-#define HASHSTEP(r, c) ((r) * 67 + ((c) - 113));
while (n--)
- r = HASHSTEP (r, *str++);
+ r = HT_HASHSTEP (r, *str++);
- return r + len;
-#undef HASHSTEP
+ return HT_HASHFINISH (r, len);
}
/* Initialize an identifier hashtable. */
@@ -96,7 +94,15 @@ hashnode
ht_lookup (hash_table *table, const unsigned char *str, size_t len,
enum ht_lookup_option insert)
{
- unsigned int hash = calc_hash (str, len);
+ return ht_lookup_with_hash (table, str, len, calc_hash (str, len),
+ insert);
+}
+
+hashnode
+ht_lookup_with_hash (hash_table *table, const unsigned char *str,
+ size_t len, unsigned int hash,
+ enum ht_lookup_option insert)
+{
unsigned int hash2;
unsigned int index;
size_t sizemask;