>From 213dc64b2820cd12f245a29ecdf13d79a7f62189 Mon Sep 17 00:00:00 2001
From: Petr Skocik
Date: Tue, 26 Sep 2017 14:35:07 +0200
Subject: [PATCH] take symlinks into account when resolving includes
---
tccpp.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/tccpp.c b/tccpp.c
index 39386f4..a383b24 100644
--- a/tccpp.c
+++ b/tccpp.c
@@ -19,6 +19,7 @@
*/
#include "tcc.h"
+#include
/********************************************************/
/* global variables */
@@ -1806,6 +1807,8 @@ ST_FUNC void preprocess(int is_bof)
n = 2 + s1->nb_include_paths + s1->nb_sysinclude_paths;
for (; i < n; ++i) {
char buf1[sizeof file->filename];
+ char pathbuf[PATH_MAX];
+
CachedInclude *e;
const char *path;
@@ -1832,7 +1835,17 @@ ST_FUNC void preprocess(int is_bof)
}
pstrcat(buf1, sizeof(buf1), buf);
+ if(NULL!=realpath(buf1, pathbuf)){
+ size_t len = strlen(pathbuf);
+ if(len+1>sizeof(buf1))
+ buf1[0]=0;
+ else
+ strcpy(buf1,pathbuf);
+ }else
+ buf1[0]=0;
+
e = search_cached_include(s1, buf1, 0);
+
if (e && (define_find(e->ifndef_macro) || e->once == pp_once)) {
/* no need to parse the include because the 'ifndef macro'
is defined (or had #pragma once) */
--
2.14.1