[vlc-commits] fix vlclua_var_toggle_or_set

Rafaël Carré git at videolan.org
Tue Oct 25 01:13:38 CEST 2011


vlc/vlc-1.1 | branch: master | Rafaël Carré <rafael.carre at gmail.com> | Fri Jul 15 21:41:49 2011 -0400| [73af767572dfeff67345589ec07f848134c20fee] | committer: Pierre Ynard

fix vlclua_var_toggle_or_set

argument is a string ("on" or "off") not a bool
(cherry picked from commit e292947855ae11068c34a1e27dbf919e3abc85c6)

Signed-off-by: Pierre Ynard <linkfanel at yahoo.fr>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.1.git/?a=commit;h=73af767572dfeff67345589ec07f848134c20fee
---

 modules/misc/lua/libs/variables.c |   24 +++++++++++++++++++-----
 1 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/modules/misc/lua/libs/variables.c b/modules/misc/lua/libs/variables.c
index e2aac27..9254ec8 100644
--- a/modules/misc/lua/libs/variables.c
+++ b/modules/misc/lua/libs/variables.c
@@ -256,15 +256,29 @@ int __vlclua_var_toggle_or_set( lua_State *L, vlc_object_t *p_obj,
     if( lua_gettop( L ) > 1 ) return vlclua_error( L );
 
     if( lua_gettop( L ) == 0 )
+    {
         b_bool = var_ToggleBool( p_obj, psz_name );
-    else /* lua_gettop( L ) == 1 */
+        goto end;
+    }
+
+    /* lua_gettop( L ) == 1 */
+    const char *s = luaL_checkstring( L, -1 );
+    lua_pop( L, 1 );
+
+    if( s && !strcmp(s, "on") )
+        b_bool = true;
+    else if( s && !strcmp(s, "off") )
+        b_bool = false;
+    else
     {
-        b_bool = luaL_checkboolean( L, -1 );
-        lua_pop( L, 1 );
-        if( b_bool != var_GetBool( p_obj, psz_name ) )
-            var_SetBool( p_obj, psz_name, b_bool );
+        b_bool = var_GetBool( p_obj, psz_name );
+        goto end;
     }
 
+    if( b_bool != var_GetBool( p_obj, psz_name ) )
+        var_SetBool( p_obj, psz_name, b_bool );
+
+end:
     lua_pushboolean( L, b_bool );
     return 1;
 }



More information about the vlc-commits mailing list