gdb/
[deliverable/binutils-gdb.git] / gdb / dictionary.c
index 4f18e8c017962390a7a2f051baa91a447b3e1e3b..8142d291bea1a3156a4aee1a15f3fa4eca421433 100644 (file)
@@ -1,6 +1,7 @@
 /* Routines for name->symbol lookups in GDB.
    
-   Copyright (C) 2003, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2007, 2008, 2009, 2010, 2011
+   Free Software Foundation, Inc.
 
    Contributed by David Carlton <carlton@bactrian.org> and by Kealia,
    Inc.
@@ -82,9 +83,7 @@
 
    * Define a function dict_<op> that looks up <op> in the dict_vector
    and calls the appropriate function.  Add a declaration for
-   dict_<op> to dictionary.h.
-   
-*/
+   dict_<op> to dictionary.h.  */
 
 /* An enum representing the various implementations of dictionaries.
    Used only for debugging.  */
@@ -118,13 +117,11 @@ struct dict_vector
   struct symbol *(*iterator_next) (struct dict_iterator *iterator);
   /* Functions to iterate over symbols with a given name.  */
   struct symbol *(*iter_match_first) (const struct dictionary *dict,
-                                    const char *name,
-                                    int (*equiv) (const char *,
-                                                  const char *),
-                                    struct dict_iterator *iterator);
+                                     const char *name,
+                                     symbol_compare_ftype *equiv,
+                                     struct dict_iterator *iterator);
   struct symbol *(*iter_match_next) (const char *name,
-                                    int (*equiv) (const char *,
-                                                  const char *),
+                                    symbol_compare_ftype *equiv,
                                     struct dict_iterator *iterator);
   /* A size function, for maint print symtabs.  */
   int (*size) (const struct dictionary *dict);
@@ -243,13 +240,11 @@ static struct symbol *iterator_next_hashed (struct dict_iterator *iterator);
 
 static struct symbol *iter_match_first_hashed (const struct dictionary *dict,
                                               const char *name,
-                                              int (*compare) (const char *,
-                                                              const char *),
+                                              symbol_compare_ftype *compare,
                                              struct dict_iterator *iterator);
 
 static struct symbol *iter_match_next_hashed (const char *name,
-                                             int (*compare) (const char *,
-                                                             const char *),
+                                             symbol_compare_ftype *compare,
                                              struct dict_iterator *iterator);
 
 static unsigned int dict_hash (const char *string);
@@ -277,13 +272,11 @@ static struct symbol *iterator_next_linear (struct dict_iterator *iterator);
 
 static struct symbol *iter_match_first_linear (const struct dictionary *dict,
                                               const char *name,
-                                              int (*compare) (const char *,
-                                                              const char *),
+                                              symbol_compare_ftype *compare,
                                               struct dict_iterator *iterator);
 
 static struct symbol *iter_match_next_linear (const char *name,
-                                             int (*compare) (const char *,
-                                                             const char *),
+                                             symbol_compare_ftype *compare,
                                              struct dict_iterator *iterator);
 
 static int size_linear (const struct dictionary *dict);
@@ -542,16 +535,15 @@ dict_iter_name_next (const char *name, struct dict_iterator *iterator)
 
 struct symbol *
 dict_iter_match_first (const struct dictionary *dict,
-                      const char *name,
-                      int (*compare) (const char *, const char *),
+                      const char *name, symbol_compare_ftype *compare,
                       struct dict_iterator *iterator)
 {
-  return (DICT_VECTOR (dict))->iter_match_first (dict, name, compare, iterator);
+  return (DICT_VECTOR (dict))->iter_match_first (dict, name,
+                                                compare, iterator);
 }
 
 struct symbol *
-dict_iter_match_next (const char *name,
-                     int (*compare) (const char *, const char *),
+dict_iter_match_next (const char *name, symbol_compare_ftype *compare,
                      struct dict_iterator *iterator)
 {
   return (DICT_VECTOR (DICT_ITERATOR_DICT (iterator)))
@@ -646,9 +638,8 @@ iterator_hashed_advance (struct dict_iterator *iterator)
 }
 
 static struct symbol *
-iter_match_first_hashed (const struct dictionary *dict,
-                        const char *name,
-                        int (*compare) (const char *, const char *),
+iter_match_first_hashed (const struct dictionary *dict, const char *name,
+                        symbol_compare_ftype *compare,
                         struct dict_iterator *iterator)
 {
   unsigned int hash_index = dict_hash (name) % DICT_HASHED_NBUCKETS (dict);
@@ -677,8 +668,7 @@ iter_match_first_hashed (const struct dictionary *dict,
 }
 
 static struct symbol *
-iter_match_next_hashed (const char *name,
-                       int (*compare) (const char *, const char *),
+iter_match_next_hashed (const char *name, symbol_compare_ftype *compare,
                        struct dict_iterator *iterator)
 {
   struct symbol *next;
@@ -798,7 +788,6 @@ dict_hash (const char *string0)
 
   const char *string;
   unsigned int hash;
-  int c;
 
   string = string0;
   if (*string == '_')
@@ -827,7 +816,9 @@ dict_hash (const char *string0)
        case '_':
          if (string[1] == '_' && string != string0)
            {
-             if (((c = string[2]) < 'a' || c > 'z') && c != 'O')
+             int c = string[2];
+
+             if ((c < 'a' || c > 'z') && c != 'O')
                return hash;
              hash = 0;
              string += 2;
@@ -835,7 +826,7 @@ dict_hash (const char *string0)
            }
          /* FALL THROUGH */
        default:
-         hash = hash * 67 + *string - 113;
+         hash = SYMBOL_HASH_NEXT (hash, *string);
          string += 1;
          break;
        }
@@ -867,8 +858,7 @@ iterator_next_linear (struct dict_iterator *iterator)
 
 static struct symbol *
 iter_match_first_linear (const struct dictionary *dict,
-                        const char *name,
-                        int (*compare) (const char *, const char *),
+                        const char *name, symbol_compare_ftype *compare,
                         struct dict_iterator *iterator)
 {
   DICT_ITERATOR_DICT (iterator) = dict;
@@ -878,8 +868,7 @@ iter_match_first_linear (const struct dictionary *dict,
 }
 
 static struct symbol *
-iter_match_next_linear (const char *name,
-                       int (*compare) (const char *, const char *),
+iter_match_next_linear (const char *name, symbol_compare_ftype *compare,
                        struct dict_iterator *iterator)
 {
   const struct dictionary *dict = DICT_ITERATOR_DICT (iterator);
This page took 0.025377 seconds and 4 git commands to generate.