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
1078}1078}
1079#endif1079#endif
1080 1080
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
1081/* extract the basename of a file */1089/* extract the basename of a file */
1082static char *tcc_basename(const char *name)1090static char *tcc_basename(const char *name)
1083{1091{
1084 char *p = strchr(name, 0);1092 char *p = strchr(name, 0);
1085 while (p > name1093 while (p > name && !IS_PATHSEP(p[-1]))
1086 && p[-1] != '/'
1087#ifdef _WIN32
1088 && p[-1] != '\\'
1089#endif
1090 )
1091 --p;1094 --p;
1092 return p;1095 return p;
1093}1096}
@@ -3086,6 +3089,13 @@ static void preprocess(int is_bof) · 1992 unmodified lines
3086 /* push current file in stack */3089 /* push current file in stack */
3087 /* XXX: fix current line init */3090 /* XXX: fix current line init */
3088 *s1->include_stack_ptr++ = file;3091 *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 }
3089 if (c == '\"') {3099 if (c == '\"') {
3090 /* first search in current dir if "header.h" */3100 /* first search in current dir if "header.h" */
3091 size = tcc_basename(file->filename) - file->filename;3101 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