summaryrefslogtreecommitdiff
path: root/include.c
diff options
context:
space:
mode:
Diffstat (limited to 'include.c')
-rw-r--r--include.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/include.c b/include.c
index f07fb70..b638011 100644
--- a/include.c
+++ b/include.c
@@ -143,7 +143,7 @@ remove_dotdot(char *path)
* Add an include file to the list of those included by 'file'.
*/
struct inclist *
-newinclude(const char *newfile, const char *incstring)
+newinclude(const char *newfile, const char *incstring, const char *incpath)
{
struct inclist *ip;
@@ -165,6 +165,20 @@ newinclude(const char *newfile, const char *incstring)
fatalerr("strdup() failure in %s()\n", __func__);
}
+ if (incpath == NULL) {
+ char r_include[PATHMAX + 1];
+
+ if (realpath(ip->i_file, r_include) == NULL)
+ ip->i_realpath = ip->i_file;
+ else
+ ip->i_realpath = strdup(r_include);
+ }
+ else {
+ ip->i_realpath = strdup(incpath);
+ }
+ if (ip->i_realpath == NULL)
+ fatalerr("strdup() failure in %s()\n", __func__);
+
inclistnext = inclistp;
return (ip);
}
@@ -328,16 +342,12 @@ inc_path(const char *file, const char *include, int type)
/*
* Same filename but same file ?
*/
- char r_saved_path[PATHMAX + 1];
-
- if (realpath(ip->i_file, r_saved_path) == NULL)
- continue;
- if (!strcmp(r_include, r_saved_path)) {
+ if (!strcmp(r_include, ip->i_realpath)) {
inclistnext = ip + 1;
return ip;
}
}
}
- return newinclude(fp, include);
+ return newinclude(fp, include, r_include);
}