From 658043eb33339177443b90b4d25e787725224a8e Mon Sep 17 00:00:00 2001 From: Joerg Sonnenberger Date: Tue, 30 Nov 2004 17:58:41 +0000 Subject: [PATCH] parse.c: 1.53->1.54 Author: ru Log: Added the new .warning directive. Submitted by: Cyrille Lefevre make.1: 1.66->1.67 Author: ru Log: Document the new .warning directive. Obtained-from: FreeBSD Submitted-by: Max Okumoto --- usr.bin/make/make.1 | 12 +++++++++--- usr.bin/make/parse.c | 38 ++++++++++++++++++++++++++++++++++---- 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/usr.bin/make/make.1 b/usr.bin/make/make.1 index 990566741b..c9af07fcaa 100644 --- a/usr.bin/make/make.1 +++ b/usr.bin/make/make.1 @@ -31,9 +31,9 @@ .\" .\" from: @(#)make.1 8.4 (Berkeley) 3/19/94 .\" $FreeBSD: src/usr.bin/make/make.1,v 1.29.2.15 2002/12/17 19:01:18 seanc Exp $ -.\" $DragonFly: src/usr.bin/make/make.1,v 1.9 2004/11/30 15:22:46 joerg Exp $ +.\" $DragonFly: src/usr.bin/make/make.1,v 1.10 2004/11/30 17:58:41 joerg Exp $ .\" -.Dd July 2, 2004 +.Dd April 12, 2004 .Dt MAKE 1 .Os .Sh NAME @@ -774,10 +774,16 @@ and future contents of the variable will be exported to the environment. Terminate processing of the makefile immediately. The filename of the makefile, the line on which the error was encountered and the specified -message are printed to standard output and +message are printed to the standard error output and .Nm terminates with exit code 1. Variables in the message are expanded. +.It Ic \&.warning Ar message +Emit a warning message. +The filename of the makefile, +the line on which the warning was encountered, +and the specified message are printed to the standard error output. +Variables in the message are expanded. .El .Pp Conditionals are used to determine which parts of the Makefile diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c index ff8b612fd8..64a366ceeb 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.22.2.2 2004/07/10 08:14:42 eik Exp $ - * $DragonFly: src/usr.bin/make/parse.c,v 1.16 2004/11/30 17:39:41 joerg Exp $ + * $DragonFly: src/usr.bin/make/parse.c,v 1.17 2004/11/30 17:58:41 joerg Exp $ */ /*- @@ -240,6 +240,7 @@ static void ParseUnreadc(int); static void ParseHasCommands(void *); static void ParseDoInclude(char *); static void ParseDoError(char *); +static void ParseDoWarning(char *); #ifdef SYSVINCLUDE static void ParseTraditionalInclude(char *); #endif @@ -1570,12 +1571,38 @@ ParseDoError(char *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", - curFile.fname, curFile.lineno, errmsg); + Parse_Error(PARSE_FATAL, "%s", errmsg); + /* Terminate immediately. */ exit(1); } +/*--------------------------------------------------------------------- + * ParseDoWarning -- + * Handle warning directive + * + * The input is the line minus the ".warning". We substitute variables + * and print the message or just print a warning if the ".warning" + * directive is malformed. + * + *--------------------------------------------------------------------- + */ +static void +ParseDoWarning(char *warnmsg) +{ + if (!isspace((unsigned char) *warnmsg)) { + Parse_Error(PARSE_WARNING, "invalid syntax: .warning%s", + warnmsg); + return; + } + + while (isspace((unsigned char) *warnmsg)) + warnmsg++; + + warnmsg = Var_Subst(NULL, warnmsg, VAR_GLOBAL, FALSE); + + Parse_Error(PARSE_WARNING, "%s", warnmsg); +} + /*- *--------------------------------------------------------------------- * ParseDoInclude -- @@ -2390,6 +2417,9 @@ Parse_File(char *name, FILE *stream) } else if (strncmp (cp, "error", 5) == 0) { ParseDoError(cp + 5); goto nextLine; + } else if (strncmp (cp, "warning", 7) == 0) { + ParseDoWarning(cp + 7); + goto nextLine; } else if (strncmp(cp, "undef", 5) == 0) { cp = stripvarname(cp + 5); cp = Var_Subst(NULL, cp, VAR_CMD, FALSE); -- 2.41.0