aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2023-05-01 08:30:11 +0100
committerRon Yorston <rmy@pobox.com>2023-05-01 08:30:11 +0100
commit6113cbb368238541e63f3b415ad044435541688b (patch)
treef019c457c074251ec2db0193b850451341957b3d
parent460a43f2761825ab1efebdd546b43da29612d3ea (diff)
downloadbusybox-w32-6113cbb368238541e63f3b415ad044435541688b.tar.gz
busybox-w32-6113cbb368238541e63f3b415ad044435541688b.tar.bz2
busybox-w32-6113cbb368238541e63f3b415ad044435541688b.zip
make: special treatment of archive members
The standard says: If a target or prerequisite contains parentheses, it shall be treated as a member of an archive library. For the lib(member.o) expression lib refers to the name of the archive library and member.o to the member name. 'lib(member.o)' is referred to as an 'expression' rather than a name; 'lib' and 'member.o' are called names. Allow for this in is_valid_name() by splitting such expressions into separate archive/member names and checking these individually.
-rw-r--r--miscutils/make.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/miscutils/make.c b/miscutils/make.c
index 07d824752..d5e7a9516 100644
--- a/miscutils/make.c
+++ b/miscutils/make.c
@@ -402,18 +402,39 @@ findname(const char *name)
402} 402}
403 403
404static int 404static int
405is_valid_target(const char *name) 405check_name(const char *name)
406{ 406{
407 const char *s; 407 const char *s;
408
409 if (!posix)
410 return TRUE;
411
408 for (s = name; *s; ++s) { 412 for (s = name; *s; ++s) {
409 if (posix && 413 if ((pragma & P_TARGET_NAME) || !POSIX_2017 ?
410 ((pragma & P_TARGET_NAME) || !POSIX_2017 ? 414 !(isfname(*s) || *s == '/') : !ispname(*s))
411 !(isfname(*s) || *s == '/') : !ispname(*s)))
412 return FALSE; 415 return FALSE;
413 } 416 }
414 return TRUE; 417 return TRUE;
415} 418}
416 419
420static char *splitlib(const char *name, char **member);
421
422static int
423is_valid_target(const char *name)
424{
425 char *archive, *member = NULL;
426 int ret;
427
428 /* Names of the form 'lib(member)' are referred to as 'expressions'
429 * in POSIX and are subjected to special treatment. The 'lib'
430 * and 'member' elements must each be a valid target name. */
431 archive = splitlib(name, &member);
432 ret = check_name(archive) && (member == NULL || check_name(member));
433 free(archive);
434
435 return ret;
436}
437
417#if ENABLE_FEATURE_MAKE_POSIX 438#if ENABLE_FEATURE_MAKE_POSIX
418static int 439static int
419potentially_valid_target(const char *name) 440potentially_valid_target(const char *name)