Fixed test case for define without a value so that it does not consume
authorLukas Krickl <lukas@krickl.dev>
Sat, 11 Nov 2023 18:39:32 +0000 (19:39 +0100)
committerLukas Krickl <lukas@krickl.dev>
Sat, 11 Nov 2023 18:39:32 +0000 (19:39 +0100)
the nearest white space anymore

src/test.c
src/ulas.c

index 6a77a865fa590a7c2bb4dc20e4c2b5f2484e86d3..c8a845bc31a92761a0af916d0e1fbb8b3060f0a4 100644 (file)
@@ -97,7 +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("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,
index 5febd33bc74c2b0c6e313c5795106f82deb3959c..a66ba52e1178016e50fc61ac38def3ac04757c30 100644 (file)
@@ -247,9 +247,9 @@ char *ulas_preprocexpand(struct ulas_preproc *pp, const char *raw_line,
       switch (def->type) {
       case ULAS_PPDEF: {
         size_t val_len = strlen(def->value);
+        int wsi = ulas_preproclws(pp, praw_line - read, *n);
         if (val_len) {
           // make sure to include leading white space
-          int wsi = ulas_preproclws(pp, praw_line - read, *n);
           // adjust total length
           *n -= strlen(pp->tok.buf);
           *n += val_len;