[vlc-commits] lua: do a binary-and operation in is_flag_set()
Hannes Domani
git at videolan.org
Tue Jul 21 11:37:15 CEST 2015
vlc | branch: master | Hannes Domani <ssbssa at yahoo.de> | Wed Jul 15 20:57:07 2015 +0200| [0d4616beb40ac1d313acc9340231402698643fd5] | committer: Jean-Baptiste Kempf
lua: do a binary-and operation in is_flag_set()
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0d4616beb40ac1d313acc9340231402698643fd5
---
share/lua/intf/modules/host.lua | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/share/lua/intf/modules/host.lua b/share/lua/intf/modules/host.lua
index b840b32..199325e 100644
--- a/share/lua/intf/modules/host.lua
+++ b/share/lua/intf/modules/host.lua
@@ -68,7 +68,14 @@ status = { init = 0, read = 1, write = 2, password = 3 }
client_type = { net = 1, stdio = 2, fifo = 3, telnet = 4 }
function is_flag_set(val, flag)
- return (((val - (val % flag)) / flag) % 2 ~= 0)
+ local bit = 65536
+ while bit > 1 do
+ val = val % bit
+ flag = flag % bit
+ bit = bit / 2
+ if val >= bit and flag >= bit then return true end
+ end
+ return false
end
function host()
More information about the vlc-commits
mailing list