From 1f685f6a332ca72505019726a5c30c0cc682ce39 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Mon, 6 Nov 2023 20:16:51 +0100 Subject: [PATCH] WIP: preproc directive detection --- src/preproc.c | 4 +++- src/test.c | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/preproc.c b/src/preproc.c index 8dbde7a..7fe00db 100644 --- a/src/preproc.c +++ b/src/preproc.c @@ -5,7 +5,7 @@ #include #include -bool ulas_tokpreproc(char c) { return !isalnum(c); } +bool ulas_tokpreproc(char c) { return !isalnum(c) && c != '#'; } char *ulas_preprocexpand(char *line, size_t linemax, const char *raw_line, size_t *n) { @@ -61,6 +61,8 @@ found: if (found_dir) { // TODO: process directive + printf("%s preproc directive!\n", tok); + fputc('\0', dst); } else { assert(fwrite(line, 1, n, dst) == n); } diff --git a/src/test.c b/src/test.c index 32d804d..a9f39ef 100644 --- a/src/test.c +++ b/src/test.c @@ -61,6 +61,7 @@ void test_preproc(void) { // should just echo back line as is assert_preproc(" test line", 0, " test line"); + assert_preproc("", 0, " #define test"); TESTEND("preproc"); } -- 2.30.2