POV-Ray : Newsgroups : povray.programming : Trivial bug in unix.cpp : Re: Trivial bug in unix.cpp Server Time
5 Jul 2024 15:50:23 EDT (-0400)
  Re: Trivial bug in unix.cpp  
From: Wolfgang Wieser
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

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