[RFA] More file-name related fixes
Eli Zaretskii
eliz@is.elta.co.il
Wed May 2 10:26:00 GMT 2001
(Elena should love this, since it eradicates a few more STREQ's ;-)
I'm seeking approval for the following patches for symtab.c which make
handling if file names in symtabs and psymtabs more portable:
2001-05-02 Eli Zaretskii <eliz@is.elta.co.il>
* symtab.c (lookup_symtab_1, lookup_partial_symtab): Use basename
instead of non-portable search for `/'. Use FILENAME_CMP instead
of STREQ, to account for case-insensitive filesystems.
(top-level): #include "filenames.h".
--- gdb/symtab.c~3 Sat Apr 28 23:18:44 2001
+++ gdb/symtab.c Wed May 2 13:42:22 2001
@@ -36,6 +36,7 @@
#include "demangle.h"
#include "inferior.h"
#include "linespec.h"
+#include "filenames.h" /* for FILENAME_CMP */
#include "obstack.h"
@@ -139,7 +140,6 @@ lookup_symtab_1 (char *name)
{
register struct symtab *s;
register struct partial_symtab *ps;
- register char *slash;
register struct objfile *objfile;
got_symtab:
@@ -147,23 +147,15 @@ got_symtab:
/* First, search for an exact match */
ALL_SYMTABS (objfile, s)
- if (STREQ (name, s->filename))
- return s;
-
- slash = strchr (name, '/');
+ if (FILENAME_CMP (name, s->filename) == 0)
+ return s;
/* Now, search for a matching tail (only if name doesn't have any dirs) */
- if (!slash)
+ if (basename (name) == name)
ALL_SYMTABS (objfile, s)
{
- char *p = s->filename;
- char *tail = strrchr (p, '/');
-
- if (tail)
- p = tail + 1;
-
- if (STREQ (p, name))
+ if (FILENAME_CMP (basename (s->filename), name) == 0)
return s;
}
@@ -242,7 +234,7 @@ lookup_partial_symtab (char *name)
ALL_PSYMTABS (objfile, pst)
{
- if (STREQ (name, pst->filename))
+ if (FILENAME_CMP (name, pst->filename) == 0)
{
return (pst);
}
@@ -250,16 +242,10 @@ lookup_partial_symtab (char *name)
/* Now, search for a matching tail (only if name doesn't have any dirs) */
- if (!strchr (name, '/'))
+ if (basename (name) == name)
ALL_PSYMTABS (objfile, pst)
{
- char *p = pst->filename;
- char *tail = strrchr (p, '/');
-
- if (tail)
- p = tail + 1;
-
- if (STREQ (p, name))
+ if (FILENAME_CMP (basename (pst->filename), name) == 0)
return (pst);
}
@@ -3085,6 +3071,8 @@ make_symbol_completion_list (char *text,
return (return_val);
}
+#if 0
+
static struct sym_and_file {
char *sym;
char *file;
@@ -3352,6 +3340,8 @@ make_file_symbol_completion_list (char *
return (return_val);
}
+#endif
+
/* A helper function for make_source_files_completion_list. It adds
another file name to a list of possible completions, growing the
list as necessary. */
More information about the Gdb-patches
mailing list