aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-08-02 02:58:29 +0900
committernsfisis <nsfisis@gmail.com>2025-08-15 10:06:21 +0900
commit386fef59fafbd1fd05e6907f100ba99cedf88822 (patch)
treeba4a566a99859aeecd48fc6d7cd55a6821041195
parent067365f74067bcd389e35123c0e3e259a8c61947 (diff)
downloadducc-386fef59fafbd1fd05e6907f100ba99cedf88822.tar.gz
ducc-386fef59fafbd1fd05e6907f100ba99cedf88822.tar.zst
ducc-386fef59fafbd1fd05e6907f100ba99cedf88822.zip
feat: allow #define to omit destination tokens
-rw-r--r--preprocess.c2
-rw-r--r--tests/079.sh27
2 files changed, 27 insertions, 2 deletions
diff --git a/preprocess.c b/preprocess.c
index 4ab1a48..db9ad13 100644
--- a/preprocess.c
+++ b/preprocess.c
@@ -682,7 +682,6 @@ PpToken* process_define_directive(Preprocessor* pp, PpToken* tok) {
} else {
fatal_error("#define: invalid function-like macro syntax");
}
- tok2 = skip_whitespace(tok2);
tok3 = find_next_newline(tok2);
if (tok3) {
pp_macro = pp->pp_macros->data + pp->pp_macros->len;
@@ -696,7 +695,6 @@ PpToken* process_define_directive(Preprocessor* pp, PpToken* tok) {
++pp->pp_macros->len;
}
} else {
- tok2 = skip_whitespace(tok2);
tok3 = find_next_newline(tok2);
if (tok3) {
pp_macro = pp->pp_macros->data + pp->pp_macros->len;
diff --git a/tests/079.sh b/tests/079.sh
new file mode 100644
index 0000000..4381f45
--- /dev/null
+++ b/tests/079.sh
@@ -0,0 +1,27 @@
+set -e
+
+cat <<'EOF' > expected
+42
+EOF
+
+cat <<'EOF' > header.h
+#ifndef HEADER_H
+#define HEADER_H
+
+int f() { return 42; }
+
+#endif
+EOF
+
+bash ../../test_diff.sh <<'EOF'
+#include "header.h"
+#include "header.h"
+#include "header.h"
+
+int printf();
+
+int main() {
+ printf("%d\n", HEADER_H HEADER_H HEADER_H f() HEADER_H HEADER_H HEADER_H);
+ return 0;
+}
+EOF