Subject: bin/9898: glitch in make variable substitutions
To: None <gnats-bugs@gnats.netbsd.org>
From: David A. Holland <dholland@hcs.harvard.edu>
List: netbsd-bugs
Date: 04/16/2000 06:27:12
>Number: 9898
>Category: bin
>Synopsis: glitch in make variable substitutions
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Apr 16 06:28:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator: David A. Holland
>Release: NetBSD-current of 20000416
>Organization:
>Environment:
System: NetBSD merlin 1.4X NetBSD 1.4X (MERLIN) #30: Sun Apr 16 08:04:29 EDT 2000 dholland@merlin:/usr/src/sys/arch/i386/compile/MERLIN i386
>Description:
There's a missing test in the code that limits variable expansions
in for loops to the iteration variable.
This causes make to expand any single-letter variable that's the
same as the first letter as the name of the iteration variable,
during expansion of the for loop instead of later. This is wrong,
though one has to contrive an example in order to observe any
difference.
>How-To-Repeat:
Try this makefile:
--- snip ---
F=foo
all:
.for FOO in a b c
@echo $(FOO)
@echo $F
.endfor
F=bar
--- snip ---
It will print "a foo b foo c foo", but should print "a bar b bar c
bar", because F shouldn't be expanded in the rule until after all the
assignments have been processed.
>Fix:
Apply this patch.
(This bug and patch are independent of the other make PR I'm about to
file.)
Index: usr.bin/make/var.c
===================================================================
RCS file: /cvsroot/basesrc/usr.bin/make/var.c,v
retrieving revision 1.37
diff -u -3 -r1.37 var.c
--- var.c 1999/09/15 22:51:05 1.37
+++ var.c 2000/04/16 13:14:55
@@ -2234,7 +2234,7 @@
int expand;
for (;;) {
if (str[1] != '(' && str[1] != '{') {
- if (str[1] != *var) {
+ if (strlen(var)>1 || str[1] != *var) {
Buf_AddBytes(buf, 2, (Byte *) str);
str += 2;
expand = FALSE;
>Release-Note:
>Audit-Trail:
>Unformatted: