From 31889e007b0383eda46a0540aaae895c4e2cccb2 Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Wed, 13 Jun 2001 18:30:07 +0000 Subject: [PATCH] s/basename/lbasename/ clean up consequences of assuming lbasename() returns const char *. --- gdb/ChangeLog | 11 +++++++++++ gdb/source.c | 4 ++-- gdb/symtab.c | 14 +++++++------- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6b1db58fdae..6538821bc6e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,14 @@ +2001-06-11 Andrew Cagney + + * symtab.c (lookup_symtab_1): Replace basename with lbasename. + (lookup_partial_symtab, file_matches): Ditto. + (make_source_files_completion_list): Ditto. + (make_file_symbol_completion_list): Ditto. Make local char* + variable ``tail'' constant. + (make_source_files_completion_list): Ditto with ``base_name''. + * source.c (open_source_file): Use lbasename. Make ``p'' const + char *. + 2001-06-13 Eli Zaretskii * config/i386/xm-go32.h (SLASH_P, ROOTED_P, SLASH_CHAR) diff --git a/gdb/source.c b/gdb/source.c index 8d705dba5d8..2895dd388f6 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -670,7 +670,7 @@ int open_source_file (struct symtab *s) { char *path = source_path; - char *p; + const char *p; int result; char *fullname; @@ -710,7 +710,7 @@ open_source_file (struct symtab *s) if (result < 0) { /* Didn't work. Try using just the basename. */ - p = basename (s->filename); + p = lbasename (s->filename); if (p != s->filename) result = openp (path, 0, p, OPEN_MODE, 0, &s->fullname); } diff --git a/gdb/symtab.c b/gdb/symtab.c index 437576384ab..a16393e81a7 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -157,7 +157,7 @@ got_symtab: if (lbasename (name) == name) ALL_SYMTABS (objfile, s) { - if (FILENAME_CMP (basename (s->filename), name) == 0) + if (FILENAME_CMP (lbasename (s->filename), name) == 0) return s; } @@ -247,7 +247,7 @@ lookup_partial_symtab (const char *name) if (lbasename (name) == name) ALL_PSYMTABS (objfile, pst) { - if (FILENAME_CMP (basename (pst->filename), name) == 0) + if (FILENAME_CMP (lbasename (pst->filename), name) == 0) return (pst); } @@ -2276,7 +2276,7 @@ file_matches (char *file, char *files[], int nfiles) { for (i = 0; i < nfiles; i++) { - if (strcmp (files[i], basename (file)) == 0) + if (strcmp (files[i], lbasename (file)) == 0) return 1; } } @@ -3167,7 +3167,7 @@ make_file_symbol_completion_list (char *text, char *word, char *srcfile) { /* Maybe they typed the file with leading directories, while the symbol tables record only its basename. */ - char *tail = basename (srcfile); + const char *tail = lbasename (srcfile); if (tail > srcfile) s = lookup_symtab (tail); @@ -3272,7 +3272,7 @@ make_source_files_completion_list (char *text, char *word) int list_used = 0; size_t text_len = strlen (text); char **list = (char **) xmalloc (list_alloced * sizeof (char *)); - char *base_name; + const char *base_name; list[0] = NULL; @@ -3302,7 +3302,7 @@ make_source_files_completion_list (char *text, char *word) debug info records leading directories, but not the other way around. This is what subroutines of breakpoint command do when they parse file names. */ - base_name = basename (s->filename); + base_name = lbasename (s->filename); if (base_name != s->filename && !filename_seen (base_name, 1, &first) #if HAVE_DOS_BASED_FILE_SYSTEM @@ -3338,7 +3338,7 @@ make_source_files_completion_list (char *text, char *word) } else { - base_name = basename (ps->filename); + base_name = lbasename (ps->filename); if (base_name != ps->filename && !filename_seen (base_name, 1, &first) #if HAVE_DOS_BASED_FILE_SYSTEM -- 2.30.2