diff options
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/lua/lauxlib.c | 37 | ||||
-rw-r--r-- | apps/plugins/lua/loadlib.c | 4 | ||||
-rw-r--r-- | apps/plugins/lua/lparser.c | 5 | ||||
-rw-r--r-- | apps/plugins/lua/rockaux.c | 34 |
4 files changed, 51 insertions, 29 deletions
diff --git a/apps/plugins/lua/lauxlib.c b/apps/plugins/lua/lauxlib.c index acd7e0e636..b8332427f0 100644 --- a/apps/plugins/lua/lauxlib.c +++ b/apps/plugins/lua/lauxlib.c | |||
@@ -268,7 +268,8 @@ static int latebind_func_index(lua_State *L) | |||
268 | const char *name = lua_tostring(L, -1); | 268 | const char *name = lua_tostring(L, -1); |
269 | 269 | ||
270 | lua_pushstring (L, "__latebind");/* basetable;name;__latebind;*/ | 270 | lua_pushstring (L, "__latebind");/* basetable;name;__latebind;*/ |
271 | lua_rawget (L, -3);/* basetable;name;__latebind(t);*/ | 271 | if(lua_istable(L, -3)) |
272 | lua_rawget (L, -3);/* basetable;name;__latebind(t);*/ | ||
272 | 273 | ||
273 | luaL_argcheck(L, lua_istable(L, -3) && lua_istable(L, -1), 1, | 274 | luaL_argcheck(L, lua_istable(L, -3) && lua_istable(L, -1), 1, |
274 | "__latebind table expected"); | 275 | "__latebind table expected"); |
@@ -324,25 +325,31 @@ static int latebind_func_pairs(lua_State *L) | |||
324 | { | 325 | { |
325 | /* basetable @ top of stack 1(basetable)-1 */ | 326 | /* basetable @ top of stack 1(basetable)-1 */ |
326 | luaL_argcheck(L, lua_istable(L, 1), 1, "table expected"); | 327 | luaL_argcheck(L, lua_istable(L, 1), 1, "table expected"); |
327 | lua_getglobal(L, "pairs"); /* function to be called / returned (btable;pairs) */ | ||
328 | 328 | ||
329 | lua_createtable(L, 0, 15); /* btable;pairs;newtable; */ | 329 | #if 0 |
330 | /* clone base table */ | 330 | lua_getglobal(L, "next"); /* function to be called / returned (btable;next) */ |
331 | lua_createtable(L, 0, 15); /* btable;next;newtable; */ | ||
332 | lua_pushnil(L); /* nil name retrieves all unbound latebound functions */ | ||
331 | lua_pushnil(L); /* first key */ | 333 | lua_pushnil(L); /* first key */ |
332 | while(lua_next(L, 1) != 0) { | 334 | #else |
333 | /* (btable;pairs;ntable;k;v) */ | 335 | /* this way is more RAM efficient in testing */ |
336 | if(luaL_dostring(L, "return next, {}, nil, nil")!= 0) | ||
337 | lua_error(L); | ||
338 | #endif | ||
339 | /* (btable;next;ntable;nil;nil) */ | ||
340 | /* clone base table */ | ||
341 | while(lua_next(L, 1) > 0) { | ||
342 | /* (btable;next;ntable;nil;k;v) */ | ||
334 | lua_pushvalue(L, -2); /* dupe key Stk = (..;k;v -> ..k;v;k)*/ | 343 | lua_pushvalue(L, -2); /* dupe key Stk = (..;k;v -> ..k;v;k)*/ |
335 | lua_insert(L, -2); /* Stk = (..k;k;v) */ | 344 | lua_insert(L, -2); /* Stk = (..k;k;v) */ |
336 | lua_rawset(L, 3); /* btable;pairs;ntable;k */ | 345 | lua_rawset(L, -5); /* btable;next;ntable;nil;k */ |
337 | } | 346 | } |
338 | 347 | /* fill the new table with all the latebound functions */ | |
339 | lua_pushnil(L); /*nil name retrieves all unbound late bound functions */ | 348 | /* nil name retrieves all unbound latebound functions */ |
340 | latebind_func_index(L);/* (btable;pairs;ntable;nil) -> (btable;pairs;ntable) */ | 349 | latebind_func_index(L);/* (btable;next;ntable;nil) -> (btable;next;ntable) */ |
341 | 350 | lua_pushnil(L); /*nil initial key for next*/ | |
342 | /* (btable;pairs;ntable) */ | 351 | /* stack = (btable;next;ntable;nil) */ |
343 | lua_call(L, 1, 3); /* pairs(ntable) -> (btable;iter;state;value) */ | 352 | return 3; /*(next,ntable,nil)*/ |
344 | |||
345 | return 3; | ||
346 | } | 353 | } |
347 | 354 | ||
348 | 355 | ||
diff --git a/apps/plugins/lua/loadlib.c b/apps/plugins/lua/loadlib.c index 1e310beed1..732ad707b5 100644 --- a/apps/plugins/lua/loadlib.c +++ b/apps/plugins/lua/loadlib.c | |||
@@ -130,9 +130,11 @@ static int ll_require (lua_State *L) { | |||
130 | lua_pushliteral(L, ""); /* error message accumulator */ | 130 | lua_pushliteral(L, ""); /* error message accumulator */ |
131 | for (i=1; ; i++) { | 131 | for (i=1; ; i++) { |
132 | lua_rawgeti(L, -2, i); /* get a loader */ | 132 | lua_rawgeti(L, -2, i); /* get a loader */ |
133 | if (lua_isnil(L, -1)) | 133 | if (lua_isnil(L, -1)) { |
134 | lua_setfield(L, 2, name); /* _LOADED[name] = nil */ | ||
134 | luaL_error(L, "module " LUA_QS " not found:%s", | 135 | luaL_error(L, "module " LUA_QS " not found:%s", |
135 | name, lua_tostring(L, -2)); | 136 | name, lua_tostring(L, -2)); |
137 | } | ||
136 | lua_pushstring(L, name); | 138 | lua_pushstring(L, name); |
137 | lua_call(L, 1, 1); /* call it */ | 139 | lua_call(L, 1, 1); /* call it */ |
138 | if (lua_isfunction(L, -1)) /* did it find module? */ | 140 | if (lua_isfunction(L, -1)) /* did it find module? */ |
diff --git a/apps/plugins/lua/lparser.c b/apps/plugins/lua/lparser.c index 8b93237918..23d3972036 100644 --- a/apps/plugins/lua/lparser.c +++ b/apps/plugins/lua/lparser.c | |||
@@ -603,7 +603,12 @@ static void parlist (LexState *ls) { | |||
603 | } while (!f->is_vararg && testnext(ls, ',')); | 603 | } while (!f->is_vararg && testnext(ls, ',')); |
604 | } | 604 | } |
605 | adjustlocalvars(ls, nparams); | 605 | adjustlocalvars(ls, nparams); |
606 | //f->numparams = cast_byte(fs->nactvar - (f->is_vararg & VARARG_HASARG)); | ||
607 | #if defined(LUA_COMPAT_VARARG) | ||
606 | f->numparams = cast_byte(fs->nactvar - (f->is_vararg & VARARG_HASARG)); | 608 | f->numparams = cast_byte(fs->nactvar - (f->is_vararg & VARARG_HASARG)); |
609 | #else | ||
610 | f->numparams = cast_byte(fs->nactvar); | ||
611 | #endif | ||
607 | luaK_reserveregs(fs, fs->nactvar); /* reserve register for parameters */ | 612 | luaK_reserveregs(fs, fs->nactvar); /* reserve register for parameters */ |
608 | } | 613 | } |
609 | 614 | ||
diff --git a/apps/plugins/lua/rockaux.c b/apps/plugins/lua/rockaux.c index 058ad313fa..929dea798b 100644 --- a/apps/plugins/lua/rockaux.c +++ b/apps/plugins/lua/rockaux.c | |||
@@ -106,7 +106,8 @@ int splash_scroller(int timeout, const char* str) | |||
106 | { | 106 | { |
107 | brk = strpbrk_n(ch+1, max_ch, break_chars); | 107 | brk = strpbrk_n(ch+1, max_ch, break_chars); |
108 | chars_next_break = (brk - ch); | 108 | chars_next_break = (brk - ch); |
109 | if (chars_next_break < 2 || w + (ch_w * chars_next_break) > max_w) | 109 | if (brk && |
110 | (chars_next_break < 2 || w + (ch_w * chars_next_break) > max_w)) | ||
110 | { | 111 | { |
111 | if (!isprint(line[linepos])) | 112 | if (!isprint(line[linepos])) |
112 | { | 113 | { |
@@ -226,7 +227,7 @@ int get_current_path(lua_State *L, int level) | |||
226 | } | 227 | } |
227 | } | 228 | } |
228 | 229 | ||
229 | lua_pushnil(L); | 230 | lua_pushnil(L); |
230 | return 1; | 231 | return 1; |
231 | } | 232 | } |
232 | 233 | ||
@@ -250,25 +251,32 @@ int filetol(int fd, long *num) | |||
250 | 251 | ||
251 | while (rb->read(fd, &chbuf, 1) == 1) | 252 | while (rb->read(fd, &chbuf, 1) == 1) |
252 | { | 253 | { |
253 | if(!isspace(chbuf) || retn == 1) | 254 | if(retn || !isspace(chbuf)) |
254 | { | 255 | { |
255 | if(chbuf == '0') /* strip preceeding zeros */ | 256 | switch(chbuf) |
256 | { | 257 | { |
257 | *num = 0; | 258 | case '-': |
258 | retn = 1; | 259 | { |
259 | } | 260 | if (retn) /* 0 preceeds, this negative sign must be in error */ |
260 | else if(chbuf == '-' && retn != 1) | 261 | goto get_digits; |
261 | neg = true; | 262 | neg = true; |
262 | else | 263 | continue; |
263 | { | 264 | } |
264 | rb->lseek(fd, -1, SEEK_CUR); | 265 | case '0': /* strip preceeding zeros */ |
265 | break; | 266 | { |
267 | *num = 0; | ||
268 | retn = 1; | ||
269 | continue; | ||
270 | } | ||
271 | default: | ||
272 | goto get_digits; | ||
266 | } | 273 | } |
267 | } | 274 | } |
268 | } | 275 | } |
269 | 276 | ||
270 | while (rb->read(fd, &chbuf, 1) == 1) | 277 | while (rb->read(fd, &chbuf, 1) == 1) |
271 | { | 278 | { |
279 | get_digits: | ||
272 | if(!isdigit(chbuf)) | 280 | if(!isdigit(chbuf)) |
273 | { | 281 | { |
274 | rb->lseek(fd, -1, SEEK_CUR); | 282 | rb->lseek(fd, -1, SEEK_CUR); |