diff options
-rw-r--r-- | lauxlib.c | 83 | ||||
-rw-r--r-- | lauxlib.h | 17 | ||||
-rw-r--r-- | lbaselib.c | 38 | ||||
-rw-r--r-- | linit.c | 5 | ||||
-rw-r--r-- | loadlib.c | 95 | ||||
-rw-r--r-- | lobject.c | 4 | ||||
-rw-r--r-- | ltablib.c | 28 | ||||
-rw-r--r-- | ltests.h | 12 | ||||
-rw-r--r-- | luaconf.h | 80 | ||||
-rw-r--r-- | lualib.h | 5 |
10 files changed, 25 insertions, 342 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lauxlib.c,v 1.292 2018/01/29 19:13:27 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.293 2018/02/21 13:48:44 roberto Exp roberto $ |
3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -846,87 +846,6 @@ LUALIB_API const char *luaL_tolstring (lua_State *L, int idx, size_t *len) { | |||
846 | 846 | ||
847 | 847 | ||
848 | /* | 848 | /* |
849 | ** {====================================================== | ||
850 | ** Compatibility with 5.1 module functions | ||
851 | ** ======================================================= | ||
852 | */ | ||
853 | #if defined(LUA_COMPAT_MODULE) | ||
854 | |||
855 | static const char *luaL_findtable (lua_State *L, int idx, | ||
856 | const char *fname, int szhint) { | ||
857 | const char *e; | ||
858 | if (idx) lua_pushvalue(L, idx); | ||
859 | do { | ||
860 | e = strchr(fname, '.'); | ||
861 | if (e == NULL) e = fname + strlen(fname); | ||
862 | lua_pushlstring(L, fname, e - fname); | ||
863 | if (lua_rawget(L, -2) == LUA_TNIL) { /* no such field? */ | ||
864 | lua_pop(L, 1); /* remove this nil */ | ||
865 | lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */ | ||
866 | lua_pushlstring(L, fname, e - fname); | ||
867 | lua_pushvalue(L, -2); | ||
868 | lua_settable(L, -4); /* set new table into field */ | ||
869 | } | ||
870 | else if (!lua_istable(L, -1)) { /* field has a non-table value? */ | ||
871 | lua_pop(L, 2); /* remove table and value */ | ||
872 | return fname; /* return problematic part of the name */ | ||
873 | } | ||
874 | lua_remove(L, -2); /* remove previous table */ | ||
875 | fname = e + 1; | ||
876 | } while (*e == '.'); | ||
877 | return NULL; | ||
878 | } | ||
879 | |||
880 | |||
881 | /* | ||
882 | ** Count number of elements in a luaL_Reg list. | ||
883 | */ | ||
884 | static int libsize (const luaL_Reg *l) { | ||
885 | int size = 0; | ||
886 | for (; l && l->name; l++) size++; | ||
887 | return size; | ||
888 | } | ||
889 | |||
890 | |||
891 | /* | ||
892 | ** Find or create a module table with a given name. The function | ||
893 | ** first looks at the LOADED table and, if that fails, try a | ||
894 | ** global variable with that name. In any case, leaves on the stack | ||
895 | ** the module table. | ||
896 | */ | ||
897 | LUALIB_API void luaL_pushmodule (lua_State *L, const char *modname, | ||
898 | int sizehint) { | ||
899 | luaL_findtable(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE, 1); | ||
900 | if (lua_getfield(L, -1, modname) != LUA_TTABLE) { /* no LOADED[modname]? */ | ||
901 | lua_pop(L, 1); /* remove previous result */ | ||
902 | /* try global variable (and create one if it does not exist) */ | ||
903 | lua_pushglobaltable(L); | ||
904 | if (luaL_findtable(L, 0, modname, sizehint) != NULL) | ||
905 | luaL_error(L, "name conflict for module '%s'", modname); | ||
906 | lua_pushvalue(L, -1); | ||
907 | lua_setfield(L, -3, modname); /* LOADED[modname] = new table */ | ||
908 | } | ||
909 | lua_remove(L, -2); /* remove LOADED table */ | ||
910 | } | ||
911 | |||
912 | |||
913 | LUALIB_API void luaL_openlib (lua_State *L, const char *libname, | ||
914 | const luaL_Reg *l, int nup) { | ||
915 | luaL_checkversion(L); | ||
916 | if (libname) { | ||
917 | luaL_pushmodule(L, libname, libsize(l)); /* get/create library table */ | ||
918 | lua_insert(L, -(nup + 1)); /* move library table to below upvalues */ | ||
919 | } | ||
920 | if (l) | ||
921 | luaL_setfuncs(L, l, nup); | ||
922 | else | ||
923 | lua_pop(L, nup); /* remove upvalues */ | ||
924 | } | ||
925 | |||
926 | #endif | ||
927 | /* }====================================================== */ | ||
928 | |||
929 | /* | ||
930 | ** set functions from list 'l' into table at top - 'nup'; each | 849 | ** set functions from list 'l' into table at top - 'nup'; each |
931 | ** function gets the 'nup' elements at the top as upvalues. | 850 | ** function gets the 'nup' elements at the top as upvalues. |
932 | ** Returns with only the table at the stack. | 851 | ** Returns with only the table at the stack. |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lauxlib.h,v 1.132 2017/04/24 18:06:12 roberto Exp roberto $ | 2 | ** $Id: lauxlib.h,v 1.133 2017/06/27 18:32:49 roberto Exp roberto $ |
3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -204,21 +204,6 @@ typedef struct luaL_Stream { | |||
204 | 204 | ||
205 | /* }====================================================== */ | 205 | /* }====================================================== */ |
206 | 206 | ||
207 | |||
208 | |||
209 | /* compatibility with old module system */ | ||
210 | #if defined(LUA_COMPAT_MODULE) | ||
211 | |||
212 | LUALIB_API void (luaL_pushmodule) (lua_State *L, const char *modname, | ||
213 | int sizehint); | ||
214 | LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname, | ||
215 | const luaL_Reg *l, int nup); | ||
216 | |||
217 | #define luaL_register(L,n,l) (luaL_openlib(L,(n),(l),0)) | ||
218 | |||
219 | #endif | ||
220 | |||
221 | |||
222 | /* | 207 | /* |
223 | ** {================================================================== | 208 | ** {================================================================== |
224 | ** "Abstraction Layer" for basic report of messages and errors | 209 | ** "Abstraction Layer" for basic report of messages and errors |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbaselib.c,v 1.320 2018/02/25 12:48:16 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.321 2018/02/27 17:48:28 roberto Exp roberto $ |
3 | ** Basic library | 3 | ** Basic library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -253,23 +253,6 @@ static int luaB_type (lua_State *L) { | |||
253 | } | 253 | } |
254 | 254 | ||
255 | 255 | ||
256 | static int pairsmeta (lua_State *L, const char *method, int iszero, | ||
257 | lua_CFunction iter) { | ||
258 | luaL_checkany(L, 1); | ||
259 | if (luaL_getmetafield(L, 1, method) == LUA_TNIL) { /* no metamethod? */ | ||
260 | lua_pushcfunction(L, iter); /* will return generator, */ | ||
261 | lua_pushvalue(L, 1); /* state, */ | ||
262 | if (iszero) lua_pushinteger(L, 0); /* and initial value */ | ||
263 | else lua_pushnil(L); | ||
264 | } | ||
265 | else { | ||
266 | lua_pushvalue(L, 1); /* argument 'self' to metamethod */ | ||
267 | lua_call(L, 1, 3); /* get 3 values from metamethod */ | ||
268 | } | ||
269 | return 3; | ||
270 | } | ||
271 | |||
272 | |||
273 | static int luaB_next (lua_State *L) { | 256 | static int luaB_next (lua_State *L) { |
274 | luaL_checktype(L, 1, LUA_TTABLE); | 257 | luaL_checktype(L, 1, LUA_TTABLE); |
275 | lua_settop(L, 2); /* create a 2nd argument if there isn't one */ | 258 | lua_settop(L, 2); /* create a 2nd argument if there isn't one */ |
@@ -283,7 +266,17 @@ static int luaB_next (lua_State *L) { | |||
283 | 266 | ||
284 | 267 | ||
285 | static int luaB_pairs (lua_State *L) { | 268 | static int luaB_pairs (lua_State *L) { |
286 | return pairsmeta(L, "__pairs", 0, luaB_next); | 269 | luaL_checkany(L, 1); |
270 | if (luaL_getmetafield(L, 1, "__pairs") == LUA_TNIL) { /* no metamethod? */ | ||
271 | lua_pushcfunction(L, luaB_next); /* will return generator, */ | ||
272 | lua_pushvalue(L, 1); /* state, */ | ||
273 | lua_pushnil(L); /* and initial value */ | ||
274 | } | ||
275 | else { | ||
276 | lua_pushvalue(L, 1); /* argument 'self' to metamethod */ | ||
277 | lua_call(L, 1, 3); /* get 3 values from metamethod */ | ||
278 | } | ||
279 | return 3; | ||
287 | } | 280 | } |
288 | 281 | ||
289 | 282 | ||
@@ -302,15 +295,11 @@ static int ipairsaux (lua_State *L) { | |||
302 | ** (The given "table" may not be a table.) | 295 | ** (The given "table" may not be a table.) |
303 | */ | 296 | */ |
304 | static int luaB_ipairs (lua_State *L) { | 297 | static int luaB_ipairs (lua_State *L) { |
305 | #if defined(LUA_COMPAT_IPAIRS) | ||
306 | return pairsmeta(L, "__ipairs", 1, ipairsaux); | ||
307 | #else | ||
308 | luaL_checkany(L, 1); | 298 | luaL_checkany(L, 1); |
309 | lua_pushcfunction(L, ipairsaux); /* iteration function */ | 299 | lua_pushcfunction(L, ipairsaux); /* iteration function */ |
310 | lua_pushvalue(L, 1); /* state */ | 300 | lua_pushvalue(L, 1); /* state */ |
311 | lua_pushinteger(L, 0); /* initial value */ | 301 | lua_pushinteger(L, 0); /* initial value */ |
312 | return 3; | 302 | return 3; |
313 | #endif | ||
314 | } | 303 | } |
315 | 304 | ||
316 | 305 | ||
@@ -506,9 +495,6 @@ static const luaL_Reg base_funcs[] = { | |||
506 | {"ipairs", luaB_ipairs}, | 495 | {"ipairs", luaB_ipairs}, |
507 | {"loadfile", luaB_loadfile}, | 496 | {"loadfile", luaB_loadfile}, |
508 | {"load", luaB_load}, | 497 | {"load", luaB_load}, |
509 | #if defined(LUA_COMPAT_LOADSTRING) | ||
510 | {"loadstring", luaB_load}, | ||
511 | #endif | ||
512 | {"next", luaB_next}, | 498 | {"next", luaB_next}, |
513 | {"pairs", luaB_pairs}, | 499 | {"pairs", luaB_pairs}, |
514 | {"pcall", luaB_pcall}, | 500 | {"pcall", luaB_pcall}, |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: linit.c,v 1.39 2016/12/04 20:17:24 roberto Exp roberto $ | 2 | ** $Id: linit.c,v 1.40 2017/06/27 18:32:49 roberto Exp roberto $ |
3 | ** Initialization of libraries for lua.c and other clients | 3 | ** Initialization of libraries for lua.c and other clients |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -50,9 +50,6 @@ static const luaL_Reg loadedlibs[] = { | |||
50 | {LUA_MATHLIBNAME, luaopen_math}, | 50 | {LUA_MATHLIBNAME, luaopen_math}, |
51 | {LUA_UTF8LIBNAME, luaopen_utf8}, | 51 | {LUA_UTF8LIBNAME, luaopen_utf8}, |
52 | {LUA_DBLIBNAME, luaopen_debug}, | 52 | {LUA_DBLIBNAME, luaopen_debug}, |
53 | #if defined(LUA_COMPAT_BITLIB) | ||
54 | {LUA_BITLIBNAME, luaopen_bit32}, | ||
55 | #endif | ||
56 | {NULL, NULL} | 53 | {NULL, NULL} |
57 | }; | 54 | }; |
58 | 55 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: loadlib.c,v 1.130 2017/01/12 17:14:26 roberto Exp roberto $ | 2 | ** $Id: loadlib.c,v 1.131 2017/12/13 12:51:42 roberto Exp roberto $ |
3 | ** Dynamic library loader for Lua | 3 | ** Dynamic library loader for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | ** | 5 | ** |
@@ -621,96 +621,10 @@ static int ll_require (lua_State *L) { | |||
621 | 621 | ||
622 | 622 | ||
623 | 623 | ||
624 | /* | ||
625 | ** {====================================================== | ||
626 | ** 'module' function | ||
627 | ** ======================================================= | ||
628 | */ | ||
629 | #if defined(LUA_COMPAT_MODULE) | ||
630 | |||
631 | /* | ||
632 | ** changes the environment variable of calling function | ||
633 | */ | ||
634 | static void set_env (lua_State *L) { | ||
635 | lua_Debug ar; | ||
636 | if (lua_getstack(L, 1, &ar) == 0 || | ||
637 | lua_getinfo(L, "f", &ar) == 0 || /* get calling function */ | ||
638 | lua_iscfunction(L, -1)) | ||
639 | luaL_error(L, "'module' not called from a Lua function"); | ||
640 | lua_pushvalue(L, -2); /* copy new environment table to top */ | ||
641 | lua_setupvalue(L, -2, 1); | ||
642 | lua_pop(L, 1); /* remove function */ | ||
643 | } | ||
644 | |||
645 | |||
646 | static void dooptions (lua_State *L, int n) { | ||
647 | int i; | ||
648 | for (i = 2; i <= n; i++) { | ||
649 | if (lua_isfunction(L, i)) { /* avoid 'calling' extra info. */ | ||
650 | lua_pushvalue(L, i); /* get option (a function) */ | ||
651 | lua_pushvalue(L, -2); /* module */ | ||
652 | lua_call(L, 1, 0); | ||
653 | } | ||
654 | } | ||
655 | } | ||
656 | |||
657 | |||
658 | static void modinit (lua_State *L, const char *modname) { | ||
659 | const char *dot; | ||
660 | lua_pushvalue(L, -1); | ||
661 | lua_setfield(L, -2, "_M"); /* module._M = module */ | ||
662 | lua_pushstring(L, modname); | ||
663 | lua_setfield(L, -2, "_NAME"); | ||
664 | dot = strrchr(modname, '.'); /* look for last dot in module name */ | ||
665 | if (dot == NULL) dot = modname; | ||
666 | else dot++; | ||
667 | /* set _PACKAGE as package name (full module name minus last part) */ | ||
668 | lua_pushlstring(L, modname, dot - modname); | ||
669 | lua_setfield(L, -2, "_PACKAGE"); | ||
670 | } | ||
671 | |||
672 | |||
673 | static int ll_module (lua_State *L) { | ||
674 | const char *modname = luaL_checkstring(L, 1); | ||
675 | int lastarg = lua_gettop(L); /* last parameter */ | ||
676 | luaL_pushmodule(L, modname, 1); /* get/create module table */ | ||
677 | /* check whether table already has a _NAME field */ | ||
678 | if (lua_getfield(L, -1, "_NAME") != LUA_TNIL) | ||
679 | lua_pop(L, 1); /* table is an initialized module */ | ||
680 | else { /* no; initialize it */ | ||
681 | lua_pop(L, 1); | ||
682 | modinit(L, modname); | ||
683 | } | ||
684 | lua_pushvalue(L, -1); | ||
685 | set_env(L); | ||
686 | dooptions(L, lastarg); | ||
687 | return 1; | ||
688 | } | ||
689 | |||
690 | |||
691 | static int ll_seeall (lua_State *L) { | ||
692 | luaL_checktype(L, 1, LUA_TTABLE); | ||
693 | if (!lua_getmetatable(L, 1)) { | ||
694 | lua_createtable(L, 0, 1); /* create new metatable */ | ||
695 | lua_pushvalue(L, -1); | ||
696 | lua_setmetatable(L, 1); | ||
697 | } | ||
698 | lua_pushglobaltable(L); | ||
699 | lua_setfield(L, -2, "__index"); /* mt.__index = _G */ | ||
700 | return 0; | ||
701 | } | ||
702 | |||
703 | #endif | ||
704 | /* }====================================================== */ | ||
705 | |||
706 | |||
707 | 624 | ||
708 | static const luaL_Reg pk_funcs[] = { | 625 | static const luaL_Reg pk_funcs[] = { |
709 | {"loadlib", ll_loadlib}, | 626 | {"loadlib", ll_loadlib}, |
710 | {"searchpath", ll_searchpath}, | 627 | {"searchpath", ll_searchpath}, |
711 | #if defined(LUA_COMPAT_MODULE) | ||
712 | {"seeall", ll_seeall}, | ||
713 | #endif | ||
714 | /* placeholders */ | 628 | /* placeholders */ |
715 | {"preload", NULL}, | 629 | {"preload", NULL}, |
716 | {"cpath", NULL}, | 630 | {"cpath", NULL}, |
@@ -722,9 +636,6 @@ static const luaL_Reg pk_funcs[] = { | |||
722 | 636 | ||
723 | 637 | ||
724 | static const luaL_Reg ll_funcs[] = { | 638 | static const luaL_Reg ll_funcs[] = { |
725 | #if defined(LUA_COMPAT_MODULE) | ||
726 | {"module", ll_module}, | ||
727 | #endif | ||
728 | {"require", ll_require}, | 639 | {"require", ll_require}, |
729 | {NULL, NULL} | 640 | {NULL, NULL} |
730 | }; | 641 | }; |
@@ -742,10 +653,6 @@ static void createsearcherstable (lua_State *L) { | |||
742 | lua_pushcclosure(L, searchers[i], 1); | 653 | lua_pushcclosure(L, searchers[i], 1); |
743 | lua_rawseti(L, -2, i+1); | 654 | lua_rawseti(L, -2, i+1); |
744 | } | 655 | } |
745 | #if defined(LUA_COMPAT_LOADERS) | ||
746 | lua_pushvalue(L, -1); /* make a copy of 'searchers' table */ | ||
747 | lua_setfield(L, -3, "loaders"); /* put it in field 'loaders' */ | ||
748 | #endif | ||
749 | lua_setfield(L, -2, "searchers"); /* put it in field 'searchers' */ | 656 | lua_setfield(L, -2, "searchers"); /* put it in field 'searchers' */ |
750 | } | 657 | } |
751 | 658 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lobject.c,v 2.122 2017/12/30 20:46:18 roberto Exp roberto $ | 2 | ** $Id: lobject.c,v 2.123 2018/01/28 15:13:26 roberto Exp roberto $ |
3 | ** Some generic functions over Lua objects | 3 | ** Some generic functions over Lua objects |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -382,12 +382,10 @@ void luaO_tostring (lua_State *L, TValue *obj) { | |||
382 | len = lua_integer2str(buff, sizeof(buff), ivalue(obj)); | 382 | len = lua_integer2str(buff, sizeof(buff), ivalue(obj)); |
383 | else { | 383 | else { |
384 | len = lua_number2str(buff, sizeof(buff), fltvalue(obj)); | 384 | len = lua_number2str(buff, sizeof(buff), fltvalue(obj)); |
385 | #if !defined(LUA_COMPAT_FLOATSTRING) | ||
386 | if (buff[strspn(buff, "-0123456789")] == '\0') { /* looks like an int? */ | 385 | if (buff[strspn(buff, "-0123456789")] == '\0') { /* looks like an int? */ |
387 | buff[len++] = lua_getlocaledecpoint(); | 386 | buff[len++] = lua_getlocaledecpoint(); |
388 | buff[len++] = '0'; /* adds '.0' to result */ | 387 | buff[len++] = '0'; /* adds '.0' to result */ |
389 | } | 388 | } |
390 | #endif | ||
391 | } | 389 | } |
392 | setsvalue(L, obj, luaS_newlstr(L, buff, len)); | 390 | setsvalue(L, obj, luaS_newlstr(L, buff, len)); |
393 | } | 391 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltablib.c,v 1.93 2016/02/25 19:41:54 roberto Exp roberto $ | 2 | ** $Id: ltablib.c,v 1.94 2018/02/25 12:48:16 roberto Exp roberto $ |
3 | ** Library for Table Manipulation | 3 | ** Library for Table Manipulation |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -58,24 +58,6 @@ static void checktab (lua_State *L, int arg, int what) { | |||
58 | } | 58 | } |
59 | 59 | ||
60 | 60 | ||
61 | #if defined(LUA_COMPAT_MAXN) | ||
62 | static int maxn (lua_State *L) { | ||
63 | lua_Number max = 0; | ||
64 | luaL_checktype(L, 1, LUA_TTABLE); | ||
65 | lua_pushnil(L); /* first key */ | ||
66 | while (lua_next(L, 1)) { | ||
67 | lua_pop(L, 1); /* remove value */ | ||
68 | if (lua_type(L, -1) == LUA_TNUMBER) { | ||
69 | lua_Number v = lua_tonumber(L, -1); | ||
70 | if (v > max) max = v; | ||
71 | } | ||
72 | } | ||
73 | lua_pushnumber(L, max); | ||
74 | return 1; | ||
75 | } | ||
76 | #endif | ||
77 | |||
78 | |||
79 | static int tinsert (lua_State *L) { | 61 | static int tinsert (lua_State *L) { |
80 | lua_Integer e = aux_getn(L, 1, TAB_RW) + 1; /* first empty element */ | 62 | lua_Integer e = aux_getn(L, 1, TAB_RW) + 1; /* first empty element */ |
81 | lua_Integer pos; /* where to insert new element */ | 63 | lua_Integer pos; /* where to insert new element */ |
@@ -425,9 +407,6 @@ static int sort (lua_State *L) { | |||
425 | 407 | ||
426 | static const luaL_Reg tab_funcs[] = { | 408 | static const luaL_Reg tab_funcs[] = { |
427 | {"concat", tconcat}, | 409 | {"concat", tconcat}, |
428 | #if defined(LUA_COMPAT_MAXN) | ||
429 | {"maxn", maxn}, | ||
430 | #endif | ||
431 | {"insert", tinsert}, | 410 | {"insert", tinsert}, |
432 | {"pack", pack}, | 411 | {"pack", pack}, |
433 | {"unpack", unpack}, | 412 | {"unpack", unpack}, |
@@ -440,11 +419,6 @@ static const luaL_Reg tab_funcs[] = { | |||
440 | 419 | ||
441 | LUAMOD_API int luaopen_table (lua_State *L) { | 420 | LUAMOD_API int luaopen_table (lua_State *L) { |
442 | luaL_newlib(L, tab_funcs); | 421 | luaL_newlib(L, tab_funcs); |
443 | #if defined(LUA_COMPAT_UNPACK) | ||
444 | /* _G.unpack = table.unpack */ | ||
445 | lua_getfield(L, -1, "unpack"); | ||
446 | lua_setglobal(L, "unpack"); | ||
447 | #endif | ||
448 | return 1; | 422 | return 1; |
449 | } | 423 | } |
450 | 424 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.h,v 2.54 2017/12/07 18:51:39 roberto Exp roberto $ | 2 | ** $Id: ltests.h,v 2.55 2017/12/18 13:01:49 roberto Exp roberto $ |
3 | ** Internal Header for Debugging of the Lua Implementation | 3 | ** Internal Header for Debugging of the Lua Implementation |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -13,16 +13,6 @@ | |||
13 | 13 | ||
14 | /* test Lua with compatibility code */ | 14 | /* test Lua with compatibility code */ |
15 | #define LUA_COMPAT_MATHLIB | 15 | #define LUA_COMPAT_MATHLIB |
16 | #define LUA_COMPAT_IPAIRS | ||
17 | #define LUA_COMPAT_BITLIB | ||
18 | #define LUA_COMPAT_APIINTCASTS | ||
19 | #define LUA_COMPAT_FLOATSTRING | ||
20 | #define LUA_COMPAT_UNPACK | ||
21 | #define LUA_COMPAT_LOADERS | ||
22 | #define LUA_COMPAT_LOG10 | ||
23 | #define LUA_COMPAT_LOADSTRING | ||
24 | #define LUA_COMPAT_MAXN | ||
25 | #define LUA_COMPAT_MODULE | ||
26 | 16 | ||
27 | 17 | ||
28 | #define LUA_DEBUG | 18 | #define LUA_DEBUG |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: luaconf.h,v 1.263 2017/12/30 20:46:18 roberto Exp roberto $ | 2 | ** $Id: luaconf.h,v 1.264 2018/02/20 20:52:50 roberto Exp roberto $ |
3 | ** Configuration file for Lua | 3 | ** Configuration file for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -295,30 +295,21 @@ | |||
295 | */ | 295 | */ |
296 | 296 | ||
297 | /* | 297 | /* |
298 | @@ LUA_COMPAT_5_2 controls other macros for compatibility with Lua 5.2. | 298 | @@ LUA_COMPAT_5_3 controls other macros for compatibility with Lua 5.2. |
299 | @@ LUA_COMPAT_5_1 controls other macros for compatibility with Lua 5.1. | ||
300 | ** You can define it to get all options, or change specific options | 299 | ** You can define it to get all options, or change specific options |
301 | ** to fit your specific needs. | 300 | ** to fit your specific needs. |
302 | */ | 301 | */ |
303 | #if defined(LUA_COMPAT_5_2) /* { */ | 302 | #if defined(LUA_COMPAT_5_3) /* { */ |
304 | 303 | ||
305 | /* | 304 | /* |
306 | @@ LUA_COMPAT_MATHLIB controls the presence of several deprecated | 305 | @@ LUA_COMPAT_MATHLIB controls the presence of several deprecated |
307 | ** functions in the mathematical library. | 306 | ** functions in the mathematical library. |
307 | ** (These functions were already officially removed in 5.3, but | ||
308 | ** nevertheless they are available by default there.) | ||
308 | */ | 309 | */ |
309 | #define LUA_COMPAT_MATHLIB | 310 | #define LUA_COMPAT_MATHLIB |
310 | 311 | ||
311 | /* | 312 | /* |
312 | @@ LUA_COMPAT_BITLIB controls the presence of library 'bit32'. | ||
313 | */ | ||
314 | #define LUA_COMPAT_BITLIB | ||
315 | |||
316 | /* | ||
317 | @@ LUA_COMPAT_IPAIRS controls the effectiveness of the __ipairs metamethod. | ||
318 | */ | ||
319 | #define LUA_COMPAT_IPAIRS | ||
320 | |||
321 | /* | ||
322 | @@ LUA_COMPAT_APIINTCASTS controls the presence of macros for | 313 | @@ LUA_COMPAT_APIINTCASTS controls the presence of macros for |
323 | ** manipulating other integer types (lua_pushunsigned, lua_tounsigned, | 314 | ** manipulating other integer types (lua_pushunsigned, lua_tounsigned, |
324 | ** luaL_checkint, luaL_checklong, etc.) | 315 | ** luaL_checkint, luaL_checklong, etc.) |
@@ -328,50 +319,6 @@ | |||
328 | #endif /* } */ | 319 | #endif /* } */ |
329 | 320 | ||
330 | 321 | ||
331 | #if defined(LUA_COMPAT_5_1) /* { */ | ||
332 | |||
333 | /* Incompatibilities from 5.2 -> 5.3 */ | ||
334 | #define LUA_COMPAT_MATHLIB | ||
335 | #define LUA_COMPAT_APIINTCASTS | ||
336 | |||
337 | /* | ||
338 | @@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'. | ||
339 | ** You can replace it with 'table.unpack'. | ||
340 | */ | ||
341 | #define LUA_COMPAT_UNPACK | ||
342 | |||
343 | /* | ||
344 | @@ LUA_COMPAT_LOADERS controls the presence of table 'package.loaders'. | ||
345 | ** You can replace it with 'package.searchers'. | ||
346 | */ | ||
347 | #define LUA_COMPAT_LOADERS | ||
348 | |||
349 | /* | ||
350 | @@ macro 'lua_cpcall' emulates deprecated function lua_cpcall. | ||
351 | ** You can call your C function directly (with light C functions). | ||
352 | */ | ||
353 | #define lua_cpcall(L,f,u) \ | ||
354 | (lua_pushcfunction(L, (f)), \ | ||
355 | lua_pushlightuserdata(L,(u)), \ | ||
356 | lua_pcall(L,1,0,0)) | ||
357 | |||
358 | |||
359 | /* | ||
360 | @@ LUA_COMPAT_LOG10 defines the function 'log10' in the math library. | ||
361 | ** You can rewrite 'log10(x)' as 'log(x, 10)'. | ||
362 | */ | ||
363 | #define LUA_COMPAT_LOG10 | ||
364 | |||
365 | /* | ||
366 | @@ LUA_COMPAT_LOADSTRING defines the function 'loadstring' in the base | ||
367 | ** library. You can rewrite 'loadstring(s)' as 'load(s)'. | ||
368 | */ | ||
369 | #define LUA_COMPAT_LOADSTRING | ||
370 | |||
371 | /* | ||
372 | @@ LUA_COMPAT_MAXN defines the function 'maxn' in the table library. | ||
373 | */ | ||
374 | #define LUA_COMPAT_MAXN | ||
375 | 322 | ||
376 | /* | 323 | /* |
377 | @@ The following macros supply trivial compatibility for some | 324 | @@ The following macros supply trivial compatibility for some |
@@ -385,23 +332,6 @@ | |||
385 | #define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ) | 332 | #define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ) |
386 | #define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT) | 333 | #define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT) |
387 | 334 | ||
388 | /* | ||
389 | @@ LUA_COMPAT_MODULE controls compatibility with previous | ||
390 | ** module functions 'module' (Lua) and 'luaL_register' (C). | ||
391 | */ | ||
392 | #define LUA_COMPAT_MODULE | ||
393 | |||
394 | #endif /* } */ | ||
395 | |||
396 | |||
397 | /* | ||
398 | @@ LUA_COMPAT_FLOATSTRING makes Lua format integral floats without a | ||
399 | @@ a float mark ('.0'). | ||
400 | ** This macro is not on by default even in compatibility mode, | ||
401 | ** because this is not really an incompatibility. | ||
402 | */ | ||
403 | /* #define LUA_COMPAT_FLOATSTRING */ | ||
404 | |||
405 | /* }================================================================== */ | 335 | /* }================================================================== */ |
406 | 336 | ||
407 | 337 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lualib.h,v 1.44 2014/02/06 17:32:33 roberto Exp roberto $ | 2 | ** $Id: lualib.h,v 1.45 2017/01/12 17:14:26 roberto Exp roberto $ |
3 | ** Lua standard libraries | 3 | ** Lua standard libraries |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -35,9 +35,6 @@ LUAMOD_API int (luaopen_string) (lua_State *L); | |||
35 | #define LUA_UTF8LIBNAME "utf8" | 35 | #define LUA_UTF8LIBNAME "utf8" |
36 | LUAMOD_API int (luaopen_utf8) (lua_State *L); | 36 | LUAMOD_API int (luaopen_utf8) (lua_State *L); |
37 | 37 | ||
38 | #define LUA_BITLIBNAME "bit32" | ||
39 | LUAMOD_API int (luaopen_bit32) (lua_State *L); | ||
40 | |||
41 | #define LUA_MATHLIBNAME "math" | 38 | #define LUA_MATHLIBNAME "math" |
42 | LUAMOD_API int (luaopen_math) (lua_State *L); | 39 | LUAMOD_API int (luaopen_math) (lua_State *L); |
43 | 40 | ||