Improved string handling.
h3rald h3rald@h3rald.com
Sat, 23 Nov 2024 14:51:41 +0100
M
hex.c
→
hex.c
@@ -570,6 +570,15 @@ else if (*ptr == '"')
{ break; } + else if (*ptr == '\n') + { + hex_error("Unescaped new line in string"); + token->value = "<newline>"; + token->type = HEX_TOKEN_INVALID; + token->line = *line; + token->column = *column; + return token; + } else { ptr++;@@ -582,6 +591,9 @@ if (*ptr != '"')
{ hex_error("Unterminated string"); token->type = HEX_TOKEN_INVALID; + token->value = strdup(ptr); + token->line = *line; + token->column = *column; return token; }@@ -656,6 +668,8 @@ }
else { token->type = HEX_TOKEN_INVALID; + token->line = *line; + token->column = *column; } }@@ -3540,6 +3554,13 @@ return result;
} token = hex_next_token(&input, &line, &column); + } + if (token->type == HEX_TOKEN_INVALID) + { + token->filename = strdup(filename); + add_to_stack_trace(token); + print_stack_trace(); + return 1; } hex_free_token(token); return 0;