From a194416d100e4229b98573bd1cff7a7397d20585 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Thu, 9 Nov 2023 07:06:18 +0100 Subject: [PATCH] WIP: macro expand --- src/test.c | 6 +++--- src/ulas.c | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/test.c b/src/test.c index 5975de7..7bd40a2 100644 --- a/src/test.c +++ b/src/test.c @@ -31,9 +31,9 @@ void test_tok(void) { TESTBEGIN("tok"); - assert_tok( - " test tokens with line / * + - , ;", - {"test", "tokens", "with", "line", "/", "*", "+", "-", ",", ";", NULL}); + assert_tok(" test tokens with line / * + - , ; \\1", + {"test", "tokens", "with", "line", "/", "*", "+", "-", ",", ";", + "\\1", NULL}); TESTEND("tok"); } diff --git a/src/ulas.c b/src/ulas.c index 51a92ed..26545ef 100644 --- a/src/ulas.c +++ b/src/ulas.c @@ -94,13 +94,16 @@ int ulas_tok(struct ulas_str *dst, const char **out_line, size_t n) { case '-': case '*': case '/': - case '\\': case ULAS_TOK_COMMENT: // single char tokens dst->buf[write++] = line[i++]; break; - // consume rest of the line but do not write anything to tokens - i = (int)n; + case '\\': + // make sure we have enough space in buffer + ulas_strensr(dst, write + 2); + // escape char tokens + dst->buf[write++] = line[i++]; + dst->buf[write++] = line[i++]; break; default: while (weld_tokcond) { -- 2.30.2