diff options
author | Ron Yorston <rmy@pobox.com> | 2023-08-23 09:22:38 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2023-08-23 09:22:38 +0100 |
commit | f4f0515429d8ace3c3314ee0e823205d8044f2ac (patch) | |
tree | 761f0ab2a23b336f5b6739bc1141f716eacf36da | |
parent | 9a80d9752d5d1867c0730c1f5bca12abd994907e (diff) | |
download | busybox-w32-f4f0515429d8ace3c3314ee0e823205d8044f2ac.tar.gz busybox-w32-f4f0515429d8ace3c3314ee0e823205d8044f2ac.tar.bz2 busybox-w32-f4f0515429d8ace3c3314ee0e823205d8044f2ac.zip |
make: allow targets of the form c:/path
Parsing of target rules was too simplistic to allow targets of
the form c:/path.
Allow such targets as a non-POSIX extension. Also add a 'windows'
pragma to allow such targets in POSIX mode. This additionally
requires the use of the 'target_name' pragma to permit slashes in
target names.
This change *doesn't* allow targets of the form c:path, but it's
probably not wise to use them anyway.
Costs 40-80 bytes.
(GitHub issue #353)
-rw-r--r-- | miscutils/make.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/miscutils/make.c b/miscutils/make.c index a152824eb..7e156e302 100644 --- a/miscutils/make.c +++ b/miscutils/make.c | |||
@@ -203,6 +203,9 @@ struct macro { | |||
203 | #define P_COMMAND_COMMENT 0x04 | 203 | #define P_COMMAND_COMMENT 0x04 |
204 | #define P_EMPTY_SUFFIX 0x08 | 204 | #define P_EMPTY_SUFFIX 0x08 |
205 | #define P_POSIX_202X 0x10 | 205 | #define P_POSIX_202X 0x10 |
206 | #if ENABLE_PLATFORM_MINGW32 | ||
207 | # define P_WINDOWS 0x20 | ||
208 | #endif | ||
206 | 209 | ||
207 | #define HTABSIZE 39 | 210 | #define HTABSIZE 39 |
208 | 211 | ||
@@ -410,6 +413,10 @@ check_name(const char *name) | |||
410 | return TRUE; | 413 | return TRUE; |
411 | 414 | ||
412 | for (s = name; *s; ++s) { | 415 | for (s = name; *s; ++s) { |
416 | #if ENABLE_PLATFORM_MINGW32 | ||
417 | if ((pragma & P_WINDOWS) && *s == ':') | ||
418 | continue; | ||
419 | #endif | ||
413 | if ((pragma & P_TARGET_NAME) || !POSIX_2017 ? | 420 | if ((pragma & P_TARGET_NAME) || !POSIX_2017 ? |
414 | !(isfname(*s) || *s == '/') : !ispname(*s)) | 421 | !(isfname(*s) || *s == '/') : !ispname(*s)) |
415 | return FALSE; | 422 | return FALSE; |
@@ -553,6 +560,9 @@ set_pragma(const char *name) | |||
553 | "command_comment\0" | 560 | "command_comment\0" |
554 | "empty_suffix\0" | 561 | "empty_suffix\0" |
555 | "posix_202x\0" | 562 | "posix_202x\0" |
563 | #if ENABLE_PLATFORM_MINGW32 | ||
564 | "windows\0" | ||
565 | #endif | ||
556 | ; | 566 | ; |
557 | int idx = index_in_strings(p_name, name); | 567 | int idx = index_in_strings(p_name, name); |
558 | 568 | ||
@@ -1134,6 +1144,29 @@ find_char(const char *str, int c) | |||
1134 | return NULL; | 1144 | return NULL; |
1135 | } | 1145 | } |
1136 | 1146 | ||
1147 | #if ENABLE_PLATFORM_MINGW32 | ||
1148 | /* | ||
1149 | * Ignore colons in targets of the form c:/path when looking for a | ||
1150 | * target rule. | ||
1151 | */ | ||
1152 | static char * | ||
1153 | find_colon(const char *str) | ||
1154 | { | ||
1155 | const char *s = str; | ||
1156 | |||
1157 | while ((s = find_char(s, ':'))) { | ||
1158 | if (posix && !(pragma & P_WINDOWS)) | ||
1159 | break; | ||
1160 | if (s[1] != '/') | ||
1161 | break; | ||
1162 | ++s; | ||
1163 | } | ||
1164 | return (char *)s; | ||
1165 | } | ||
1166 | #else | ||
1167 | # define find_colon(s) find_char(s, ':') | ||
1168 | #endif | ||
1169 | |||
1137 | /* | 1170 | /* |
1138 | * Recursively expand any macros in str to an allocated string. | 1171 | * Recursively expand any macros in str to an allocated string. |
1139 | */ | 1172 | */ |
@@ -1911,7 +1944,7 @@ input(FILE *fd, int ilevel) | |||
1911 | p = expanded = expand_macros(str, FALSE); | 1944 | p = expanded = expand_macros(str, FALSE); |
1912 | 1945 | ||
1913 | // Look for colon separator | 1946 | // Look for colon separator |
1914 | q = find_char(p, ':'); | 1947 | q = find_colon(p); |
1915 | if (q == NULL) | 1948 | if (q == NULL) |
1916 | error("expected separator"); | 1949 | error("expected separator"); |
1917 | 1950 | ||
@@ -1928,7 +1961,7 @@ input(FILE *fd, int ilevel) | |||
1928 | if (s) { | 1961 | if (s) { |
1929 | *s = '\0'; | 1962 | *s = '\0'; |
1930 | // Retrieve command from copy of line | 1963 | // Retrieve command from copy of line |
1931 | if ((p = find_char(copy, ':')) && (p = strchr(p, ';'))) | 1964 | if ((p = find_colon(copy)) && (p = strchr(p, ';'))) |
1932 | newcmd(&cp, process_command(p + 1)); | 1965 | newcmd(&cp, process_command(p + 1)); |
1933 | } | 1966 | } |
1934 | semicolon_cmd = cp != NULL; | 1967 | semicolon_cmd = cp != NULL; |