*BSD News Article 34927


Return to BSD News archive

Newsgroups: comp.os.386bsd.bugs
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!bunyip.cc.uq.oz.au!munnari.oz.au!news.Hawaii.Edu!ames!pacbell.com!ihnp4.ucsd.edu!agate!howland.reston.ans.net!math.ohio-state.edu!jussieu.fr!univ-lyon1.fr!swidir.switch.ch!newsfeed.ACO.net!Austria.EU.net!EU.net!uunet!brunix!mhw
From: mhw@cs.brown.edu (Mark Weaver)
Subject: Re: FreeBSD 1.1.5 -- Bug in /usr/bin/leave
Message-ID: <1994Aug17.172837.4215@cs.brown.edu>
Sender: news@cs.brown.edu
Organization: Brown University Department of Computer Science
References: <NILS.94Aug14230659@guru.stgt.sub.org> <1994Aug15.034212.20767@cs.brown.edu> <NILS.94Aug16025340@guru.stgt.sub.org>
Date: Wed, 17 Aug 1994 17:28:37 GMT
Lines: 50

In article <NILS.94Aug16025340@guru.stgt.sub.org>,
Cornelis van der Laan <nils@ims.uni-stuttgart.de> wrote:
>In article <1994Aug15.034212.20767@cs.brown.edu> mhw@cs.brown.edu (Mark Weaver) writes:
>
>> Your fix doesn't change the program at all.  In C, "&&" has a higher
>> precedence than "||", and both have a lower precedence than the
>> comparison operators.  I don't know why you thought this changed
>> anything, but I'm sure it didn't.
>
>You're right, of course. My patch was reversed by some strange
>mistake. The error in the code is that && has higher precedence over
>all the preceding || expressions, which it shouldn't have. 

No, I'm saying that the two versions of the program are EQUIVALENT,
regardless of which way the patch goes.  Due to the normal precedence of
operators in C, the parentheses are irrelevant.

"&&" has higher precedence than "||" in C, even without parentheses.

>(But you're wrong too: my patch would have changed the program.
>At 22:30 setting an alarm at 23:15 would have given you an error.)

I don't think so.

>Sorry for the inconvenience. The right patch must read like this:
>
>*** leave.c     Tue Aug 16 02:45:30 1994
>--- leave.c.orig        Tue Aug 16 02:45:11 1994
>***************
>*** 97,103 ****
>                secs = hours * 60 * 60 + minutes * 60;
>        else {
>                if (hours > 23 || t->tm_hour > hours ||
>!                   (t->tm_hour == hours && minutes <= t->tm_min))
>                        usage();
>                secs = (hours - t->tm_hour) * 60 * 60;
>                secs += (minutes - t->tm_min) * 60;
>--- 97,103 ----
>                secs = hours * 60 * 60 + minutes * 60;
>        else {
>                if (hours > 23 || t->tm_hour > hours ||
>!                   t->tm_hour == hours && minutes <= t->tm_min)
>                        usage();
>                secs = (hours - t->tm_hour) * 60 * 60;
>                secs += (minutes - t->tm_min) * 60;

	Mark
--------------------------------------------------------------------
Email: Mark_Weaver@brown.edu           | Brown University
PGP Key: finger mhw@cs.brown.edu       | Dept of Computer Science