diff options
author | harti <harti@FreeBSD.org> | 2004-08-12 11:49:55 +0000 |
---|---|---|
committer | harti <harti@FreeBSD.org> | 2004-08-12 11:49:55 +0000 |
commit | 328c4c7fcefd02207b2a88ae95b841d9721afeec (patch) | |
tree | f624104ca2635e474abfca990316e516d724de20 | |
parent | cf9aacc17d91946a2fd42c057bc9778ee464f1ce (diff) | |
download | FreeBSD-src-328c4c7fcefd02207b2a88ae95b841d9721afeec.zip FreeBSD-src-328c4c7fcefd02207b2a88ae95b841d9721afeec.tar.gz |
Put variable assignments on .MAKEFLAGS and .MFLAGS targets into
the .MAKEFLAGS variable so that these are also passed to sub-makes.
This makes the handling of variables in the command environment more
consistent.
PR: bin/68853
Submitted by: Martin Kamerhofer <data@sbox.tugraz.at>
-rw-r--r-- | usr.bin/make/Makefile | 2 | ||||
-rw-r--r-- | usr.bin/make/main.c | 13 | ||||
-rw-r--r-- | usr.bin/make/nonints.h | 2 | ||||
-rw-r--r-- | usr.bin/make/var.c | 48 |
4 files changed, 13 insertions, 52 deletions
diff --git a/usr.bin/make/Makefile b/usr.bin/make/Makefile index ca728fd..cf2f449 100644 --- a/usr.bin/make/Makefile +++ b/usr.bin/make/Makefile @@ -15,7 +15,7 @@ SRCS+= lstAppend.c lstAtEnd.c lstAtFront.c lstClose.c lstConcat.c \ NOSHARED?= YES -CFLAGS+=-DMAKE_VERSION=\"5200408030\" +CFLAGS+=-DMAKE_VERSION=\"5200408120\" .if defined(_UPGRADING) CFLAGS+=-D__FBSDID=__RCSID .endif diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c index b835586..284cfe2 100644 --- a/usr.bin/make/main.c +++ b/usr.bin/make/main.c @@ -355,9 +355,14 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != -1) { * on the end of the "create" list. */ for (argv += optind, argc -= optind; *argv; ++argv, --argc) - if (Parse_IsVar(*argv)) + if (Parse_IsVar(*argv)) { + char *ptr = Var_Quote(*argv); + + Var_Append(MAKEFLAGS, ptr, VAR_GLOBAL); + free(ptr); + Parse_DoVar(*argv, VAR_CMD); - else { + } else { if (!**argv) Punt("illegal (null) argument."); if (**argv == '-') { @@ -645,10 +650,6 @@ main(int argc, char **argv) MainParseArgs(argc, argv); -#ifdef POSIX - Var_AddCmdLine(MAKEFLAGS); -#endif - /* * Find where we are... * All this code is so that we know where we are when we start up diff --git a/usr.bin/make/nonints.h b/usr.bin/make/nonints.h index e1bfae3..f6e0700 100644 --- a/usr.bin/make/nonints.h +++ b/usr.bin/make/nonints.h @@ -136,7 +136,7 @@ void Var_Set(char *, char *, GNode *); void Var_Append(char *, char *, GNode *); Boolean Var_Exists(char *, GNode *); char *Var_Value(char *, GNode *, char **); -void Var_AddCmdLine(char *); +char *Var_Quote(const char *); char *Var_Parse(char *, GNode *, Boolean, int *, Boolean *); char *Var_Subst(char *, char *, GNode *, Boolean); char *Var_GetTail(char *); diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c index 42c56c5..c00353b 100644 --- a/usr.bin/make/var.c +++ b/usr.bin/make/var.c @@ -137,7 +137,6 @@ static void VarAdd(char *, char *, GNode *); static void VarDelete(void *); static char *VarGetPattern(GNode *, int, char **, int, int *, int *, VarPattern *); -static char *VarQuote(const char *); static char *VarModify(char *, Boolean (*)(const char *, Boolean, Buffer, void *), void *); @@ -773,7 +772,7 @@ VarGetPattern(GNode *ctxt, int err, char **tstr, int delim, int *flags, /*- *----------------------------------------------------------------------- - * VarQuote -- + * Var_Quote -- * Quote shell meta-characters in the string * * Results: @@ -784,8 +783,8 @@ VarGetPattern(GNode *ctxt, int err, char **tstr, int delim, int *flags, * *----------------------------------------------------------------------- */ -static char * -VarQuote(const char *str) +char * +Var_Quote(const char *str) { Buffer buf; @@ -831,45 +830,6 @@ VarREError(int err, regex_t *pat, const char *str) free(errbuf); } - -#ifdef POSIX - - -/* In POSIX mode, variable assignments passed on the command line are - * propagated to sub makes through MAKEFLAGS. - */ -void -Var_AddCmdLine(char *name) -{ - const Var *v; - LstNode ln; - Buffer buf; - static const char quotable[] = " \t\n\\'\""; - char *s; - int first = 1; - - buf = Buf_Init (MAKE_BSIZE); - - for (ln = Lst_First(VAR_CMD->context); ln != NULL; - ln = Lst_Succ(ln)) { - if (!first) - Buf_AddByte(buf, ' '); - first = 0; - /* We assume variable names don't need quoting */ - v = (Var *)Lst_Datum(ln); - Buf_AddBytes(buf, strlen(v->name), v->name); - Buf_AddByte(buf, '='); - for (s = Buf_GetAll(v->val, (int *)NULL); *s != '\0'; s++) { - if (strchr(quotable, *s)) - Buf_AddByte(buf, '\\'); - Buf_AddByte(buf, *s); - } - } - Var_Append(name, Buf_GetAll(buf, (int *)NULL), VAR_GLOBAL); - Buf_Destroy(buf, 1); -} -#endif - /*- *----------------------------------------------------------------------- * Var_Parse -- @@ -1526,7 +1486,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr) /* FALLTHROUGH */ case 'Q': if (tstr[1] == endc || tstr[1] == ':') { - newStr = VarQuote (str); + newStr = Var_Quote (str); cp = tstr + 1; termc = *cp; break; |