[vlc-devel] [PATCH] Changes to support lua 5.2

Kelly Anderson kelly at silka.with-linux.com
Sat Dec 31 23:26:14 CET 2011


---
 modules/lua/intf.c                      |    4 ----
 modules/lua/libs/acl.c                  |    3 ---
 modules/lua/libs/configuration.c        |    3 ---
 modules/lua/libs/dialog.c               |    3 ---
 modules/lua/libs/equalizer.c            |    3 ---
 modules/lua/libs/gettext.c              |    4 ----
 modules/lua/libs/httpd.c                |    4 ----
 modules/lua/libs/input.c                |    4 +---
 modules/lua/libs/input.h                |    2 ++
 modules/lua/libs/messages.c             |    4 ----
 modules/lua/libs/misc.c                 |    4 ----
 modules/lua/libs/net.c                  |    3 ---
 modules/lua/libs/objects.c              |    3 ---
 modules/lua/libs/osd.c                  |    3 ---
 modules/lua/libs/playlist.c             |    4 +---
 modules/lua/libs/sd.c                   |    4 ----
 modules/lua/libs/stream.c               |    3 ---
 modules/lua/libs/strings.c              |    3 ---
 modules/lua/libs/variables.c            |    4 ----
 modules/lua/libs/video.c                |    3 ---
 modules/lua/libs/vlm.c                  |    3 ---
 modules/lua/libs/volume.c               |    4 ----
 modules/lua/libs/xml.c                  |    3 ---
 modules/lua/vlc.c                       |    4 ----
 modules/lua/vlc.h                       |    6 ++++++
 share/lua/extensions/imdb.lua           |    2 +-
 share/lua/intf/cli.lua                  |    2 +-
 share/lua/intf/modules/httprequests.lua |    4 ++--
 share/lua/playlist/appletrailers.lua    |    6 +++---
 share/lua/playlist/extreme.lua          |    2 +-
 share/lua/playlist/katsomo.lua          |    2 +-
 share/lua/playlist/mpora.lua            |    2 +-
 share/lua/playlist/pinkbike.lua         |    4 ++--
 33 files changed, 22 insertions(+), 90 deletions(-)

diff --git a/modules/lua/intf.c b/modules/lua/intf.c
index 3b01727..61fe362 100644
--- a/modules/lua/intf.c
+++ b/modules/lua/intf.c
@@ -37,10 +37,6 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 
-#include <lua.h>        /* Low level lua C API */
-#include <lauxlib.h>    /* Higher level C API */
-#include <lualib.h>     /* Lua libs */
-
 #include "vlc.h"
 #include "libs.h"
 
diff --git a/modules/lua/libs/acl.c b/modules/lua/libs/acl.c
index 4deb66e..693137d 100644
--- a/modules/lua/libs/acl.c
+++ b/modules/lua/libs/acl.c
@@ -35,9 +35,6 @@
 #include <vlc_common.h>
 #include <vlc_acl.h>
 
-#include <lua.h>        /* Low level lua C API */
-#include <lauxlib.h>    /* Higher level C API */
-
 #include "../vlc.h"
 #include "../libs.h"
 
diff --git a/modules/lua/libs/configuration.c b/modules/lua/libs/configuration.c
index 7a4785f..7b5f732 100644
--- a/modules/lua/libs/configuration.c
+++ b/modules/lua/libs/configuration.c
@@ -34,9 +34,6 @@
 
 #include <vlc_common.h>
 
-#include <lua.h>        /* Low level lua C API */
-#include <lauxlib.h>    /* Higher level C API */
-
 #include "../vlc.h"
 #include "../libs.h"
 
diff --git a/modules/lua/libs/dialog.c b/modules/lua/libs/dialog.c
index 3ca67b2..55468f3 100644
--- a/modules/lua/libs/dialog.c
+++ b/modules/lua/libs/dialog.c
@@ -35,9 +35,6 @@
 #include <vlc_common.h>
 #include <vlc_extensions.h>
 
-#include <lua.h>        /* Low level lua C API */
-#include <lauxlib.h>    /* Higher level C API */
-
 #include "../vlc.h"
 #include "../libs.h"
 
diff --git a/modules/lua/libs/equalizer.c b/modules/lua/libs/equalizer.c
index 75b2334..e698c6f 100644
--- a/modules/lua/libs/equalizer.c
+++ b/modules/lua/libs/equalizer.c
@@ -38,9 +38,6 @@
 #include <vlc_input.h>
 #include <vlc_charset.h>
 
-#include <lua.h>        /* Low level lua C API */
-#include <lauxlib.h>    /* Higher level C API */
-
 #include "input.h"
 #include "../libs.h"
 #include "../vlc.h"
diff --git a/modules/lua/libs/gettext.c b/modules/lua/libs/gettext.c
index b461e73..2781d35 100644
--- a/modules/lua/libs/gettext.c
+++ b/modules/lua/libs/gettext.c
@@ -32,10 +32,6 @@
 # include "config.h"
 #endif
 
-#include <lua.h>        /* Low level lua C API */
-#include <lauxlib.h>    /* Higher level C API */
-#include <lualib.h>     /* Lua libs */
-
 #include "../vlc.h"
 #include "../libs.h"
 
diff --git a/modules/lua/libs/httpd.c b/modules/lua/libs/httpd.c
index b4520d9..85a38cc 100644
--- a/modules/lua/libs/httpd.c
+++ b/modules/lua/libs/httpd.c
@@ -35,10 +35,6 @@
 #include <vlc_common.h>
 #include <vlc_httpd.h>
 
-#include <lua.h>        /* Low level lua C API */
-#include <lauxlib.h>    /* Higher level C API */
-#include <lualib.h>     /* Lua libs */
-
 #include "../vlc.h"
 #include "../libs.h"
 
diff --git a/modules/lua/libs/input.c b/modules/lua/libs/input.c
index 60211fd..7b413e2 100644
--- a/modules/lua/libs/input.c
+++ b/modules/lua/libs/input.c
@@ -37,13 +37,11 @@
 
 #include <vlc_playlist.h>
 
-#include <lua.h>        /* Low level lua C API */
-#include <lauxlib.h>    /* Higher level C API */
 #include <assert.h>
 
+#include "../vlc.h"
 #include "input.h"
 #include "playlist.h"
-#include "../vlc.h"
 #include "../libs.h"
 #include "../extension.h"
 
diff --git a/modules/lua/libs/input.h b/modules/lua/libs/input.h
index dbe76df..903134a 100644
--- a/modules/lua/libs/input.h
+++ b/modules/lua/libs/input.h
@@ -24,6 +24,8 @@
 #ifndef VLC_LUA_INPUT_H
 #define VLC_LUA_INPUT_H
 
+#include "../vlc.h"
+
 input_thread_t * vlclua_get_input_internal( lua_State * );
 
 #endif
diff --git a/modules/lua/libs/messages.c b/modules/lua/libs/messages.c
index 9c40e53..589d162 100644
--- a/modules/lua/libs/messages.c
+++ b/modules/lua/libs/messages.c
@@ -38,10 +38,6 @@
 #include <vlc_meta.h>
 #include <vlc_aout.h>
 
-#include <lua.h>        /* Low level lua C API */
-#include <lauxlib.h>    /* Higher level C API */
-#include <lualib.h>     /* Lua libs */
-
 #include "../vlc.h"
 #include "../libs.h"
 
diff --git a/modules/lua/libs/misc.c b/modules/lua/libs/misc.c
index f98d28a..5b793bd 100644
--- a/modules/lua/libs/misc.c
+++ b/modules/lua/libs/misc.c
@@ -41,10 +41,6 @@
 #include <vlc_interface.h>
 #include <vlc_keys.h>
 
-#include <lua.h>        /* Low level lua C API */
-#include <lauxlib.h>    /* Higher level C API */
-#include <lualib.h>     /* Lua libs */
-
 #include "../vlc.h"
 #include "../libs.h"
 
diff --git a/modules/lua/libs/net.c b/modules/lua/libs/net.c
index 1c7cd12..0e832cc 100644
--- a/modules/lua/libs/net.c
+++ b/modules/lua/libs/net.c
@@ -41,9 +41,6 @@
 #include <vlc_url.h>
 #include <vlc_fs.h>
 
-#include <lua.h>        /* Low level lua C API */
-#include <lauxlib.h>    /* Higher level C API */
-
 #ifdef HAVE_POLL
 #include <poll.h>       /* poll structures and defines */
 #endif
diff --git a/modules/lua/libs/objects.c b/modules/lua/libs/objects.c
index c3543d6..bcdb43e 100644
--- a/modules/lua/libs/objects.c
+++ b/modules/lua/libs/objects.c
@@ -35,9 +35,6 @@
 #include <vlc_common.h>
 #include <vlc_vout.h>
 
-#include <lua.h>        /* Low level lua C API */
-#include <lauxlib.h>    /* Higher level C API */
-
 #include "../vlc.h"
 #include "../libs.h"
 #include "objects.h"
diff --git a/modules/lua/libs/osd.c b/modules/lua/libs/osd.c
index fb36ed5..e06646b 100644
--- a/modules/lua/libs/osd.c
+++ b/modules/lua/libs/osd.c
@@ -35,9 +35,6 @@
 #include <vlc_vout.h>
 #include <vlc_osd.h>
 
-#include <lua.h>        /* Low level lua C API */
-#include <lauxlib.h>    /* Higher level C API */
-
 #include "../vlc.h"
 #include "../libs.h"
 #include "input.h"
diff --git a/modules/lua/libs/playlist.c b/modules/lua/libs/playlist.c
index ae610f3..4bd8024 100644
--- a/modules/lua/libs/playlist.c
+++ b/modules/lua/libs/playlist.c
@@ -37,9 +37,6 @@
 #include <vlc_interface.h>
 #include <vlc_playlist.h>
 
-#include <lua.h>        /* Low level lua C API */
-#include <lauxlib.h>    /* Higher level C API */
-
 #include "../vlc.h"
 #include "../libs.h"
 #include "playlist.h"
@@ -381,6 +378,7 @@ static const luaL_Reg vlclua_playlist_reg[] = {
     { "loop", vlclua_playlist_loop },
     { "random", vlclua_playlist_random },
     { "goto", vlclua_playlist_goto },
+    { "goto_", vlclua_playlist_goto },
     { "add", vlclua_playlist_add },
     { "enqueue", vlclua_playlist_enqueue },
     { "get", vlclua_playlist_get },
diff --git a/modules/lua/libs/sd.c b/modules/lua/libs/sd.c
index 7ca9476..d88cab2 100644
--- a/modules/lua/libs/sd.c
+++ b/modules/lua/libs/sd.c
@@ -38,10 +38,6 @@
 #include <vlc_playlist.h>
 #include <vlc_charset.h>
 
-#include <lua.h>        /* Low level lua C API */
-#include <lauxlib.h>    /* Higher level C API */
-#include <lualib.h>     /* Lua libs */
-
 #include "../vlc.h"
 #include "../libs.h"
 #include "playlist.h"
diff --git a/modules/lua/libs/stream.c b/modules/lua/libs/stream.c
index ef7187c..6a366f1 100644
--- a/modules/lua/libs/stream.c
+++ b/modules/lua/libs/stream.c
@@ -38,9 +38,6 @@
 #include <vlc_meta.h>
 #include <vlc_aout.h>
 
-#include <lua.h>        /* Low level lua C API */
-#include <lauxlib.h>    /* Higher level C API */
-
 #include "../vlc.h"
 #include "../libs.h"
 
diff --git a/modules/lua/libs/strings.c b/modules/lua/libs/strings.c
index ab8e435..88c5f0e 100644
--- a/modules/lua/libs/strings.c
+++ b/modules/lua/libs/strings.c
@@ -39,9 +39,6 @@
 #include <vlc_aout.h>
 #include <vlc_charset.h>
 
-#include <lua.h>        /* Low level lua C API */
-#include <lauxlib.h>    /* Higher level C API */
-
 #include "../vlc.h"
 #include "../libs.h"
 
diff --git a/modules/lua/libs/variables.c b/modules/lua/libs/variables.c
index f3becae..aad5ae1 100644
--- a/modules/lua/libs/variables.c
+++ b/modules/lua/libs/variables.c
@@ -34,10 +34,6 @@
 
 #include <vlc_common.h>
 
-#include <lua.h>        /* Low level lua C API */
-#include <lauxlib.h>    /* Higher level C API */
-#include <lualib.h>     /* Lua libs */
-
 #include "../vlc.h"
 #include "../libs.h"
 #include "variables.h"
diff --git a/modules/lua/libs/video.c b/modules/lua/libs/video.c
index eb914b5..258e0d2 100644
--- a/modules/lua/libs/video.c
+++ b/modules/lua/libs/video.c
@@ -34,9 +34,6 @@
 
 #include <vlc_vout.h>
 
-#include <lua.h>        /* Low level lua C API */
-#include <lauxlib.h>    /* Higher level C API */
-
 #include "../vlc.h"
 #include "../libs.h"
 #include "input.h"
diff --git a/modules/lua/libs/vlm.c b/modules/lua/libs/vlm.c
index d48755c..7b2b708 100644
--- a/modules/lua/libs/vlm.c
+++ b/modules/lua/libs/vlm.c
@@ -35,9 +35,6 @@
 #include <vlc_common.h>
 #include <vlc_vlm.h>
 
-#include <lua.h>        /* Low level lua C API */
-#include <lauxlib.h>    /* Higher level C API */
-
 #include "../vlc.h"
 #include "../libs.h"
 
diff --git a/modules/lua/libs/volume.c b/modules/lua/libs/volume.c
index 3aab542..bae1534 100644
--- a/modules/lua/libs/volume.c
+++ b/modules/lua/libs/volume.c
@@ -38,10 +38,6 @@
 #include <vlc_meta.h>
 #include <vlc_aout_intf.h>
 
-#include <lua.h>        /* Low level lua C API */
-#include <lauxlib.h>    /* Higher level C API */
-#include <lualib.h>     /* Lua libs */
-
 #include "../vlc.h"
 #include "../libs.h"
 #include "playlist.h"
diff --git a/modules/lua/libs/xml.c b/modules/lua/libs/xml.c
index f8b0afe..80f53fb 100644
--- a/modules/lua/libs/xml.c
+++ b/modules/lua/libs/xml.c
@@ -35,9 +35,6 @@
 #include <vlc_common.h>
 #include <vlc_xml.h>
 
-#include <lua.h>        /* Low level lua C API */
-#include <lauxlib.h>    /* Higher level C API */
-
 #include "../vlc.h"
 #include "../libs.h"
 
diff --git a/modules/lua/vlc.c b/modules/lua/vlc.c
index 5433eb8..a0132cf 100644
--- a/modules/lua/vlc.c
+++ b/modules/lua/vlc.c
@@ -45,10 +45,6 @@
 #include <vlc_stream.h>
 #include <sys/stat.h>
 
-#include <lua.h>        /* Low level lua C API */
-#include <lauxlib.h>    /* Higher level C API */
-#include <lualib.h>     /* Lua libs */
-
 #include "vlc.h"
 
 /*****************************************************************************
diff --git a/modules/lua/vlc.h b/modules/lua/vlc.h
index 5d87914..2b8fbff 100644
--- a/modules/lua/vlc.h
+++ b/modules/lua/vlc.h
@@ -36,9 +36,15 @@
 #include <vlc_strings.h>
 #include <vlc_stream.h>
 
+#define LUA_COMPAT_MODULE
 #include <lua.h>        /* Low level lua C API */
 #include <lauxlib.h>    /* Higher level C API */
 #include <lualib.h>     /* Lua libs */
+#if LUA_VERSION_NUM >= 502
+#define lua_equal(L,idx1,idx2)		lua_compare(L,(idx1),(idx2),LUA_OPEQ)
+#define lua_objlen(L,idx)			lua_rawlen(L,idx)
+#define lua_strlen(L,idx)			lua_rawlen(L,idx)
+#endif
 
 /*****************************************************************************
  * Module entry points
diff --git a/share/lua/extensions/imdb.lua b/share/lua/extensions/imdb.lua
index 829948d..194a219 100644
--- a/share/lua/extensions/imdb.lua
+++ b/share/lua/extensions/imdb.lua
@@ -237,7 +237,7 @@ function parse_resultspage(data)
                 if not link then break end -- this would not be normal behavior...
                 _, pos, thistitle = string.find(table, "<a href=\"" .. link .. "\"[^>]*>([^<]+)</a>", pos)
                 if not thistitle then break end -- this would not be normal behavior...
-                local _, _, year = string.find(table, "\((%d+)\)", pos)
+                local _, _, year = string.find(table, "%((%d+)%)", pos)
                 -- Add this title to the list
                 count = count + 1
                 local _, _, imdbID = string.find(link, "/([^/]+)/$")
diff --git a/share/lua/intf/cli.lua b/share/lua/intf/cli.lua
index 265b938..8a13194 100644
--- a/share/lua/intf/cli.lua
+++ b/share/lua/intf/cli.lua
@@ -535,7 +535,7 @@ commands_ordered = {
     { "stop"; { func = skip2(vlc.playlist.stop); help = "stop stream" } };
     { "next"; { func = skip2(vlc.playlist.next); help = "next playlist item" } };
     { "prev"; { func = skip2(vlc.playlist.prev); help = "previous playlist item" } };
-    { "goto"; { func = skip2(vlc.playlist.goto); help = "goto item at index" } };
+    { "goto"; { func = skip2(vlc.playlist.goto_); help = "goto item at index" } };
     { "repeat"; { func = skip2(vlc.playlist.repeat_); args = "[on|off]"; help = "toggle playlist repeat" } };
     { "loop"; { func = skip2(vlc.playlist.loop); args = "[on|off]"; help = "toggle playlist loop" } };
     { "random"; { func = skip2(vlc.playlist.random); args = "[on|off]"; help = "toggle playlist random" } };
diff --git a/share/lua/intf/modules/httprequests.lua b/share/lua/intf/modules/httprequests.lua
index 407ab3e..b90ea5a 100644
--- a/share/lua/intf/modules/httprequests.lua
+++ b/share/lua/intf/modules/httprequests.lua
@@ -93,14 +93,14 @@ processcommands = function ()
       if id == -1 then
         vlc.playlist.play()
       else
-        vlc.playlist.goto(id)
+        vlc.playlist.goto_(id)
       end
     elseif command == "pl_pause" then
       if vlc.playlist.status() == "stopped" then
         if id == -1 then
           vlc.playlist.play()
         else
-          vlc.playlist.goto(id)
+          vlc.playlist.goto_(id)
         end
       else
         vlc.playlist.pause()
diff --git a/share/lua/playlist/appletrailers.lua b/share/lua/playlist/appletrailers.lua
index 8bd4bea..4d0f5e7 100644
--- a/share/lua/playlist/appletrailers.lua
+++ b/share/lua/playlist/appletrailers.lua
@@ -67,7 +67,7 @@ function parse()
             description = find( line, "h%d.->(.-)</h%d") .. ' '
         end
         if string.match( line, 'img src=') then
-            for img in string.gmatch(line, '<img src="(http://.*\.jpg)" ') do
+            for img in string.gmatch(line, '<img src="(http://.*%.jpg)" ') do
                 art_url = img
             end
             for i,value in pairs(playlist) do
@@ -76,8 +76,8 @@ function parse()
                 else break end
             end
         end
-        if string.match( line, "class=\"hd\".-\.mov") then
-            for urlline,resolution in string.gmatch(line, "class=\"hd\".-href=\"(.-.mov)\".-(%d+.-p)") do
+        if string.match( line, 'class="hd".-%.mov') then
+            for urlline,resolution in string.gmatch(line, 'class="hd".-href="(.-%.mov)".-(%d+.-p)') do
                 urlline = string.gsub( urlline, "_"..resolution, "_h"..resolution )
                 table.insert( playlist, { path = urlline,
                                           name = description ..  '(' .. resolution .. ')',
diff --git a/share/lua/playlist/extreme.lua b/share/lua/playlist/extreme.lua
index 6fd7251..a71564b 100644
--- a/share/lua/playlist/extreme.lua
+++ b/share/lua/playlist/extreme.lua
@@ -41,7 +41,7 @@ end
 
 -- Parse function.
 function parse()
-    if (string.match( vlc.path, "extreme\.com/." ) or string.match( vlc.path, "freecaster\.tv/." )) and not string.match( vlc.path, "player.extreme.com/info/") then
+    if (string.match( vlc.path, "extreme.com/." ) or string.match( vlc.path, "freecaster.tv/." )) and not string.match( vlc.path, "player.extreme.com/info/") then
         while true do
             line = vlc.readline()
             if not line then break end
diff --git a/share/lua/playlist/katsomo.lua b/share/lua/playlist/katsomo.lua
index bf461c7..85c3c41 100644
--- a/share/lua/playlist/katsomo.lua
+++ b/share/lua/playlist/katsomo.lua
@@ -57,7 +57,7 @@ function parse()
         then
             arturl = "http://www.katsomo.fi"..find( line, " src=\"(.-)\" alt=" )
         end
-        for treeid,name in string.gmatch( line, "/\?treeId=(%d+)\">([^<]+)</a") do
+        for treeid,name in string.gmatch( line, '/?treeId=(%d+)">([^<]+)</a') do
             name = vlc.strings.resolve_xml_special_chars( name )
             name = vlc.strings.from_charset( "ISO_8859-1", name )
             path = "http://www.katsomo.fi/?treeId="..treeid
diff --git a/share/lua/playlist/mpora.lua b/share/lua/playlist/mpora.lua
index cfee5d0..81ffbcd 100644
--- a/share/lua/playlist/mpora.lua
+++ b/share/lua/playlist/mpora.lua
@@ -40,7 +40,7 @@ function parse()
             _,_,arturl = string.find( line, "image_src\" href=\"(.*)\" />" )
         end
         if string.match( line, "video_src" ) then
-            _,_,video = string.find( line, "href=\"http://video\.mpora\.com/ep/(.*).swf\" />" )
+            _,_,video = string.find( line, 'href="http://video.mpora.com/ep/(.*)%.swf" />' )
         end
 
     end
diff --git a/share/lua/playlist/pinkbike.lua b/share/lua/playlist/pinkbike.lua
index 06105d7..f6787c8 100644
--- a/share/lua/playlist/pinkbike.lua
+++ b/share/lua/playlist/pinkbike.lua
@@ -45,10 +45,10 @@ function parse()
 			end
 			-- Try to find server which has our video
 			if string.match( line, "<link rel=\"videothumbnail\" href=\"http://(.*)/vt/svt-") then
-				_,_,server = string.find (line, "<link rel=\"videothumbnail\"\ href=\"http://(.*)/vt/svt-" )
+				_,_,server = string.find (line, '<link rel="videothumbnail" href="http://(.*)/vt/svt-' )
 			end
 			if string.match( line, "<link rel=\"videothumbnail\" href=\"(.*)\" type=\"image/jpeg\"") then
-				_,_,arturl = string.find (line, "<link rel=\"videothumbnail\" href=\"(.*)\"\ type=\"image/jpeg\"")
+				_,_,arturl = string.find (line, '<link rel="videothumbnail" href="(.*)" type="image/jpeg"')
 			end
 		end
 
-- 
1.7.7




More information about the vlc-devel mailing list