summaryrefslogtreecommitdiff
path: root/libcpp/files.c
diff options
context:
space:
mode:
Diffstat (limited to 'libcpp/files.c')
-rw-r--r--libcpp/files.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/libcpp/files.c b/libcpp/files.c
index 456c0b0f1a5..e3cff498d8c 100644
--- a/libcpp/files.c
+++ b/libcpp/files.c
@@ -1155,7 +1155,7 @@ file_hash_eq (const void *p, const void *q)
else
hname = entry->u.dir->name;
- return strcmp (hname, fname) == 0;
+ return filename_cmp (hname, fname) == 0;
}
/* Compare entries in the nonexistent file hash table. These are just
@@ -1163,7 +1163,7 @@ file_hash_eq (const void *p, const void *q)
static int
nonexistent_file_hash_eq (const void *p, const void *q)
{
- return strcmp ((const char *) p, (const char *) q) == 0;
+ return filename_cmp ((const char *) p, (const char *) q) == 0;
}
/* Initialize everything in this source file. */
@@ -1413,7 +1413,7 @@ append_file_to_dir (const char *fname, cpp_dir *dir)
flen = strlen (fname);
path = XNEWVEC (char, dlen + 1 + flen + 1);
memcpy (path, dir->name, dlen);
- if (dlen && path[dlen - 1] != '/')
+ if (dlen && !IS_DIR_SEPARATOR (path[dlen - 1]))
path[dlen++] = '/';
memcpy (&path[dlen], fname, flen + 1);
@@ -1461,7 +1461,7 @@ read_name_map (cpp_dir *dir)
len = dir->len;
name = (char *) alloca (len + sizeof (FILE_NAME_MAP_FILE) + 1);
memcpy (name, dir->name, len);
- if (len && name[len - 1] != '/')
+ if (len && !IS_DIR_SEPARATOR (name[len - 1]))
name[len++] = '/';
strcpy (name + len, FILE_NAME_MAP_FILE);
f = fopen (name, "r");
@@ -1532,10 +1532,18 @@ remap_filename (cpp_reader *pfile, _cpp_file *file)
read_name_map (dir);
for (index = 0; dir->name_map[index]; index += 2)
- if (!strcmp (dir->name_map[index], fname))
+ if (!filename_cmp (dir->name_map[index], fname))
return xstrdup (dir->name_map[index + 1]);
-
+ if (IS_ABSOLUTE_PATH (fname))
+ return NULL;
p = strchr (fname, '/');
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+ {
+ char *p2 = strchr (fname, '\\');
+ if (!p || (p > p2))
+ p = p2;
+ }
+#endif
if (!p || p == fname)
return NULL;