Commit 52cf95a7 by Doug Evans

(do_include): Check for redundant file before opening in relative path case.

(do_include): Check for redundant file before opening in
relative path case.  Don't call fstat unnecessarily.

From-SVN: r9091
parent e7faa2f6
...@@ -4351,6 +4351,11 @@ get_filename: ...@@ -4351,6 +4351,11 @@ get_filename:
} }
} }
#endif /* VMS */ #endif /* VMS */
/* ??? There are currently 3 separate mechanisms for avoiding processing
of redundant include files: #import, #pragma once, and
redundant_include_p. It would be nice if they were unified. */
if (redundant_include_p (fname))
return 0;
if (importing) if (importing)
f = lookup_import (fname, searchptr); f = lookup_import (fname, searchptr);
else else
...@@ -4361,10 +4366,6 @@ get_filename: ...@@ -4361,10 +4366,6 @@ get_filename:
else if (f == -1 && errno == EACCES) else if (f == -1 && errno == EACCES)
warning ("Header file %s exists, but is not readable", fname); warning ("Header file %s exists, but is not readable", fname);
#endif #endif
if (redundant_include_p (fname)) {
close (f);
return 0;
}
if (f >= 0) if (f >= 0)
break; break;
} }
...@@ -4424,8 +4425,6 @@ get_filename: ...@@ -4424,8 +4425,6 @@ get_filename:
else else
error ("No include path in which to find %s", fname); error ("No include path in which to find %s", fname);
} else { } else {
struct stat stat_f;
/* Check to see if this include file is a once-only include file. /* Check to see if this include file is a once-only include file.
If so, give up. */ If so, give up. */
...@@ -4476,34 +4475,38 @@ get_filename: ...@@ -4476,34 +4475,38 @@ get_filename:
pcfbuf = 0; pcfbuf = 0;
pcfnum = 0; pcfnum = 0;
fstat (f, &stat_f);
if (!no_precomp) if (!no_precomp)
do { {
sprintf (pcftry, "%s%d", fname, pcfnum++); struct stat stat_f;
pcf = open (pcftry, O_RDONLY, 0666);
if (pcf != -1)
{
struct stat s;
fstat (pcf, &s); fstat (f, &stat_f);
if (bcmp ((char *) &stat_f.st_ino, (char *) &s.st_ino,
sizeof (s.st_ino)) do {
|| stat_f.st_dev != s.st_dev) sprintf (pcftry, "%s%d", fname, pcfnum++);
{
pcfbuf = check_precompiled (pcf, fname, &pcfbuflimit); pcf = open (pcftry, O_RDONLY, 0666);
/* Don't need it any more. */ if (pcf != -1)
close (pcf); {
} struct stat s;
else
{ fstat (pcf, &s);
/* Don't need it at all. */ if (bcmp ((char *) &stat_f.st_ino, (char *) &s.st_ino,
close (pcf); sizeof (s.st_ino))
break; || stat_f.st_dev != s.st_dev)
} {
} pcfbuf = check_precompiled (pcf, fname, &pcfbuflimit);
} while (pcf != -1 && !pcfbuf); /* Don't need it any more. */
close (pcf);
}
else
{
/* Don't need it at all. */
close (pcf);
break;
}
}
} while (pcf != -1 && !pcfbuf);
}
/* Actually process the file */ /* Actually process the file */
if (pcfbuf) { if (pcfbuf) {
......
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