From dba067b170fe16330f58536bb5808bbd9fb21ba9 Mon Sep 17 00:00:00 2001 From: Ruslan Ermilov Date: Mon, 12 Apr 2004 17:57:51 +0000 Subject: Added the new .warning directive. Submitted by: Cyrille Lefevre --- usr.bin/make/parse.c | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'usr.bin/make') diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c index 29bda4ce34d8..e245a043c415 100644 --- a/usr.bin/make/parse.c +++ b/usr.bin/make/parse.c @@ -241,6 +241,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 @@ -1571,12 +1572,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 -- @@ -2368,6 +2395,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) { char *cp2; for (cp += 5; isspace((unsigned char) *cp); cp++) { -- cgit v1.3