From owner-freebsd-bugs@FreeBSD.ORG Thu Mar 4 08:00:35 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B6E8A16A4CE for ; Thu, 4 Mar 2004 08:00:35 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id B021143D4C for ; Thu, 4 Mar 2004 08:00:35 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i24G0Zbv003959 for ; Thu, 4 Mar 2004 08:00:35 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.10/8.12.10/Submit) id i24G0Zdn003958; Thu, 4 Mar 2004 08:00:35 -0800 (PST) (envelope-from gnats) Date: Thu, 4 Mar 2004 08:00:35 -0800 (PST) Message-Id: <200403041600.i24G0Zdn003958@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Cyrille Lefevre Subject: Re: bin/41070: added .warning in make(1) + two fixes X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Cyrille Lefevre List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Mar 2004 16:00:35 -0000 The following reply was made to PR bin/41070; it has been noted by GNATS. From: Cyrille Lefevre To: freebsd gnats , Juli Mallett Cc: Subject: Re: bin/41070: added .warning in make(1) + two fixes Date: Thu, 4 Mar 2004 16:53:18 +0100 Hi Juli, could you commit this PR ? thanks in advance. cvs diff against -current (FreeBSD 5.2-CURRENT #1: Sat Jan 31 15:17:05 CET 2004) added feature : error messages output the current directory a la gnumake which help a lot to find errors in buildworld parallel make. ex.: $ echo 'all:;@false' > Makefile $ make *** Error code 1 in /tmp Stop in /tmp. Index: compat.c =================================================================== RCS file: /home/ncvs/src/usr.bin/make/compat.c,v retrieving revision 1.36 diff -u -I$Id.*$ -I$.+BSD.*$ -r1.36 compat.c --- compat.c 3 Oct 2003 21:33:39 -0000 1.36 +++ compat.c 29 Oct 2003 23:44:59 -0000 @@ -356,13 +356,12 @@ } else if (WIFEXITED(reason)) { status = WEXITSTATUS(reason); /* exited */ if (status != 0) { - printf ("*** Error code %d", status); + printf ("*** Error code %d in %s", status, curdir); } } else { status = WTERMSIG(reason); /* signaled */ - printf ("*** Signal %d", status); + printf ("*** Signal %d in %s", status, curdir); } - if (!WIFEXITED(reason) || (status != 0)) { if (errCheck) { Index: job.c =================================================================== RCS file: /home/ncvs/src/usr.bin/make/job.c,v retrieving revision 1.48 diff -u -I$Id.*$ -I$.+BSD.*$ -r1.48 job.c --- job.c 1 Dec 2002 13:38:25 -0000 1.48 +++ job.c 29 Oct 2003 22:54:04 -0000 @@ -808,8 +808,8 @@ MESSAGE(out, job->node); lastNode = job->node; } - (void) fprintf(out, "*** Error code %d%s\n", - WEXITSTATUS(*status), + (void) fprintf(out, "*** Error code %d in %s%s\n", + WEXITSTATUS(*status), curdir, (job->flags & JOB_IGNERR) ? "(ignored)" : ""); if (job->flags & JOB_IGNERR) { @@ -883,7 +883,8 @@ MESSAGE(out, job->node); lastNode = job->node; } - (void) fprintf(out, "*** Signal %d\n", WTERMSIG(*status)); + (void) fprintf(out, "*** Signal %d in %s\n", + WTERMSIG(*status), curdir); } (void) fflush(out); Index: main.c =================================================================== RCS file: /home/ncvs/src/usr.bin/make/main.c,v retrieving revision 1.86 diff -u -I$Id.*$ -I$.+BSD.*$ -r1.86 main.c --- main.c 13 Dec 2003 15:26:27 -0000 1.86 +++ main.c 27 Jan 2004 23:30:31 -0000 @@ -127,7 +127,7 @@ static int ReadMakefile(void *, void *); static void usage(void); -static char *curdir; /* startup directory */ +char *curdir; /* startup directory */ static char *objdir; /* where we chdir'ed to */ /*- Index: make.h =================================================================== RCS file: /home/ncvs/src/usr.bin/make/make.h,v retrieving revision 1.23 diff -u -I$Id.*$ -I$.+BSD.*$ -r1.23 make.h --- make.h 10 Oct 2002 19:27:48 -0000 1.23 +++ make.h 29 Oct 2003 22:25:01 -0000 @@ -301,6 +301,7 @@ extern Lst envFirstVars; /* List of specific variables for which the * environment should be searched before the * global context */ +extern char *curdir; /* startup directory */ extern GNode *DEFAULT; /* .DEFAULT rule */ Index: parse.c =================================================================== RCS file: /home/ncvs/src/usr.bin/make/parse.c,v retrieving revision 1.50 diff -u -I$Id.*$ -I$.+BSD.*$ -r1.50 parse.c --- parse.c 28 Nov 2002 12:47:56 -0000 1.50 +++ parse.c 5 Feb 2003 22:34:23 -0000 @@ -112,6 +112,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 */ @@ -244,6 +245,7 @@ static void ParseUnreadc(int); static void ParseHasCommands(void *); static void ParseDoInclude(char *); +static void ParseDoWarning(char *); static void ParseDoError(char *); #ifdef SYSVINCLUDE static void ParseTraditionalInclude(char *); @@ -1552,6 +1554,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 * @@ -1574,8 +1603,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); } @@ -1792,7 +1820,7 @@ curFILE = NULL; curPTR = (PTR *) emalloc (sizeof (PTR)); curPTR->str = curPTR->ptr = str; - lineno = 0; + lineno = savedlineno; fname = estrdup(fname); } @@ -2277,6 +2305,7 @@ if (For_Eval(line)) { int ok; free(line); + savedlineno = lineno; do { /* * Skip after the matching end @@ -2377,7 +2406,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++) { @@ -2390,6 +2422,8 @@ } *cp2 = '\0'; + + cp = Var_Subst(NULL, cp, VAR_GLOBAL, FALSE); Var_Delete(cp, VAR_GLOBAL); goto nextLine; Cyrille Lefevre -- mailto:cyrille.lefevre@laposte.net