commit c7d9514e1617396ea5fa36788cc84f5ff0874142
parent d596976f8d6082ec001da268c92f99c70218000c
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Wed, 15 Jan 2025 16:45:24 +0100
make: Check blank after include
The specs explicitely says that an include line must be formed
by "include" in the column 0 followed by a blank character, because
otherwise macro names beginning with include would fail.
Diffstat:
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/src/cmd/scc-make/parser.c b/src/cmd/scc-make/parser.c
@@ -359,7 +359,7 @@ repeat:
if (!strcmp(input->buf, ""))
goto repeat;
- if (strncmp(input->buf, "include", 7) == 0) {
+ if (!strncmp(input->buf, "include", 7) && isblank(input->buf[7])) {
input->pos = input->siz;
include(input->buf+7);
goto repeat;
diff --git a/tests/make/execute/0105-include.sh b/tests/make/execute/0105-include.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+trap 'rm -f $tmp1 $tmp2' EXIT INT TERM HUP
+
+tmp1=tmp1.$$
+tmp2=tmp2.$$
+
+cat > $tmp1 <<EOF
+/usr/local/include
+EOF
+
+scc make -f - <<'EOF' > $tmp2 2>&1
+prefix = /usr/local
+includedir = ${prefix}/include
+
+all:
+ @echo $(includedir)
+EOF
+
+diff $tmp1 $tmp2