diff options
Diffstat (limited to 'contrib/bmake/parse.c')
-rw-r--r-- | contrib/bmake/parse.c | 67 |
1 files changed, 53 insertions, 14 deletions
diff --git a/contrib/bmake/parse.c b/contrib/bmake/parse.c index 41323b5..0f9a8fc 100644 --- a/contrib/bmake/parse.c +++ b/contrib/bmake/parse.c @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.191 2013/08/28 21:56:49 sjg Exp $ */ +/* $NetBSD: parse.c,v 1.194 2014/02/15 00:17:17 christos Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: parse.c,v 1.191 2013/08/28 21:56:49 sjg Exp $"; +static char rcsid[] = "$NetBSD: parse.c,v 1.194 2014/02/15 00:17:17 christos Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: parse.c,v 1.191 2013/08/28 21:56:49 sjg Exp $"); +__RCSID("$NetBSD: parse.c,v 1.194 2014/02/15 00:17:17 christos Exp $"); #endif #endif /* not lint */ #endif @@ -364,6 +364,7 @@ static int ParseAddCmd(void *, void *); static void ParseHasCommands(void *); static void ParseDoInclude(char *); static void ParseSetParseFile(const char *); +static void ParseSetIncludedFile(void); #ifdef SYSVINCLUDE static void ParseTraditionalInclude(char *); #endif @@ -855,7 +856,8 @@ ParseLinkSrc(void *pgnp, void *cgnp) (void)Lst_AtEnd(cgn->parents, pgn); pgn->unmade += 1; if (DEBUG(PARSE)) { - fprintf(debug_file, "# ParseLinkSrc: added child %s - %s\n", pgn->name, cgn->name); + fprintf(debug_file, "# %s: added child %s - %s\n", __func__, + pgn->name, cgn->name); Targ_PrintNode(pgn, 0); Targ_PrintNode(cgn, 0); } @@ -1030,8 +1032,8 @@ ParseDoSrc(int tOp, const char *src) (void)Lst_AtEnd(predecessor->order_succ, gn); (void)Lst_AtEnd(gn->order_pred, predecessor); if (DEBUG(PARSE)) { - fprintf(debug_file, "# ParseDoSrc: added Order dependency %s - %s\n", - predecessor->name, gn->name); + fprintf(debug_file, "# %s: added Order dependency %s - %s\n", + __func__, predecessor->name, gn->name); Targ_PrintNode(predecessor, 0); Targ_PrintNode(gn, 0); } @@ -1216,9 +1218,8 @@ ParseDoDependency(char *line) */ int length; void *freeIt; - char *result; - result = Var_Parse(cp, VAR_CMD, TRUE, &length, &freeIt); + (void)Var_Parse(cp, VAR_CMD, TRUE, &length, &freeIt); if (freeIt) free(freeIt); cp += length-1; @@ -2175,6 +2176,7 @@ Parse_include_file(char *file, Boolean isSystem, int silent) /* load it */ lf = loadfile(fullname, fd); + ParseSetIncludedFile(); /* Start reading from this file next */ Parse_SetInput(fullname, 0, -1, loadedfile_nextbuf, lf); curFile->lf = lf; @@ -2234,6 +2236,41 @@ ParseDoInclude(char *line) /*- *--------------------------------------------------------------------- + * ParseSetIncludedFile -- + * Set the .INCLUDEDFROMFILE variable to the contents of .PARSEFILE + * and the .INCLUDEDFROMDIR variable to the contents of .PARSEDIR + * + * Results: + * None + * + * Side Effects: + * The .INCLUDEDFROMFILE variable is overwritten by the contents + * of .PARSEFILE and the .INCLUDEDFROMDIR variable is overwriten + * by the contents of .PARSEDIR + *--------------------------------------------------------------------- + */ +static void +ParseSetIncludedFile(void) +{ + char *pf, *fp = NULL; + char *pd, *dp = NULL; + + pf = Var_Value(".PARSEFILE", VAR_GLOBAL, &fp); + Var_Set(".INCLUDEDFROMFILE", pf, VAR_GLOBAL, 0); + pd = Var_Value(".PARSEDIR", VAR_GLOBAL, &dp); + Var_Set(".INCLUDEDFROMDIR", pd, VAR_GLOBAL, 0); + + if (DEBUG(PARSE)) + fprintf(debug_file, "%s: ${.INCLUDEDFROMDIR} = `%s' " + "${.INCLUDEDFROMFILE} = `%s'\n", __func__, pd, pf); + + if (fp) + free(fp); + if (dp) + free(dp); +} +/*- + *--------------------------------------------------------------------- * ParseSetParseFile -- * Set the .PARSEDIR and .PARSEFILE variables to the dirname and * basename of the given filename @@ -2267,8 +2304,8 @@ ParseSetParseFile(const char *filename) Var_Set(".PARSEFILE", pf = slash + 1, VAR_GLOBAL, 0); } if (DEBUG(PARSE)) - fprintf(debug_file, "ParseSetParseFile: ${.PARSEDIR} = `%s' " - "${.PARSEFILE} = `%s'\n", pd, pf); + fprintf(debug_file, "%s: ${.PARSEDIR} = `%s' ${.PARSEFILE} = `%s'\n", + __func__, pd, pf); free(dirname); } @@ -2330,8 +2367,8 @@ Parse_SetInput(const char *name, int line, int fd, ParseTrackInput(name); if (DEBUG(PARSE)) - fprintf(debug_file, "Parse_SetInput: file %s, line %d, fd %d, nextbuf %p, arg %p\n", - name, line, fd, nextbuf, arg); + fprintf(debug_file, "%s: file %s, line %d, fd %d, nextbuf %p, arg %p\n", + __func__, name, line, fd, nextbuf, arg); if (fd == -1 && nextbuf == NULL) /* sanity */ @@ -2403,7 +2440,7 @@ ParseTraditionalInclude(char *line) char *all_files; if (DEBUG(PARSE)) { - fprintf(debug_file, "ParseTraditionalInclude: %s\n", file); + fprintf(debug_file, "%s: %s\n", __func__, file); } /* @@ -2462,7 +2499,7 @@ ParseGmakeExport(char *line) char *value; if (DEBUG(PARSE)) { - fprintf(debug_file, "ParseGmakeExport: %s\n", variable); + fprintf(debug_file, "%s: %s\n", __func__, variable); } /* @@ -2542,6 +2579,8 @@ ParseEOF(void) /* We've run out of input */ Var_Delete(".PARSEDIR", VAR_GLOBAL); Var_Delete(".PARSEFILE", VAR_GLOBAL); + Var_Delete(".INCLUDEDFROMDIR", VAR_GLOBAL); + Var_Delete(".INCLUDEDFROMFILE", VAR_GLOBAL); return DONE; } |