Date: Sun, 28 Jul 2002 03:21:46 +0200 (CEST) From: Cyrille Lefevre <cyrille.lefevre@laposte.net> To: FreeBSD-gnats-submit@FreeBSD.org Cc: Ruslan Ermilov <ru@FreeBSD.org>, Juli Mallett <jmallett@FreeBSD.org> Subject: bin/41070: added .warning in make(1) + two fixes Message-ID: <200207280121.g6S1LkhD099740@gits.gits.dyndns.org>
next in thread | raw e-mail | index | archive | help
>Number: 41070 >Category: bin >Synopsis: added .warning in make(1) + two fixes >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sat Jul 27 18:30:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Cyrille Lefevre >Release: FreeBSD 4.6-STABLE i386 >Organization: ACME >Environment: System: FreeBSD gits 4.6-STABLE FreeBSD 4.6-STABLE #17: Tue Jul 23 08:29:49 CEST 2002 root@gits:/disk2/freebsd/stable/src/sys/compile/CUSTOM i386 >Description: this patch will be necessary for the NOFOO to NO_FOO transition. src/usr.bin/make/parce.c - saveline added to make lineno happy in `.for' loops in debug mode. - ParseDoWarning added - Var_Subst added in `.undef' to avoid inconsistencies such as : .for var in ${vars} .undef ${var} .endfor vs. .for var in ${vars} tmp=${var} .undef ${tmp} .endfor >How-To-Repeat: see above. >Fix: Index: parse.c =================================================================== RCS file: /home/ncvs/src/usr.bin/make/parse.c,v retrieving revision 1.22 diff -u -r1.22 parse.c --- parse.c 28 Aug 1999 01:03:35 -0000 1.22 +++ parse.c 26 Jul 2002 02:12:52 -0000 @@ -120,6 +120,7 @@ static char *fname; /* name of current file (for errors) */ static int lineno; /* line number in current file */ +static int savedlineno; /* saved line number */ static FILE *curFILE = NULL; /* current makefile */ static PTR *curPTR = NULL; /* current makefile */ @@ -252,6 +253,7 @@ static void ParseUnreadc __P((int)); static void ParseHasCommands __P((ClientData)); static void ParseDoInclude __P((char *)); +static void ParseDoWarning __P((char *)); static void ParseDoError __P((char *)); #ifdef SYSVINCLUDE static void ParseTraditionalInclude __P((char *)); @@ -1557,6 +1559,33 @@ } /*--------------------------------------------------------------------- + * ParseDoWarning -- + * Handle warning directive + * + * The input is the line minus the ".warning". We substitute variables + * and the message or print a warning if the ".warning" directive is + * malformed. + * + *--------------------------------------------------------------------- + */ +static void +ParseDoWarning(errmsg) + char *errmsg; /* error message */ +{ + if (!isspace(*errmsg)) { + Parse_Error(PARSE_WARNING, "invalid syntax: .warning%s", errmsg); + return; + } + + while (isspace(*errmsg)) + errmsg++; + + errmsg = Var_Subst(NULL, errmsg, VAR_GLOBAL, FALSE); + + Parse_Error(PARSE_WARNING, "%s", errmsg); +} + +/*--------------------------------------------------------------------- * ParseDoError -- * Handle error directive * @@ -1580,8 +1609,7 @@ 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); + Parse_Error(PARSE_FATAL, "%s", errmsg); exit(1); } @@ -1801,7 +1829,7 @@ curFILE = NULL; curPTR = (PTR *) emalloc (sizeof (PTR)); curPTR->str = curPTR->ptr = str; - lineno = 0; + lineno = savedlineno; fname = estrdup(fname); } @@ -2321,6 +2349,7 @@ if (For_Eval(line)) { int ok; free(line); + savedlineno = lineno; do { /* * Skip after the matching end @@ -2421,7 +2450,10 @@ goto nextLine; } else if (strncmp (cp, "error", 5) == 0) { ParseDoError(cp + 5); - goto nextLine; + /* NOTREACHED */ + } 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++) { @@ -2434,6 +2466,8 @@ } *cp2 = '\0'; + + cp = Var_Subst(NULL, cp, VAR_GLOBAL, FALSE); Var_Delete(cp, VAR_GLOBAL); goto nextLine; >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200207280121.g6S1LkhD099740>