From: Lukas Krickl Date: Thu, 9 Nov 2023 06:06:18 +0000 (+0100) Subject: WIP: macro expand X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=a194416d100e4229b98573bd1cff7a7397d20585;p=ulas%2F.git WIP: macro expand --- 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) {