[vlc-commits] lua: move url_parse() from net to strings (fixes #3447)

Rémi Denis-Courmont git at videolan.org
Wed Nov 16 16:29:48 CET 2016


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Nov 16 17:28:24 2016 +0200| [4aa188cac86e89ecaa589f8f28ce31281103b45f] | committer: Rémi Denis-Courmont

lua: move url_parse() from net to strings (fixes #3447)

Leave an alias in url_parse() for compatiblity for the time being.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4aa188cac86e89ecaa589f8f28ce31281103b45f
---

 modules/lua/libs.h         |  2 ++
 modules/lua/libs/net.c     | 33 +--------------------------------
 modules/lua/libs/strings.c | 29 +++++++++++++++++++++++++++++
 3 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/modules/lua/libs.h b/modules/lua/libs.h
index 861cba9..c553bbf 100644
--- a/modules/lua/libs.h
+++ b/modules/lua/libs.h
@@ -49,4 +49,6 @@ void luaopen_equalizer( lua_State *L );
 void luaopen_win( lua_State *L );
 #endif
 
+int vlclua_url_parse( lua_State *L );
+
 #endif
diff --git a/modules/lua/libs/net.c b/modules/lua/libs/net.c
index 147061a..5162096 100644
--- a/modules/lua/libs/net.c
+++ b/modules/lua/libs/net.c
@@ -163,37 +163,6 @@ static void vlclua_fd_unmap_safe( lua_State *L, unsigned idx )
 }
 
 /*****************************************************************************
- *
- *****************************************************************************/
-static int vlclua_url_parse( lua_State *L )
-{
-    const char *psz_url = luaL_checkstring( L, 1 );
-    vlc_url_t url;
-
-    vlc_UrlParse( &url, psz_url );
-
-    lua_newtable( L );
-    lua_pushstring( L, url.psz_protocol );
-    lua_setfield( L, -2, "protocol" );
-    lua_pushstring( L, url.psz_username );
-    lua_setfield( L, -2, "username" );
-    lua_pushstring( L, url.psz_password );
-    lua_setfield( L, -2, "password" );
-    lua_pushstring( L, url.psz_host );
-    lua_setfield( L, -2, "host" );
-    lua_pushinteger( L, url.i_port );
-    lua_setfield( L, -2, "port" );
-    lua_pushstring( L, url.psz_path );
-    lua_setfield( L, -2, "path" );
-    lua_pushstring( L, url.psz_option );
-    lua_setfield( L, -2, "option" );
-
-    vlc_UrlClean( &url );
-
-    return 1;
-}
-
-/*****************************************************************************
  * Net listen
  *****************************************************************************/
 static int vlclua_net_listen_close( lua_State * );
@@ -508,7 +477,7 @@ static const luaL_Reg vlclua_net_intf_reg[] = {
 #endif
     /* The following functions do not depend on intf_thread_t and do not really
      * belong in net.* but are left here for backward compatibility: */
-    { "url_parse", vlclua_url_parse },
+    { "url_parse", vlclua_url_parse /* deprecated since 3.0.0 */ },
     { "stat", vlclua_stat }, /* Not really "net" */
     { "opendir", vlclua_opendir }, /* Not really "net" */
     { NULL, NULL }
diff --git a/modules/lua/libs/strings.c b/modules/lua/libs/strings.c
index 8ae557e..66fb754 100644
--- a/modules/lua/libs/strings.c
+++ b/modules/lua/libs/strings.c
@@ -100,6 +100,34 @@ static int vlclua_make_path( lua_State *L )
     return 1;
 }
 
+int vlclua_url_parse( lua_State *L )
+{
+    const char *psz_url = luaL_checkstring( L, 1 );
+    vlc_url_t url;
+
+    vlc_UrlParse( &url, psz_url );
+
+    lua_newtable( L );
+    lua_pushstring( L, url.psz_protocol );
+    lua_setfield( L, -2, "protocol" );
+    lua_pushstring( L, url.psz_username );
+    lua_setfield( L, -2, "username" );
+    lua_pushstring( L, url.psz_password );
+    lua_setfield( L, -2, "password" );
+    lua_pushstring( L, url.psz_host );
+    lua_setfield( L, -2, "host" );
+    lua_pushinteger( L, url.i_port );
+    lua_setfield( L, -2, "port" );
+    lua_pushstring( L, url.psz_path );
+    lua_setfield( L, -2, "path" );
+    lua_pushstring( L, url.psz_option );
+    lua_setfield( L, -2, "option" );
+
+    vlc_UrlClean( &url );
+
+    return 1;
+}
+
 static int vlclua_resolve_xml_special_chars( lua_State *L )
 {
     int i_top = lua_gettop( L );
@@ -155,6 +183,7 @@ static const luaL_Reg vlclua_strings_reg[] = {
     { "encode_uri_component", vlclua_encode_uri_component },
     { "make_uri", vlclua_make_uri },
     { "make_path", vlclua_make_path },
+    { "url_parse", vlclua_url_parse },
     { "resolve_xml_special_chars", vlclua_resolve_xml_special_chars },
     { "convert_xml_special_chars", vlclua_convert_xml_special_chars },
     { "from_charset", vlclua_from_charset },



More information about the vlc-commits mailing list