POV-Ray : Newsgroups : povray.programming : Trivial bug in unix.cpp Server Time
5 Jul 2024 16:16:46 EDT (-0400)
  Trivial bug in unix.cpp (Message 7 to 16 of 16)  
<<< Previous 6 Messages Goto Initial 10 Messages
From: Wolfgang Wieser
Subject: Re: Trivial bug in unix.cpp
Date: 25 Nov 2003 16:35:52
Message: <3fc3cb37@news.povray.org>
Nicolas Calimet wrote:

>> Sorry, but the presence of a flag is tested by using
>>   state & flag
>> and not
>>   state | flag
>> because the latter is always true.
> 
> No. The latter is false when both state and flag are false.
> It's true in any other case.
>
Oh dear... I was doing raw Xlib programming, so thinks like 
these are familiar to me: 

bash# fgrep -r ControlMask /usr/include/X11/*.h 
/usr/include/X11/X.h:#define ControlMask                (1<<2)

> Maybe it's always true in the context of the povray code
> you report, but honestly I have no idea what can be the values
> of theEvent->xkey.state and ControlMask.
> 
It's simple: When the control key is pressed, the ControlMask 
bit is set on the state value. Otherwise not. To test for 
pressed control key, one checks for if(state & ControlMask)

>> I was not aware that any clarification was needed for that...
>> ...or what is the problem?
> 
> When fixing a problem, you'd better give a description
> of the problem _first_  :-)
>
Yeah -- and I thought everyone would see the point after looking 
just 2 seconds at the code. It was just soooo evident to me. 

Wolfgang


Post a reply to this message

From: Christoph Hormann
Subject: Re: Trivial bug in unix.cpp
Date: 25 Nov 2003 16:52:03
Message: <vgvc91-tpv.ln1@triton.imagico.de>
Wolfgang Wieser wrote:
> 
> Yeah -- and I thought everyone would see the point after looking 
> just 2 seconds at the code. It was just soooo evident to me. 
> 

Please understand that also for a user interface bug the basic rules of 
bug reporting apply, i.e. clear description of the symptoms of the 
problem is required.  If you had said you tested that this change fixes 
a lack of response to ctrl-l in POV-Ray everything would have been clear.

Christoph

-- 
POV-Ray tutorials, include files, Sim-POV,
HCR-Edit and more: http://www.tu-bs.de/~y0013390/
Last updated 25 Oct. 2003 _____./\/^>_*_<^\/\.______


Post a reply to this message

From: Nicolas Calimet
Subject: Re: Trivial bug in unix.cpp
Date: 25 Nov 2003 16:56:40
Message: <3FC3D017.2080202@free.fr>
> bash# fgrep -r ControlMask /usr/include/X11/*.h 
> /usr/include/X11/X.h:#define ControlMask                (1<<2)

	Okay, in this case I agree it's always true  :-)

> Yeah -- and I thought everyone would see the point after looking 
> just 2 seconds at the code. It was just soooo evident to me.

	Sure, and I actually got the point when reading the code
(but was still too lazy to grep for ControlMask).  My first post
was simply intended to pass the message that giving a clear & simple
description of the problem may help saving time.  However, this
message was not clear either...  ;-)

	Anyway, thanx for fiding this.  The Xwindows code would
actually need more extensive review, so if you find any other
problem which is not related to Xwindows-specific command-line
options (this part of the code is quite buggy; currently fixed),
you're welcome to report !

	- NC


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Trivial bug in unix.cpp
Date: 25 Nov 2003 17:18:36
Message: <3fc3d53c@news.povray.org>
In article <3fc3c9ad@news.povray.org> , Wolfgang Wieser <wwi### [at] gmxde>  
wrote:

>>> Sorry, but the presence of a flag is tested by using
>>>   state & flag
>>> and not
>>>   state | flag
>>> because the latter is always true.
>>
>> Does the phrase "if it ain't broken, don't fix it" mean anything to you?
>>
> This phrase does not reflect my philisophy.
>
> And -- if you read code like that:
>     if(state | StateBit) { do sth }
> What would you think about the author? -- Oh dear...

Compared to code used in some commercial applications, the code in POV-Ray
is almost perfect. ;-)

Sadly, for any project that is big or complex enough you cannot say much
about the authors if you just look at the code when it is 15 years old and
has been treated by dozens of people.  Even if it would be a new project, at
best you can say how good the project management was, but still very little
about the authors.

Saying something about one particular author requires to make sure only one
author ever touched the code.  If you are lucky you find such condition in
an entry-level programming course, not anywhere else :-(

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Christopher James Huff
Subject: Re: Trivial bug in unix.cpp
Date: 25 Nov 2003 18:02:27
Message: <cjameshuff-DA813A.18012225112003@netplex.aussie.org>
In article <3FC### [at] freefr>,
 Nicolas Calimet <pov### [at] freefr> wrote:

> > Sorry, but the presence of a flag is tested by using 
> >   state & flag 
> > and not
> >   state | flag
> > because the latter is always true. 
> 
> 	No. The latter is false when both state and flag are false.
> It's true in any other case.

Of what use would this be? And even then, it wouldn't work 
properly...such a flag could never be set, but state | flag would be 
true if any other flag is set.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

From: Nicolas Calimet
Subject: Re: Trivial bug in unix.cpp
Date: 25 Nov 2003 18:16:43
Message: <3FC3E2DA.40801@free.fr>
>>>  state | flag
>>>because the latter is always true. 
>>
>>	No. The latter is false when both state and flag are false.
>>It's true in any other case.
>
> Of what use would this be?

	None.  I was simply noticing that the statement:
"state | flag  is always true" is not correct in the general
sense (i.e. as written here).

	- NC


Post a reply to this message

From: Wolfgang Wieser
Subject: Re: Trivial bug in unix.cpp
Date: 26 Nov 2003 11:54:03
Message: <3fc4daa6@news.povray.org>
Thorsten Froehlich wrote:
> In article <3fc3c9ad@news.povray.org> , Wolfgang Wieser wrote:
>> And -- if you read code like that:
>>     if(state | StateBit) { do sth }
>> What would you think about the author? -- Oh dear...
> 
> Compared to code used in some commercial applications, the code in POV-Ray
> is almost perfect. ;-)
> 
> Sadly, for any project that is big or complex enough you cannot say much
> about the authors if you just look at the code when it is 15 years old and
> has been treated by dozens of people.  Even if it would be a new project,
> at best you can say how good the project management was, but still very
> little about the authors.
> 
> Saying something about one particular author requires to make sure only
> one
> author ever touched the code.  If you are lucky you find such condition in
> an entry-level programming course, not anywhere else :-(
> 
You misunderstood me...

I just wanted to make a point stating that the above code should 
be fixed even "if it ain't broken"...

(For the same reson why people fix typos in a book even if you can read 
the book _with_ the typos.)

Wolfgang


Post a reply to this message

From: Wolfgang Wieser
Subject: Re: Trivial bug in unix.cpp
Date: 26 Nov 2003 12:17:41
Message: <3fc4e034@news.povray.org>
Christoph Hormann wrote:
> Please understand that also for a user interface bug the basic rules of
> bug reporting apply, i.e. clear description of the symptoms of the
> problem is required.  If you had said you tested that this change fixes
> a lack of response to ctrl-l in POV-Ray everything would have been clear.
> 
I completely understand you. 

Just to give you the background: 
The bug was _not_ discovered by observing misbehaviour. I just had 
a casual look at unix.cpp while writing my PRT patch and that 
particular line just jumped on me. It was so evident to me that this 
was a bug because from doing XLib programming for years, 
XEvent.state and ControlMask were familiar to me and so I thought 
any deeper explanation would just bore the maintainer...

Wolfgang


Post a reply to this message

From: Wolfgang Wieser
Subject: Re: Trivial bug in unix.cpp
Date: 26 Nov 2003 12:18:43
Message: <3fc4e072@news.povray.org>
Nicolas Calimet wrote:
> Anyway, thanx for fiding this.  The Xwindows code would
> actually need more extensive review, so if you find any other
> problem which is not related to Xwindows-specific command-line
> options (this part of the code is quite buggy; currently fixed),
> you're welcome to report !
> 
Okay, that's no problem -- If I find a bug and have a fix, I always 
report it. In case I don't have a fix, I report only severe bugs. 
It would, however, be helpful if you gave me the current development 
version of POVRay. 

Wolfgang


Post a reply to this message

From: Nicolas Calimet
Subject: Re: Trivial bug in unix.cpp
Date: 27 Nov 2003 03:22:36
Message: <3FC5B44C.6010201@free.fr>
> It would, however, be helpful if you gave me the current development 
> version of POVRay. 

	Apart the obvious bugfixes in XWIN_init_povray() that I mentioned
before, the current Xwindows-specific code is still the same as in 3.50c,
so reviewing the latter would be for sure of a great help.

	- NC


Post a reply to this message

<<< Previous 6 Messages Goto Initial 10 Messages

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.