History

check for absolute include paths

Suggested by Sandor Zsolt <narkoskatona@yahoo.com>

grischka committed 17 years ago

Commit 6c104291 parent 29c8e151 file · +16 −6Browse files

Unified · Split

tcc.c+16−6
@@ -1078,16 +1078,19 @@ static int strstart(const char *str, const char *val, const char **ptr) · 1077 unmodified lines
10781078 }
10791079 #endif
10801080
1081+#ifdef _WIN32
1082+#define IS_PATHSEP(c) (c == '/' || c == '\\')
1083+#define IS_ABSPATH(p) (IS_PATHSEP(p[0]) || (p[0] && p[1] == ':' && IS_PATHSEP(p[2])))
1084+#else
1085+#define IS_PATHSEP(c) (c == '/')
1086+#define IS_ABSPATH(p) IS_PATHSEP(p[0])
1087+#endif
1088+
10811089 /* extract the basename of a file */
10821090 static char *tcc_basename(const char *name)
10831091 {
10841092 char *p = strchr(name, 0);
1085− while (p > name
1086− && p[-1] != '/'
1087−#ifdef _WIN32
1088− && p[-1] != '\\'
1089−#endif
1090− )
1093+ while (p > name && !IS_PATHSEP(p[-1]))
10911094 --p;
10921095 return p;
10931096 }
@@ -3086,6 +3089,13 @@ static void preprocess(int is_bof) · 1992 unmodified lines
30863089 /* push current file in stack */
30873090 /* XXX: fix current line init */
30883091 *s1->include_stack_ptr++ = file;
3092+
3093+ /* check absolute include path */
3094+ if (IS_ABSPATH(buf)) {
3095+ f = tcc_open(s1, buf);
3096+ if (f)
3097+ goto found;
3098+ }
30893099 if (c == '\"') {
30903100 /* first search in current dir if "header.h" */
30913101 size = tcc_basename(file->filename) - file->filename;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t