mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-21 10:42:07 +00:00
Support character escapes in linkerscript strings
This allows linkerscripts to refer to section names even if they contain special characters: '\r' '\n' '\t' '"' '\\'.
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "extern/err.h"
|
||||
|
||||
FILE * linkerScript;
|
||||
FILE *linkerScript;
|
||||
char *includeFileName;
|
||||
|
||||
static uint32_t lineNo;
|
||||
@@ -223,12 +223,28 @@ static struct LinkerScriptToken *nextToken(void)
|
||||
|
||||
do {
|
||||
curchar = readChar(linkerScript);
|
||||
if (curchar == EOF || isNewline(curchar))
|
||||
if (curchar == EOF || isNewline(curchar)) {
|
||||
errx(1, "%s(%" PRIu32 "): Unterminated string",
|
||||
linkerScriptName, lineNo);
|
||||
else if (curchar == '"')
|
||||
} else if (curchar == '"') {
|
||||
/* Quotes force a string termination */
|
||||
curchar = '\0';
|
||||
} else if (curchar == '\\') {
|
||||
/* Backslashes are escape sequences */
|
||||
curchar = readChar(linkerScript);
|
||||
if (curchar == EOF || isNewline(curchar))
|
||||
errx(1, "%s(%" PRIu32 "): Unterminated string",
|
||||
linkerScriptName, lineNo);
|
||||
else if (curchar == 'n')
|
||||
curchar = '\n';
|
||||
else if (curchar == 'r')
|
||||
curchar = '\r';
|
||||
else if (curchar == 't')
|
||||
curchar = '\t';
|
||||
else if (curchar != '\\' && curchar != '"')
|
||||
errx(1, "%s(%" PRIu32 "): Illegal character escape",
|
||||
linkerScriptName, lineNo);
|
||||
}
|
||||
|
||||
if (size >= capacity || token.attr.string == NULL) {
|
||||
capacity *= 2;
|
||||
|
||||
Reference in New Issue
Block a user