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
[-- Attachment #1 --]
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= shells/zsh lang/perl5
> >
> > mytarget:
> > .for i in ${WANTED_PORTS}
> > @echo "${i}"
> > .if ${i} == lang/perl5
> > @echo "Yep, perl5."
> > .endif
> > .endfor
> > ---snip---
>
> Bug. A simpler case:
>
> .if "shells/zsh" == "lang/perl5"
> .endif
>
> dhcp01% make -f mf
> "mf", line 1: Malformed conditional ("shells/zsh" == "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
>
> 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") ...
>
> The attached patches partly fixes it by allowing string comparisons
> (ie make sure you have the lhs and rhs quoted)
>
> Try it out,
>
> --
> Marcel Moolenaar USPA: A-39004 marcel@xcllnt.net
> Index: cond.c
> ===================================================================
> 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 = 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 = Err;
> - lhs = Var_Parse(condExpr, VAR_CMD, doEval,&varSpecLen,&doFree);
> - if (lhs == var_Error) {
> - /*
> - * Even if !doEval, we still report syntax errors, which
> - * is what getting var_Error back with !doEval means.
> - */
> - return(Err);
> - }
> - condExpr += varSpecLen;
> + if (*condExpr == '$') {
> + t = Err;
> + lhs = Var_Parse(condExpr, VAR_CMD, doEval, &varSpecLen,
> + &doFree);
> + if (lhs == var_Error) {
> + /*
> + * Even if !doEval, we still report syntax
> + * errors, which is what getting var_Error
> + * back with !doEval means.
> + */
> + return(Err);
> + }
> + condExpr += varSpecLen;
> + } else
> + lhs = NULL;
>
> if (!isspace((unsigned char) *condExpr) &&
> strchr("!=><", *condExpr) == NULL) {
> @@ -529,8 +535,10 @@
>
> buf = Buf_Init(0);
>
> - for (cp = lhs; *cp; cp++)
> - Buf_AddByte(buf, (Byte)*cp);
> + if (lhs != NULL) {
> + for (cp = lhs; *cp; cp++)
> + Buf_AddByte(buf, (Byte)*cp);
> + }
>
> if (doFree)
> free(lhs);
> @@ -545,6 +553,9 @@
>
> doFree = TRUE;
> }
> +
> + if (lhs == NULL)
> + return (Err);
>
> /*
> * Skip whitespace to get to the operator
--
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
[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (FreeBSD)
iD8DBQE+c6dbUkv4P6juNwoRAnixAJ9dgK623qgZhAjMHEon0cNtKCnYtgCfQpJN
SOVaZ8UTtT8LT++Fs4vh7Fw=
=npMK
-----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030315222115.GC54789>
