Bug 158023

Summary: [PATCH] C++ xor operator is ^
Product: [Unmaintained] kdelibs Reporter: David Benjamin <davidben>
Component: kdeuiAssignee: kdelibs bugs <kdelibs-bugs-null>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description David Benjamin 2008-02-18 22:41:26 UTC
Version:            (using Devel)
Installed from:    Compiled sources
OS:                Linux

Sorry if this isn't the best place to mention this. (Should such things be dealt with on a mailing list instead? I wasn't sure which was more appropriate for super-minor stuff.)

I was poking around the kdelibs code and noticed an amusing TODO.
// TODO: what's the xor operator in c++?

And a patch, if it's really necessary. (I expect, for something like this, it's not worth the email-spam of filing a bug + attaching the patch.)

--- kdeui/shortcuts/kglobalaccel_x11.cpp        (revision 774182)
+++ kdeui/shortcuts/kglobalaccel_x11.cpp        (working copy)
@@ -208,7 +208,6 @@ bool KGlobalAccelImpl::x11KeyPress( cons
        //  e.g., KP_4 => Shift+KP_Left, and Shift+KP_4 => KP_Left.
        if( pEvent->xkey.state & KKeyServer::modXNumLock() ) {
                uint sym = XKeycodeToKeysym( QX11Info::display(), keyCodeX, 0 );
-               // TODO: what's the xor operator in c++?
                // If this is a keypad key,
                if( sym >= XK_KP_Space && sym <= XK_KP_9 ) {
                        switch( sym ) {
@@ -220,10 +219,7 @@ bool KGlobalAccelImpl::x11KeyPress( cons
                                case XK_KP_Divide:
                                        break;
                                default:
-                                       if( keyModX & KKeyServer::modXShift() )
-                                               keyModX &= ~KKeyServer::modXShift();
-                                       else
-                                               keyModX |= KKeyServer::modXShift();
+                                       keyModX ^= KKeyServer::modXShift();
                        }
                }
        }
Comment 1 Urs Wolfer 2008-02-18 22:59:46 UTC
SVN commit 776857 by uwolfer:

Nice catch.
Thanks to David Benjamin for the small patch.
BUG:158023

 M  +1 -5      kglobalaccel_x11.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=776857