Date: Sat, 5 Jun 1999 05:50:02 -0700 (PDT) From: Mark Valentine <mark@thuvia.demon.co.uk> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/5297: make incompatibility with System V style variable substitions Message-ID: <199906051250.FAA44451@freefall.freebsd.org>
index | next in thread | raw e-mail
The following reply was made to PR bin/5297; it has been noted by GNATS.
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/
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
home |
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199906051250.FAA44451>
