Date: Thu, 31 Oct 2002 17:43:19 +0200 From: Ruslan Ermilov <ru@FreeBSD.ORG> To: Juli Mallett <jmallett@FreeBSD.ORG> Cc: Alan Eldridge <alane@FreeBSD.ORG>, Warner Losh <imp@FreeBSD.ORG>, current@FreeBSD.ORG Subject: Re: changes to make(1) Message-ID: <20021031154319.GD55353@sunbay.com> In-Reply-To: <20021031062125.A54740@FreeBSD.org> References: <20021030152046.GA93680@sunbay.com> <20021030161329.GC72564@wwweasel.geeksrus.net> <20021030204920.L38444@freebsdmall.com> <20021031060320.GB87766@wwweasel.geeksrus.net> <20021031060820.GA19819@dragon.nuxi.com> <20021031061246.GA45936@wwweasel.geeksrus.net> <20021031092026.GA23436@sunbay.com> <20021031093732.GA531@wwweasel.geeksrus.net> <20021031141315.GB55353@sunbay.com> <20021031062125.A54740@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--hxkXGo8AKqTJ+9QI
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Thu, Oct 31, 2002 at 06:21:25AM -0800, Juli Mallett wrote:
> * De: Ruslan Ermilov <ru@FreeBSD.org> [ Data: 2002-10-31 ]
> [ Subjecte: Re: changes to make(1) ]
>=20
> Interesting. It seems to me we really need a 'CondIsExpressionTerminator'
> or something. ')' should only be a terminator if we are inside a '('. are
> both of those cases in '(' code? If so then everything else is bogus, so
> I'd bet not :(
>=20
')' should either be escaped or quoted to be recognized properly here.
With or without my patch (make -r -dc):
STR=3D foo
=2Eif ${STR} =3D=3D foo) =3D=3D> lhs =3D "foo", rhs =3D "foo", op =3D =3D=
=3D (malformed conditional)
=2Eif ${STR} =3D=3D foo\) =3D=3D> lhs =3D "foo", rhs =3D "foo)", op =3D =3D=
=3D
=2Eif ${STR} =3D=3D "foo)" =3D=3D> lhs =3D "foo", rhs =3D "foo)", op =3D =
=3D=3D
You'll get the similar results with the NUM=3D1 and .if ${NUM} =3D=3D 1
except here:
=2Eif ${NUM} =3D=3D 1)
old version will =3D=3D> lhs =3D "1", rhs =3D "1", op =3D =3D=3D
new version will =3D=3D> left =3D 1.000000, right =3D 1.000000, op =3D =3D=
=3D
(both will fail with malformed conditional)
If we go further and back out the change in rev. 1.9, we can
even make the following code work (no surrounding spaces for &&):
NUM=3D 1
num:
=2Eif (${NUM}=3D=3D1&&${NUM}=3D=3D1)
@echo OK.
=2Eendif
But this will cost us the following:
=2Eif ${NUM} > 0z
@echo OK.
=2Eendif
make(1) won't now complain about "z". A small improvement gives us:
%%%
Index: cond.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/ncvs/src/usr.bin/make/cond.c,v
retrieving revision 1.25
diff -u -p -u -r1.25 cond.c
--- cond.c 23 Oct 2002 23:16:42 -0000 1.25
+++ cond.c 31 Oct 2002 15:26:16 -0000
@@ -688,16 +688,13 @@ do_string_compare:
}
} else {
char *c =3D CondCvtArg(rhs, &right);
- if (*c !=3D '\0' && !isspace((unsigned char) *c))
+ if (c =3D=3D rhs)
goto do_string_compare;
if (rhs =3D=3D condExpr) {
/*
* Skip over the right-hand side
*/
- while(!isspace((unsigned char) *condExpr) &&
- (*condExpr !=3D '\0')) {
- condExpr++;
- }
+ condExpr =3D c;
}
}
=20
%%%
> > %%%
> > Index: cond.c
> > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> > RCS file: /home/ncvs/src/usr.bin/make/cond.c,v
> > retrieving revision 1.25
> > diff -u -p -r1.25 cond.c
> > --- cond.c 23 Oct 2002 23:16:42 -0000 1.25
> > +++ cond.c 31 Oct 2002 13:10:13 -0000
> > @@ -688,14 +688,15 @@ do_string_compare:
> > }
> > } else {
> > char *c =3D CondCvtArg(rhs, &right);
> > - if (*c !=3D '\0' && !isspace((unsigned char) *c))
> > + if (*c !=3D '\0' && *c !=3D ')' &&
> > + !isspace((unsigned char) *c))
> > goto do_string_compare;
> > if (rhs =3D=3D condExpr) {
> > /*
> > * Skip over the right-hand side
> > */
> > while(!isspace((unsigned char) *condExpr) &&
> > - (*condExpr !=3D '\0')) {
> > + *condExpr !=3D ')' && *condExpr !=3D '\0') {
> > condExpr++;
> > }
> > }
> > %%%
> >=20
> > ports/devel/pmake is also vulnerable to this (even the latest beta),
> > and unless I'm dreadfully mistaken, OpenBSD's make(1) too.
Cheers,
--=20
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
--hxkXGo8AKqTJ+9QI
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (FreeBSD)
iD8DBQE9wU+XUkv4P6juNwoRAr9DAKCA4F8KfmyNDW5hE5FAsa7l98TL7gCeIFEr
rMSUtuezddrXQKy9H1U1TKA=
=Ms5n
-----END PGP SIGNATURE-----
--hxkXGo8AKqTJ+9QI--
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021031154319.GD55353>
