+2011-03-25 Kai Tietz <ktietz@redhat.com>
+
+ * collect2.c (write_c_file_stat): Handle backslash
+ as right-hand directory separator.
+ (resolve_lib_name): Use IS_DIR_SEPARATOR instead of
+ checking just for slash.
+ * coverage.c (coverage_init): Use IS_ABSOLUTE_PATH
+ instead of checking for trailing slash.
+ * gcc.c (record_temp_file): Use filename_cmp instead
+ of strcmp.
+ (do_spec_1): Likewise.
+ (replace_outfile_spec_function): Likewise.
+ (is_directory): Use filename_ncmp instead of strncmp.
+ (print_multilib_info): Likewise.
+ * gcov.c (find_source): Use filename_cmp instead
+ instead of strcmp.
+ (make_gcov_file_name): Fix order of slash/backslash
+ checks.
+ * incpath.c (DIRS_EQ): Use filename_cmp instead of strcmp.
+ (add_standard_paths): Likewise.
+ * mips-tfile.c (saber_stop): Handle backslash.
+ * prefix.c (update_path): Use filename_ncmp instead of
+ strncmp.
+ * profile.c (output_location): Use filename_cmp instead
+ of strcmp.
+ * read-md.c (handle_toplevel_file): Handle backslash.
+ * tlink.c (frob_extension): Likewise.
+ * tree-cfg.c (same_line_p): Use filename_cmp instead of
+ strcmp.
+ * tree-dump.c (dequeue_and_dump): Handle backslash.
+ * tree.c (get_file_function_name): Likewise.
+ * gengtype.c (read_input_list): Likewise.
+ (get_file_realbasename): Likewise.
+ (get_output_file_with_visibility): Use filename_cmp
+ instead of strcmp.
+
2011-03-25 Richard Sandiford <richard.sandiford@linaro.org>
* config/arm/arm.h (CANNOT_CHANGE_MODE_CLASS): Restrict FPA_REGS
+2011-03-25 Kai Tietz <ktietz@redhat.com>
+
+ * c-ada-spec.c (compare_comment): Use filename_cmp
+ instead of strcmp for filename.
+
2011-03-25 Jeff Law <law@redhat.com>
* c-family/c-common.c (def_fn_type): Add missing va_end.
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);
#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
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,'.');
}
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;
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++)
{
#include "tree-pass.h"
#include "diagnostic-core.h"
#include "intl.h"
+#include "filenames.h"
#include "gcov-io.c"
/* + 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;
+2011-03-25 Kai Tietz <ktietz@redhat.com>
+
+ * lex.c (interface_strcmp): Handle dos-paths.
+ (handle_pragma_implementation): Use filename_cmp instead of
+ strcmp.
+ (in_main_input_context): Likewise.
+
2011-03-25 Jason Merrill <jason@redhat.com>
Core 1135
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. */
for (; ifiles; ifiles = ifiles->next)
{
- if (! strcmp (ifiles->filename, filename))
+ if (! filename_cmp (ifiles->filename, filename))
break;
}
if (ifiles == 0)
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;
}
+2011-03-25 Kai Tietz <ktietz@redhat.com>
+
+ * scanner.c (preprocessor_line): Use filename_cmp
+ instead of strcmp.
+
2011-03-25 Tobias Burnus <burnus@net-b.de>
PR fortran/48174
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,
/* 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
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,
#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 */
{
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);
{
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);
{
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;
}
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;
/* 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)
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));
}
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");
/* 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;
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;
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;
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)
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;
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++;
}
#include "xregex.h"
#include "obstack.h"
#include "gengtype.h"
+#include "filenames.h"
/* Data types, macros, etc. used only in this file. */
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)
{
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
/* 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,
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));
}
#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 };
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)
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,
+2011-03-25 Kai Tietz <ktietz@redhat.com>
+
+ * jcf-parse.c (java_read_sourcefilenames): Use filename_cmp
+ instead of strcmp.
+ (set_source_filename): Likewise.
+ * win32-host.c (jcf_open_exact_case): Likewise.
+
2011-03-21 Kai Tietz <ktietz@redhat.com>
PR target/12171
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
/* 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;
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); */
+2011-03-25 Kai Tietz <ktietz@redhat.com>
+
+ * lto.c (lto_resolution_read): Use filename_cmp instead
+ of strcmp.
+ (lto_read_section_data): Likewise.
+
2011-03-25 Jeff Law <law@redhat.com>
* lto/lto-lang.c (def_fn_type): Add missing va_end.
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)
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);
#include "tm.h"
#include "version.h"
#include "intl.h"
+#include "filenames.h"
#ifndef __SABER__
#define saber_stop()
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);
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)
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)
static void
handle_toplevel_file (directive_handler_t handle_directive)
{
- char *lastsl;
+ const char *base;
in_fname = read_md_filename;
- lastsl = strrchr (in_fname, '/');
- if (lastsl != NULL)
- base_dir = xstrndup (in_fname, lastsl - in_fname + 1);
- else
+ base = lbasename (in_fname);
+ if (base == in_fname)
base_dir = NULL;
+ else
+ base_dir = xstrndup (in_fname, base - in_fname);
handle_file (handle_directive);
}
#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
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);
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
#include "tm.h"
#include "tree.h"
#include "splay-tree.h"
+#include "filenames.h"
#include "diagnostic-core.h"
#include "toplev.h"
#include "tree-dump.h"
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,
#include "toplev.h"
#include "ggc.h"
#include "hashtab.h"
+#include "filenames.h"
#include "output.h"
#include "target.h"
#include "langhooks.h"
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
{