From owner-freebsd-arch@FreeBSD.ORG Mon Jul 28 04:00:39 2003 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EB22B37B401; Mon, 28 Jul 2003 04:00:38 -0700 (PDT) Received: from whale.sunbay.crimea.ua (whale.sunbay.crimea.ua [212.110.138.65]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1647943F3F; Mon, 28 Jul 2003 04:00:28 -0700 (PDT) (envelope-from ru@sunbay.com) Received: from whale.sunbay.crimea.ua (ru@localhost [127.0.0.1]) h6SB080U070509 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 28 Jul 2003 14:00:08 +0300 (EEST) (envelope-from ru@sunbay.com) Received: (from ru@localhost) by whale.sunbay.crimea.ua (8.12.9/8.12.8/Submit) id h6SB08kV070504; Mon, 28 Jul 2003 14:00:08 +0300 (EEST) (envelope-from ru) Date: Mon, 28 Jul 2003 14:00:08 +0300 From: Ruslan Ermilov To: arch@FreeBSD.org Message-ID: <20030728110008.GA63471@sunbay.com> References: <20030728084254.GA51172@rot13.obsecurity.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="8GpibOaaTibBMecb" Content-Disposition: inline In-Reply-To: <20030728084254.GA51172@rot13.obsecurity.org> User-Agent: Mutt/1.5.4i cc: Kris Kennaway Subject: Conditional evaluation in make(1) X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Jul 2003 11:00:39 -0000 --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--