From root@gits.dyndns.org  Sat Jul 27 18:21:51 2002
Return-Path: <root@gits.dyndns.org>
Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 535C237B401
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 27 Jul 2002 18:21:51 -0700 (PDT)
Received: from smtp.noos.fr (claudel.noos.net [212.198.2.83])
	by mx1.FreeBSD.org (Postfix) with ESMTP id B4A6343E65
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 27 Jul 2002 18:21:49 -0700 (PDT)
	(envelope-from root@gits.dyndns.org)
Received: (qmail 35026457 invoked by uid 0); 28 Jul 2002 01:21:47 -0000
Received: from unknown (HELO gits.gits.dyndns.org) ([212.198.229.153]) (envelope-sender <root@gits.dyndns.org>)
          by 212.198.2.83 (qmail-ldap-1.03) with SMTP
          for <FreeBSD-gnats-submit@freebsd.org>; 28 Jul 2002 01:21:47 -0000
Received: from gits.gits.dyndns.org (9d61i5kzo0nl121s@localhost [127.0.0.1])
	by gits.gits.dyndns.org (8.12.5/8.12.5) with ESMTP id g6S1LlNc099741;
	Sun, 28 Jul 2002 03:21:47 +0200 (CEST)
	(envelope-from root@gits.dyndns.org)
Received: (from root@localhost)
	by gits.gits.dyndns.org (8.12.5/8.12.5/Submit) id g6S1LkhD099740;
	Sun, 28 Jul 2002 03:21:46 +0200 (CEST)
	(envelope-from root)
Message-Id: <200207280121.g6S1LkhD099740@gits.gits.dyndns.org>
Date: Sun, 28 Jul 2002 03:21:46 +0200 (CEST)
From: Cyrille Lefevre <cyrille.lefevre@laposte.net>
Reply-To: Cyrille Lefevre <cyrille.lefevre@laposte.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc: Ruslan Ermilov <ru@freebsd.org>,
	Juli Mallett <jmallett@freebsd.org>
Subject: added .warning in make(1) + two fixes
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         41070
>Category:       bin
>Synopsis:       added .warning in make(1) + two fixes
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jul 27 18:30:01 PDT 2002
>Closed-Date:    Thu Feb 17 09:35:22 GMT 2005
>Last-Modified:  Thu Feb 17 09:35:22 GMT 2005
>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:
Responsible-Changed-From-To: freebsd-bugs->jmallett 
Responsible-Changed-By: jmallett 
Responsible-Changed-When: Sat Jul 27 20:02:57 PDT 2002 
Responsible-Changed-Why:  
I'll handle this, folks. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=41070 

From: Giorgos Keramidas <keramida@FreeBSD.org>
To: Cyrille Lefevre <cyrille.lefevre@laposte.net>
Cc: bug-followup@FreeBSD.org, Ruslan Ermilov <ru@FreeBSD.org>,
	Juli Mallett <jmallett@FreeBSD.org>
Subject: Re: bin/41070: added .warning in make(1) + two fixes
Date: Tue, 20 Aug 2002 04:06:09 +0300

 [-- Add to audit trail --]
 
 Message-Id: <20020727200322.A73128@FreeBSD.org>
 Date: Sat, 27 Jul 2002 20:03:23 -0700
 From: Juli Mallett <jmallett@FreeBSD.org>
 Subject: Re: added .warning in make(1) + two fixes
 
 * De: Cyrille Lefevre <cyrille.lefevre@laposte.net> [ Data: 2002-07-27 ]
 	[ Subjecte: added .warning in make(1) + two fixes ]
 
 > 	this patch will be necessary for the NOFOO to NO_FOO transition.
 >
 > [...]
 > Index: parse.c
 > ===================================================================
 > RCS file: /home/ncvs/src/usr.bin/make/parse.c,v
 > retrieving revision 1.22
 > diff -u -r1.22 parse.c
 
 Give me a patch relative to 1.37 and I'll commit it.
 -- 
 Juli Mallett <jmallett@FreeBSD.org>       | FreeBSD: The Power To Serve
 Will break world for fulltime employment. | finger jmallett@FreeBSD.org
Responsible-Changed-From-To: jmallett->freebsd-bugs 
Responsible-Changed-By: jmallett 
Responsible-Changed-When: Tue Oct 29 04:51:18 PST 2002 
Responsible-Changed-Why:  
Back to freebsd-bugs. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=41070 

From: Cyrille Lefevre <cyrille.lefevre@laposte.net>
To: freebsd gnats <freebsd-gnats-submit@freebsd.org>,
	Juli Mallett <jmallett@freebsd.org>
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
State-Changed-From-To: open->closed 
State-Changed-By: ru 
State-Changed-When: Thu Feb 17 09:34:51 GMT 2005 
State-Changed-Why:  
From what I can tell, all bugs from this PR have been fixed now. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=41070 
>Unformatted:
