From owner-freebsd-arch Sat Mar 15 11:21:49 2003 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 2182037B401 for ; Sat, 15 Mar 2003 11:21:46 -0800 (PST) Received: from ns1.xcllnt.net (209-128-86-226.BAYAREA.NET [209.128.86.226]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5A9EF43F93 for ; Sat, 15 Mar 2003 11:21:43 -0800 (PST) (envelope-from marcel@xcllnt.net) Received: from dhcp01.pn.xcllnt.net (dhcp01.pn.xcllnt.net [192.168.4.201]) by ns1.xcllnt.net (8.12.8/8.12.8) with ESMTP id h2FJLgSd071043; Sat, 15 Mar 2003 11:21:42 -0800 (PST) (envelope-from marcel@piii.pn.xcllnt.net) Received: from dhcp01.pn.xcllnt.net (localhost [127.0.0.1]) by dhcp01.pn.xcllnt.net (8.12.7/8.12.7) with ESMTP id h2FJLflO001048; Sat, 15 Mar 2003 11:21:41 -0800 (PST) (envelope-from marcel@dhcp01.pn.xcllnt.net) Received: (from marcel@localhost) by dhcp01.pn.xcllnt.net (8.12.7/8.12.7/Submit) id h2FJLfON001047; Sat, 15 Mar 2003 11:21:41 -0800 (PST) (envelope-from marcel) Date: Sat, 15 Mar 2003 11:21:41 -0800 From: Marcel Moolenaar To: Alexander Leidinger Cc: arch@FreeBSD.ORG Subject: Re: Bug in our make or undocumented feature? Message-ID: <20030315192141.GA564@dhcp01.pn.xcllnt.net> References: <20030315165221.27d3d424.Alexander@Leidinger.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="2oS5YaxWCcQjTEyO" Content-Disposition: inline In-Reply-To: <20030315165221.27d3d424.Alexander@Leidinger.net> User-Agent: Mutt/1.5.3i Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --2oS5YaxWCcQjTEyO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --2oS5YaxWCcQjTEyO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="make.diff" 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 --2oS5YaxWCcQjTEyO-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message