diff options
author | steve <steve@FreeBSD.org> | 1998-05-25 03:28:37 +0000 |
---|---|---|
committer | steve <steve@FreeBSD.org> | 1998-05-25 03:28:37 +0000 |
commit | d0fc5c4c1bd3b08907cdc02d739d460ec2e5c415 (patch) | |
tree | 06d1e4bf621e829db260e1e54a9df0b70c58c9bb /usr.bin/make/parse.c | |
parent | 2a35d9a031e1583518d2c0ece24b216981bfdd0f (diff) | |
download | FreeBSD-src-d0fc5c4c1bd3b08907cdc02d739d460ec2e5c415.zip FreeBSD-src-d0fc5c4c1bd3b08907cdc02d739d460ec2e5c415.tar.gz |
Add a graceful jumping off point with a new .error directive.
PR: 6720
Submitted by: Niall Smart <njs3@doc.ic.ac.uk>
Diffstat (limited to 'usr.bin/make/parse.c')
-rw-r--r-- | usr.bin/make/parse.c | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c index 448aa96..388fa07 100644 --- a/usr.bin/make/parse.c +++ b/usr.bin/make/parse.c @@ -41,7 +41,7 @@ static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94"; #endif static const char rcsid[] = - "$Id$"; + "$Id: parse.c,v 1.18 1997/07/24 06:58:08 charnier Exp $"; #endif /* not lint */ /*- @@ -251,6 +251,7 @@ static int ParseReadc __P((void)); static void ParseUnreadc __P((int)); static void ParseHasCommands __P((ClientData)); static void ParseDoInclude __P((char *)); +static void ParseDoError __P((char *)); #ifdef SYSVINCLUDE static void ParseTraditionalInclude __P((char *)); #endif @@ -1552,6 +1553,35 @@ Parse_AddIncludeDir (dir) Dir_AddDir (parseIncPath, dir); } +/*--------------------------------------------------------------------- + * ParseDoError -- + * Handle error directive + * + * The input is the line minus the ".error". We substitute variables, + * print the message and exit(1) or just print a warning if the ".error" + * directive is malformed. + * + *--------------------------------------------------------------------- + */ +static void +ParseDoError(errmsg) + char *errmsg; /* error message */ +{ + if (!isspace(*errmsg)) { + Parse_Error(PARSE_WARNING, "invalid syntax: .error%s", errmsg); + return; + } + + while (isspace(*errmsg)) + errmsg++; + + errmsg = Var_Subst(NULL, errmsg, VAR_GLOBAL, FALSE); + + /* use fprintf/exit instead of Parse_Error to terminate immediately */ + fprintf(stderr, "\"%s\", line %d: %s\n", fname, lineno, errmsg); + exit(1); +} + /*- *--------------------------------------------------------------------- * ParseDoInclude -- @@ -1734,6 +1764,7 @@ ParseDoInclude (file) } + /*- *--------------------------------------------------------------------- * Parse_FromString -- @@ -2385,6 +2416,9 @@ Parse_File(name, stream) if (strncmp (cp, "include", 7) == 0) { ParseDoInclude (cp + 7); goto nextLine; + } else if (strncmp (cp, "error", 5) == 0) { + ParseDoError(cp + 5); + goto nextLine; } else if (strncmp(cp, "undef", 5) == 0) { char *cp2; for (cp += 5; isspace((unsigned char) *cp); cp++) { |