zsh-workers
 help / color / mirror / code / Atom feed
* Small bug in zsh 2.6beta9
@ 1995-06-05  7:52 Heiko Schroeder
  1995-06-05  9:37 ` P.Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: Heiko Schroeder @ 1995-06-05  7:52 UTC (permalink / raw)
  To: zsh-workers


Hi!

I found a small bug in zsh 2.6beta9.

In the file exec.c, line 493, the line

    if (ornext ^ ret) {

should read

    if (ornext ^ (ret!=0)) {

to get the documented behaviour of && and || in regard to being true
for values not equal to zero.

CU
   Heiko


-- 
-----------------------------------------------------------------------------
 Email:                                  | Snail-mail:
                                         |    Heiko Schroeder
    heiko@pool.informatik.rwth-aachen.de |    Lerchenweg 120
                                         |    52223 Stolberg
                                         |    GERMANY
-----------------------------------------------------------------------------


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Small bug in zsh 2.6beta9
  1995-06-05  7:52 Small bug in zsh 2.6beta9 Heiko Schroeder
@ 1995-06-05  9:37 ` P.Stephenson
  1995-06-07  9:40   ` Zvi Har'El
  0 siblings, 1 reply; 4+ messages in thread
From: P.Stephenson @ 1995-06-05  9:37 UTC (permalink / raw)
  To: Zsh hackers list

heiko@pool.informatik.rwth-aachen.de wrote:
> In the file exec.c, line 493, the line
> 
>     if (ornext ^ ret) {
> 
> should read
> 
>     if (ornext ^ (ret!=0)) {

You're quite right --- this is my fault again.  Here's an actual patch
for that.

*** Src/exec.c.ret	Mon Jun  5 10:16:14 1995
--- Src/exec.c	Mon Jun  5 10:34:30 1995
***************
*** 506,512 ****
  	     */
  	    ornext = (slist->type == ORNEXT);
  
! 	    if (ornext ^ ret) {
  		/*
  		 * If either (1) it's an or, and the return code
  		 * was zero, or (2) it's an and, and the return
--- 506,512 ----
  	     */
  	    ornext = (slist->type == ORNEXT);
  
! 	    if (ornext ^ (ret != 0)) {
  		/*
  		 * If either (1) it's an or, and the return code
  		 * was zero, or (2) it's an and, and the return

-- 
Peter Stephenson <P.Stephenson@swansea.ac.uk>  Tel: +44 1792 205678 extn. 4461
WWW:  http://python.swan.ac.uk/~pypeters/      Fax: +44 1792 295324
Department of Physics, University of Wales, Swansea,
Singleton Park, Swansea, SA2 8PP, U.K.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Small bug in zsh 2.6beta9
  1995-06-05  9:37 ` P.Stephenson
@ 1995-06-07  9:40   ` Zvi Har'El
  1995-06-07 10:10     ` Bas V. de Bakker
  0 siblings, 1 reply; 4+ messages in thread
From: Zvi Har'El @ 1995-06-07  9:40 UTC (permalink / raw)
  To: P.Stephenson; +Cc: zsh-workers

Peter,

YOU were right all the time. The two lines of code are identical. Perhaps
the idiom of checking if(a) rather then if(a!=0) is not clear to people
who are not seasoned C programmers, but personally I prefer your original code.


On Mon Jun  5 12:37:34 1995, P.Stephenson@swansea.ac.uk wrote about ``Re: Small bug in zsh 2.6beta9'':
> 
> heiko@pool.informatik.rwth-aachen.de wrote:
> > In the file exec.c, line 493, the line
> > 
> >     if (ornext ^ ret) {
> > 
> > should read
> > 
> >     if (ornext ^ (ret!=0)) {
> 
> You're quite right --- this is my fault again.  Here's an actual patch
> for that.
> 
> *** Src/exec.c.ret	Mon Jun  5 10:16:14 1995
> --- Src/exec.c	Mon Jun  5 10:34:30 1995
> ***************
> *** 506,512 ****
>   	     */
>   	    ornext = (slist->type == ORNEXT);
>   
> ! 	    if (ornext ^ ret) {
>   		/*
>   		 * If either (1) it's an or, and the return code
>   		 * was zero, or (2) it's an and, and the return
> --- 506,512 ----
>   	     */
>   	    ornext = (slist->type == ORNEXT);
>   
> ! 	    if (ornext ^ (ret != 0)) {
>   		/*
>   		 * If either (1) it's an or, and the return code
>   		 * was zero, or (2) it's an and, and the return
> 
> -- 
> Peter Stephenson <P.Stephenson@swansea.ac.uk>  Tel: +44 1792 205678 extn. 4461
> WWW:  http://python.swan.ac.uk/~pypeters/      Fax: +44 1792 295324
> Department of Physics, University of Wales, Swansea,
> Singleton Park, Swansea, SA2 8PP, U.K.
> 
> 
> 


-- 
Dr. Zvi Har'El <rl@math.technion.ac.il>              Department of Mathematics
+972-4-294094(Phone)                 Technion - Israel Institute of Technology
+972-4-324654(FAX)     http://gauss.technion.ac.il/~rl     Haifa 32000, ISRAEL
``If you can't say somethin' nice, don't say nothin' at all.''--Thumper (1942)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Small bug in zsh 2.6beta9
  1995-06-07  9:40   ` Zvi Har'El
@ 1995-06-07 10:10     ` Bas V. de Bakker
  0 siblings, 0 replies; 4+ messages in thread
From: Bas V. de Bakker @ 1995-06-07 10:10 UTC (permalink / raw)
  To: zsh-workers

Zvi Har'El <rl@leeor.technion.ac.il> writes:

>> >     if (ornext ^ ret) {
>> > 
>> > should read
>> > 
>> >     if (ornext ^ (ret!=0)) {

> YOU were right all the time. The two lines of code are
> identical. Perhaps the idiom of checking if(a) rather then if(a!=0)
> is not clear to people who are not seasoned C programmers, but
> personally I prefer your original code.

I haven't really followed the discussion, but although "if (a)" and
"if (a!=0)" are equivalent, the two lines above certainly aren't.  If
ornext == 1 and ret == 2 then

ornext ^ ret == 3

but

ornext ^ (ret != 0) == 0

Bas.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1995-06-07 10:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-06-05  7:52 Small bug in zsh 2.6beta9 Heiko Schroeder
1995-06-05  9:37 ` P.Stephenson
1995-06-07  9:40   ` Zvi Har'El
1995-06-07 10:10     ` Bas V. de Bakker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).