Fri Jan 10 16:12:52 2014 UTC ()
add .INCLUDEDFROM{FILE,DIR}


(christos)
diff -r1.226 -r1.227 src/usr.bin/make/make.1
diff -r1.192 -r1.193 src/usr.bin/make/parse.c

cvs diff -r1.226 -r1.227 src/usr.bin/make/make.1 (expand / switch to unified diff)

--- src/usr.bin/make/make.1 2013/11/07 18:50:46 1.226
+++ src/usr.bin/make/make.1 2014/01/10 16:12:52 1.227
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1.\" $NetBSD: make.1,v 1.226 2013/11/07 18:50:46 dholland Exp $ 1.\" $NetBSD: make.1,v 1.227 2014/01/10 16:12:52 christos Exp $
2.\" 2.\"
3.\" Copyright (c) 1990, 1993 3.\" Copyright (c) 1990, 1993
4.\" The Regents of the University of California. All rights reserved. 4.\" The Regents of the University of California. All rights reserved.
5.\" 5.\"
6.\" Redistribution and use in source and binary forms, with or without 6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions 7.\" modification, are permitted provided that the following conditions
8.\" are met: 8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright 9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer. 10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the 12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution. 13.\" documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors 14.\" 3. Neither the name of the University nor the names of its contributors
@@ -628,26 +628,30 @@ The seven local variables are as follows @@ -628,26 +628,30 @@ The seven local variables are as follows
628.Bl -tag -width ".ARCHIVE" 628.Bl -tag -width ".ARCHIVE"
629.It Va .ALLSRC 629.It Va .ALLSRC
630The list of all sources for this target; also known as 630The list of all sources for this target; also known as
631.Ql Va \&\*[Gt] . 631.Ql Va \&\*[Gt] .
632.It Va .ARCHIVE 632.It Va .ARCHIVE
633The name of the archive file. 633The name of the archive file.
634.It Va .IMPSRC 634.It Va .IMPSRC
635In suffix-transformation rules, the name/path of the source from which the 635In suffix-transformation rules, the name/path of the source from which the
636target is to be transformed (the 636target is to be transformed (the
637.Dq implied 637.Dq implied
638source); also known as 638source); also known as
639.Ql Va \&\*[Lt] . 639.Ql Va \&\*[Lt] .
640It is not defined in explicit rules. 640It is not defined in explicit rules.
 641.It Va .INCLUDEDFROMDIR
 642The directory of the file this Makefile was included from.
 643.It Va .INCLUDEDFROMFILE
 644The filename of the file this Makefile was included from.
641.It Va .MEMBER 645.It Va .MEMBER
642The name of the archive member. 646The name of the archive member.
643.It Va .OODATE 647.It Va .OODATE
644The list of sources for this target that were deemed out-of-date; also 648The list of sources for this target that were deemed out-of-date; also
645known as 649known as
646.Ql Va \&? . 650.Ql Va \&? .
647.It Va .PREFIX 651.It Va .PREFIX
648The file prefix of the target, containing only the file portion, no suffix 652The file prefix of the target, containing only the file portion, no suffix
649or preceding directory components; also known as 653or preceding directory components; also known as
650.Ql Va * . 654.Ql Va * .
651.It Va .TARGET 655.It Va .TARGET
652The name of the target; also known as 656The name of the target; also known as
653.Ql Va @ . 657.Ql Va @ .

cvs diff -r1.192 -r1.193 src/usr.bin/make/parse.c (expand / switch to unified diff)

--- src/usr.bin/make/parse.c 2013/10/18 20:47:06 1.192
+++ src/usr.bin/make/parse.c 2014/01/10 16:12:52 1.193
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: parse.c,v 1.192 2013/10/18 20:47:06 christos Exp $ */ 1/* $NetBSD: parse.c,v 1.193 2014/01/10 16:12:52 christos Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1988, 1989, 1990, 1993 4 * Copyright (c) 1988, 1989, 1990, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Adam de Boor. 8 * Adam de Boor.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -59,34 +59,34 @@ @@ -59,34 +59,34 @@
59 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 59 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
60 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 60 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
61 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 61 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
62 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 62 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
63 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 63 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
64 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 64 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 65 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
66 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 66 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
67 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 67 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
68 * SUCH DAMAGE. 68 * SUCH DAMAGE.
69 */ 69 */
70 70
71#ifndef MAKE_NATIVE 71#ifndef MAKE_NATIVE
72static char rcsid[] = "$NetBSD: parse.c,v 1.192 2013/10/18 20:47:06 christos Exp $"; 72static char rcsid[] = "$NetBSD: parse.c,v 1.193 2014/01/10 16:12:52 christos Exp $";
73#else 73#else
74#include <sys/cdefs.h> 74#include <sys/cdefs.h>
75#ifndef lint 75#ifndef lint
76#if 0 76#if 0
77static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94"; 77static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
78#else 78#else
79__RCSID("$NetBSD: parse.c,v 1.192 2013/10/18 20:47:06 christos Exp $"); 79__RCSID("$NetBSD: parse.c,v 1.193 2014/01/10 16:12:52 christos Exp $");
80#endif 80#endif
81#endif /* not lint */ 81#endif /* not lint */
82#endif 82#endif
83 83
84/*- 84/*-
85 * parse.c -- 85 * parse.c --
86 * Functions to parse a makefile. 86 * Functions to parse a makefile.
87 * 87 *
88 * One function, Parse_Init, must be called before any functions 88 * One function, Parse_Init, must be called before any functions
89 * in this module are used. After that, the function Parse_File is the 89 * in this module are used. After that, the function Parse_File is the
90 * main entry point and controls most of the other functions in this 90 * main entry point and controls most of the other functions in this
91 * module. 91 * module.
92 * 92 *
@@ -351,26 +351,27 @@ static void ParseVErrorInternal(FILE *,  @@ -351,26 +351,27 @@ static void ParseVErrorInternal(FILE *,
351 MAKE_ATTR_PRINTFLIKE(5, 0); 351 MAKE_ATTR_PRINTFLIKE(5, 0);
352static int ParseFindKeyword(const char *); 352static int ParseFindKeyword(const char *);
353static int ParseLinkSrc(void *, void *); 353static int ParseLinkSrc(void *, void *);
354static int ParseDoOp(void *, void *); 354static int ParseDoOp(void *, void *);
355static void ParseDoSrc(int, const char *); 355static void ParseDoSrc(int, const char *);
356static int ParseFindMain(void *, void *); 356static int ParseFindMain(void *, void *);
357static int ParseAddDir(void *, void *); 357static int ParseAddDir(void *, void *);
358static int ParseClearPath(void *, void *); 358static int ParseClearPath(void *, void *);
359static void ParseDoDependency(char *); 359static void ParseDoDependency(char *);
360static int ParseAddCmd(void *, void *); 360static int ParseAddCmd(void *, void *);
361static void ParseHasCommands(void *); 361static void ParseHasCommands(void *);
362static void ParseDoInclude(char *); 362static void ParseDoInclude(char *);
363static void ParseSetParseFile(const char *); 363static void ParseSetParseFile(const char *);
 364static void ParseSetIncludedFile(void);
364#ifdef SYSVINCLUDE 365#ifdef SYSVINCLUDE
365static void ParseTraditionalInclude(char *); 366static void ParseTraditionalInclude(char *);
366#endif 367#endif
367#ifdef GMAKEEXPORT 368#ifdef GMAKEEXPORT
368static void ParseGmakeExport(char *); 369static void ParseGmakeExport(char *);
369#endif 370#endif
370static int ParseEOF(void); 371static int ParseEOF(void);
371static char *ParseReadLine(void); 372static char *ParseReadLine(void);
372static void ParseFinishLine(void); 373static void ParseFinishLine(void);
373static void ParseMark(GNode *); 374static void ParseMark(GNode *);
374 375
375//////////////////////////////////////////////////////////// 376////////////////////////////////////////////////////////////
376// file loader 377// file loader
@@ -835,27 +836,28 @@ ParseMessage(char *line) @@ -835,27 +836,28 @@ ParseMessage(char *line)
835static int 836static int
836ParseLinkSrc(void *pgnp, void *cgnp) 837ParseLinkSrc(void *pgnp, void *cgnp)
837{ 838{
838 GNode *pgn = (GNode *)pgnp; 839 GNode *pgn = (GNode *)pgnp;
839 GNode *cgn = (GNode *)cgnp; 840 GNode *cgn = (GNode *)cgnp;
840 841
841 if ((pgn->type & OP_DOUBLEDEP) && !Lst_IsEmpty (pgn->cohorts)) 842 if ((pgn->type & OP_DOUBLEDEP) && !Lst_IsEmpty (pgn->cohorts))
842 pgn = (GNode *)Lst_Datum(Lst_Last(pgn->cohorts)); 843 pgn = (GNode *)Lst_Datum(Lst_Last(pgn->cohorts));
843 (void)Lst_AtEnd(pgn->children, cgn); 844 (void)Lst_AtEnd(pgn->children, cgn);
844 if (specType == Not) 845 if (specType == Not)
845 (void)Lst_AtEnd(cgn->parents, pgn); 846 (void)Lst_AtEnd(cgn->parents, pgn);
846 pgn->unmade += 1; 847 pgn->unmade += 1;
847 if (DEBUG(PARSE)) { 848 if (DEBUG(PARSE)) {
848 fprintf(debug_file, "# ParseLinkSrc: added child %s - %s\n", pgn->name, cgn->name); 849 fprintf(debug_file, "# %s: added child %s - %s\n", __func__,
 850 pgn->name, cgn->name);
849 Targ_PrintNode(pgn, 0); 851 Targ_PrintNode(pgn, 0);
850 Targ_PrintNode(cgn, 0); 852 Targ_PrintNode(cgn, 0);
851 } 853 }
852 return (0); 854 return (0);
853} 855}
854 856
855/*- 857/*-
856 *--------------------------------------------------------------------- 858 *---------------------------------------------------------------------
857 * ParseDoOp -- 859 * ParseDoOp --
858 * Apply the parsed operator to the given target node. Used in a 860 * Apply the parsed operator to the given target node. Used in a
859 * Lst_ForEach call by ParseDoDependency once all targets have 861 * Lst_ForEach call by ParseDoDependency once all targets have
860 * been found and their operator parsed. If the previous and new 862 * been found and their operator parsed. If the previous and new
861 * operators are incompatible, a major error is taken. 863 * operators are incompatible, a major error is taken.
@@ -1010,28 +1012,28 @@ ParseDoSrc(int tOp, const char *src) @@ -1010,28 +1012,28 @@ ParseDoSrc(int tOp, const char *src)
1010 1012
1011 case Order: 1013 case Order:
1012 /* 1014 /*
1013 * Create proper predecessor/successor links between the previous 1015 * Create proper predecessor/successor links between the previous
1014 * source and the current one. 1016 * source and the current one.
1015 */ 1017 */
1016 gn = Targ_FindNode(src, TARG_CREATE); 1018 gn = Targ_FindNode(src, TARG_CREATE);
1017 if (doing_depend) 1019 if (doing_depend)
1018 ParseMark(gn); 1020 ParseMark(gn);
1019 if (predecessor != NULL) { 1021 if (predecessor != NULL) {
1020 (void)Lst_AtEnd(predecessor->order_succ, gn); 1022 (void)Lst_AtEnd(predecessor->order_succ, gn);
1021 (void)Lst_AtEnd(gn->order_pred, predecessor); 1023 (void)Lst_AtEnd(gn->order_pred, predecessor);
1022 if (DEBUG(PARSE)) { 1024 if (DEBUG(PARSE)) {
1023 fprintf(debug_file, "# ParseDoSrc: added Order dependency %s - %s\n", 1025 fprintf(debug_file, "# %s: added Order dependency %s - %s\n",
1024 predecessor->name, gn->name); 1026 __func__, predecessor->name, gn->name);
1025 Targ_PrintNode(predecessor, 0); 1027 Targ_PrintNode(predecessor, 0);
1026 Targ_PrintNode(gn, 0); 1028 Targ_PrintNode(gn, 0);
1027 } 1029 }
1028 } 1030 }
1029 /* 1031 /*
1030 * The current source now becomes the predecessor for the next one. 1032 * The current source now becomes the predecessor for the next one.
1031 */ 1033 */
1032 predecessor = gn; 1034 predecessor = gn;
1033 break; 1035 break;
1034 1036
1035 default: 1037 default:
1036 /* 1038 /*
1037 * If the source is not an attribute, we need to find/create 1039 * If the source is not an attribute, we need to find/create
@@ -2154,26 +2156,27 @@ Parse_include_file(char *file, Boolean i @@ -2154,26 +2156,27 @@ Parse_include_file(char *file, Boolean i
2154 2156
2155 /* Actually open the file... */ 2157 /* Actually open the file... */
2156 fd = open(fullname, O_RDONLY); 2158 fd = open(fullname, O_RDONLY);
2157 if (fd == -1) { 2159 if (fd == -1) {
2158 if (!silent) 2160 if (!silent)
2159 Parse_Error(PARSE_FATAL, "Cannot open %s", fullname); 2161 Parse_Error(PARSE_FATAL, "Cannot open %s", fullname);
2160 free(fullname); 2162 free(fullname);
2161 return; 2163 return;
2162 } 2164 }
2163 2165
2164 /* load it */ 2166 /* load it */
2165 lf = loadfile(fullname, fd); 2167 lf = loadfile(fullname, fd);
2166 2168
 2169 ParseSetIncludedFile();
2167 /* Start reading from this file next */ 2170 /* Start reading from this file next */
2168 Parse_SetInput(fullname, 0, -1, loadedfile_nextbuf, lf); 2171 Parse_SetInput(fullname, 0, -1, loadedfile_nextbuf, lf);
2169 curFile->lf = lf; 2172 curFile->lf = lf;
2170} 2173}
2171 2174
2172static void 2175static void
2173ParseDoInclude(char *line) 2176ParseDoInclude(char *line)
2174{ 2177{
2175 char endc; /* the character which ends the file spec */ 2178 char endc; /* the character which ends the file spec */
2176 char *cp; /* current position in file spec */ 2179 char *cp; /* current position in file spec */
2177 int silent = (*line != 'i') ? 1 : 0; 2180 int silent = (*line != 'i') ? 1 : 0;
2178 char *file = &line[7 + silent]; 2181 char *file = &line[7 + silent];
2179 2182
@@ -2213,26 +2216,61 @@ ParseDoInclude(char *line) @@ -2213,26 +2216,61 @@ ParseDoInclude(char *line)
2213 /* 2216 /*
2214 * Substitute for any variables in the file name before trying to 2217 * Substitute for any variables in the file name before trying to
2215 * find the thing. 2218 * find the thing.
2216 */ 2219 */
2217 file = Var_Subst(NULL, file, VAR_CMD, FALSE); 2220 file = Var_Subst(NULL, file, VAR_CMD, FALSE);
2218 2221
2219 Parse_include_file(file, endc == '>', silent); 2222 Parse_include_file(file, endc == '>', silent);
2220 free(file); 2223 free(file);
2221} 2224}
2222 2225
2223 2226
2224/*- 2227/*-
2225 *--------------------------------------------------------------------- 2228 *---------------------------------------------------------------------
 2229 * ParseSetIncludedFile --
 2230 * Set the .INCLUDEDFROMFILE variable to the contents of .PARSEFILE
 2231 * and the .INCLUDEDFROMDIR variable to the contents of .PARSEDIR
 2232 *
 2233 * Results:
 2234 * None
 2235 *
 2236 * Side Effects:
 2237 * The .INCLUDEDFROMFILE variable is overwritten by the contents
 2238 * of .PARSEFILE and the .INCLUDEDFROMDIR variable is overwriten
 2239 * but the contents of .PARSEDIR
 2240 *---------------------------------------------------------------------
 2241 */
 2242static void
 2243ParseSetIncludedFile(void)
 2244{
 2245 char *pf, *fp = NULL;
 2246 char *pd, *dp = NULL;
 2247
 2248 pf = Var_Value(".PARSEFILE", VAR_GLOBAL, &fp);
 2249 Var_Set(".INCLUDEDFROMFILE", pf, VAR_GLOBAL, 0);
 2250 pd = Var_Value(".PARSEDIR", VAR_GLOBAL, &dp);
 2251 Var_Set(".INCLUDEDFROMDIR", pd, VAR_GLOBAL, 0);
 2252
 2253 if (DEBUG(PARSE))
 2254 fprintf(debug_file, "%s: ${.INCLUDEDFROMDIR} = `%s' "
 2255 "${.INCLUDEDFROMFILE} = `%s'\n", __func__, pd, pf);
 2256
 2257 if (fp)
 2258 free(fp);
 2259 if (dp)
 2260 free(dp);
 2261}
 2262/*-
 2263 *---------------------------------------------------------------------
2226 * ParseSetParseFile -- 2264 * ParseSetParseFile --
2227 * Set the .PARSEDIR and .PARSEFILE variables to the dirname and 2265 * Set the .PARSEDIR and .PARSEFILE variables to the dirname and
2228 * basename of the given filename 2266 * basename of the given filename
2229 * 2267 *
2230 * Results: 2268 * Results:
2231 * None 2269 * None
2232 * 2270 *
2233 * Side Effects: 2271 * Side Effects:
2234 * The .PARSEDIR and .PARSEFILE variables are overwritten by the 2272 * The .PARSEDIR and .PARSEFILE variables are overwritten by the
2235 * dirname and basename of the given filename. 2273 * dirname and basename of the given filename.
2236 *--------------------------------------------------------------------- 2274 *---------------------------------------------------------------------
2237 */ 2275 */
2238static void 2276static void
@@ -2246,28 +2284,28 @@ ParseSetParseFile(const char *filename) @@ -2246,28 +2284,28 @@ ParseSetParseFile(const char *filename)
2246 if (slash == NULL) { 2284 if (slash == NULL) {
2247 Var_Set(".PARSEDIR", pd = curdir, VAR_GLOBAL, 0); 2285 Var_Set(".PARSEDIR", pd = curdir, VAR_GLOBAL, 0);
2248 Var_Set(".PARSEFILE", pf = filename, VAR_GLOBAL, 0); 2286 Var_Set(".PARSEFILE", pf = filename, VAR_GLOBAL, 0);
2249 dirname= NULL; 2287 dirname= NULL;
2250 } else { 2288 } else {
2251 len = slash - filename; 2289 len = slash - filename;
2252 dirname = bmake_malloc(len + 1); 2290 dirname = bmake_malloc(len + 1);
2253 memcpy(dirname, filename, len); 2291 memcpy(dirname, filename, len);
2254 dirname[len] = '\0'; 2292 dirname[len] = '\0';
2255 Var_Set(".PARSEDIR", pd = dirname, VAR_GLOBAL, 0); 2293 Var_Set(".PARSEDIR", pd = dirname, VAR_GLOBAL, 0);
2256 Var_Set(".PARSEFILE", pf = slash + 1, VAR_GLOBAL, 0); 2294 Var_Set(".PARSEFILE", pf = slash + 1, VAR_GLOBAL, 0);
2257 } 2295 }
2258 if (DEBUG(PARSE)) 2296 if (DEBUG(PARSE))
2259 fprintf(debug_file, "ParseSetParseFile: ${.PARSEDIR} = `%s' " 2297 fprintf(debug_file, "%s: ${.PARSEDIR} = `%s' ${.PARSEFILE} = `%s'\n",
2260 "${.PARSEFILE} = `%s'\n", pd, pf); 2298 __func__, pd, pf);
2261 free(dirname); 2299 free(dirname);
2262} 2300}
2263 2301
2264/* 2302/*
2265 * Track the makefiles we read - so makefiles can 2303 * Track the makefiles we read - so makefiles can
2266 * set dependencies on them. 2304 * set dependencies on them.
2267 * Avoid adding anything more than once. 2305 * Avoid adding anything more than once.
2268 */ 2306 */
2269 2307
2270static void 2308static void
2271ParseTrackInput(const char *name) 2309ParseTrackInput(const char *name)
2272{ 2310{
2273 char *old; 2311 char *old;
@@ -2309,28 +2347,28 @@ ParseTrackInput(const char *name) @@ -2309,28 +2347,28 @@ ParseTrackInput(const char *name)
2309void 2347void
2310Parse_SetInput(const char *name, int line, int fd, 2348Parse_SetInput(const char *name, int line, int fd,
2311 char *(*nextbuf)(void *, size_t *), void *arg) 2349 char *(*nextbuf)(void *, size_t *), void *arg)
2312{ 2350{
2313 char *buf; 2351 char *buf;
2314 size_t len; 2352 size_t len;
2315 2353
2316 if (name == NULL) 2354 if (name == NULL)
2317 name = curFile->fname; 2355 name = curFile->fname;
2318 else 2356 else
2319 ParseTrackInput(name); 2357 ParseTrackInput(name);
2320 2358
2321 if (DEBUG(PARSE)) 2359 if (DEBUG(PARSE))
2322 fprintf(debug_file, "Parse_SetInput: file %s, line %d, fd %d, nextbuf %p, arg %p\n", 2360 fprintf(debug_file, "%s: file %s, line %d, fd %d, nextbuf %p, arg %p\n",
2323 name, line, fd, nextbuf, arg); 2361 __func__, name, line, fd, nextbuf, arg);
2324 2362
2325 if (fd == -1 && nextbuf == NULL) 2363 if (fd == -1 && nextbuf == NULL)
2326 /* sanity */ 2364 /* sanity */
2327 return; 2365 return;
2328 2366
2329 if (curFile != NULL) 2367 if (curFile != NULL)
2330 /* Save exiting file info */ 2368 /* Save exiting file info */
2331 Lst_AtFront(includes, curFile); 2369 Lst_AtFront(includes, curFile);
2332 2370
2333 /* Allocate and fill in new structure */ 2371 /* Allocate and fill in new structure */
2334 curFile = bmake_malloc(sizeof *curFile); 2372 curFile = bmake_malloc(sizeof *curFile);
2335 2373
2336 /* 2374 /*
@@ -2382,27 +2420,27 @@ Parse_SetInput(const char *name, int lin @@ -2382,27 +2420,27 @@ Parse_SetInput(const char *name, int lin
2382 * fname and curFILE are altered for the new file 2420 * fname and curFILE are altered for the new file
2383 *--------------------------------------------------------------------- 2421 *---------------------------------------------------------------------
2384 */ 2422 */
2385static void 2423static void
2386ParseTraditionalInclude(char *line) 2424ParseTraditionalInclude(char *line)
2387{ 2425{
2388 char *cp; /* current position in file spec */ 2426 char *cp; /* current position in file spec */
2389 int done = 0; 2427 int done = 0;
2390 int silent = (line[0] != 'i') ? 1 : 0; 2428 int silent = (line[0] != 'i') ? 1 : 0;
2391 char *file = &line[silent + 7]; 2429 char *file = &line[silent + 7];
2392 char *all_files; 2430 char *all_files;
2393 2431
2394 if (DEBUG(PARSE)) { 2432 if (DEBUG(PARSE)) {
2395 fprintf(debug_file, "ParseTraditionalInclude: %s\n", file); 2433 fprintf(debug_file, "%s: %s\n", __func__, file);
2396 } 2434 }
2397 2435
2398 /* 2436 /*
2399 * Skip over whitespace 2437 * Skip over whitespace
2400 */ 2438 */
2401 while (isspace((unsigned char)*file)) 2439 while (isspace((unsigned char)*file))
2402 file++; 2440 file++;
2403 2441
2404 /* 2442 /*
2405 * Substitute for any variables in the file name before trying to 2443 * Substitute for any variables in the file name before trying to
2406 * find the thing. 2444 * find the thing.
2407 */ 2445 */
2408 all_files = Var_Subst(NULL, file, VAR_CMD, FALSE); 2446 all_files = Var_Subst(NULL, file, VAR_CMD, FALSE);
@@ -2441,27 +2479,27 @@ ParseTraditionalInclude(char *line) @@ -2441,27 +2479,27 @@ ParseTraditionalInclude(char *line)
2441 * None 2479 * None
2442 * 2480 *
2443 * Side Effects: 2481 * Side Effects:
2444 * None 2482 * None
2445 *--------------------------------------------------------------------- 2483 *---------------------------------------------------------------------
2446 */ 2484 */
2447static void 2485static void
2448ParseGmakeExport(char *line) 2486ParseGmakeExport(char *line)
2449{ 2487{
2450 char *variable = &line[6]; 2488 char *variable = &line[6];
2451 char *value; 2489 char *value;
2452 2490
2453 if (DEBUG(PARSE)) { 2491 if (DEBUG(PARSE)) {
2454 fprintf(debug_file, "ParseGmakeExport: %s\n", variable); 2492 fprintf(debug_file, "%s: %s\n", __func__, variable);
2455 } 2493 }
2456 2494
2457 /* 2495 /*
2458 * Skip over whitespace 2496 * Skip over whitespace
2459 */ 2497 */
2460 while (isspace((unsigned char)*variable)) 2498 while (isspace((unsigned char)*variable))
2461 variable++; 2499 variable++;
2462 2500
2463 for (value = variable; *value && *value != '='; value++) 2501 for (value = variable; *value && *value != '='; value++)
2464 continue; 2502 continue;
2465 2503
2466 if (*value != '=') { 2504 if (*value != '=') {
2467 Parse_Error(PARSE_FATAL, 2505 Parse_Error(PARSE_FATAL,
@@ -2521,26 +2559,27 @@ ParseEOF(void) @@ -2521,26 +2559,27 @@ ParseEOF(void)
2521 } 2559 }
2522 2560
2523 /* Dispose of curFile info */ 2561 /* Dispose of curFile info */
2524 /* Leak curFile->fname because all the gnodes have pointers to it */ 2562 /* Leak curFile->fname because all the gnodes have pointers to it */
2525 free(curFile->P_str); 2563 free(curFile->P_str);
2526 free(curFile); 2564 free(curFile);
2527 2565
2528 curFile = Lst_DeQueue(includes); 2566 curFile = Lst_DeQueue(includes);
2529 2567
2530 if (curFile == NULL) { 2568 if (curFile == NULL) {
2531 /* We've run out of input */ 2569 /* We've run out of input */
2532 Var_Delete(".PARSEDIR", VAR_GLOBAL); 2570 Var_Delete(".PARSEDIR", VAR_GLOBAL);
2533 Var_Delete(".PARSEFILE", VAR_GLOBAL); 2571 Var_Delete(".PARSEFILE", VAR_GLOBAL);
 2572 Var_Delete(".INCLUDED_FROM", VAR_GLOBAL);
2534 return DONE; 2573 return DONE;
2535 } 2574 }
2536 2575
2537 if (DEBUG(PARSE)) 2576 if (DEBUG(PARSE))
2538 fprintf(debug_file, "ParseEOF: returning to file %s, line %d\n", 2577 fprintf(debug_file, "ParseEOF: returning to file %s, line %d\n",
2539 curFile->fname, curFile->lineno); 2578 curFile->fname, curFile->lineno);
2540 2579
2541 /* Restore the PARSEDIR/PARSEFILE variables */ 2580 /* Restore the PARSEDIR/PARSEFILE variables */
2542 ParseSetParseFile(curFile->fname); 2581 ParseSetParseFile(curFile->fname);
2543 return (CONTINUE); 2582 return (CONTINUE);
2544} 2583}
2545 2584
2546#define PARSE_RAW 1 2585#define PARSE_RAW 1