From 62ecbc733ea5065acd331186a3c67ac74714f935 Mon Sep 17 00:00:00 2001 From: Max Okumoto Date: Mon, 23 May 2005 20:04:43 +0000 Subject: [PATCH] Move the create list variable out of global scope and put it into the newly created Parser object. And Pass the parser object around as a function paramter. --- usr.bin/make/cond.c | 70 +++++++++++++++++++++--------------------- usr.bin/make/cond.h | 12 +++++--- usr.bin/make/globals.h | 8 +---- usr.bin/make/main.c | 55 +++++++++++++++++---------------- usr.bin/make/parse.c | 69 ++++++++++++++++++++--------------------- usr.bin/make/parse.h | 14 +++++++-- 6 files changed, 117 insertions(+), 111 deletions(-) diff --git a/usr.bin/make/cond.c b/usr.bin/make/cond.c index 20f3682252..1847880be5 100644 --- a/usr.bin/make/cond.c +++ b/usr.bin/make/cond.c @@ -38,7 +38,7 @@ * * @(#)cond.c 8.2 (Berkeley) 1/2/94 * $FreeBSD: src/usr.bin/make/cond.c,v 1.39 2005/02/07 07:49:16 harti Exp $ - * $DragonFly: src/usr.bin/make/cond.c,v 1.44 2005/05/16 17:29:42 okumoto Exp $ + * $DragonFly: src/usr.bin/make/cond.c,v 1.45 2005/05/23 20:04:43 okumoto Exp $ */ /* @@ -107,7 +107,7 @@ typedef enum { Err } Token; -typedef Boolean CondProc(int, char *); +typedef Boolean CondProc(Parser *, int, char *); /*- * Structures to handle elegantly the different forms of #if's. The @@ -120,10 +120,10 @@ static CondProc CondDoMake; static CondProc CondDoExists; static CondProc CondDoTarget; static char *CondCvtArg(char *, double *); -static Token CondToken(Boolean); -static Token CondT(Boolean); -static Token CondF(Boolean); -static Token CondE(Boolean); +static Token CondToken(Parser *, Boolean); +static Token CondT(Parser *, Boolean); +static Token CondF(Parser *, Boolean); +static Token CondE(Parser *, Boolean); static const struct If { Boolean doNot; /* TRUE if default function should be negated */ @@ -279,7 +279,7 @@ CondGetArg(char **linePtr, char **argPtr, const char *func, Boolean parens) * TRUE if the given variable is defined. */ static Boolean -CondDoDefined(int argLen, char *arg) +CondDoDefined(Parser *parser __unused, int argLen, char *arg) { char savec = arg[argLen]; Boolean result; @@ -302,7 +302,7 @@ CondDoDefined(int argLen, char *arg) * TRUE if the given target is being made. */ static Boolean -CondDoMake(int argLen, char *arg) +CondDoMake(Parser *parser, int argLen, char *arg) { char savec = arg[argLen]; Boolean result; @@ -310,7 +310,7 @@ CondDoMake(int argLen, char *arg) arg[argLen] = '\0'; result = FALSE; - LST_FOREACH(ln, &create) { + LST_FOREACH(ln, parser->create) { if (Str_Match(Lst_Datum(ln), arg)) { result = TRUE; break; @@ -328,7 +328,7 @@ CondDoMake(int argLen, char *arg) * TRUE if the file exists and FALSE if it does not. */ static Boolean -CondDoExists(int argLen, char *arg) +CondDoExists(Parser *parser __unused, int argLen, char *arg) { char savec = arg[argLen]; Boolean result; @@ -354,7 +354,7 @@ CondDoExists(int argLen, char *arg) * TRUE if the node exists as a target and FALSE if it does not. */ static Boolean -CondDoTarget(int argLen, char *arg) +CondDoTarget(Parser *parser __unused, int argLen, char *arg) { char savec = arg[argLen]; Boolean result; @@ -427,7 +427,7 @@ CondCvtArg(char *str, double *value) * condPushback will be set back to None if it is used. */ static Token -CondToken(Boolean doEval) +CondToken(Parser *parser, Boolean doEval) { Token t; @@ -859,7 +859,7 @@ CondToken(Boolean doEval) * invert is TRUE, we invert the sense of the * function. */ - t = (!doEval || (*evalProc) (arglen, arg) ? + t = (!doEval || evalProc(parser, arglen, arg) ? (invert ? False : True) : (invert ? True : False)); free(arg); @@ -884,11 +884,11 @@ CondToken(Boolean doEval) * Tokens are consumed. */ static Token -CondT(Boolean doEval) +CondT(Parser *parser, Boolean doEval) { Token t; - t = CondToken(doEval); + t = CondToken(parser, doEval); if (t == EndOfFile) { /* * If we reached the end of the expression, the expression @@ -899,14 +899,14 @@ CondT(Boolean doEval) /* * T -> ( E ) */ - t = CondE(doEval); + t = CondE(parser, doEval); if (t != Err) { - if (CondToken(doEval) != RParen) { + if (CondToken(parser, doEval) != RParen) { t = Err; } } } else if (t == Not) { - t = CondT(doEval); + t = CondT(parser, doEval); if (t == True) { t = False; } else if (t == False) { @@ -928,13 +928,13 @@ CondT(Boolean doEval) * Tokens are consumed. */ static Token -CondF(Boolean doEval) +CondF(Parser *parser, Boolean doEval) { Token l, o; - l = CondT(doEval); + l = CondT(parser, doEval); if (l != Err) { - o = CondToken(doEval); + o = CondToken(parser, doEval); if (o == And) { /* @@ -946,9 +946,9 @@ CondF(Boolean doEval) * be it an Err or no. */ if (l == True) { - l = CondF(doEval); + l = CondF(parser, doEval); } else { - CondF(FALSE); + CondF(parser, FALSE); } } else { /* @@ -972,13 +972,13 @@ CondF(Boolean doEval) * Tokens are, of course, consumed. */ static Token -CondE(Boolean doEval) +CondE(Parser *parser, Boolean doEval) { Token l, o; - l = CondF(doEval); + l = CondF(parser, doEval); if (l != Err) { - o = CondToken(doEval); + o = CondToken(parser, doEval); if (o == Or) { /* @@ -991,9 +991,9 @@ CondE(Boolean doEval) * we parse the r.h.s. to throw it away. */ if (l == False) { - l = CondE(doEval); + l = CondE(parser, doEval); } else { - CondE(FALSE); + CondE(parser, FALSE); } } else { /* @@ -1011,7 +1011,7 @@ CondE(Boolean doEval) * This function is called even when we're skipping. */ void -Cond_If(char *line, int code, int lineno) +Cond_If(Parser *parser, char *line, int code, int lineno) { const struct If *ifp; Boolean value; @@ -1058,15 +1058,15 @@ Cond_If(char *line, int code, int lineno) condExpr = line; condPushBack = None; - switch (CondE(TRUE)) { + switch (CondE(parser, TRUE)) { case True: - if (CondToken(TRUE) != EndOfFile) + if (CondToken(parser, TRUE) != EndOfFile) goto err; value = TRUE; break; case False: - if (CondToken(TRUE) != EndOfFile) + if (CondToken(parser, TRUE) != EndOfFile) goto err; value = FALSE; break; @@ -1115,7 +1115,7 @@ Cond_If(char *line, int code, int lineno) * Handle .else statement. */ void -Cond_Else(char *line __unused, int code __unused, int lineno __unused) +Cond_Else(Parser *parser __unused, char *line __unused, int code __unused, int lineno __unused) { while (isspace((u_char)*line)) @@ -1156,7 +1156,7 @@ Cond_Else(char *line __unused, int code __unused, int lineno __unused) * Handle .endif statement. */ void -Cond_Endif(char *line __unused, int code __unused, int lineno __unused) +Cond_Endif(Parser *parser __unused, char *line __unused, int code __unused, int lineno __unused) { while (isspace((u_char)*line)) @@ -1198,7 +1198,7 @@ Cond_Endif(char *line __unused, int code __unused, int lineno __unused) * Parse_Error will be called if open conditionals are around. */ void -Cond_End(void) +Cond_End(Parser *parser __unused, char *line __unused, int code __unused, int lineno __unused) { int level; diff --git a/usr.bin/make/cond.h b/usr.bin/make/cond.h index 0b99ff9b8d..a62a24e763 100644 --- a/usr.bin/make/cond.h +++ b/usr.bin/make/cond.h @@ -35,12 +35,14 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/usr.bin/make/cond.h,v 1.4 2005/04/15 21:01:27 okumoto Exp $ + * $DragonFly: src/usr.bin/make/cond.h,v 1.5 2005/05/23 20:04:43 okumoto Exp $ */ #ifndef cond_h_6e96ad7c #define cond_h_6e96ad7c +#include "parse.h" + /* * Values returned by Cond_Eval. */ @@ -63,10 +65,10 @@ enum { COND_ENDIF, }; -void Cond_If(char *, int, int); -void Cond_Else(char *, int, int); -void Cond_Endif(char *, int, int); -void Cond_End(void); +DirectiveHandler Cond_If; +DirectiveHandler Cond_Else; +DirectiveHandler Cond_Endif; +DirectiveHandler Cond_End; extern Boolean skipLine; diff --git a/usr.bin/make/globals.h b/usr.bin/make/globals.h index 91a2f656a7..1531c56e0b 100644 --- a/usr.bin/make/globals.h +++ b/usr.bin/make/globals.h @@ -35,7 +35,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/usr.bin/make/globals.h,v 1.12 2005/05/23 18:26:25 okumoto Exp $ + * $DragonFly: src/usr.bin/make/globals.h,v 1.13 2005/05/23 20:04:43 okumoto Exp $ */ #ifndef globals_h_1c1edb96 @@ -54,12 +54,6 @@ struct GNode; struct Path; -/* - * The list of target names specified on the command line. - * Used to resolve #if make(...) statements - */ -extern Lst create; - /* The list of directories to search when looking for targets */ extern struct Path dirSearchPath; diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c index 72868299a5..17492f146f 100644 --- a/usr.bin/make/main.c +++ b/usr.bin/make/main.c @@ -38,7 +38,7 @@ * @(#) Copyright (c) 1988, 1989, 1990, 1993 The Regents of the University of California. All rights reserved. * @(#)main.c 8.3 (Berkeley) 3/19/94 * $FreeBSD: src/usr.bin/make/main.c,v 1.118 2005/02/13 13:33:56 harti Exp $ - * $DragonFly: src/usr.bin/make/main.c,v 1.108 2005/05/23 20:04:04 okumoto Exp $ + * $DragonFly: src/usr.bin/make/main.c,v 1.109 2005/05/23 20:04:43 okumoto Exp $ */ /* @@ -95,12 +95,15 @@ extern char **environ; /* XXX what header declares this variable? */ #define DEFMAXJOBS 1 typedef struct MakeFlags { - /* ordered list of makefiles to read */ + /** ordered list of makefiles to read */ Lst makefiles; - /* list of variables to print */ + /** list of variables to print */ Lst variables; + /** Targets to be made */ + Lst create; + Boolean expandVars; /* fully expand printed variables */ Boolean noBuiltins; /* -r flag */ Boolean forceJobs; /* -j argument given */ @@ -116,9 +119,6 @@ typedef struct MakeFlags { /* (-E) vars to override from env */ Lst envFirstVars = Lst_Initializer(envFirstVars); -/* Targets to be made */ -Lst create = Lst_Initializer(create); - Boolean allPrecious; /* .PRECIOUS given on line by itself */ Boolean beSilent; /* -s flag */ Boolean beVerbose; /* -v flag */ @@ -184,7 +184,7 @@ MFLAGS_append(const char *flag, char *arg) * TRUE if ok. FALSE if couldn't open file. */ static Boolean -ReadMakefile(MakeFlags *mf, const char file[], const char curdir[], const char objdir[]) +ReadMakefile(Parser *parser, MakeFlags *mf, const char file[], const char curdir[], const char objdir[]) { char path[MAXPATHLEN]; FILE *stream; @@ -192,7 +192,7 @@ ReadMakefile(MakeFlags *mf, const char file[], const char curdir[], const char o char *name; if (!strcmp(file, "-")) { - Parse_File(mf, "(stdin)", stdin); + Parse_File(parser, mf, "(stdin)", stdin); Var_SetGlobal("MAKEFILE", ""); return (TRUE); } @@ -232,7 +232,7 @@ ReadMakefile(MakeFlags *mf, const char file[], const char curdir[], const char o if (stream != NULL) { if (strcmp(file, ".depend") != 0) Var_SetGlobal("MAKEFILE", file); - Parse_File(mf, path, stream); + Parse_File(parser, mf, path, stream); fclose(stream); return (TRUE); } @@ -256,7 +256,7 @@ ReadMakefile(MakeFlags *mf, const char file[], const char curdir[], const char o */ if (strcmp(file, ".depend") != 0) Var_SetGlobal("MAKEFILE", name); - Parse_File(mf, name, stream); + Parse_File(parser, mf, name, stream); fclose(stream); return (TRUE); } @@ -271,7 +271,7 @@ ReadMakefile(MakeFlags *mf, const char file[], const char curdir[], const char o * makefile. */ static void -ReadInputFiles(MakeFlags *mf, const char curdir[], const char objdir[]) +ReadInputFiles(Parser *parser, MakeFlags *mf, const char curdir[], const char objdir[]) { if (!mf->noBuiltins) { /* Path of sys.mk */ @@ -283,7 +283,7 @@ ReadInputFiles(MakeFlags *mf, const char curdir[], const char objdir[]) if (Lst_IsEmpty(&sysMkPath)) Fatal("make: no system rules (%s).", PATH_DEFSYSMK); LST_FOREACH(ln, &sysMkPath) { - if (!ReadMakefile(mf, Lst_Datum(ln), curdir, objdir)) + if (!ReadMakefile(parser, mf, Lst_Datum(ln), curdir, objdir)) break; } if (ln != NULL) @@ -295,22 +295,22 @@ ReadInputFiles(MakeFlags *mf, const char curdir[], const char objdir[]) LstNode *ln; LST_FOREACH(ln, &mf->makefiles) { - if (!ReadMakefile(mf, Lst_Datum(ln), curdir, objdir)) + if (!ReadMakefile(parser, mf, Lst_Datum(ln), curdir, objdir)) break; } if (ln != NULL) Fatal("make: cannot open %s.", (char *)Lst_Datum(ln)); - } else if (ReadMakefile(mf, "BSDmakefile", curdir, objdir)) { + } else if (ReadMakefile(parser, mf, "BSDmakefile", curdir, objdir)) { /* read BSDmakefile */ - } else if (ReadMakefile(mf, "makefile", curdir, objdir)) { + } else if (ReadMakefile(parser, mf, "makefile", curdir, objdir)) { /* read makefile */ - } else if (ReadMakefile(mf, "Makefile", curdir, objdir)) { + } else if (ReadMakefile(parser, mf, "Makefile", curdir, objdir)) { /* read Makefile */ } else { /* No Makefile found */ } - ReadMakefile(mf, ".depend", curdir, objdir); + ReadMakefile(parser, mf, ".depend", curdir, objdir); } /** @@ -589,7 +589,7 @@ rearg: * any more options. But what do we do * with it? For now treat it like a target. */ - Lst_AtEnd(&create, estrdup(*argv)); + Lst_AtEnd(&mf->create, estrdup(*argv)); } else { /* * (*argv) is a -flag, so backup argv and @@ -605,7 +605,7 @@ rearg: Punt("illegal (null) argument."); } else { - Lst_AtEnd(&create, estrdup(*argv)); + Lst_AtEnd(&mf->create, estrdup(*argv)); } } } @@ -835,12 +835,12 @@ InitVariables(MakeFlags *mf, int argc, char *argv[], char curdir[], char objdir[ * created. If none specified, make the variable empty -- the parser * will fill the thing in with the default or .MAIN target. */ - if (Lst_IsEmpty(&create)) { + if (Lst_IsEmpty(&mf->create)) { Var_SetGlobal(".TARGETS", ""); } else { LstNode *ln; - for (ln = Lst_First(&create); ln != NULL; ln = Lst_Succ(ln)) { + for (ln = Lst_First(&mf->create); ln != NULL; ln = Lst_Succ(ln)) { char *name = Lst_Datum(ln); Var_Append(".TARGETS", name, VAR_GLOBAL); @@ -869,6 +869,7 @@ int main(int argc, char **argv) { MakeFlags mf; + Parser parser; Boolean outOfDate = TRUE; /* FALSE if all targets up to date */ char curdir[MAXPATHLEN]; /* startup directory */ @@ -895,6 +896,7 @@ main(int argc, char **argv) */ Lst_Init(&mf.makefiles); Lst_Init(&mf.variables); + Lst_Init(&mf.create); mf.expandVars = TRUE; mf.noBuiltins = FALSE; /* Read the built-in rules */ @@ -905,6 +907,8 @@ main(int argc, char **argv) else mf.forceJobs = TRUE; + parser.create = &mf.create; + /* * Initialize the parsing, directory and variable modules to prepare * for the reading of inclusion paths and variable settings on the @@ -966,8 +970,7 @@ main(int argc, char **argv) } } - - ReadInputFiles(&mf, curdir, objdir); + ReadInputFiles(&parser, &mf, curdir, objdir); /* Install all the flags into the MAKE envariable. */ { @@ -1031,10 +1034,10 @@ main(int argc, char **argv) */ Lst targs = Lst_Initializer(targs); - if (Lst_IsEmpty(&create)) + if (Lst_IsEmpty(&mf.create)) Parse_MainName(&targs); else - Targ_FindList(&targs, &create, TARG_CREATE); + Targ_FindList(&targs, &mf.create, TARG_CREATE); /* Traverse the graph, checking on all the targets */ if (compatMake) { @@ -1050,7 +1053,7 @@ main(int argc, char **argv) Lst_Destroy(&mf.variables, free); Lst_Destroy(&mf.makefiles, free); - Lst_Destroy(&create, free); + Lst_Destroy(&mf.create, free); /* print the graph now it's been processed if the user requested it */ if (DEBUG(GRAPH2)) diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c index 7f87bee1bf..38cd59e182 100644 --- a/usr.bin/make/parse.c +++ b/usr.bin/make/parse.c @@ -37,7 +37,7 @@ * * @(#)parse.c 8.3 (Berkeley) 3/19/94 * $FreeBSD: src/usr.bin/make/parse.c,v 1.75 2005/02/07 11:27:47 harti Exp $ - * $DragonFly: src/usr.bin/make/parse.c,v 1.88 2005/05/20 11:48:55 okumoto Exp $ + * $DragonFly: src/usr.bin/make/parse.c,v 1.89 2005/05/23 20:04:43 okumoto Exp $ */ /*- @@ -237,18 +237,18 @@ static const struct keyword { }; #define NKEYWORDS (sizeof(parseKeywords) / sizeof(parseKeywords[0])) -static void parse_include(char *, int, int); -static void parse_message(char *, int, int); -static void parse_makeenv(char *, int, int); -static void parse_undef(char *, int, int); -static void parse_for(char *, int, int); -static void parse_endfor(char *, int, int); +static DirectiveHandler parse_include; +static DirectiveHandler parse_message; +static DirectiveHandler parse_makeenv; +static DirectiveHandler parse_undef; +static DirectiveHandler parse_for; +static DirectiveHandler parse_endfor; static const struct directive { - const char *name; - int code; - Boolean skip_flag; /* execute even when skipped */ - void (*func)(char *, int, int); + const char *name; + int code; + Boolean skip_flag; /* execute even when skipped */ + DirectiveHandler *func; } directives[] = { /* DIRECTIVES-START-TAG */ { "elif", COND_ELIF, TRUE, Cond_If }, @@ -542,7 +542,7 @@ ParseDoOp(int op) *--------------------------------------------------------------------- */ static void -ParseDoSrc(int tOp, char *src, Lst *allsrc) +ParseDoSrc(Parser *parser, int tOp, char *src, Lst *allsrc) { GNode *gn = NULL; const struct keyword *kw; @@ -570,7 +570,7 @@ ParseDoSrc(int tOp, char *src, Lst *allsrc) * invoked if the user didn't specify a target on the command * line. This is to allow #ifmake's to succeed, or something... */ - Lst_AtEnd(&create, estrdup(src)); + Lst_AtEnd(parser->create, estrdup(src)); /* * Add the name to the .TARGETS variable as well, so the user * can employ that, if desired. @@ -693,7 +693,7 @@ ParseDoSrc(int tOp, char *src, Lst *allsrc) *--------------------------------------------------------------------- */ static void -ParseDoDependency(struct MakeFlags *mf, char line[]) +ParseDoDependency(Parser *parser, struct MakeFlags *mf, char line[]) { char *cp; /* our current position */ GNode *gn; /* a general purpose temporary node */ @@ -864,7 +864,7 @@ ParseDoDependency(struct MakeFlags *mf, char line[]) Lst_AtEnd(&paths, &dirSearchPath); break; case Main: - if (!Lst_IsEmpty(&create)) { + if (!Lst_IsEmpty(parser->create)) { specType = Not; } break; @@ -1213,7 +1213,7 @@ ParseDoDependency(struct MakeFlags *mf, char line[]) while (!Lst_IsEmpty(&sources)) { gnp = Lst_DeQueue(&sources); - ParseDoSrc(tOp, gnp->name, &curSrcs); + ParseDoSrc(parser, tOp, gnp->name, &curSrcs); } cp = line; } else { @@ -1222,7 +1222,7 @@ ParseDoDependency(struct MakeFlags *mf, char line[]) cp += 1; } - ParseDoSrc(tOp, line, &curSrcs); + ParseDoSrc(parser, tOp, line, &curSrcs); } while (*cp && isspace((unsigned char)*cp)) { cp++; @@ -2066,7 +2066,7 @@ ParseFinishLine(void) * options */ static void -parse_include(char *file, int code __unused, int lineno __unused) +parse_include(Parser *parser __unused, char *file, int code __unused, int lineno __unused) { char *fullname; /* full pathname of file */ char endc; /* the character which ends the file spec */ @@ -2205,7 +2205,7 @@ parse_include(char *file, int code __unused, int lineno __unused) * a warning if the directive is malformed. */ static void -parse_message(char *line, int iserror, int lineno __unused) +parse_message(Parser *parser __unused, char *line, int iserror, int lineno __unused) { if (!isspace((u_char)*line)) { @@ -2232,7 +2232,7 @@ parse_message(char *line, int iserror, int lineno __unused) * Parse an .undef directive. */ static void -parse_undef(char *line, int code __unused, int lineno __unused) +parse_undef(Parser *parser __unused, char *line, int code __unused, int lineno __unused) { char *cp; @@ -2254,7 +2254,7 @@ parse_undef(char *line, int code __unused, int lineno __unused) * Parse an .makeenv directive. */ static void -parse_makeenv(char *line, int code __unused, int lineno __unused) +parse_makeenv(Parser *parser __unused, char *line, int code __unused, int lineno __unused) { char *cp; @@ -2276,7 +2276,7 @@ parse_makeenv(char *line, int code __unused, int lineno __unused) * Parse a .for directive. */ static void -parse_for(char *line, int code __unused, int lineno) +parse_for(Parser *parser __unused, char *line, int code __unused, int lineno) { if (!For_For(line)) { @@ -2308,7 +2308,7 @@ parse_for(char *line, int code __unused, int lineno) * Parse endfor. This may only happen if there was no matching .for. */ static void -parse_endfor(char *line __unused, int code __unused, int lineno __unused) +parse_endfor(Parser *parser __unused, char *line __unused, int code __unused, int lineno __unused) { Parse_Error(PARSE_FATAL, "for-less endfor"); @@ -2323,7 +2323,7 @@ parse_endfor(char *line __unused, int code __unused, int lineno __unused) * TRUE if line was a directive, FALSE otherwise. */ static Boolean -parse_directive(char *line) +parse_directive(Parser *parser, char *line) { char *start; char *cp; @@ -2356,17 +2356,15 @@ parse_directive(char *line) } if (!skipLine || directives[dir].skip_flag) - (*directives[dir].func)(cp, directives[dir].code, + (*directives[dir].func)(parser, cp, directives[dir].code, CURFILE->lineno); return (TRUE); } -/*- - *--------------------------------------------------------------------- - * Parse_File -- - * Parse a file into its component parts, incorporating it into the - * current dependency graph. This is the main function and controls - * almost every other function in this module +/** + * Parse a file into its component parts, incorporating it into the + * current dependency graph. This is the main function and controls + * almost every other function in this module * * Results: * None @@ -2374,10 +2372,9 @@ parse_directive(char *line) * Side Effects: * Loads. Nodes are added to the list of all targets, nodes and links * are added to the dependency graph. etc. etc. etc. - *--------------------------------------------------------------------- */ void -Parse_File(struct MakeFlags *mf, const char name[], FILE *stream) +Parse_File(Parser *parser, struct MakeFlags *mf, const char name[], FILE *stream) { char *cp; /* pointer into the line */ char *line; /* the line we're working on */ @@ -2388,7 +2385,7 @@ Parse_File(struct MakeFlags *mf, const char name[], FILE *stream) ParsePushInput(estrdup(name), stream, NULL, 0); while ((line = ParseReadLine()) != NULL) { - if (*line == '.' && parse_directive(line + 1)) { + if (*line == '.' && parse_directive(parser, line + 1)) { /* directive consumed */ goto nextLine; } @@ -2491,7 +2488,7 @@ Parse_File(struct MakeFlags *mf, const char name[], FILE *stream) Lst_Destroy(&targets, NOFREE); inLine = TRUE; - ParseDoDependency(mf, line); + ParseDoDependency(parser, mf, line); } nextLine: @@ -2503,7 +2500,7 @@ Parse_File(struct MakeFlags *mf, const char name[], FILE *stream) /* * Make sure conditionals are clean */ - Cond_End(); + Cond_End(parser, NULL, 0, 0); if (fatals) errx(1, "fatal errors encountered -- cannot continue"); diff --git a/usr.bin/make/parse.h b/usr.bin/make/parse.h index 6e83c15c9b..229cc24725 100644 --- a/usr.bin/make/parse.h +++ b/usr.bin/make/parse.h @@ -35,7 +35,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/usr.bin/make/parse.h,v 1.10 2005/05/19 16:49:32 okumoto Exp $ + * $DragonFly: src/usr.bin/make/parse.h,v 1.11 2005/05/23 20:04:43 okumoto Exp $ */ #ifndef parse_h_470eeb9a @@ -49,6 +49,16 @@ struct GNode; struct Lst; struct MakeFlags; +typedef struct Parser { + /** + * The list of target names specified on the command line. + * Used to resolve #if make(...) statements + */ + struct Lst *create; +} Parser; + +typedef void DirectiveHandler(Parser *, char *, int, int); + /* * Error levels for parsing. PARSE_FATAL means the process cannot continue * once the makefile has been parsed. PARSE_WARNING means it can. Passed @@ -80,7 +90,7 @@ Boolean Parse_AnyExport(void); Boolean Parse_IsVar(char *); void Parse_DoVar(char *, struct GNode *); void Parse_AddIncludeDir(char *); -void Parse_File(struct MakeFlags *, const char [], FILE *); +void Parse_File(Parser *, struct MakeFlags *, const char [], FILE *); void Parse_FromString(char *, int); void Parse_MainName(struct Lst *); -- 2.41.0