From owner-freebsd-hackers Sat Feb 22 13:07:10 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id NAA18696 for hackers-outgoing; Sat, 22 Feb 1997 13:07:10 -0800 (PST) Received: from phaeton.artisoft.com (phaeton.Artisoft.COM [198.17.250.50]) by freefall.freebsd.org (8.8.5/8.8.5) with SMTP id NAA18547; Sat, 22 Feb 1997 13:05:37 -0800 (PST) Received: (from terry@localhost) by phaeton.artisoft.com (8.6.11/8.6.9) id OAA05142; Sat, 22 Feb 1997 14:02:06 -0700 From: Terry Lambert Message-Id: <199702222102.OAA05142@phaeton.artisoft.com> Subject: Re: hmm To: abelits@phobos.illtel.denver.co.us (Alex Belits) Date: Sat, 22 Feb 1997 14:02:06 -0700 (MST) Cc: terry@lambert.org, guido@gvr.win.tue.nl, dillon@best.net, gurney_j@resnet.uoregon.edu, top@sonic.cris.net, audit-bin@FreeBSD.ORG, FreeBSD-hackers@FreeBSD.ORG In-Reply-To: from "Alex Belits" at Feb 22, 97 12:35:09 pm X-Mailer: ELM [version 2.4 PL24] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > > > *p != '\0' && p[strlen(p) - 1] == '[' _still_ will read a byte p[-1]. > > > > What? > > > > IF p = "" > > THEN *p = '\0' > > > > by definition of ""... > > but p[strlen(p) - 1] will be p[-1] > Optimization done by compiler may skip it, but depending on that will be > rather dangerous. && is a McCarthy AND... if the first expression is not true, then by definition of the C language use of the operator, the second expression will not be evaluated. The first expression is not true, so p[strlen(p) - 1] will never be evaluated. That's the whole point of having McCarthy operators, aside from lazy people not using !0 as boolean "true" and wanting their code to still work for fear of bitwise AND. Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.