Skip to content

Commit

Permalink
Update ltablib.c
Browse files Browse the repository at this point in the history
Added import for lua standard libraries:

base (tostring(), `tonumber(), etc.)
math
table (insert(), sort(), remove(), ...)
string (len(), match(), ...)
Replaced print() function with the original version modified with Serial
  • Loading branch information
sfranzyshen committed Nov 2, 2019
1 parent d4b7988 commit 6406afc
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/lua/ltablib.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,14 @@ typedef unsigned int IdxT;
** is to copy them to an array of a known type and use the array values.
*/
static unsigned int l_randomizePivot (void) {
clock_t c = clock();
// clock_t c = clock();
time_t t = time(NULL);
unsigned int buff[sof(c) + sof(t)];
// unsigned int buff[sof(c) + sof(t)];
unsigned int buff[sof(t)];
unsigned int i, rnd = 0;
memcpy(buff, &c, sof(c) * sizeof(unsigned int));
memcpy(buff + sof(c), &t, sof(t) * sizeof(unsigned int));
// memcpy(buff, &c, sof(c) * sizeof(unsigned int));
// memcpy(buff + sof(c), &t, sof(t) * sizeof(unsigned int));
memcpy(buff, &t, sof(t) * sizeof(unsigned int));
for (i = 0; i < sof(buff); i++)
rnd += buff[i];
return rnd;
Expand Down Expand Up @@ -440,6 +442,7 @@ static const luaL_Reg tab_funcs[] = {

LUAMOD_API int luaopen_table (lua_State *L) {
luaL_newlib(L, tab_funcs);
lua_setglobal(L, "table");
#if defined(LUA_COMPAT_UNPACK)
/* _G.unpack = table.unpack */
lua_getfield(L, -1, "unpack");
Expand Down

0 comments on commit 6406afc

Please sign in to comment.