diff options
author | Roberto E. Vargas Caballero <k0ga@shike2.com> | 2013-06-23 10:33:53 +0200 |
---|---|---|
committer | Roberto E. Vargas Caballero <k0ga@shike2.com> | 2013-07-04 09:21:57 +0200 |
commit | 6e1c7c8afce3a0e6f896231a3155a27543d261e5 (patch) | |
tree | 456a2c4de042d4b6a3928e4463275e58eff03ceb | |
parent | 90c6f055b637a58da0381a21b4a290ce26f56d8f (diff) | |
download | st-6e1c7c8afce3a0e6f896231a3155a27543d261e5.tar.gz st-6e1c7c8afce3a0e6f896231a3155a27543d261e5.tar.bz2 st-6e1c7c8afce3a0e6f896231a3155a27543d261e5.zip |
Fix match function bugs
There were two problems with match denfinition.
1) There was a forward declaration in the form:
static inline bool match(uint, uint);
but later the function was defined as:
inline bool
match(uint mask, uint state) {
This causes that there were two different functions in the code, one local
and inline, and other inline but extern. All was working without problems
due to we were using -Os, and the compiler was using the extern definition
and it was no expanding the static declaration. If you removed the -Os flag,
then you got linker errors due it was no able to find the static definition
of the static declaration.
2) The mask checking was incorrect because we were doing the test:
(state & mask) != state
and this test only was saying that at least all the enabled bits of state
were enabled also in mask, but no all the possible bits in mask. This was
the origin of the bug reported by Xavier Cartron, where he said it was
possible activated some shortcuts with some of the modifiers defined in the
config.h file.
-rw-r--r-- | st.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -3355,17 +3355,17 @@ focus(XEvent *ev) { } } -inline bool +static inline bool match(uint mask, uint state) { - state &= ~(ignoremod); + state &= ~ignoremod; if(mask == XK_NO_MOD && state) return false; if(mask != XK_ANY_MOD && mask != XK_NO_MOD && !state) return false; - if((state & mask) != state) - return false; - return true; + if(mask == XK_ANY_MOD) + return true; + return state == mask; } void |