As the "descriptor" function is called with absolutely no libraries
loaded, even the built-in "require" function is not present at scan
time.
This closes #3453.
Note: this is a bit of a hack, but I prefer not to load any libs when
scanning the available extensions
Remove some useless debug, too
+/**
+ * Dummy Lua function: does nothing
+ * @note This function can be used to replace "require" while scanning for
+ * extensions
+ * Even the built-in libraries are not loaded when calling descriptor()
+ **/
+static int vlclua_dummy_require( lua_State *L )
+{
+ (void) L;
+ return 0;
+}
+
/**
* Batch scan all Lua files in folder "extensions": callback
* @param p_this This extensions_manager_t object
/**
* Batch scan all Lua files in folder "extensions": callback
* @param p_this This extensions_manager_t object
vlc_mutex_init( &p_ext->p_sys->running_lock );
vlc_cond_init( &p_ext->p_sys->wait );
vlc_mutex_init( &p_ext->p_sys->running_lock );
vlc_cond_init( &p_ext->p_sys->wait );
- /* Load and run the script(s) */
+ /* Prepare Lua state */
lua_State *L = luaL_newstate();
lua_State *L = luaL_newstate();
+ lua_register( L, "require", &vlclua_dummy_require );
+
+ /* Let's run it */
if( luaL_dofile( L, psz_script ) )
{
msg_Warn( p_mgr, "Error loading script %s: %s", psz_script,
if( luaL_dofile( L, psz_script ) )
{
msg_Warn( p_mgr, "Error loading script %s: %s", psz_script,
-#ifndef NDEBUG
- else
- {
- msg_Dbg( p_mgr, "Reusing old Lua state for extension '%s'",
- p_ext->psz_name );
- }
-#endif