mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Merge pull request #402 from dbrotz/fix-386
Fix nested if statements that don't have following whitespace
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
%{
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -289,16 +290,21 @@ static void copymacro(void)
|
||||
yyskipbytes(ulNewMacroSize + 4);
|
||||
}
|
||||
|
||||
static bool endsIf(char c)
|
||||
{
|
||||
return isWhiteSpace(c) || c == '(' || c == '{';
|
||||
}
|
||||
|
||||
static uint32_t isIf(char *s)
|
||||
{
|
||||
return (strncasecmp(s, "IF", 2) == 0)
|
||||
&& isWhiteSpace(s[-1]) && isWhiteSpace(s[2]);
|
||||
&& isWhiteSpace(s[-1]) && endsIf(s[2]);
|
||||
}
|
||||
|
||||
static uint32_t isElif(char *s)
|
||||
{
|
||||
return (strncasecmp(s, "ELIF", 4) == 0)
|
||||
&& isWhiteSpace(s[-1]) && isWhiteSpace(s[4]);
|
||||
&& isWhiteSpace(s[-1]) && endsIf(s[4]);
|
||||
}
|
||||
|
||||
static uint32_t isElse(char *s)
|
||||
|
||||
18
test/asm/nested-if.asm
Normal file
18
test/asm/nested-if.asm
Normal file
@@ -0,0 +1,18 @@
|
||||
if 0
|
||||
if(1)
|
||||
endc
|
||||
if 1
|
||||
endc
|
||||
if{x}
|
||||
endc
|
||||
endc
|
||||
|
||||
if 1
|
||||
else
|
||||
if(1)
|
||||
endc
|
||||
if 1
|
||||
endc
|
||||
if{x}
|
||||
endc
|
||||
endc
|
||||
0
test/asm/nested-if.out
Normal file
0
test/asm/nested-if.out
Normal file
0
test/asm/nested-if.out.pipe
Normal file
0
test/asm/nested-if.out.pipe
Normal file
Reference in New Issue
Block a user