Page 1 of 1

(Solved) Fixing the cli.lua help option to build with Lua 5.3

Posted: 28 May 2015 20:06
by nokangaroo
Since my bug reports keep getting killed, I have to fix this myself:

Code: Select all

diff --git a/share/lua/intf/cli.lua b/share/lua/intf/cli.lua index e2fa856..d6d3001 100644 --- a/share/lua/intf/cli.lua +++ b/share/lua/intf/cli.lua @@ -343,7 +343,7 @@ function help(name,client,arg) end if val.args then str = str .. " " .. val.args end if #str%2 == 1 then str = str .. " " end - str = str .. string.rep(" .",(width-(#str+#val.help)-1)/2) + str = str .. string.rep(" .",math.floor((width-(#str+#val.help)-1)/2)) str = str .. string.rep(" ",width-#str-#val.help) .. val.help end client:append(str)

This is for vlc-3.0 and vlc-2.2.



I believe that

a) math.floor will get VERY popular in Lua 5.3

b) cli.lua almost certainly has other bugs (that I won't find because I don't use it)

and c) DEVELOPERS: It's time to replace cli.lua with something less crappy and
obfuscated and more maintainable. Also, the cleanest solution would be to just
represent all times as integer microseconds insted of this timid

Code: Select all

client:append(math.floor(vlc.var.get( input, var ) / 1000000))
and

Code: Select all

vlc.var.set(input,"time",vlc.var.get(input,"time") + (posTime * 1000000))
To be honest, cli.lua looks like a prank to me, with its strip() and skip() and
skip2() and other levels of indirection. The kind of thing a capable programmer
might write as a practical joke.

Besides, interface scripts for local control through the commandline or a fifo
don't even need the host module.

vlc.net.write(1,"blabla") writes to stdout and vlc.net.read(0,<length>) reads
from stdin.

vlc.net.write(1) can be replaced by something like this:

Code: Select all

var = "testing" value = 123.456 var1 = string.format("%s %s=%f","echo",var,value) os.execute(var1)
which should also work in Windows if you replace echo with its Windows
equivalent (I assume there is one).

Re: (Solved) Fixing the cli.lua help option to build with Lua 5.3

Posted: 16 Jul 2015 12:37
by Jean-Baptiste Kempf
a) we need to maintain 5.1 compatibility.
b) so, why report them, if you don't know where it is?
c) patches welcome, as always. But as you seem to suggest os.execute, I'm not sure you know what you are speaking about.