From: Lukas Krickl Date: Mon, 6 Nov 2023 19:16:51 +0000 (+0100) Subject: WIP: preproc directive detection X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=1f685f6a332ca72505019726a5c30c0cc682ce39;p=ulas%2F.git WIP: preproc directive detection --- 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"); }