More accurate processing of #include
This commit is contained in:
parent
e506eea53f
commit
46ef4260dc
|
@ -939,7 +939,7 @@ int cppparser_include(CppParser * cp, char const * include)
|
||||||
static char * _include_path(CppParser * cpp, char const * str)
|
static char * _include_path(CppParser * cpp, char const * str)
|
||||||
{
|
{
|
||||||
int d;
|
int d;
|
||||||
size_t len;
|
size_t i;
|
||||||
char * path = NULL;
|
char * path = NULL;
|
||||||
char * p;
|
char * p;
|
||||||
|
|
||||||
|
@ -955,8 +955,9 @@ static char * _include_path(CppParser * cpp, char const * str)
|
||||||
error_set("%s", "Invalid include directive");
|
error_set("%s", "Invalid include directive");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
len = strlen(str);
|
for(i = 1; str[i] != '\0' && str[i] != d; i++);
|
||||||
if(len < 3 || str[len - 1] != d)
|
/* FIXME also check what's behind the directive */
|
||||||
|
if(i == 1 || str[i] != d)
|
||||||
{
|
{
|
||||||
error_set("%s", "Invalid include directive");
|
error_set("%s", "Invalid include directive");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -966,7 +967,7 @@ static char * _include_path(CppParser * cpp, char const * str)
|
||||||
error_set("%s", strerror(errno));
|
error_set("%s", strerror(errno));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
path[len - 2] = '\0';
|
path[i - 1] = '\0';
|
||||||
p = _path_lookup(cpp, path, d == '>');
|
p = _path_lookup(cpp, path, d == '>');
|
||||||
free(path);
|
free(path);
|
||||||
return p;
|
return p;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user