* i386b-nat.c: Comment changes.
[deliverable/binutils-gdb.git] / gdb / symtab.c
index cb97621d7a98114707dd1fe3be75f1bcc5294fe7..fdda171bb8d519c7ab57ca0e36c20af6f7cc493c 100644 (file)
@@ -1269,31 +1269,6 @@ find_pc_line_pc_range (pc, startptr, endptr)
   return sal.symtab != 0;
 }
 \f
-struct type *
-find_nested_type (type, name)
-     struct type *type;
-     char *name;
-{
-  int i;
-  for (i = TYPE_NFIELDS (type) - 1; i >= TYPE_N_BASECLASSES (type); i--)
-    {
-      char *t_field_name = TYPE_FIELD_NAME (type, i);
-
-      if (t_field_name && !strcmp (t_field_name, name))
-       if (TYPE_FIELD_NESTED (type, i))
-         {
-           return TYPE_FIELD_TYPE (type, i);
-         }
-    }
-  for (i = TYPE_N_BASECLASSES (type) - 1; i >= 0; i--)
-    {
-      struct type * t = find_nested_type (TYPE_BASECLASS (type, i), name);
-      if (t)
-       return t;
-    }
-  return NULL;
-}
-
 /* If P is of the form "operator[ \t]+..." where `...' is
    some legitimate operator text, return a pointer to the
    beginning of the substring of the operator text.
@@ -2482,35 +2457,50 @@ completion_list_add_symbol (symname, text, text_len)
 {
   char *demangled;
   int newsize;
+  int i;
 
-  /* First see if SYMNAME is a C++ mangled name, and if so, use the
-     demangled name instead, including any parameters. */
+  /* clip symbols that cannot match */
+
+  if (!cplus_match (symname, text, text_len)) {
+    return;
+  }
+
+  /* matches mangled, may match unmangled.  now clip any symbol names
+     that we've already considered.  (This is a time optimization)  */
+
+  for (i = 0; i < return_val_index; ++i) {
+    if (strcmp (symname, return_val[i]) == 0) {
+      return;
+    }
+  }
+  
+  /* See if SYMNAME is a C++ mangled name, and if so, use the
+     demangled name instead, including any parameters.  */
 
   if ((demangled = cplus_demangle (symname, DMGL_PARAMS | DMGL_ANSI)) != NULL)
     {
+      if (strncmp (demangled, text, text_len) != 0) {
+       return;
+      }        /* demangled, but didn't match so clip it */
+
       symname = demangled;
+    } else {
+      symname = savestring (symname, strlen (symname));
     }
 
   /* If we have a match for a completion, then add SYMNAME to the current
-     list of matches. Note that we always make a copy of the string, even
-     if it is one that was returned from cplus_demangle and is already
-     in malloc'd memory. */
+     list of matches. Note that the name is in freshly malloc'd space;
+     either from cplus_demangle or from savestring above.  */
 
-  if (strncmp (symname, text, text_len) == 0)
+  if (return_val_index + 3 > return_val_size)
     {
-      if (return_val_index + 3 > return_val_size)
-       {
-         newsize = (return_val_size *= 2) * sizeof (char *);
-         return_val = (char **) xrealloc ((char *) return_val, newsize);
-       }
-      return_val[return_val_index++] = savestring (symname, strlen (symname));
-      return_val[return_val_index] = NULL;
+      newsize = (return_val_size *= 2) * sizeof (char *);
+      return_val = (char **) xrealloc ((char *) return_val, newsize);
     }
+  return_val[return_val_index++] = symname;
+  return_val[return_val_index] = NULL;
 
-  if (demangled != NULL)
-    {
-      free (demangled);
-    }
+  return;
 }
 
 /* Return a NULL terminated array of all symbols (regardless of class) which
This page took 0.026146 seconds and 4 git commands to generate.