[vlc-devel] [vlc-commits] lua: use vlc_strerror_c()
Steve Lhomme
robux4 at ycbcr.xyz
Mon May 20 08:44:42 CEST 2019
On 2019-05-19 19:20, Rémi Denis-Courmont wrote:
> 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;
This is not equivalent to ENOENT.
> + case VLC_ENOOBJ: err = ENOENT; break;
This is not equivalent to ENOENT.
> + case VLC_ENOVAR: err = ENOENT; break;
This is not equivalent to ENOENT.
> + 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;
> }
>
>
> _______________________________________________
> vlc-commits mailing list
> vlc-commits at videolan.org
> https://mailman.videolan.org/listinfo/vlc-commits
>
More information about the vlc-devel
mailing list