mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Fix size of unterminated REPT/FOREACH blocks
Do not "uncapture" ENDR if it was not read in the first place
This commit is contained in:
@@ -2127,6 +2127,11 @@ void lexer_CaptureRept(char **capture, size_t *size)
|
|||||||
|
|
||||||
case T_POP_ENDR:
|
case T_POP_ENDR:
|
||||||
if (!level) {
|
if (!level) {
|
||||||
|
/*
|
||||||
|
* The final ENDR has been captured, but we don't want it!
|
||||||
|
* We know we have read exactly "ENDR", not e.g. an EQUS
|
||||||
|
*/
|
||||||
|
lexerState->captureSize -= strlen("ENDR");
|
||||||
/* Read (but don't capture) until EOL or EOF */
|
/* Read (but don't capture) until EOL or EOF */
|
||||||
lexerState->capturing = false;
|
lexerState->capturing = false;
|
||||||
do {
|
do {
|
||||||
@@ -2159,7 +2164,7 @@ void lexer_CaptureRept(char **capture, size_t *size)
|
|||||||
finish:
|
finish:
|
||||||
assert(!lexerState->capturing);
|
assert(!lexerState->capturing);
|
||||||
*capture = captureStart;
|
*capture = captureStart;
|
||||||
*size = lexerState->captureSize - strlen("ENDR");
|
*size = lexerState->captureSize;
|
||||||
lexerState->captureBuf = NULL;
|
lexerState->captureBuf = NULL;
|
||||||
lexerState->disableMacroArgs = false;
|
lexerState->disableMacroArgs = false;
|
||||||
lexerState->disableInterpolation = false;
|
lexerState->disableInterpolation = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user