From owner-freebsd-hackers Wed Nov 6 9: 3:37 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4302B37B401; Wed, 6 Nov 2002 09:03:36 -0800 (PST) Received: from typhoeus.it.uu.se (typhoeus.it.uu.se [130.238.8.11]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3C33043E6E; Wed, 6 Nov 2002 09:03:33 -0800 (PST) (envelope-from ertr1013@csd.uu.se) Received: (from ertr1013@localhost) by typhoeus.it.uu.se (8.8.5/8.8.5) id SAA21505; Wed, 6 Nov 2002 18:03:25 +0100 (MET) Date: Wed, 6 Nov 2002 18:03:25 +0100 From: Erik Trulsson To: John Baldwin Cc: Marc Olzheim , hackers@FreeBSD.org Subject: Re: RE: /usr/src/ed/bin/re.c:99 Message-ID: <20021106170325.GB19789@student.uu.se> References: <20021106164653.GA95733@stack.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4i Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Wed, Nov 06, 2002 at 11:54:17AM -0500, John Baldwin wrote: > > On 06-Nov-2002 Marc Olzheim wrote: > > .. > > if ((nd = parse_char_class(++nd)) == NULL) { > > .. > > > > Hmmm... is this legal ? > > > > http://www.eskimo.com/~scs/C-faq/q3.1.html seems to tell otherwise... > > If it were nd++, yes. However, it is ++nd, thus, the increment > happens first, then the call to parse_char_class(), then the assignment > to nd. It might be clearer to rewrite this like so however: In this regard nd++ and ++nd are completely equivalent. If parse_char_class is a function (and not a macro) I think the expression might be legal anyway since there is a sequence point after evaluating the arguments for a function call and making the call. If, OTOH, parse_char_class is a macro then the above expression is definitely not legal. (It is not legal to modify an object more than once without a sequence point in between.) > > if ((nd = parse_char_class(nd + 1)) == NULL) { > > Since that is effectively what it is doing. Yes, that would be clearer and definitely legal. -- Erik Trulsson ertr1013@student.uu.se To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message