Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Nov 2002 18:03:25 +0100
From:      Erik Trulsson <ertr1013@student.uu.se>
To:        John Baldwin <jhb@FreeBSD.org>
Cc:        Marc Olzheim <marcolz@stack.nl>, hackers@FreeBSD.org
Subject:   Re: RE: /usr/src/ed/bin/re.c:99
Message-ID:  <20021106170325.GB19789@student.uu.se>
In-Reply-To: <XFMail.20021106115417.jhb@FreeBSD.org>
References:  <20021106164653.GA95733@stack.nl> <XFMail.20021106115417.jhb@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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.


-- 
<Insert your favourite quote here.>
Erik Trulsson
ertr1013@student.uu.se


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




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