2011/3/14 Pedro Alves <pe...@codesourcery.com>: > On Monday 14 March 2011 21:19:52, Kai Tietz wrote: >> @@ -1572,6 +1579,12 @@ get_file_realbasename (const input_file >> { >> const char *f = get_input_file_name (inpf); >> const char *lastslash = strrchr (f, '/'); >> +#ifdef HAVE_DOS_BASED_FILE_SYSTEM >> + const char *lastslash2 = strrchr (f, '\\'); >> + >> + if (!lastslash || (lastslash2 && lastslash2 > lastslash)) >> + lastslash = lastslash2; >> +#endif >> >> return (lastslash != NULL) ? lastslash + 1 : f; > > All of this is just > > return lbasename (get_input_file_name (inpf)); > > There are other similar cases in the patch. > > -- > Pedro Alves >
Well, as I wrote in my initial mail, I am aware of this optimization. Anyway thanks for pointing to it. So here is the updated patch using lbasename in places suitable. Retested for x86_64-pc-linux-gnu and x86_64-w64-mingw32. Ok for apply? Kai
Index: gcc/gcc/c-family/c-ada-spec.c =================================================================== --- gcc.orig/gcc/c-family/c-ada-spec.c 2011-03-14 18:45:20.566392100 +0100 +++ gcc/gcc/c-family/c-ada-spec.c 2011-03-14 20:22:19.023299300 +0100 @@ -559,7 +559,8 @@ compare_comment (const void *lp, const v const cpp_comment *rhs = (const cpp_comment *) rp; if (LOCATION_FILE (lhs->sloc) != LOCATION_FILE (rhs->sloc)) - return strcmp (LOCATION_FILE (lhs->sloc), LOCATION_FILE (rhs->sloc)); + return filename_cmp (LOCATION_FILE (lhs->sloc), + LOCATION_FILE (rhs->sloc)); if (LOCATION_LINE (lhs->sloc) != LOCATION_LINE (rhs->sloc)) return LOCATION_LINE (lhs->sloc) - LOCATION_LINE (rhs->sloc); Index: gcc/gcc/collect2.c =================================================================== --- gcc.orig/gcc/collect2.c 2011-03-14 18:45:20.567392100 +0100 +++ gcc/gcc/collect2.c 2011-03-15 07:57:54.540718100 +0100 @@ -30,6 +30,7 @@ along with GCC; see the file COPYING3. #include "system.h" #include "coretypes.h" #include "tm.h" +#include "filenames.h" /* TARGET_64BIT may be defined to use driver specific functionality. */ #undef TARGET_64BIT @@ -2314,12 +2315,8 @@ write_c_file_stat (FILE *stream, const c int frames = (frame_tables.number > 0); /* Figure out name of output_file, stripping off .so version. */ - p = strrchr (output_file, '/'); - if (p == 0) - p = output_file; - else - p++; - q = p; + q = p = lbasename (output_file); + while (q) { q = strchr (q,'.'); @@ -2330,7 +2327,7 @@ write_c_file_stat (FILE *stream, const c } else { - if (strncmp (q, SHLIB_SUFFIX, strlen (SHLIB_SUFFIX)) == 0) + if (filename_ncmp (q, SHLIB_SUFFIX, strlen (SHLIB_SUFFIX)) == 0) { q += strlen (SHLIB_SUFFIX); break; @@ -3192,10 +3189,10 @@ resolve_lib_name (const char *name) for (; list; list = list->next) { /* The following lines are needed because path_prefix list - may contain directories both with trailing '/' and + may contain directories both with trailing DIR_SEPARATOR and without it. */ const char *p = ""; - if (list->prefix[strlen(list->prefix)-1] != '/') + if (!IS_DIR_SEPARATOR (list->prefix[strlen(list->prefix)-1])) p = "/"; for (j = 0; j < 2; j++) { Index: gcc/gcc/coverage.c =================================================================== --- gcc.orig/gcc/coverage.c 2011-03-14 18:45:20.569392100 +0100 +++ gcc/gcc/coverage.c 2011-03-14 18:45:52.497503800 +0100 @@ -49,6 +49,7 @@ along with GCC; see the file COPYING3. #include "tree-pass.h" #include "diagnostic-core.h" #include "intl.h" +#include "filenames.h" #include "gcov-io.c" @@ -982,7 +983,7 @@ coverage_init (const char *filename) /* + 1 for extra '/', in case prefix doesn't end with /. */ int prefix_len; - if (profile_data_prefix == 0 && filename[0] != '/') + if (profile_data_prefix == 0 && !IS_ABSOLUTE_PATH(&filename[0])) profile_data_prefix = getpwd (); prefix_len = (profile_data_prefix) ? strlen (profile_data_prefix) + 1 : 0; Index: gcc/gcc/fortran/scanner.c =================================================================== --- gcc.orig/gcc/fortran/scanner.c 2011-03-14 18:45:20.588392100 +0100 +++ gcc/gcc/fortran/scanner.c 2011-03-14 18:45:52.506505000 +0100 @@ -1754,7 +1754,7 @@ preprocessor_line (gfc_char_t *c) if (flag[2]) /* Ending current file. */ { if (!current_file->up - || strcmp (current_file->up->filename, filename) != 0) + || filename_cmp (current_file->up->filename, filename) != 0) { gfc_warning_now ("%s:%d: file %s left but not entered", current_file->filename, current_file->line, @@ -1774,7 +1774,7 @@ preprocessor_line (gfc_char_t *c) /* The name of the file can be a temporary file produced by cpp. Replace the name if it is different. */ - if (strcmp (current_file->filename, filename) != 0) + if (filename_cmp (current_file->filename, filename) != 0) { /* FIXME: we leak the old filename because a pointer to it may be stored in the linemap. Alternative could be using GC or updating linemap to @@ -1891,7 +1891,7 @@ load_file (const char *realfilename, con filename = displayedname ? displayedname : realfilename; for (f = current_file; f; f = f->up) - if (strcmp (filename, f->filename) == 0) + if (filename_cmp (filename, f->filename) == 0) { fprintf (stderr, "%s:%d: Error: File '%s' is being included " "recursively\n", current_file->filename, current_file->line, Index: gcc/gcc/gcc.c =================================================================== --- gcc.orig/gcc/gcc.c 2011-03-14 18:45:20.589392100 +0100 +++ gcc/gcc/gcc.c 2011-03-14 18:45:52.522006900 +0100 @@ -44,6 +44,7 @@ compilation is specified by a string cal #include "flags.h" #include "opts.h" #include "vec.h" +#include "filenames.h" /* By default there is no special suffix for target executables. */ /* FIXME: when autoconf is fixed, remove the host check - dj */ @@ -1936,7 +1937,7 @@ record_temp_file (const char *filename, { struct temp_file *temp; for (temp = always_delete_queue; temp; temp = temp->next) - if (! strcmp (name, temp->name)) + if (! filename_cmp (name, temp->name)) goto already1; temp = XNEW (struct temp_file); @@ -1951,7 +1952,7 @@ record_temp_file (const char *filename, { struct temp_file *temp; for (temp = failure_delete_queue; temp; temp = temp->next) - if (! strcmp (name, temp->name)) + if (! filename_cmp (name, temp->name)) goto already2; temp = XNEW (struct temp_file); @@ -3606,9 +3607,9 @@ process_command (unsigned int decoded_op { temp = gcc_exec_prefix + len - sizeof ("/lib/gcc/") + 1; if (IS_DIR_SEPARATOR (*temp) - && strncmp (temp + 1, "lib", 3) == 0 + && filename_ncmp (temp + 1, "lib", 3) == 0 && IS_DIR_SEPARATOR (temp[4]) - && strncmp (temp + 5, "gcc", 3) == 0) + && filename_ncmp (temp + 5, "gcc", 3) == 0) len -= sizeof ("/lib/gcc/") - 1; } @@ -4706,7 +4707,7 @@ do_spec_1 (const char *spec, int inswitc tmp[basename_length + suffix_length] = '\0'; temp_filename = tmp; - if (strcmp (temp_filename, gcc_input_filename) != 0) + if (filename_cmp (temp_filename, gcc_input_filename) != 0) { #ifndef HOST_LACKS_INODE_NUMBERS struct stat st_temp; @@ -4732,7 +4733,7 @@ do_spec_1 (const char *spec, int inswitc /* Just compare canonical pathnames. */ char* input_realname = lrealpath (gcc_input_filename); char* temp_realname = lrealpath (temp_filename); - bool files_differ = strcmp (input_realname, temp_realname); + bool files_differ = filename_cmp (input_realname, temp_realname); free (input_realname); free (temp_realname); if (files_differ) @@ -5911,11 +5912,11 @@ is_directory (const char *path1, bool li if (linker && IS_DIR_SEPARATOR (path[0]) && ((cp - path == 6 - && strncmp (path + 1, "lib", 3) == 0) + && filename_ncmp (path + 1, "lib", 3) == 0) || (cp - path == 10 - && strncmp (path + 1, "usr", 3) == 0 + && filename_ncmp (path + 1, "usr", 3) == 0 && IS_DIR_SEPARATOR (path[4]) - && strncmp (path + 5, "lib", 3) == 0))) + && filename_ncmp (path + 5, "lib", 3) == 0))) return 0; return (stat (path, &st) >= 0 && S_ISDIR (st.st_mode)); @@ -6737,8 +6738,8 @@ warranty; not even for MERCHANTABILITY o } gcc_assert (debug_check_temp_file[1] - && strcmp (debug_check_temp_file[0], - debug_check_temp_file[1])); + && filename_cmp (debug_check_temp_file[0], + debug_check_temp_file[1])); if (verbose_flag) inform (0, "comparing final insns dumps"); @@ -7638,7 +7639,7 @@ print_multilib_info (void) /* If this is a duplicate, skip it. */ skip = (last_path != 0 && (unsigned int) (p - this_path) == last_path_len - && ! strncmp (last_path, this_path, last_path_len)); + && ! filename_ncmp (last_path, this_path, last_path_len)); last_path = this_path; last_path_len = p - this_path; @@ -7842,7 +7843,7 @@ replace_outfile_spec_function (int argc, for (i = 0; i < n_infiles; i++) { - if (outfiles[i] && !strcmp (outfiles[i], argv[0])) + if (outfiles[i] && !filename_cmp (outfiles[i], argv[0])) outfiles[i] = xstrdup (argv[1]); } return NULL; @@ -7863,7 +7864,7 @@ remove_outfile_spec_function (int argc, for (i = 0; i < n_infiles; i++) { - if (outfiles[i] && !strcmp (outfiles[i], argv[0])) + if (outfiles[i] && !filename_cmp (outfiles[i], argv[0])) outfiles[i] = NULL; } return NULL; Index: gcc/gcc/gcov.c =================================================================== --- gcc.orig/gcc/gcov.c 2011-03-14 18:45:20.591392100 +0100 +++ gcc/gcc/gcov.c 2011-03-14 21:49:23.961282200 +0100 @@ -728,7 +728,7 @@ find_source (const char *file_name) file_name = "<unknown>"; for (src = sources; src; src = src->next) - if (!strcmp (file_name, src->name)) + if (!filename_cmp (file_name, src->name)) break; if (!src) @@ -1527,7 +1527,7 @@ make_gcov_file_name (const char *input_n if (flag_preserve_paths) { - /* Convert '/' and '\' to '#', remove '/./', convert '/../' to '/^/', + /* Convert '/' and '\' to '#', remove '/./', convert '/../' to '#^#', convert ':' to '~' on DOS based file system. */ char *pnew = name, *pold = name; @@ -1535,33 +1535,42 @@ make_gcov_file_name (const char *input_n while (*pold != '\0') { - if (*pold == '/' || *pold == '\\') - { - *pnew++ = '#'; - pold++; - } #if defined (HAVE_DOS_BASED_FILE_SYSTEM) - else if (*pold == ':') + if (*pold == ':') { *pnew++ = '~'; pold++; } + else #endif - else if ((*pold == '/' && strstr (pold, "/./") == pold) - || (*pold == '\\' && strstr (pold, "\\.\\") == pold)) + if ((*pold == '/' + && (strstr (pold, "/./") == pold + || strstr (pold, "/.\\") == pold)) + || (*pold == '\\' + && (strstr (pold, "\\.\\") == pold + || strstr (pold, "\\./") == pold))) pold += 3; - else if (*pold == '/' && strstr (pold, "/../") == pold) + else if (*pold == '/' + && (strstr (pold, "/../") == pold + || strstr (pold, "/..\\") == pold)) { - strcpy (pnew, "/^/"); + strcpy (pnew, "#^#"); pnew += 3; pold += 4; } - else if (*pold == '\\' && strstr (pold, "\\..\\") == pold) + else if (*pold == '\\' + && (strstr (pold, "\\..\\") == pold + || strstr (pold, "\\../") == pold)) { - strcpy (pnew, "\\^\\"); + strcpy (pnew, "#^#"); pnew += 3; pold += 4; } + else if (*pold == '/' || *pold == '\\') + { + *pnew++ = '#'; + pold++; + } else *pnew++ = *pold++; } Index: gcc/gcc/incpath.c =================================================================== --- gcc.orig/gcc/incpath.c 2011-03-14 18:45:20.593392100 +0100 +++ gcc/gcc/incpath.c 2011-03-14 18:45:52.568012800 +0100 @@ -45,7 +45,7 @@ #define DIRS_EQ(A, B) ((A)->dev == (B)->dev \ && INO_T_EQ((A)->ino, (B)->ino)) #else -#define DIRS_EQ(A, B) (!strcmp ((A)->canonical_name, (B)->canonical_name)) +#define DIRS_EQ(A, B) (!filename_cmp ((A)->canonical_name, (B)->canonical_name)) #endif static const char dir_separator_str[] = { DIR_SEPARATOR, 0 }; @@ -147,7 +147,7 @@ add_standard_paths (const char *sysroot, now. */ if (sysroot && p->add_sysroot) continue; - if (!strncmp (p->fname, cpp_GCC_INCLUDE_DIR, len)) + if (!filename_ncmp (p->fname, cpp_GCC_INCLUDE_DIR, len)) { char *str = concat (iprefix, p->fname + len, NULL); if (p->multilib && imultilib) @@ -168,7 +168,7 @@ add_standard_paths (const char *sysroot, if (sysroot && p->add_sysroot) str = concat (sysroot, p->fname, NULL); else if (!p->add_sysroot && relocated - && strncmp (p->fname, cpp_PREFIX, cpp_PREFIX_len) == 0) + && !filename_ncmp (p->fname, cpp_PREFIX, cpp_PREFIX_len)) { static const char *relocated_prefix; /* If this path starts with the configure-time prefix, Index: gcc/gcc/java/jcf-parse.c =================================================================== --- gcc.orig/gcc/java/jcf-parse.c 2011-03-14 18:45:20.594392100 +0100 +++ gcc/gcc/java/jcf-parse.c 2011-03-14 21:16:41.985142800 +0100 @@ -176,9 +176,9 @@ java_read_sourcefilenames (const char *f if (fsource_filename && filenames == 0 && strlen (fsource_filename) > strlen (".java") - && strcmp ((fsource_filename - + strlen (fsource_filename) - - strlen (".java")), + && filename_cmp ((fsource_filename + + strlen (fsource_filename) + - strlen (".java")), ".java") != 0) { /* fsource_filename isn't a .java file but a list of filenames @@ -322,7 +322,7 @@ set_source_filename (JCF *jcf, int index /* Use the current input_filename (derived from the class name) if it has a directory prefix, but otherwise matches sfname. */ if (old_len > new_len - && strcmp (sfname, old_filename + old_len - new_len) == 0 + && filename_cmp (sfname, old_filename + old_len - new_len) == 0 && (old_filename[old_len - new_len - 1] == '/' || old_filename[old_len - new_len - 1] == '\\')) return; Index: gcc/gcc/java/win32-host.c =================================================================== --- gcc.orig/gcc/java/win32-host.c 2011-03-14 18:45:20.613392100 +0100 +++ gcc/gcc/java/win32-host.c 2011-03-14 18:45:52.594516200 +0100 @@ -72,7 +72,7 @@ jcf_open_exact_case (const char *filenam all directory components would be tedious and time-consuming and it's a pretty safe assumption that mixed-case package names are a fringe case.... */ - if (strcmp (filename + filename_len - found_file_len, fd.cFileName)) + if (filename_cmp (filename + filename_len - found_file_len, fd.cFileName)) { /* Reject this because it is not a perfect-case match. */ /* printf("************\nRejected:\n%s\n%s\n************\n\n", filename, fd.cFileName); */ Index: gcc/gcc/lto/lto.c =================================================================== --- gcc.orig/gcc/lto/lto.c 2011-03-14 18:45:20.639392100 +0100 +++ gcc/gcc/lto/lto.c 2011-03-14 18:45:52.599516800 +0100 @@ -345,7 +345,7 @@ lto_resolution_read (splay_tree file_ids fread (obj_name, sizeof (char), name_len, resolution); obj_name[name_len] = '\0'; - if (strcmp (obj_name, file->filename) != 0) + if (filename_cmp (obj_name, file->filename) != 0) internal_error ("unexpected file name %s in linker resolution file. " "Expected %s", obj_name, file->filename); if (file->offset != 0) @@ -582,7 +582,7 @@ lto_read_section_data (struct lto_file_d or rather fix function body streaming to not stream them in practically random order. */ if (fd != -1 - && strcmp (fd_name, file_data->file_name) != 0) + && filename_cmp (fd_name, file_data->file_name) != 0) { free (fd_name); close (fd); Index: gcc/gcc/mips-tfile.c =================================================================== --- gcc.orig/gcc/mips-tfile.c 2011-03-14 18:45:20.641392100 +0100 +++ gcc/gcc/mips-tfile.c 2011-03-15 08:02:12.281947100 +0100 @@ -606,6 +606,7 @@ along with GCC; see the file COPYING3. #include "tm.h" #include "version.h" #include "intl.h" +#include "filenames.h" #ifndef __SABER__ #define saber_stop() @@ -4693,12 +4694,11 @@ int main (int argc, char **argv) { int iflag = 0; - char *p = strrchr (argv[0], '/'); char *num_end; int option; int i; - progname = (p != 0) ? p+1 : argv[0]; + progname = lbasename (argv[0]); (void) signal (SIGSEGV, catch_signal); (void) signal (SIGBUS, catch_signal); Index: gcc/gcc/prefix.c =================================================================== --- gcc.orig/gcc/prefix.c 2011-03-14 18:45:20.642392100 +0100 +++ gcc/gcc/prefix.c 2011-03-14 18:45:52.640522000 +0100 @@ -251,7 +251,7 @@ update_path (const char *path, const cha char *result, *p; const int len = strlen (std_prefix); - if (! strncmp (path, std_prefix, len) + if (! filename_ncmp (path, std_prefix, len) && (IS_DIR_SEPARATOR(path[len]) || path[len] == '\0') && key != 0) Index: gcc/gcc/profile.c =================================================================== --- gcc.orig/gcc/profile.c 2011-03-14 18:45:20.643392100 +0100 +++ gcc/gcc/profile.c 2011-03-14 18:45:52.645522600 +0100 @@ -853,7 +853,7 @@ output_location (char const *file_name, return; } - name_differs = !prev_file_name || strcmp (file_name, prev_file_name); + name_differs = !prev_file_name || filename_cmp (file_name, prev_file_name); line_differs = prev_line != line; if (name_differs || line_differs) Index: gcc/gcc/read-md.c =================================================================== --- gcc.orig/gcc/read-md.c 2011-03-14 18:45:20.644392100 +0100 +++ gcc/gcc/read-md.c 2011-03-14 18:45:52.654523800 +0100 @@ -989,6 +989,13 @@ handle_toplevel_file (directive_handler_ in_fname = read_md_filename; lastsl = strrchr (in_fname, '/'); +#ifdef HAVE_DOS_BASED_FILE_SYSTEM + { + char *lsl2 = strrchr (in_fname, '\\'); + if (!lastsl || (lsl2 && lsl2 > lastsl)) + lastsl = lsl2; + } +#endif if (lastsl != NULL) base_dir = xstrndup (in_fname, lastsl - in_fname + 1); else Index: gcc/gcc/tlink.c =================================================================== --- gcc.orig/gcc/tlink.c 2011-03-14 18:45:20.645392100 +0100 +++ gcc/gcc/tlink.c 2011-03-15 08:06:28.695007400 +0100 @@ -30,6 +30,7 @@ along with GCC; see the file COPYING3. #include "hashtab.h" #include "demangle.h" #include "collect2.h" +#include "filenames.h" /* TARGET_64BIT may be defined to use driver specific functionality. */ #undef TARGET_64BIT @@ -293,10 +294,9 @@ tlink_execute (const char *prog, char ** static char * frob_extension (const char *s, const char *ext) { - const char *p = strrchr (s, '/'); - if (! p) - p = s; - p = strrchr (p, '.'); + const char *p; + + p = strrchr (lbasename (s), '.'); if (! p) p = s + strlen (s); Index: gcc/gcc/tree-cfg.c =================================================================== --- gcc.orig/gcc/tree-cfg.c 2011-03-14 18:45:20.647392100 +0100 +++ gcc/gcc/tree-cfg.c 2011-03-14 18:45:52.672026000 +0100 @@ -757,7 +757,7 @@ same_line_p (location_t locus1, location return true; return (from.file != NULL && to.file != NULL - && strcmp (from.file, to.file) == 0); + && filename_cmp (from.file, to.file) == 0); } /* Assign a unique discriminator value to block BB if it begins at the same Index: gcc/gcc/tree-dump.c =================================================================== --- gcc.orig/gcc/tree-dump.c 2011-03-14 18:45:20.648392100 +0100 +++ gcc/gcc/tree-dump.c 2011-03-15 08:08:03.332024800 +0100 @@ -25,6 +25,7 @@ along with GCC; see the file COPYING3. #include "tm.h" #include "tree.h" #include "splay-tree.h" +#include "filenames.h" #include "diagnostic-core.h" #include "toplev.h" #include "tree-dump.h" @@ -359,12 +360,7 @@ dequeue_and_dump (dump_info_p di) xloc = expand_location (DECL_SOURCE_LOCATION (t)); if (xloc.file) { - const char *filename = strrchr (xloc.file, '/'); - if (!filename) - filename = xloc.file; - else - /* Skip the slash. */ - ++filename; + const char *filename = lbasename (xloc.file); dump_maybe_newline (di); fprintf (di->stream, "srcp: %s:%-6d ", filename, Index: gcc/gcc/tree.c =================================================================== --- gcc.orig/gcc/tree.c 2011-03-14 18:45:20.684392100 +0100 +++ gcc/gcc/tree.c 2011-03-15 08:09:31.954778400 +0100 @@ -41,6 +41,7 @@ along with GCC; see the file COPYING3. #include "toplev.h" #include "ggc.h" #include "hashtab.h" +#include "filenames.h" #include "output.h" #include "target.h" #include "langhooks.h" @@ -8564,12 +8565,7 @@ get_file_function_name (const char *type file = input_filename; /* Just use the file's basename, because the full pathname might be quite long. */ - p = strrchr (file, '/'); - if (p) - p++; - else - p = file; - p = q = ASTRDUP (p); + p = q = ASTRDUP (lbasename (file)); } else { Index: gcc/gcc/cp/lex.c =================================================================== --- gcc.orig/gcc/cp/lex.c 2011-03-14 18:46:35.000000000 +0100 +++ gcc/gcc/cp/lex.c 2011-02-24 13:11:08.498763100 +0100 @@ -280,10 +280,10 @@ interface_strcmp (const char* s) const char *t1 = ifiles->filename; s1 = s; - if (*s1 != *t1 || *s1 == 0) + if (*s1 == 0 || filename_ncmp (s1, t1, 1) != 0) continue; - while (*s1 == *t1 && *s1 != 0) + while (*s1 != 0 && filename_ncmp (s1, t1, 1) == 0) s1++, t1++; /* A match. */ @@ -412,7 +412,7 @@ handle_pragma_implementation (cpp_reader for (; ifiles; ifiles = ifiles->next) { - if (! strcmp (ifiles->filename, filename)) + if (! filename_cmp (ifiles->filename, filename)) break; } if (ifiles == 0) @@ -706,8 +706,8 @@ in_main_input_context (void) struct tinst_level *tl = outermost_tinst_level(); if (tl) - return strcmp (main_input_filename, - LOCATION_FILE (tl->locus)) == 0; + return filename_cmp (main_input_filename, + LOCATION_FILE (tl->locus)) == 0; else - return strcmp (main_input_filename, input_filename) == 0; + return filename_cmp (main_input_filename, input_filename) == 0; } Index: gcc/gcc/gengtype.c =================================================================== --- gcc.orig/gcc/gengtype.c 2011-03-14 18:45:20.000000000 +0100 +++ gcc/gcc/gengtype.c 2011-03-15 08:12:21.436299900 +0100 @@ -28,6 +28,7 @@ #include "xregex.h" #include "obstack.h" #include "gengtype.h" +#include "filenames.h" /* Data types, macros, etc. used only in this file. */ @@ -429,6 +430,12 @@ read_input_list (const char *listname) lang_bitmap bitmap = get_lang_bitmap (gt_files[f]); const char *basename = get_file_basename (gt_files[f]); const char *slashpos = strchr (basename, '/'); +#ifdef HAVE_DOS_BASED_FILE_SYSTEM + const char *slashpos2 = strchr (basename, '\\'); + + if (!slashpos || (slashpos2 && slashpos2 < slashpos)) + slashpos = slashpos2; +#endif if (slashpos) { @@ -1570,10 +1577,7 @@ open_base_files (void) static const char * get_file_realbasename (const input_file *inpf) { - const char *f = get_input_file_name (inpf); - const char *lastslash = strrchr (f, '/'); - - return (lastslash != NULL) ? lastslash + 1 : f; + return lbasename (get_input_file_name (inpf)); } /* For INPF a filename, return the relative path to INPF from @@ -2067,7 +2071,7 @@ get_output_file_with_visibility (input_f /* Look through to see if we've ever seen this output filename before. If found, cache the result in inpf. */ for (r = output_files; r; r = r->next) - if (strcmp (r->name, output_name) == 0) + if (filename_cmp (r->name, output_name) == 0) { inpf->inpoutf = r; DBGPRINTF ("found r @ %p for output_name %s for_name %s", (void*)r, @@ -4817,7 +4821,7 @@ htab_eq_inputfile (const void *x, const const input_file *inpfx = (const input_file *) x; const input_file *inpfy = (const input_file *) y; gcc_assert (inpfx != NULL && inpfy != NULL); - return !strcmp (get_input_file_name (inpfx), get_input_file_name (inpfy)); + return !filename_cmp (get_input_file_name (inpfx), get_input_file_name (inpfy)); }