diff options
author | sjg <sjg@FreeBSD.org> | 2015-10-23 17:38:01 +0000 |
---|---|---|
committer | sjg <sjg@FreeBSD.org> | 2015-10-23 17:38:01 +0000 |
commit | a1cf517b9773cdac110ae2e070a8b6a211054302 (patch) | |
tree | 90f609aa8fbb06b6220e1227adcc383d6ee1e5c4 /contrib/bmake/compat.c | |
parent | 495cadb99fd3b99f7ac1a08451c84940d3fb747a (diff) | |
parent | fc737f02d4dbedb056bf90a3107fd7c5af012f0f (diff) | |
download | FreeBSD-src-a1cf517b9773cdac110ae2e070a8b6a211054302.zip FreeBSD-src-a1cf517b9773cdac110ae2e070a8b6a211054302.tar.gz |
Merge bmake 20151020
Diffstat (limited to 'contrib/bmake/compat.c')
-rw-r--r-- | contrib/bmake/compat.c | 54 |
1 files changed, 17 insertions, 37 deletions
diff --git a/contrib/bmake/compat.c b/contrib/bmake/compat.c index fd00eb7..6cf963f 100644 --- a/contrib/bmake/compat.c +++ b/contrib/bmake/compat.c @@ -1,4 +1,4 @@ -/* $NetBSD: compat.c,v 1.96 2014/09/07 20:55:34 joerg Exp $ */ +/* $NetBSD: compat.c,v 1.101 2015/10/11 04:51:24 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: compat.c,v 1.96 2014/09/07 20:55:34 joerg Exp $"; +static char rcsid[] = "$NetBSD: compat.c,v 1.101 2015/10/11 04:51:24 sjg Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: compat.c,v 1.96 2014/09/07 20:55:34 joerg Exp $"); +__RCSID("$NetBSD: compat.c,v 1.101 2015/10/11 04:51:24 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -111,37 +111,14 @@ __RCSID("$NetBSD: compat.c,v 1.96 2014/09/07 20:55:34 joerg Exp $"); #include "hash.h" #include "dir.h" #include "job.h" +#include "metachar.h" #include "pathnames.h" -/* - * The following array is used to make a fast determination of which - * characters are interpreted specially by the shell. If a command - * contains any of these characters, it is executed by the shell, not - * directly by us. - */ - -static char meta[256]; static GNode *curTarg = NULL; static GNode *ENDNode; static void CompatInterrupt(int); -static void -Compat_Init(void) -{ - const char *cp; - - Shell_Init(); /* setup default shell */ - - for (cp = "~#=|^(){};&<>*?[]:$`\\\n"; *cp != '\0'; cp++) { - meta[(unsigned char) *cp] = 1; - } - /* - * The null character serves as a sentinel in the string. - */ - meta[0] = 1; -} - /*- *----------------------------------------------------------------------- * CompatInterrupt -- @@ -236,7 +213,7 @@ CompatRunCommand(void *cmdp, void *gnp) doIt = FALSE; cmdNode = Lst_Member(gn->commands, cmd); - cmdStart = Var_Subst(NULL, cmd, gn, FALSE); + cmdStart = Var_Subst(NULL, cmd, gn, FALSE, TRUE); /* * brk_string will return an argv with a NULL in av[0], thus causing @@ -271,8 +248,8 @@ CompatRunCommand(void *cmdp, void *gnp) break; case '+': doIt = TRUE; - if (!meta[0]) /* we came here from jobs */ - Compat_Init(); + if (!shellName) /* we came here from jobs */ + Shell_Init(); break; } cmd++; @@ -300,11 +277,13 @@ CompatRunCommand(void *cmdp, void *gnp) * Search for meta characters in the command. If there are no meta * characters, there's no need to execute a shell to execute the * command. + * + * Additionally variable assignments and empty commands + * go to the shell. Therefore treat '=' and ':' like shell + * meta characters as documented in make(1). */ - for (cp = cmd; !meta[(unsigned char)*cp]; cp++) { - continue; - } - useShell = (*cp != '\0'); + + useShell = needshell(cmd, FALSE); #endif /* @@ -512,8 +491,8 @@ Compat_Make(void *gnp, void *pgnp) GNode *gn = (GNode *)gnp; GNode *pgn = (GNode *)pgnp; - if (!meta[0]) /* we came here from jobs */ - Compat_Init(); + if (!shellName) /* we came here from jobs */ + Shell_Init(); if (gn->made == UNMADE && (gn == pgn || (pgn->type & OP_MADE) == 0)) { /* * First mark ourselves to be made, then apply whatever transformations @@ -693,7 +672,8 @@ Compat_Run(Lst targs) GNode *gn = NULL;/* Current root target */ int errors; /* Number of targets not remade due to errors */ - Compat_Init(); + if (!shellName) + Shell_Init(); if (bmake_signal(SIGINT, SIG_IGN) != SIG_IGN) { bmake_signal(SIGINT, CompatInterrupt); |