From mark@thuvia.demon.co.uk  Sun Dec 14 16:43:34 1997
Received: from thuvia.demon.co.uk (dejah.spider.com [194.217.109.33])
          by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id QAA28075
          for <FreeBSD-gnats-submit@freebsd.org>; Sun, 14 Dec 1997 16:43:29 -0800 (PST)
          (envelope-from mark@thuvia.demon.co.uk)
Received: (from mark@localhost)
	by thuvia.demon.co.uk (8.8.8/8.8.7) id AAA29620;
	Mon, 15 Dec 1997 00:43:38 GMT
Message-Id: <199712150043.AAA29620@thuvia.demon.co.uk>
Date: Mon, 15 Dec 1997 00:43:38 GMT
From: Mark Valentine <mark@thuvia.demon.co.uk>
Reply-To: mark@thuvia.demon.co.uk
To: FreeBSD-gnats-submit@freebsd.org
Subject: make incompatibility with System V style variable substitions
X-Send-Pr-Version: 3.2

>Number:         5297
>Category:       bin
>Synopsis:       make incompatibility with System V style variable substitions
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    jmallett
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Dec 14 16:50:01 PST 1997
>Closed-Date:    Sun Jun 16 21:31:10 PDT 2002
>Last-Modified:  Sun Jun 16 21:31:10 PDT 2002
>Originator:     Mark Valentine
>Release:        FreeBSD 3.0-CURRENT i386
>Organization:
>Environment:

>Description:

	make(1) has an incompatibility with other implementations (such
	as GNU make and Sun's make) when performing System V style variable
	substitions involving empty strings.

>How-To-Repeat:

	Using the following makefile and "make all",

	    FOO = 
	    FOOBAR = $(FOO:=bar)

	    all:
		    @echo FOOBAR = $(FOOBAR)

	GNU make and Sun's make generate the output:

	    FOOBAR = 

	whereas FreeBSD's make produces:

	    FOOBAR = bar

	If FOO is non-empty, FreeBSD does the right thing, e.g.
	with "make all FOO='foo1 foo2'":

	    FOOBAR = foo1bar foo2bar

>Fix:
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->suspended 
State-Changed-By: phk 
State-Changed-When: Thu Apr 30 12:59:51 PDT 1998 
State-Changed-Why:  
The manual page doesn't contradict this claim. 

From: Guy Helmer <ghelmer@cs.iastate.edu>
To: freebsd-gnats-submit@freebsd.org, mark@thuvia.demon.co.uk,
	phk@freebsd.org
Cc:  
Subject: Re: bin/5297: make incompatibility with System V style variable substitions
Date: Thu, 03 Jun 1999 21:17:18 -0500

 Is the FreeBSD behavior incorrect, or should this PR be closed?  It is
 over 1.5 years old...
 
 Guy Helmer
 ghelmer@
 

From: Mark Valentine <mark@thuvia.demon.co.uk>
To: Guy Helmer <ghelmer@cs.iastate.edu>,
	freebsd-gnats-submit@freebsd.org, phk@freebsd.org
Cc:  
Subject: Re: bin/5297: make incompatibility with System V style variable substitions
Date: Sat, 5 Jun 1999 13:43:52 +0100 (BST)

 > From: Guy Helmer <ghelmer@cs.iastate.edu>
 > Date: Thu 3 Jun, 1999
 > Subject: Re: bin/5297: make incompatibility with System V style variable substitions
 
 > Is the FreeBSD behavior incorrect, or should this PR be closed?  It is
 > over 1.5 years old...
 
 I don't have access to the POSIX.2 spec to see if it says anything about it;
 the Single UNIX Specification isn't sufficiently detailed.
 
 However, I think it's a real problem (I rely on this behaviour for our
 products' build system, which has to use only lowest common denominator
 make(1) functionality, and there's no easy workaround).
 
 Here are some more realistic examples to illustrate why the FreeBSD
 behaviour may be sub-optimal.
 
 First, an example with a non-NULL LHS pattern:
 
     SOURCES = foo.c bar.c
     OBJECTS = $(SOURCES:.c=.o)
 
     clean::
 	rm -f $(OBJECTS)
 
 This works as intended even if SOURCES is empty (rm passed no arguments).
 
 The next example shows why I think the "empty LHS" behaviour is inconsistent
 (even ignoring it being different from other implementations):
 
     PROGRAMS = foo bar
     SOURCES = $(PROGRAMS:=.c)
 
     tags::
 	ctags $(SOURCES)
 
 In this case, an empty PROGRAMS list causes ctags to be passed an argument
 of ".c", instead of the expected no arguments.
 
 Now that you've prodded me, here's a somewhat clumsy attempt at a fix.
 
 The problem appears to be in the way str.c::brk_string() treats "empty"
 strings; argc is 2 and argv[1] is "".  The following change returns argc
 of 1 and argv[1] of NULL.
 
 I looked at all other uses of brk_string(), which either avoid passing
 an empty string, or will also work with this behaviour.  However, I haven't
 tried to test this (except that it works for my problem case above).
 
 		Cheers,
 
 		Mark.
 
 Index: str.c
 ===================================================================
 RCS file: /usr/cvs/src/usr.bin/make/str.c,v
 retrieving revision 1.9
 diff -u -r1.9 str.c
 --- str.c	1997/02/22 19:27:23	1.9
 +++ str.c	1999/06/05 12:22:25
 @@ -148,6 +148,11 @@
  	for (; *str == ' ' || *str == '\t'; ++str)
  		continue;
  
 +	if (*str == '\0') {
 +		argc = 1;
 +		goto done;
 +	}
 +
  	/* allocate room for a copy of the string */
  	if ((len = strlen(str) + 1) > curlen) {
  		if (buffer)
 
 -- 
 Mark Valentine at Home <mark@thuvia.org>            http://www.thuvia.org/mark/
   "I'll be mellow when I'm DEAD."
 Mark Valentine uses and endorses FreeBSD                http://www.freebsd.org/
 
State-Changed-From-To: suspended->open 
State-Changed-By: nbm 
State-Changed-When: Thu Jul 13 04:11:35 PDT 2000 
State-Changed-Why:  
This PR received feedback, and a patch has been proposed.  Leave it open 
for others to look at. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=5297 
Responsible-Changed-From-To: freebsd-bugs->will 
Responsible-Changed-By: will 
Responsible-Changed-When: Fri Sep 29 13:41:42 PDT 2000 
Responsible-Changed-Why:  
Over to MAINTAINER. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=5297 
Responsible-Changed-From-To: will->freebsd-bugs 
Responsible-Changed-By: will 
Responsible-Changed-When: Wed Aug 29 16:24:24 PDT 2001 
Responsible-Changed-Why:  
I don't have time for make(1) anymore... 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=5297 

From: "Matthew Emmerton" <matt@gsicomp.on.ca>
To: <freebsd-gnats-submit@FreeBSD.org>, <mark@thuvia.demon.co.uk>
Cc:  
Subject: Re: bin/5297: make incompatibility with System V style variable substitions
Date: Sun, 13 Jan 2002 00:19:39 -0500

 The real problem is that Str_SYSVMatch doesn't check for an empty word,
 which obviously won't match anything.
 
 --- str.c       Sat Sep 11 09:08:01 1999
 +++ str.c.matt  Sun Jan 13 00:01:22 2002
 @@ -421,6 +421,12 @@
      char *w = word;
      char *m;
 
 +    if (*w == '\0') {
 +       /* Null word can't be matched against */
 +       *len = 0;
 +       return NULL;
 +    }
 +
      if (*p == '\0') {
         /* Null pattern is the whole string */
         *len = strlen(w);
 
Responsible-Changed-From-To: freebsd-bugs->jmallett 
Responsible-Changed-By: jmallett 
Responsible-Changed-When: Sun May 5 12:02:52 PDT 2002 
Responsible-Changed-Why:  
Over to me. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=5297 
State-Changed-From-To: open->patched 
State-Changed-By: jmallett 
State-Changed-When: Sun May 5 12:05:09 PDT 2002 
State-Changed-Why:  
Committed to 5.0-CURRENT, along with a regression test. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=5297 
State-Changed-From-To: patched->closed 
State-Changed-By: jmallett 
State-Changed-When: Sun Jun 16 21:30:50 PDT 2002 
State-Changed-Why:  
Merged into RELENG_4 thanks! :) 

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