aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2024-06-02 13:04:12 +0100
committerRon Yorston <rmy@pobox.com>2024-06-02 13:04:12 +0100
commitb845dac43ac170d8b5a40d0e75dbd4276e5a3df6 (patch)
treea376a8ed6196aed172486d6f1d38eb7ef823d26a
parent25373f4d5f5b211fb959937eb370a03e2bacd7b3 (diff)
downloadbusybox-w32-b845dac43ac170d8b5a40d0e75dbd4276e5a3df6.tar.gz
busybox-w32-b845dac43ac170d8b5a40d0e75dbd4276e5a3df6.tar.bz2
busybox-w32-b845dac43ac170d8b5a40d0e75dbd4276e5a3df6.zip
make: report POSIX 202X issue with include
Synchronising with upstream pdpmake showed that a test was missing from the BusyBox port. POSIX 202X doesn't specify what should happen if an include statement has no arguments. When the POSIX 202X standard is being enforced this is reported as an error. Adds 32 bytes.
-rw-r--r--miscutils/make.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/miscutils/make.c b/miscutils/make.c
index deb04ec88..8394c4e7b 100644
--- a/miscutils/make.c
+++ b/miscutils/make.c
@@ -750,10 +750,12 @@ is_valid_macro(const char *name)
750 for (s = name; *s; ++s) { 750 for (s = name; *s; ++s) {
751 // In POSIX mode only a limited set of characters are guaranteed 751 // In POSIX mode only a limited set of characters are guaranteed
752 // to be allowed in macro names. 752 // to be allowed in macro names.
753 if (posix && 753 if (posix) {
754 ((pragma & P_MACRO_NAME) || !POSIX_2017 ? 754 // Find the appropriate character set
755 !isfname(*s) : !ispname(*s))) 755 if ((pragma & P_MACRO_NAME) || !POSIX_2017 ?
756 !isfname(*s) : !ispname(*s))
756 return FALSE; 757 return FALSE;
758 }
757 // As an extension allow anything that can get through the 759 // As an extension allow anything that can get through the
758 // input parser, apart from the following. 760 // input parser, apart from the following.
759 if (*s == '=' || isblank(*s) || iscntrl(*s)) 761 if (*s == '=' || isblank(*s) || iscntrl(*s))
@@ -1993,6 +1995,10 @@ input(FILE *fd, int ilevel)
1993 if (p == NULL || gettok(&q)) { 1995 if (p == NULL || gettok(&q)) {
1994 error("one include file per line"); 1996 error("one include file per line");
1995 } 1997 }
1998 } else if (makefile == old_makefile) {
1999 // In POSIX 202X no include file is unspecified behaviour.
2000 if (posix)
2001 error("no include file");
1996 } 2002 }
1997 2003
1998 makefile = old_makefile; 2004 makefile = old_makefile;
@@ -3071,12 +3077,12 @@ int make_main(int argc UNUSED_PARAM, char **argv)
3071 setmacro("$", "$", 0 | M_VALID); 3077 setmacro("$", "$", 0 | M_VALID);
3072 3078
3073 // Process macro definitions from the command line 3079 // Process macro definitions from the command line
3074 if (posix) 3080 if (!posix)
3081 process_macros(argv, 1);
3082 else
3075 // In POSIX mode macros must appear before targets. 3083 // In POSIX mode macros must appear before targets.
3076 // argv should now point to targets only. 3084 // argv should now point to targets only.
3077 argv = process_macros(argv, 1); 3085 argv = process_macros(argv, 1);
3078 else
3079 process_macros(argv, 1);
3080 3086
3081 // Process macro definitions from MAKEFLAGS 3087 // Process macro definitions from MAKEFLAGS
3082 if (fargv) { 3088 if (fargv) {