27
27
28
28
# define LUA_OK 0
29
29
# define lua_rawlen lua_objlen
30
- # define luaL_newlib (L ,l ) (lua_newtable(L), luaL_register(L,NULL,l))
31
30
# define luaL_setfuncs (L ,l ,n ) (assert(n==0), luaL_register(L,NULL,l))
32
31
# define luaL_setmetatable (L , name ) \
33
32
(luaL_getmetatable((L), (name)), lua_setmetatable(L, -2))
@@ -49,12 +48,22 @@ void lua_rawsetp(lua_State *L, int idx, const void *p) {
49
48
lua_rawset (L , relindex (idx , 1 ));
50
49
}
51
50
51
+ #ifndef luaL_newlib /* not LuaJIT 2.1 */
52
+ #define luaL_newlib (L ,l ) (lua_newtable(L), luaL_register(L,NULL,l))
53
+
52
54
static lua_Integer lua_tointegerx (lua_State * L , int idx , int * isint ) {
53
55
lua_Integer i = lua_tointeger (L , idx );
54
56
if (isint ) * isint = (i != 0 || lua_type (L , idx ) == LUA_TNUMBER );
55
57
return i ;
56
58
}
57
59
60
+ static lua_Number lua_tonumberx (lua_State * L , int idx , int * isnum ) {
61
+ lua_Number i = lua_tonumber (L , idx );
62
+ if (isnum ) * isnum = (i != 0 || lua_type (L , idx ) == LUA_TNUMBER );
63
+ return i ;
64
+ }
65
+ #endif
66
+
58
67
#ifdef LUAI_BITSINT /* not LuaJIT */
59
68
#include <errno.h>
60
69
static int luaL_fileresult (lua_State * L , int stat , const char * fname ) {
@@ -834,7 +843,7 @@ static int Lslice_enter(lua_State *L) {
834
843
pb_SliceExt view ;
835
844
if (lua_isnoneornil (L , 2 )) {
836
845
if (pb_readbytes (& s -> curr .base , & view .base ) == 0 )
837
- argerror (L , 1 , "bytes wireformat expected at offset %d" ,
846
+ return argerror (L , 1 , "bytes wireformat expected at offset %d" ,
838
847
lpb_offset (& s -> curr ));
839
848
view .head = view .base .p ;
840
849
lpb_enterview (L , s , view );
@@ -1412,7 +1421,7 @@ LUALIB_API int luaopen_pb(lua_State *L) {
1412
1421
return 1 ;
1413
1422
}
1414
1423
1415
- /* cc: flags+='-ggdb -pedantic -std=c90 -Wall -Wextra --coverage'
1424
+ /* cc: flags+='-O3 - ggdb -pedantic -std=c90 -Wall -Wextra --coverage'
1416
1425
* maccc: flags+='-shared -undefined dynamic_lookup' output='pb.so'
1417
1426
* win32cc: flags+='-mdll -DLUA_BUILD_AS_DLL ' output='pb.dll' libs+='-llua53' */
1418
1427
0 commit comments