Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
c90a3e02
Commit
c90a3e02
authored
Jan 07, 2012
by
Pierre Ynard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lua: add and use us_tonumber() for decimal numbers
Closes #5705
parent
4b709298
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
3 deletions
+16
-3
share/lua/intf/cli.lua
share/lua/intf/cli.lua
+1
-1
share/lua/intf/modules/common.lua
share/lua/intf/modules/common.lua
+15
-2
No files found.
share/lua/intf/cli.lua
View file @
c90a3e02
...
@@ -464,7 +464,7 @@ end
...
@@ -464,7 +464,7 @@ end
function
rate
(
name
,
client
,
value
)
function
rate
(
name
,
client
,
value
)
local
input
=
vlc
.
object
.
input
()
local
input
=
vlc
.
object
.
input
()
if
name
==
"rate"
then
if
name
==
"rate"
then
vlc
.
var
.
set
(
input
,
"rate"
,
tonumber
(
value
))
vlc
.
var
.
set
(
input
,
"rate"
,
common
.
us_
tonumber
(
value
))
elseif
name
==
"normal"
then
elseif
name
==
"normal"
then
vlc
.
var
.
set
(
input
,
"rate"
,
1
)
vlc
.
var
.
set
(
input
,
"rate"
,
1
)
else
else
...
...
share/lua/intf/modules/common.lua
View file @
c90a3e02
...
@@ -46,6 +46,19 @@ function table_copy(t)
...
@@ -46,6 +46,19 @@ function table_copy(t)
return
c
return
c
end
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
-- strip leading and trailing spaces
function
strip
(
str
)
function
strip
(
str
)
return
string.gsub
(
str
,
"^%s*(.-)%s*$"
,
"%1"
)
return
string.gsub
(
str
,
"^%s*(.-)%s*$"
,
"%1"
)
...
@@ -119,9 +132,9 @@ function seek(value)
...
@@ -119,9 +132,9 @@ function seek(value)
local input = vlc.object.input()
local input = vlc.object.input()
if input ~= nil and value ~= nil then
if input ~= nil and value ~= nil then
if string.sub(value,-1) == "
%
" 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
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
if string.sub(value,1,1) == "
+
" or string.sub(value,1,1) == "
-
" then
vlc.var.set(input,"
position
",vlc.var.get(input,"
position
") + posPercent)
vlc.var.set(input,"
position
",vlc.var.get(input,"
position
") + posPercent)
else
else
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment