aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)