diff options
author | ru <ru@FreeBSD.org> | 2004-04-12 17:57:51 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2004-04-12 17:57:51 +0000 |
commit | 5108eb2d06bff980fcd89846841ebae529aeedd0 (patch) | |
tree | 271eed19d32b9dabf14dca45107b765f49d83976 /usr.bin | |
parent | 7eb8531271fac4b9cdf820c038b73b1b85c0003b (diff) | |
download | FreeBSD-src-5108eb2d06bff980fcd89846841ebae529aeedd0.zip FreeBSD-src-5108eb2d06bff980fcd89846841ebae529aeedd0.tar.gz |
Added the new .warning directive.
Submitted by: Cyrille Lefevre
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/make/parse.c | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c index 29bda4c..e245a04 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++) { |