From owner-freebsd-hackers Sat Jul 29 3:52: 2 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from mta01-svc.ntlworld.com (mta01-svc.ntlworld.com [62.253.162.41]) by hub.freebsd.org (Postfix) with ESMTP id 96A2B37B5B3 for ; Sat, 29 Jul 2000 03:51:59 -0700 (PDT) (envelope-from mark@ukug.uk.freebsd.org) Received: from parish.my.domain ([62.253.84.67]) by mta01-svc.ntlworld.com (InterMail vM.4.01.02.27 201-229-119-110) with ESMTP id <20000729105157.BJGS26680.mta01-svc.ntlworld.com@parish.my.domain> for ; Sat, 29 Jul 2000 11:51:57 +0100 Received: (from mark@localhost) by parish.my.domain (8.9.3/8.9.3) id LAA00972 for hackers@freebsd.org; Sat, 29 Jul 2000 11:51:54 +0100 (BST) (envelope-from mark) Date: Sat, 29 Jul 2000 11:51:53 +0100 From: Mark Ovens To: hackers@freebsd.org Subject: ANSI compliance, gcc(1) and FreeBSD Message-ID: <20000729115153.C236@parish> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.2i Organization: Total lack of Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Apologies if this is the wrong list for this question but it seems the best place to get a *definitive* answer. In the ANSI Standard (K&R 2e, A7.14 & A7.15) it states that, in the case of the ``&&'' operator, the right operand is evaluated only if the left operand evaluates to non-zero, and, for ``||'', the right operand is evaluated only if the left operand evaluates to zero. My questions are: does gcc(1) honour this, and is it permitted to rely on this behaviour in FreeBSD (base system)?, e.g., would the following be acceptable if we wanted to guarantee that foobar was set to BAR *only* if FOO was unset or NULL? char *foobar; if ((foobar = getenv("FOO")) != NULL || (foobar = getenv("BAR")) != NULL) I couldn't find the answer in style(9). Please Cc: me as I'm not subscribed to -hackers. TIA -- If I buy a copy of WinDelete, and it doesn't delete Windows, am I entitled to my money back? ________________________________________________________________ 51.44°N FreeBSD - The Power To Serve http://www.freebsd.org 2.057°W My Webpage http://ukug.uk.freebsd.org/~mark mailto:marko@freebsd.org http://www.radan.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message