Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 Mar 2003 00:21:15 +0200
From:      Ruslan Ermilov <ru@FreeBSD.ORG>
To:        Marcel Moolenaar <marcel@xcllnt.net>
Cc:        Alexander Leidinger <Alexander@Leidinger.net>, arch@FreeBSD.ORG
Subject:   Re: Bug in our make or undocumented feature?
Message-ID:  <20030315222115.GC54789@sunbay.com>
In-Reply-To: <20030315192141.GA564@dhcp01.pn.xcllnt.net>
References:  <20030315165221.27d3d424.Alexander@Leidinger.net> <20030315192141.GA564@dhcp01.pn.xcllnt.net>

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

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

Marcel,

I will look into this patch some time later and let you know.
Thanks for taking care of this.

On Sat, Mar 15, 2003 at 11:21:41AM -0800, Marcel Moolenaar wrote:
> On Sat, Mar 15, 2003 at 04:52:21PM +0100, Alexander Leidinger wrote:
> > this part of a makefile doesn't work for me:
> > ---snip---
> > WANTED_PORTS=3D	shells/zsh lang/perl5
> >=20
> > mytarget:
> > .for i in ${WANTED_PORTS}
> > 	@echo "${i}"
> > .if ${i} =3D=3D lang/perl5 =20
> > 	@echo "Yep, perl5."
> > .endif
> > .endfor
> > ---snip---
>=20
> Bug. A simpler case:
>=20
> 	.if "shells/zsh" =3D=3D "lang/perl5"
> 	.endif
>=20
> dhcp01% make -f mf
> "mf", line 1: Malformed conditional ("shells/zsh" =3D=3D "lang/perl5")
> "mf", line 1: Need an operator
> "mf", line 2: if-less endif
> "mf", line 2: Need an operator
> make: fatal errors encountered -- cannot continue
>=20
> The problem is that our make needs a variable on the left in order
> to parse this correctly as a comparison. Now we end up evaluating this
> like:
> 	.if defined("shells/zsh") ...
>=20
> The attached patches partly fixes it by allowing string comparisons
> (ie make sure you have the lhs and rhs quoted)
>=20
> Try it out,
>=20
> --=20
>  Marcel Moolenaar	  USPA: A-39004		 marcel@xcllnt.net

> 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 -r1.25 cond.c
> --- cond.c	23 Oct 2002 23:16:42 -0000	1.25
> +++ cond.c	15 Mar 2003 19:17:24 -0000
> @@ -500,6 +500,7 @@
>  	    case '\0':
>  		t =3D EndOfFile;
>  		break;
> +	    case '"':
>  	    case '$': {
>  		char	*lhs;
>  		char	*rhs;
> @@ -511,16 +512,21 @@
>  		 * Parse the variable spec and skip over it, saving its
>  		 * value in lhs.
>  		 */
> -		t =3D Err;
> -		lhs =3D Var_Parse(condExpr, VAR_CMD, doEval,&varSpecLen,&doFree);
> -		if (lhs =3D=3D var_Error) {
> -		    /*
> -		     * Even if !doEval, we still report syntax errors, which
> -		     * is what getting var_Error back with !doEval means.
> -		     */
> -		    return(Err);
> -		}
> -		condExpr +=3D varSpecLen;
> +		if (*condExpr =3D=3D '$') {
> +		    t =3D Err;
> +		    lhs =3D Var_Parse(condExpr, VAR_CMD, doEval, &varSpecLen,
> +			&doFree);
> +		    if (lhs =3D=3D var_Error) {
> +			/*
> +			 * Even if !doEval, we still report syntax
> +			 * errors, which is what getting var_Error
> +			 * back with !doEval means.
> +			 */
> +			return(Err);
> +		    }
> +		    condExpr +=3D varSpecLen;
> +		} else
> +		    lhs =3D NULL;
> =20
>  		if (!isspace((unsigned char) *condExpr) &&
>  		    strchr("!=3D><", *condExpr) =3D=3D NULL) {
> @@ -529,8 +535,10 @@
> =20
>  		    buf =3D Buf_Init(0);
> =20
> -		    for (cp =3D lhs; *cp; cp++)
> -			Buf_AddByte(buf, (Byte)*cp);
> +		    if (lhs !=3D NULL) {
> +			for (cp =3D lhs; *cp; cp++)
> +			    Buf_AddByte(buf, (Byte)*cp);
> +		    }
> =20
>  		    if (doFree)
>  			free(lhs);
> @@ -545,6 +553,9 @@
> =20
>  		    doFree =3D TRUE;
>  		}
> +
> +		if (lhs =3D=3D NULL)
> +			return (Err);
> =20
>  		/*
>  		 * Skip whitespace to get to the operator


--=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

--0lnxQi9hkpPO77W3
Content-Type: application/pgp-signature
Content-Disposition: inline

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

iD8DBQE+c6dbUkv4P6juNwoRAnixAJ9dgK623qgZhAjMHEon0cNtKCnYtgCfQpJN
SOVaZ8UTtT8LT++Fs4vh7Fw=
=npMK
-----END PGP SIGNATURE-----

--0lnxQi9hkpPO77W3--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




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