From cc18727f1bf006c6bd60f49609fc72f7864cef46 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Sat, 11 Nov 2023 19:38:58 +0100 Subject: [PATCH] Added additional test case for define with no value --- src/test.c | 5 +++-- src/ulas.c | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/test.c b/src/test.c index bfb4188..6a77a86 100644 --- a/src/test.c +++ b/src/test.c @@ -97,6 +97,7 @@ void test_preproc(void) { // define assert_preproc("123", 0, " #define test 123\ntest"); + assert_preproc("this is a", 0, " #define test\nthis is a test"); assert_preproc("", -1, " #define 1test 123\n"); assert_preproc("", -1, " #define\n"); assert_preproc("this is a 123 for defs", 0, @@ -108,8 +109,8 @@ void test_preproc(void) { // macro assert_preproc( - " line p1 1 label01,2\n line p2 2\n line p3 3 p1, p2, p3\n", 0, - "#macro test\n line $1 1 label$$$$,$$\n line $2 2\n line $3 3 " + " line p1 1 label01,2 3\n line p2 2\n line p3 3 p1, p2, p3\n", 0, + "#macro test\n line $1 1 label$$$$,$$ $$\n line $2 2\n line $3 3 " "$0\n#endmacro\ntest p1, p2, p3"); assert_preproc("test macro with no args\n", 0, "#macro test\ntest macro with no args\n#endmacro\ntest"); diff --git a/src/ulas.c b/src/ulas.c index 3c7fa98..5febd33 100644 --- a/src/ulas.c +++ b/src/ulas.c @@ -254,6 +254,9 @@ char *ulas_preprocexpand(struct ulas_preproc *pp, const char *raw_line, *n -= strlen(pp->tok.buf); *n += val_len; ulas_strensr(&pp->line, (*n) + 1 + wsi); + + // only remove the first white space char if the lenght of value + // is greater than 1, otherwise just leave it be... if (val_len > 1) { strncat(pp->line.buf, def->value + 1, val_len - 1); } else { -- 2.30.2