Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 28 Jul 2003 14:00:08 +0300
From:      Ruslan Ermilov <ru@FreeBSD.org>
To:        arch@FreeBSD.org
Cc:        Kris Kennaway <kris@FreeBSD.org>
Subject:   Conditional evaluation in make(1)
Message-ID:  <20030728110008.GA63471@sunbay.com>
In-Reply-To: <20030728084254.GA51172@rot13.obsecurity.org>
References:  <20030728084254.GA51172@rot13.obsecurity.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--8GpibOaaTibBMecb
Content-Type: multipart/mixed; boundary="nFreZHaLTZJo0R7j"
Content-Disposition: inline


--nFreZHaLTZJo0R7j
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Gang,

> Script started on Mon Jul 28 11:02:58 2003
> goshik# cd /usr/ports ; make index ; cd /usr/local/etc; exit
>=20
> Generating INDEX - please wait.."/usr/ports/print/pips2200/../pips800/Mak=
efile", line 60: Malformed conditional (${PRTYPE} =3D=3D 780cs)
> "/usr/ports/print/pips2200/../pips800/Makefile", line 63: Malformed condi=
tional (${PRTYPE} =3D=3D 820ug)
> "/usr/ports/print/pips2200/../pips800/Makefile", line 1: Malformed condit=
ional (${PRTYPE} =3D=3D 750_2000)
> "/usr/ports/print/pips2200/../pips800/Makefile", line 1: Need an operator
> "/usr/ports/print/pips2200/../pips800/Makefile", line 5: Malformed condit=
ional (${PRTYPE} =3D=3D 780cs)
> "/usr/ports/print/pips2200/../pips800/Makefile", line 7: Malformed condit=
ional (${PRTYPE} =3D=3D 820ug)
> "/usr/ports/print/pips2200/../pips800/Makefile", line 305: if-less endif
> "/usr/ports/print/pips2200/../pips800/Makefile", line 305: Need an operat=
or
> make: fatal errors encountered -- cannot continue
> make_index: icemc-0.2.4: no entry for /usr/ports/x11-toolkits/qt31
> [...]
> make_index: bugzilla-2.16.3_1: no entry for /usr/ports/www/p5-Template-To=
olkit
> Warning: Duplicate INDEX entry: *** Error code 1
> Warning: Duplicate INDEX entry:
>  Done.
> exit
>=20
> Script done on Mon Jul 28 11:13:07 2003

I've just fixed ports/print/pips800/Makefile that was broken.
Its string conditional operators were broken, and just sitting
hidden behind another bug in make(1) that was recently fixed.

As explained in section 4.3 of the "PMake -- A Tutorial"
(PSD:12-39) book,

: The arithmetic and string operators may only be used to test
: the value of a variable.  The lefthand side must contain the
: variable expansion, while the righthand side contains either
: a string, enclosed in double-quotes, or a number.  The stan-
            ^^^^^^^^^^^^^^^^^^^^^^^^^
: dard C numeric conventions (except for specifying an octal
: number) apply to both sides.  E.g.
:=20
:      #if $(OS) =3D=3D 4.3
:=20
:      #if $(MACHINE) =3D=3D "sun3"
:=20
:      #if $(LOAD_ADDR) < 0xc000
:=20
: are all valid conditionals.

Since "1.3.2" doesn't represent a valid number, the test
condition against it should be written like this (with
RHS enclosed in quotes):

    .if ${PORTVERSION} =3D=3D "1.3.2"

But not like this:

    .if ${PORTVERSION} =3D=3D 1.3.2

which currently results in a "malformed conditional" complaint
=66rom make(1), and in my opinion, for a good reason.  The reason
why I think conditionals of the form

    .if ${VAR} =3D=3D (number)(non-number)

(without double quotes) should be complained about by make(1)
is to avoid hiding user bugs of the form:

    .if ${VAR} =3D=3D 0z

where "z" was put by mistake.  Note that

    .if ${VAR} =3D=3D (all-non-number)

conditionals with an unquoted RHS are still perfectly supported,
and result in a string comparison being performed.

The -dc option to make(1) can be used to debug conditional
evalulation.

I can easily "fix" our make code to restore the support for
broken string comparisons with the attached patch, so it's
rather a question of do we want to continue supporting this
bug or not.


Cheers,
--=20
Ruslan Ermilov		Sysadmin and DBA,
ru@sunbay.com		Sunbay Software Ltd,
ru@FreeBSD.org		FreeBSD committer

--nFreZHaLTZJo0R7j
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=p

Index: cond.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/make/cond.c,v
retrieving revision 1.26
diff -u -r1.26 cond.c
--- cond.c	4 Jul 2003 13:33:48 -0000	1.26
+++ cond.c	28 Jul 2003 10:47:29 -0000
@@ -688,7 +688,8 @@
 			}
 		    } else {
 			char *c = CondCvtArg(rhs, &right);
-			if (c == rhs)
+			if (*c != '\0' && !isspace((unsigned char) *c) &&
+			    *c != ')')
 			    goto do_string_compare;
 			if (rhs == condExpr) {
 			    /*

--nFreZHaLTZJo0R7j--

--8GpibOaaTibBMecb
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (FreeBSD)

iD8DBQE/JQI4Ukv4P6juNwoRAm6eAJ4xSF6SnNuzdKLONajdUDlVn0g13wCcD9Fk
4lJlZVSyfJb1txr+vE0SHR8=
=5VtI
-----END PGP SIGNATURE-----

--8GpibOaaTibBMecb--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030728110008.GA63471>