Commit 5c1cb49e authored by Pierre Ynard's avatar Pierre Ynard

lua: add and use us_tonumber() for decimal numbers

Closes #5705
(cherry picked from commit c90a3e02)
Signed-off-by: default avatarPierre Ynard <linkfanel@yahoo.fr>
parent 92bea26d
......@@ -464,7 +464,7 @@ end
function rate(name,client,value)
local input = vlc.object.input()
if name == "rate" then
vlc.var.set(input, "rate", tonumber(value))
vlc.var.set(input, "rate", common.us_tonumber(value))
elseif name == "normal" then
vlc.var.set(input,"rate",1)
else
......
......@@ -46,6 +46,19 @@ function table_copy(t)
return c
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
i = "0"
end
if d == nil or d == "" then
d = "0"
end
return tonumber(i) + tonumber(d)/(10^string.len(d))
end
-- strip leading and trailing spaces
function strip(str)
return string.gsub(str, "^%s*(.-)%s*$", "%1")
......@@ -119,9 +132,9 @@ function seek(value)
local input = vlc.object.input()
if input ~= nil and value ~= nil then
if string.sub(value,-1) == "%" then
local number = tonumber(string.sub(value,1,-2))
local number = us_tonumber(string.sub(value,1,-2))
if number ~= nil then
local posPercent = tonumber( string.sub(value,1,-2))/100.
local posPercent = number/100.
if string.sub(value,1,1) == "+" or string.sub(value,1,1) == "-" then
vlc.var.set(input,"position",vlc.var.get(input,"position") + posPercent)
else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment