aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2024-03-11 09:12:47 +0000
committerRon Yorston <rmy@pobox.com>2024-03-11 09:20:47 +0000
commit1eee84b800408e53e659ff303eaa08ee09d67c3b (patch)
tree052da978f08edf8915e10fafe9d9813a9b57d6f1 /miscutils
parent912d65cba97db3d27a747decb1c1635aece8bb90 (diff)
downloadbusybox-w32-1eee84b800408e53e659ff303eaa08ee09d67c3b.tar.gz
busybox-w32-1eee84b800408e53e659ff303eaa08ee09d67c3b.tar.bz2
busybox-w32-1eee84b800408e53e659ff303eaa08ee09d67c3b.zip
make: allow '#' to be escaped with a backslash
POSIX doesn't allow the '#' comment marker to be escaped, though some implementations do. As a non-POSIX extension allow '#' to be escaped with a preceding backslash. It isn't necessary to escape '#' in macro expansions or command lines: these cases are covered by an existing extension. Commit 0aceca867 (make: comments in macro expansions and command lines) Adds 16-32 bytes. (pdpmake GitHub issue 38)
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/make.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/miscutils/make.c b/miscutils/make.c
index 841daa93e..87f17aad7 100644
--- a/miscutils/make.c
+++ b/miscutils/make.c
@@ -1373,9 +1373,17 @@ process_line(char *s)
1373 1373
1374 // Strip comment 1374 // Strip comment
1375 // don't treat '#' in macro expansion as a comment 1375 // don't treat '#' in macro expansion as a comment
1376 if (!posix) 1376 // nor '#' outside macro expansion preceded by backslash
1377 t = find_char(s, '#'); 1377 if (!posix) {
1378 else 1378 char *u = s;
1379 while ((t = find_char(u, '#')) && t > u && t[-1] == '\\') {
1380 for (u = t; *u; ++u) {
1381 u[-1] = u[0];
1382 }
1383 *u = '\0';
1384 u = t;
1385 }
1386 } else
1379 t = strchr(s, '#'); 1387 t = strchr(s, '#');
1380 if (t) 1388 if (t)
1381 *t = '\0'; 1389 *t = '\0';