From mi@aldan.algebra.com  Wed Oct 17 08:50:24 2001
Return-Path: <mi@aldan.algebra.com>
Received: from aldan.algebra.com (aldan.algebra.com [216.254.65.224])
	by hub.freebsd.org (Postfix) with ESMTP id 7526637B409
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 17 Oct 2001 08:50:21 -0700 (PDT)
Received: (from mi@localhost)
	by aldan.algebra.com (8.11.6/8.11.5) id f9HFldP03628;
	Wed, 17 Oct 2001 11:47:39 -0400 (EDT)
	(envelope-from mi)
Message-Id: <200110171547.f9HFldP03628@aldan.algebra.com>
Date: Wed, 17 Oct 2001 11:47:39 -0400 (EDT)
From: Mikhail Teterin <mi@aldan.algebra.com>
Reply-To: Mikhail Teterin <mi@aldan.algebra.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: make's .if processing buggy
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         31339
>Category:       bin
>Synopsis:       make's .if processing buggy
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Oct 17 09:00:01 PDT 2001
>Closed-Date:    Mon Dec 23 19:08:02 PST 2002
>Last-Modified:  Mon Dec 23 19:08:02 PST 2002
>Originator:     Mikhail Teterin
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
Virtual Estates, Inc.
>Environment:
System: FreeBSD aldan.algebra.com 5.0-CURRENT FreeBSD 5.0-CURRENT #3: Sun Oct 14 18:09:07 EDT 2001 mi@aldan.algebra.com:/ccd/obj/ccd/src/sys/DEBUG i386


>Description:

	The following makefile breaks make for unknown reason:
	.if o != a
	all:
		@echo "not equal"
	.else
		@echo "equal"
	.endif

	Modifying it to instead start with
	o=o
	.if $o != a
	...
	works around the problem. It will work even if o is explicitly
	set to "", but will not if it is not set at all (which is supposed
	to imply an empty string "" too).

>How-To-Repeat:
	See description.
>Fix:
	See description.
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: jmallett 
State-Changed-When: Wed Oct 23 17:16:10 PDT 2002 
State-Changed-Why:  
I'll take responsibility for this... 

Can the submitter verify general string compare support in NetBSD make(1) 
or similar?  We specifically don't support LHS being a bareword in string 
compares, it's been documented in comments in Makefiles that I've seen 
dating to the late 1980s...  But if you can provide an example in a BSD 
make(1) implementation of this not working as it does, I'll do my best 
to merge in the required changes. 


Responsible-Changed-From-To: freebsd-bugs->jmallett 
Responsible-Changed-By: jmallett 
Responsible-Changed-When: Wed Oct 23 17:16:10 PDT 2002 
Responsible-Changed-Why:  
I'll take responsibility for this... 

Can the submitter verify general string compare support in NetBSD make(1) 
or similar?  We specifically don't support LHS being a bareword in string 
compares, it's been documented in comments in Makefiles that I've seen 
dating to the late 1980s...  But if you can provide an example in a BSD 
make(1) implementation of this not working as it does, I'll do my best 
to merge in the required changes. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=31339 
State-Changed-From-To: feedback->closed 
State-Changed-By: jmallett 
State-Changed-When: Mon Nov 4 11:03:42 PST 2002 
State-Changed-Why:  
Verified as not an "issue". 

http://www.freebsd.org/cgi/query-pr.cgi?pr=31339 
State-Changed-From-To: closed->open 
State-Changed-By: jmallett 
State-Changed-When: Mon Nov 4 11:28:56 PST 2002 
State-Changed-Why:  
Submitter has other issues here than what I recalled, 
assing it back to -bugs for whoever wants it. 

Sorry! 


Responsible-Changed-From-To: jmallett->freebsd-bugs 
Responsible-Changed-By: jmallett 
Responsible-Changed-When: Mon Nov 4 11:28:56 PST 2002 
Responsible-Changed-Why:  
Submitter has other issues here than what I recalled, 
assing it back to -bugs for whoever wants it. 

Sorry! 

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

From: Ruslan Ermilov <ru@FreeBSD.org>
To: Mikhail Teterin <mi+mx@aldan.algebra.com>
Cc: Juli Mallett <jmallett@FreeBSD.org>, bug-followup@FreeBSD.org
Subject: Re: bin/31339: make's .if processing buggy
Date: Fri, 22 Nov 2002 11:18:57 +0200

 On Thu, Nov 21, 2002 at 05:56:07PM -0500, Mikhail Teterin wrote:
 > On Thursday 21 November 2002 01:23 pm, you wrote:
 > = Juli, Mikhail!
 > = 
 > = What are these "other" issues that you've mentioned in the audit trail
 > = so briefly?
 > 
 > Inconsitency. make's general rule is, being not defined is the same
 > as being defined empty -- except when the "definedness" is explicitly
 > queried (with defined() or ?= ).
 > 
 No, this is not the general rule -- here are a few interesting
 examples from the PMake tutorial in /usr/share/doc/psd/12.make:
 
 :    empty    This  syntax  is  much  like the others, except the
 :             string inside the parentheses is of the  same  form
 :             as you would put between parentheses when expanding
 :             a variable, complete with modifiers and everything.
 :             The  function  returns true if the resulting string
 :             is empty (NOTE: an undefined variable in this  con-
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 :             text will cause at the very least a warning message
 :             about a malformed conditional,  and  at  the  worst
 :             will cause the process to stop once it has read the
 :             makefile. If you want to check for a variable being
 :             defined    or    empty,    use    the    expression
 :             ``!defined(var) || empty(var)'' as  the  definition
 :             of || will prevent the empty() from being evaluated
 :             and causing an error,  if  the  variable  is  unde-
 :             fined).  This can be used to see if a variable con-
 :             tains a given word, for example:
 : 
 :                  #if !empty(var:Mword)
 : 
 :    The arithmetic and string operators may only be used to test
 :    the  value of a variable. The lefthand side must contain the
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 :    variable expansion, while the righthand side contains either
      ^^^^^^^^^^^^^^^^^^
 :    a  string, enclosed in double-quotes, or a number. The stan-
 :    dard C numeric conventions (except for specifying  an  octal
 :    number) apply to both sides. E.g.
 
 > The example in the PR shows how the rule is gratuitously broken...
 > 
 All of the examples in PR are broken.  It is now documented (as of
 make.1,v 1.60) that the LHS in comparison conditionals is required
 to be a variable expansion, so your first example is incorrect.
 As for your second example,
 
 .if ${notdef} == value
 
 it is also documented to not work in the PMake tutorial:
 
 :    -B   Forces PMake to be as backwards-compatible with Make as
 :         possible while still being itself.  This includes:
 :         o Executing one shell per shell command
 :         o Expanding  anything  that  looks  even vaguely like a
 :           variable, with the empty string replacing  any  vari-
 :           able PMake doesn't know.
 :         o Refusing  to  allow  you to escape a `#' with a back-
 :           slash.
 :         o Permitting undefined variables  on  dependency  lines
 :           and  conditionals  (see  below). Normally this causes
                                              ^^^^^^^^^^^^^^^^^^^^
 :           PMake to abort.
             ^^^^^^^^^^^^^^
 
 Despite this statement about -B, PMake (ports/devel/pmake) does
 not permit undefined variables on conditionals.  Nevertheless,
 it does not make them permissible without -B either.
 
 What you want is achieved by the patch below, but I consider
 the exising behavior more correct:
 
 .if ${notdef1} == ${notdef2}
 
 should not result in TRUE, as would be with the below patch.
 (See also my .sig later on, and realize that undefined values
 are treated differently from empty strings in SQL.  :-)
 
 %%%
 Index: cond.c
 ===================================================================
 RCS file: /home/ncvs/src/usr.bin/make/cond.c,v
 retrieving revision 1.25
 diff -u -p -u -p -r1.25 cond.c
 --- cond.c	23 Oct 2002 23:16:42 -0000	1.25
 +++ cond.c	22 Nov 2002 09:11:25 -0000
 @@ -512,7 +512,7 @@ CondToken(Boolean doEval)
  		 * value in lhs.
  		 */
  		t = Err;
 -		lhs = Var_Parse(condExpr, VAR_CMD, doEval,&varSpecLen,&doFree);
 +		lhs = Var_Parse(condExpr, VAR_CMD, FALSE,&varSpecLen,&doFree);
  		if (lhs == var_Error) {
  		    /*
  		     * Even if !doEval, we still report syntax errors, which
 @@ -620,7 +620,7 @@ do_string_compare:
  			    int	len;
  			    Boolean freeIt;
  
 -			    cp2 = Var_Parse(cp, VAR_CMD, doEval,&len, &freeIt);
 +			    cp2 = Var_Parse(cp, VAR_CMD, FALSE,&len, &freeIt);
  			    if (cp2 != var_Error) {
  				Buf_AddBytes(buf, strlen(cp2), (Byte *)cp2);
  				if (freeIt) {
 @@ -672,7 +672,7 @@ do_string_compare:
  			int 	len;
  			Boolean	freeIt;
  
 -			string = Var_Parse(rhs, VAR_CMD, doEval,&len,&freeIt);
 +			string = Var_Parse(rhs, VAR_CMD, FALSE,&len,&freeIt);
  			if (string == var_Error) {
  			    right = 0.0;
  			} else {
 %%%
 
 I'd like to close this PR now.
 
 
 Cheers,
 -- 
 Ruslan Ermilov		Sysadmin and DBA,
 ru@sunbay.com		Sunbay Software AG,
 ru@FreeBSD.org		FreeBSD committer,
 +380.652.512.251	Simferopol, Ukraine
 
 http://www.FreeBSD.org	The Power To Serve
 http://www.oracle.com	Enabling The Information Age
State-Changed-From-To: open->closed 
State-Changed-By: trhodes 
State-Changed-When: Mon Dec 23 19:07:14 PST 2002 
State-Changed-Why:  
ru has wanted to close this PR for over a month now, so do so. 

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