Implemented a subset of #if
This commit is contained in:
parent
ec4a31ea90
commit
59d80dffd6
|
@ -575,6 +575,7 @@ static int _cpp_callback_dequeue(Parser * parser, Token * token, int c,
|
|||
switch(cpp->queue_code)
|
||||
{
|
||||
case CPP_CODE_META_DEFINE:
|
||||
case CPP_CODE_META_IF:
|
||||
case CPP_CODE_META_IFDEF:
|
||||
case CPP_CODE_META_IFNDEF:
|
||||
case CPP_CODE_META_INCLUDE:
|
||||
|
|
|
@ -223,9 +223,26 @@ static int _scan_ifndef(Cpp * cpp, Token ** token)
|
|||
|
||||
static int _scan_if(Cpp * cpp, Token ** token)
|
||||
{
|
||||
char * str;
|
||||
char * p;
|
||||
|
||||
DEBUG_SCOPE();
|
||||
/* FIXME check the condition */
|
||||
_cpp_scope_push(cpp, CPP_SCOPE_TAKING);
|
||||
if((str = token_get_data(*token)) == NULL)
|
||||
/* FIXME it's probably an error case instead */
|
||||
_cpp_scope_push(cpp, CPP_SCOPE_NOTYET);
|
||||
else if(strcmp(str, "1") == 0)
|
||||
_cpp_scope_push(cpp, CPP_SCOPE_TAKING);
|
||||
else if(strncmp(str, "defined(", 8) == 0 &&
|
||||
(p = strchr(str, ')')) != NULL)
|
||||
{
|
||||
*p = '\0';
|
||||
_cpp_scope_push(cpp, cpp_define_get(cpp, &str[8]) != NULL
|
||||
? CPP_SCOPE_TAKING : CPP_SCOPE_NOTYET);
|
||||
}
|
||||
else
|
||||
/* FIXME really check the condition */
|
||||
_cpp_scope_push(cpp, CPP_SCOPE_NOTYET);
|
||||
free(str);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user