Commit 4489800d by Kai Tietz Committed by Kai Tietz

files.c (file_hash_eq): Use filename_cmp instead of strcmp.

2011-03-25  Kai Tietz  <ktietz@redhat.com>

	* files.c (file_hash_eq): Use filename_cmp
	instead of strcmp.
	(nonexistent_file_hash_eq): Likewise.
	(remap_filename): Likewise.
	Handle absolute DOS-path,
	(append_file_to_dir): Check for IS_DIR_SEPARATOR
	instead of slash.
	(read_name_map): Likewise.
	* linemap.c (linemap_add): Use filename_cmp
	instead of strcmp.
	* mkdeps.c (apply_vpath): Use filename_ncmp
	instead of strncmp.
	(deps_restore): Use filename_cmp instead of
	strcmp.
	* init.c (read_original_directory): Use
	IS_DIR_SEPARATOR instead of checking for slash.

From-SVN: r171521
parent 75f6ec9a
2011-03-25 Kai Tietz <ktietz@redhat.com>
* files.c (file_hash_eq): Use filename_cmp
instead of strcmp.
(nonexistent_file_hash_eq): Likewise.
(remap_filename): Likewise.
Handle absolute DOS-path,
(append_file_to_dir): Check for IS_DIR_SEPARATOR
instead of slash.
(read_name_map): Likewise.
* linemap.c (linemap_add): Use filename_cmp
instead of strcmp.
* mkdeps.c (apply_vpath): Use filename_ncmp
instead of strncmp.
(deps_restore): Use filename_cmp instead of
strcmp.
* init.c (read_original_directory): Use
IS_DIR_SEPARATOR instead of checking for slash.
2011-03-21 Michael Meissner <meissner@linux.vnet.ibm.com> 2011-03-21 Michael Meissner <meissner@linux.vnet.ibm.com>
PR preprocessor/48192 PR preprocessor/48192
......
...@@ -1155,7 +1155,7 @@ file_hash_eq (const void *p, const void *q) ...@@ -1155,7 +1155,7 @@ file_hash_eq (const void *p, const void *q)
else else
hname = entry->u.dir->name; 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 /* Compare entries in the nonexistent file hash table. These are just
...@@ -1163,7 +1163,7 @@ file_hash_eq (const void *p, const void *q) ...@@ -1163,7 +1163,7 @@ file_hash_eq (const void *p, const void *q)
static int static int
nonexistent_file_hash_eq (const void *p, const void *q) 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. */ /* Initialize everything in this source file. */
...@@ -1413,7 +1413,7 @@ append_file_to_dir (const char *fname, cpp_dir *dir) ...@@ -1413,7 +1413,7 @@ append_file_to_dir (const char *fname, cpp_dir *dir)
flen = strlen (fname); flen = strlen (fname);
path = XNEWVEC (char, dlen + 1 + flen + 1); path = XNEWVEC (char, dlen + 1 + flen + 1);
memcpy (path, dir->name, dlen); memcpy (path, dir->name, dlen);
if (dlen && path[dlen - 1] != '/') if (dlen && !IS_DIR_SEPARATOR (path[dlen - 1]))
path[dlen++] = '/'; path[dlen++] = '/';
memcpy (&path[dlen], fname, flen + 1); memcpy (&path[dlen], fname, flen + 1);
...@@ -1461,7 +1461,7 @@ read_name_map (cpp_dir *dir) ...@@ -1461,7 +1461,7 @@ read_name_map (cpp_dir *dir)
len = dir->len; len = dir->len;
name = (char *) alloca (len + sizeof (FILE_NAME_MAP_FILE) + 1); name = (char *) alloca (len + sizeof (FILE_NAME_MAP_FILE) + 1);
memcpy (name, dir->name, len); memcpy (name, dir->name, len);
if (len && name[len - 1] != '/') if (len && !IS_DIR_SEPARATOR (name[len - 1]))
name[len++] = '/'; name[len++] = '/';
strcpy (name + len, FILE_NAME_MAP_FILE); strcpy (name + len, FILE_NAME_MAP_FILE);
f = fopen (name, "r"); f = fopen (name, "r");
...@@ -1532,10 +1532,18 @@ remap_filename (cpp_reader *pfile, _cpp_file *file) ...@@ -1532,10 +1532,18 @@ remap_filename (cpp_reader *pfile, _cpp_file *file)
read_name_map (dir); read_name_map (dir);
for (index = 0; dir->name_map[index]; index += 2) 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]); return xstrdup (dir->name_map[index + 1]);
if (IS_ABSOLUTE_PATH (fname))
return NULL;
p = strchr (fname, '/'); p = strchr (fname, '/');
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
{
char *p2 = strchr (fname, '\\');
if (!p || (p > p2))
p = p2;
}
#endif
if (!p || p == fname) if (!p || p == fname)
return NULL; return NULL;
......
...@@ -26,6 +26,7 @@ along with this program; see the file COPYING3. If not see ...@@ -26,6 +26,7 @@ along with this program; see the file COPYING3. If not see
#include "internal.h" #include "internal.h"
#include "mkdeps.h" #include "mkdeps.h"
#include "localedir.h" #include "localedir.h"
#include "filenames.h"
static void init_library (void); static void init_library (void);
static void mark_named_operators (cpp_reader *, int); static void mark_named_operators (cpp_reader *, int);
...@@ -640,8 +641,8 @@ read_original_directory (cpp_reader *pfile) ...@@ -640,8 +641,8 @@ read_original_directory (cpp_reader *pfile)
if (token->type != CPP_STRING if (token->type != CPP_STRING
|| ! (token->val.str.len >= 5 || ! (token->val.str.len >= 5
&& token->val.str.text[token->val.str.len-2] == '/' && IS_DIR_SEPARATOR (token->val.str.text[token->val.str.len-2])
&& token->val.str.text[token->val.str.len-3] == '/')) && IS_DIR_SEPARATOR (token->val.str.text[token->val.str.len-3])))
{ {
_cpp_backup_tokens (pfile, 3); _cpp_backup_tokens (pfile, 3);
return; return;
......
...@@ -138,7 +138,7 @@ linemap_add (struct line_maps *set, enum lc_reason reason, ...@@ -138,7 +138,7 @@ linemap_add (struct line_maps *set, enum lc_reason reason,
else else
{ {
from = INCLUDED_FROM (set, map - 1); from = INCLUDED_FROM (set, map - 1);
error = to_file && strcmp (from->to_file, to_file); error = to_file && filename_cmp (from->to_file, to_file);
} }
/* Depending upon whether we are handling preprocessed input or /* Depending upon whether we are handling preprocessed input or
......
...@@ -130,7 +130,7 @@ apply_vpath (struct deps *d, const char *t) ...@@ -130,7 +130,7 @@ apply_vpath (struct deps *d, const char *t)
unsigned int i; unsigned int i;
for (i = 0; i < d->nvpaths; i++) for (i = 0; i < d->nvpaths; i++)
{ {
if (!strncmp (d->vpathv[i], t, d->vpathlv[i])) if (!filename_ncmp (d->vpathv[i], t, d->vpathlv[i]))
{ {
const char *p = t + d->vpathlv[i]; const char *p = t + d->vpathlv[i];
if (!IS_DIR_SEPARATOR (*p)) if (!IS_DIR_SEPARATOR (*p))
...@@ -421,7 +421,7 @@ deps_restore (struct deps *deps, FILE *fd, const char *self) ...@@ -421,7 +421,7 @@ deps_restore (struct deps *deps, FILE *fd, const char *self)
buf[num_to_read] = '\0'; buf[num_to_read] = '\0';
/* Generate makefile dependencies from .pch if -nopch-deps. */ /* Generate makefile dependencies from .pch if -nopch-deps. */
if (self != NULL && strcmp (buf, self) != 0) if (self != NULL && filename_cmp (buf, self) != 0)
deps_add_dep (deps, buf); deps_add_dep (deps, buf);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment