>Number:         164361
>Category:       bin
>Synopsis:       make handles "+=" incorrectly when the variable has zero length
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jan 22 03:30:14 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Stephen Montgomery-Smith
>Release:        FreeBSD 8.2-STABLE amd64
>Organization:
>Environment:
System: FreeBSD wilberforce 8.2-STABLE FreeBSD 8.2-STABLE #0: Sat Dec 24 
10:10:36 CST 2011 stephen@wilberforce:/usr/obj/usr/src/sys/GENERIC amd64


        
>Description:

make handles "+=" incorrectly when the variable has zero length.

This creates a mystery space if one does something like

cd /usr/ports/math/lapack
make -V LDFLAGS

because of many lines in /usr/share/mk/sys.mk like
LDFLAGS         ?=

>How-To-Repeat:
Create a Makefile containing
XXX=
XXX+=   xxx

all:
        echo +${XXX}+


make produces the output
echo + xxx+
+ xxx+

>Fix:

        

diff -ur usr.bin/make/var.c-orig usr.bin/make/var.c
--- usr.bin/make/var.c-orig     2012-01-21 21:10:50.000000000 -0600
+++ usr.bin/make/var.c  2012-01-21 21:12:05.000000000 -0600
@@ -1101,7 +1101,8 @@
        if (v == NULL) {
                VarAdd(n, val, ctxt);
        } else {
-               Buf_AddByte(v->val, (Byte)' ');
+               if (Buf_Size(v->val) != 0)
+                       Buf_AddByte(v->val, (Byte)' ');
                Buf_Append(v->val, val);
                DEBUGF(VAR, ("%s:%s = %s\n", ctxt->name, n, Buf_Data(v->val)));
        }

>Release-Note:
>Audit-Trail:
>Unformatted:
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[email protected]"

Reply via email to