tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

make: empty lhs for SysV style subst



Our make seems to be the odd man out (esp wrt Solaris) for the following
makefile:

FOO ?=
FOOBAR = $(FOO:=bar)
all:
        @echo FOOBAR = $(FOOBAR)

if FOO is empty it should print

FOOBAR =

Fix is simple enough.

Index: var.c
===================================================================
RCS file: /cvsroot/src/usr.bin/make/var.c,v
retrieving revision 1.161
diff -u -p -r1.161 var.c
--- var.c       2 Dec 2010 16:46:22 -0000       1.161
+++ var.c       4 Mar 2011 17:56:48 -0000
@@ -3346,9 +3346,13 @@ ApplyModifiers(char *nstr, const char *t
                 */
                termc = *--cp;
                delim = '\0';
-               newStr = VarModify(ctxt, &parsestate, nstr,
-                                  VarSYSVMatch,
-                                  &pattern);
+               if (pattern.leftLen == 0 && *nstr == '\0') {
+                   newStr = nstr;      /* special case */
+               } else {
+                   newStr = VarModify(ctxt, &parsestate, nstr,
+                                      VarSYSVMatch,
+                                      &pattern);
+               }
                free(UNCONST(pattern.lhs));
                free(UNCONST(pattern.rhs));
            } else


Home | Main Index | Thread Index | Old Index