aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2024-06-08 11:42:57 +0100
committerRon Yorston <rmy@pobox.com>2024-06-08 12:13:28 +0100
commit997961d8a9a2c67e06508ac5f3733edb3ad6ebc7 (patch)
treefef75726ff8a8c7807f1a081099c09b32cc27c8e
parentbe285ff1ddc59ff96d9012cba4590d3cf3f4cbee (diff)
downloadbusybox-w32-997961d8a9a2c67e06508ac5f3733edb3ad6ebc7.tar.gz
busybox-w32-997961d8a9a2c67e06508ac5f3733edb3ad6ebc7.tar.bz2
busybox-w32-997961d8a9a2c67e06508ac5f3733edb3ad6ebc7.zip
make: allow := macro assignment on command line
Only the forms of macro assignment required by POSIX were allowed on the command line. Add support for the non-POSIX := form too. Adds 16-24 bytes.
-rw-r--r--miscutils/make.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/miscutils/make.c b/miscutils/make.c
index e098b0880..7d2196139 100644
--- a/miscutils/make.c
+++ b/miscutils/make.c
@@ -51,10 +51,10 @@
51 51
52//usage:#define make_trivial_usage 52//usage:#define make_trivial_usage
53//usage: IF_FEATURE_MAKE_POSIX( 53//usage: IF_FEATURE_MAKE_POSIX(
54//usage: "[--posix] [-C DIR] [-f FILE] [-j NUM] [-x PRAG] [-eiknpqrsSt] [MACRO[::[:]]=VAL]... [TARGET]..." 54//usage: "[--posix] [-C DIR] [-f FILE] [-j NUM] [-x PRAG] [-eiknpqrsSt] [MACRO[:[:[:]]]=VAL]... [TARGET]..."
55//usage: ) 55//usage: )
56//usage: IF_NOT_FEATURE_MAKE_POSIX( 56//usage: IF_NOT_FEATURE_MAKE_POSIX(
57//usage: "[-C DIR] [-f FILE] [-j NUM] [-eiknpqrsSt] [MACRO[::[:]]=VAL]... [TARGET]..." 57//usage: "[-C DIR] [-f FILE] [-j NUM] [-eiknpqrsSt] [MACRO[:[:[:]]]=VAL]... [TARGET]..."
58//usage: ) 58//usage: )
59//usage:#define make_full_usage "\n\n" 59//usage:#define make_full_usage "\n\n"
60//usage: "Maintain files based on their dependencies\n" 60//usage: "Maintain files based on their dependencies\n"
@@ -2855,21 +2855,29 @@ process_macros(char **argv, int level)
2855 break; 2855 break;
2856 } 2856 }
2857 2857
2858 if (equal - 2 > *argv && equal[-1] == ':' && equal[-2] == ':') { 2858 if (equal - 1 > *argv && equal[-1] == ':') {
2859 if (POSIX_2017) 2859 if (equal - 2 > *argv && equal[-2] == ':') {
2860 error("invalid macro assignment"); 2860 if (POSIX_2017)
2861 if (equal - 3 > *argv && equal[-3] == ':') { 2861 error("invalid macro assignment");
2862 // BSD-style ':='. Expand RHS, but not '$$', 2862 if (equal - 3 > *argv && equal[-3] == ':') {
2863 // resulting macro is delayed expansion. 2863 // BSD-style ':='. Expand RHS, but not '$$',
2864 colon = equal - 3; 2864 // resulting macro is delayed expansion.
2865 except_dollar = TRUE; 2865 colon = equal - 3;
2866 except_dollar = TRUE;
2867 } else {
2868 // GNU-style ':='. Expand RHS, including '$$',
2869 // resulting macro is immediate expansion.
2870 colon = equal - 2;
2871 immediate = M_IMMEDIATE;
2872 }
2873 *colon = '\0';
2866 } else { 2874 } else {
2867 // GNU-style ':='. Expand RHS, including '$$', 2875 if (posix)
2868 // resulting macro is immediate expansion. 2876 error("invalid macro assignment");
2869 colon = equal - 2; 2877 colon = equal - 1;
2870 immediate = M_IMMEDIATE; 2878 immediate = M_IMMEDIATE;
2879 *colon = '\0';
2871 } 2880 }
2872 *colon = '\0';
2873 } else 2881 } else
2874 *equal = '\0'; 2882 *equal = '\0';
2875 2883