vlc | branch: master | Pierre Ynard <linkfa...@yahoo.fr> | Sat Jan 7 19:36:09 2012 +0100| [541ccdc6134a6340afcf9e0f9612f2a86e733ed6] | committer: Pierre Ynard
lua: fix sign errors in us_tonumber() > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=541ccdc6134a6340afcf9e0f9612f2a86e733ed6 --- share/lua/intf/modules/common.lua | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-) diff --git a/share/lua/intf/modules/common.lua b/share/lua/intf/modules/common.lua index ca51344..cc6251f 100644 --- a/share/lua/intf/modules/common.lua +++ b/share/lua/intf/modules/common.lua @@ -49,14 +49,23 @@ end -- tonumber() for decimals number, using a dot as decimal separator -- regardless of the system locale function us_tonumber(str) - local i, d = string.match(str, "([+-]?%d*)%.?(%d*)") - if i == nil or i == "" then + local s, i, d = string.match(str, "^([+-]?)(%d*)%.?(%d*)$") + if not s or not i or not d then + return nil + end + + if s == "-" then + s = -1 + else + s = 1 + end + if i == "" then i = "0" end if d == nil or d == "" then d = "0" end - return tonumber(i) + tonumber(d)/(10^string.len(d)) + return s * (tonumber(i) + tonumber(d)/(10^string.len(d))) end -- strip leading and trailing spaces _______________________________________________ vlc-commits mailing list vlc-commits@videolan.org http://mailman.videolan.org/listinfo/vlc-commits