- struct symbol_search **symbols, *symp;
- int i, j, nunique;
-
- gdb_assert (found != NULL && nfound > 0);
-
- /* Build an array out of the list so we can easily sort them. */
- symbols = XNEWVEC (struct symbol_search *, nfound);
-
- symp = found;
- for (i = 0; i < nfound; i++)
- {
- gdb_assert (symp != NULL);
- gdb_assert (symp->block >= 0 && symp->block <= 1);
- symbols[i] = symp;
- symp = symp->next;
- }
- gdb_assert (symp == NULL);
-
- qsort (symbols, nfound, sizeof (struct symbol_search *),
- compare_search_syms);
-
- /* Collapse out the dups. */
- for (i = 1, j = 1; i < nfound; ++i)
- {
- if (compare_search_syms (&symbols[j - 1], &symbols[i]) != 0)
- symbols[j++] = symbols[i];
- else
- xfree (symbols[i]);
- }
- nunique = j;
- symbols[j - 1]->next = NULL;
-
- /* Rebuild the linked list. */
- for (i = 0; i < nunique - 1; i++)
- symbols[i]->next = symbols[i + 1];
- symbols[nunique - 1]->next = NULL;
-
- *new_head = symbols[0];
- *new_tail = symbols[nunique - 1];
- xfree (symbols);
-}
-
-/* An object of this type is passed as the user_data to the
- expand_symtabs_matching method. */
-struct search_symbols_data
-{
- int nfiles;
- const char **files;
-
- /* It is true if PREG contains valid data, false otherwise. */
- unsigned preg_p : 1;
- regex_t preg;
-};
-
-/* A callback for expand_symtabs_matching. */
-
-static int
-search_symbols_file_matches (const char *filename, void *user_data,
- int basenames)
-{
- struct search_symbols_data *data = (struct search_symbols_data *) user_data;
-
- return file_matches (filename, data->files, data->nfiles, basenames);
-}
-
-/* A callback for expand_symtabs_matching. */
-
-static int
-search_symbols_name_matches (const char *symname, void *user_data)
-{
- struct search_symbols_data *data = (struct search_symbols_data *) user_data;
-
- return !data->preg_p || regexec (&data->preg, symname, 0, NULL, 0) == 0;