[vlc-commits] lua: use vlc_strerror_c()

Rémi Denis-Courmont git at videolan.org
Sun May 19 19:20:11 CEST 2019


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun May 19 20:13:33 2019 +0300| [161832532aa60c2f06798f79c1898680f39a2c1d] | committer: Rémi Denis-Courmont

lua: use vlc_strerror_c()

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

 modules/lua/libs/misc.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/modules/lua/libs/misc.c b/modules/lua/libs/misc.c
index b251eb7f22..25f44c3047 100644
--- a/modules/lua/libs/misc.c
+++ b/modules/lua/libs/misc.c
@@ -33,6 +33,7 @@
 # include "config.h"
 #endif
 
+#include <errno.h>
 #include <math.h>
 #include <stdlib.h>
 
@@ -84,7 +85,27 @@ vlc_object_t * vlclua_get_this( lua_State *L )
 int vlclua_push_ret( lua_State *L, int i_error )
 {
     lua_pushnumber( L, i_error );
-    lua_pushstring( L, vlc_error_string( i_error ) );
+
+    int err;
+
+    switch( i_error )
+    {
+        case VLC_SUCCESS:   err = 0;         break;
+        case VLC_ENOMEM:    err = ENOMEM;    break;
+        case VLC_ETIMEOUT:  err = ETIMEDOUT; break;
+        case VLC_EBADVAR:   err = EINVAL;    break;
+        case VLC_ENOMOD:    err = ENOENT;    break;
+        case VLC_ENOOBJ:    err = ENOENT;    break;
+        case VLC_ENOVAR:    err = ENOENT;    break;
+        case VLC_EGENERIC:
+            lua_pushstring( L, "generic error" );
+            return 2;
+        default:
+            lua_pushstring( L, "unknown error" );
+            return 2;
+    }
+
+    lua_pushstring( L, vlc_strerror_c(err) );
     return 2;
 }
 



More information about the vlc-commits mailing list