Commit 8d973a83 by Neil Booth Committed by Neil Booth

cppfiles.c (open_file_pch): Don't put unused entries in the splay tree.

	* cppfiles.c (open_file_pch): Don't put unused entries in the
	splay tree.  Remove dead code.

From-SVN: r69647
parent 49a64b24
2003-07-21 Neil Booth <neil@daikokuya.co.uk>
* cppfiles.c (open_file_pch): Don't put unused entries in the
splay tree. Remove dead code.
2003-07-21 Geoffrey Keating <geoffk@apple.com> 2003-07-21 Geoffrey Keating <geoffk@apple.com>
* c-pragma.c (maybe_apply_pragma_weak): Don't get DECL_ASSEMBLER_NAME * c-pragma.c (maybe_apply_pragma_weak): Don't get DECL_ASSEMBLER_NAME
......
...@@ -301,50 +301,47 @@ open_file_pch (cpp_reader *pfile, const char *filename) ...@@ -301,50 +301,47 @@ open_file_pch (cpp_reader *pfile, const char *filename)
{ {
size_t namelen = strlen (filename); size_t namelen = strlen (filename);
char *pchname = alloca (namelen + 5); char *pchname = alloca (namelen + 5);
struct include_file * file; struct include_file *file = NULL;
splay_tree_node nd; struct stat st;
memcpy (pchname, filename, namelen); memcpy (pchname, filename, namelen);
memcpy (pchname + namelen, ".gch", 5); memcpy (pchname + namelen, ".gch", 5);
cpp_simplify_path (pchname);
nd = find_or_create_entry (pfile, pchname); if (stat (pchname, &st) == 0 && S_ISDIR (st.st_mode))
file = (struct include_file *) nd->value;
if (file != NULL)
{ {
if (stat (file->name, &file->st) == 0 && S_ISDIR (file->st.st_mode)) DIR * thedir;
{ struct dirent *d;
DIR * thedir; size_t subname_len = namelen + 64;
struct dirent *d; char *subname = xmalloc (subname_len);
size_t subname_len = namelen + 64;
char *subname = xmalloc (subname_len);
thedir = opendir (pchname); thedir = opendir (pchname);
if (thedir == NULL) if (thedir == NULL)
return NULL; return NULL;
memcpy (subname, pchname, namelen + 4); memcpy (subname, pchname, namelen + 4);
subname[namelen+4] = '/'; subname[namelen+4] = '/';
while ((d = readdir (thedir)) != NULL) while ((d = readdir (thedir)) != NULL)
{
if (strlen (d->d_name) + namelen + 7 > subname_len)
{ {
if (strlen (d->d_name) + namelen + 7 > subname_len) subname_len = strlen (d->d_name) + namelen + 64;
{ subname = xrealloc (subname, subname_len);
subname_len = strlen (d->d_name) + namelen + 64;
subname = xrealloc (subname, subname_len);
}
strcpy (subname + namelen + 5, d->d_name);
file = validate_pch (pfile, filename, subname);
if (file)
break;
} }
closedir (thedir); strcpy (subname + namelen + 5, d->d_name);
free (subname); file = validate_pch (pfile, filename, subname);
if (file)
break;
} }
else closedir (thedir);
file = validate_pch (pfile, filename, pchname); free (subname);
if (file)
return file;
} }
else
file = validate_pch (pfile, filename, pchname);
if (file)
return file;
} }
return open_file (pfile, filename); return open_file (pfile, filename);
} }
......
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