Module Name: src Committed By: dholland Date: Thu Sep 18 08:06:13 UTC 2014
Modified Files: src/usr.bin/make: parse.c Log Message: Comments, and one very minor tidyup. To generate a diff of this commit: cvs rdiff -u -r1.203 -r1.204 src/usr.bin/make/parse.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/make/parse.c diff -u src/usr.bin/make/parse.c:1.203 src/usr.bin/make/parse.c:1.204 --- src/usr.bin/make/parse.c:1.203 Sun Sep 7 20:55:34 2014 +++ src/usr.bin/make/parse.c Thu Sep 18 08:06:13 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.203 2014/09/07 20:55:34 joerg Exp $ */ +/* $NetBSD: parse.c,v 1.204 2014/09/18 08:06:13 dholland Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: parse.c,v 1.203 2014/09/07 20:55:34 joerg Exp $"; +static char rcsid[] = "$NetBSD: parse.c,v 1.204 2014/09/18 08:06:13 dholland 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.203 2014/09/07 20:55:34 joerg Exp $"); +__RCSID("$NetBSD: parse.c,v 1.204 2014/09/18 08:06:13 dholland Exp $"); #endif #endif /* not lint */ #endif @@ -1193,7 +1193,17 @@ ParseDoDependency(char *line) curTargs = Lst_Init(FALSE); + /* + * First, grind through the targets. + */ + do { + /* + * Here LINE points to the beginning of the next word, and + * LSTART points to the actual beginning of the line. + */ + + /* Find the end of the next word. */ for (cp = line; *cp && (ParseIsEscaped(lstart, cp) || !(isspace((unsigned char)*cp) || *cp == '!' || *cp == ':' || *cp == LPAREN)); @@ -1216,6 +1226,10 @@ ParseDoDependency(char *line) } } + /* + * If the word is followed by a left parenthesis, it's the + * name of an object file inside an archive (ar file). + */ if (!ParseIsEscaped(lstart, cp) && *cp == LPAREN) { /* * Archives must be handled specially to make sure the OP_ARCHV @@ -1232,13 +1246,16 @@ ParseDoDependency(char *line) "Error in archive specification: \"%s\"", line); goto out; } else { + /* Done with this word; on to the next. */ continue; } } - savec = *cp; if (!*cp) { /* + * We got to the end of the line while we were still + * looking at targets. + * * Ending a dependency line without an operator is a Bozo * no-no. As a heuristic, this is also often triggered by * undetected conflicts from cvs/rcs merges. @@ -1253,10 +1270,13 @@ ParseDoDependency(char *line) : "Need an operator"); goto out; } + + /* Insert a null terminator. */ + savec = *cp; *cp = '\0'; /* - * Have a word in line. See if it's a special target and set + * Got the word. See if it's a special target and if so set * specType to match it. */ if (*line == '.' && isupper ((unsigned char)line[1])) { @@ -1395,6 +1415,8 @@ ParseDoDependency(char *line) (void)Lst_AtEnd(curTargs, line); } + /* Apply the targets. */ + while(!Lst_IsEmpty(curTargs)) { char *targName = (char *)Lst_DeQueue(curTargs); @@ -1412,7 +1434,9 @@ ParseDoDependency(char *line) Parse_Error(PARSE_WARNING, "Extra target (%s) ignored", line); } + /* Don't need the inserted null terminator any more. */ *cp = savec; + /* * If it is a special type and not .PATH, it's the only target we * allow on this line... @@ -1488,12 +1512,21 @@ ParseDoDependency(char *line) goto out; } - cp++; /* Advance beyond operator */ + /* Advance beyond the operator */ + cp++; + /* + * Apply the operator to the target. This is how we remember which + * operator a target was defined with. It fails if the operator + * used isn't consistent across all references. + */ Lst_ForEach(targets, ParseDoOp, &op); /* - * Get to the first source + * Onward to the sources. + * + * LINE will now point to the first source word, if any, or the + * end of the string if not. */ while (*cp && isspace ((unsigned char)*cp)) { cp++;