From 474f94ef2511d65ae12cc7b5010c21882c8d9ff2 Mon Sep 17 00:00:00 2001 From: Lactozilla <jp6781615@gmail.com> Date: Sat, 13 Jan 2024 19:45:45 -0300 Subject: [PATCH] Fix escaping of '{' --- src/usdf.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/usdf.c b/src/usdf.c index c129f2b87e..c376415ca1 100644 --- a/src/usdf.c +++ b/src/usdf.c @@ -268,6 +268,10 @@ static char *EscapeStringChars(const char *string, int tokenizer_line) case '\'': BUFWRITE('\''); break; + case '{': + BUFWRITE('\\'); + BUFWRITE('{'); + break; case 'x': { int out = 0, c; int i = 0; @@ -319,6 +323,8 @@ static char *EscapeStringChars(const char *string, int tokenizer_line) BUFWRITE((char)out); } + else + ParseError(tokenizer_line, CONS_WARNING, "In string: unknown escape sequence '\\%c'", chr); break; } } @@ -659,16 +665,15 @@ static char *ParseText(char *text, size_t *text_length, boolean parse_scripts, i if (chr == '\\') { - if (input[1] == '{') + unsigned char nextchar = input[1]; + if (nextchar == '{') { - WRITE_TEXTCHAR(input[1]); - input += 2; + WRITE_TEXTCHAR(nextchar); + input++; } else WRITE_TEXTCHAR(chr); } - else if (chr == 0xFF) - ; // Just ignore it else if (chr == '{') { input++; @@ -680,6 +685,8 @@ static char *ParseText(char *text, size_t *text_length, boolean parse_scripts, i GetCommandEnd(&input); } + else if (chr == 0xFF) + ; // Just ignore it else WRITE_TEXTCHAR(chr); -- GitLab