Author: fperrad
Date: Mon Apr 16 23:11:07 2007
New Revision: 18253
Modified:
trunk/languages/lua/lib/luabasic.pir
trunk/languages/lua/lib/luaos.pir
trunk/languages/lua/pmc/lua.pmc
trunk/src/call_list.txt
Log:
[Lua]
- improvement Lua 5.1.1 -> 5.1.2
Modified: trunk/languages/lua/lib/luabasic.pir
==============================================================================
--- trunk/languages/lua/lib/luabasic.pir (original)
+++ trunk/languages/lua/lib/luabasic.pir Mon Apr 16 23:11:07 2007
@@ -404,7 +404,7 @@
.const .LuaNumber zero = '0'
if f == zero goto L2
L1:
- f = getfunc(f)
+ f = getfunc(f, 1)
$I0 = isa f, 'LuaClosure'
if $I0 goto L3
L2:
@@ -416,6 +416,7 @@
.sub 'getfunc' :anon
.param pmc f
+ .param int opt
if null f goto L1
$I0 = isa f, 'LuaFunction'
if $I0 goto L2
@@ -423,10 +424,15 @@
if $I0 goto L2
L1:
.local int level
+ unless opt goto L3
level = optint(f, 1)
- if level >= 0 goto L3
- error("level must be non-negative")
+ goto L4
L3:
+ level = checknumber(f)
+L4:
+ if level >= 0 goto L5
+ error("level must be non-negative")
+L5:
$P0 = getinterp
inc level
push_eh _handler
@@ -840,7 +846,7 @@
not_implemented()
.return ()
L1:
- f = getfunc(f)
+ f = getfunc(f, 0)
$I0 = isa f, 'LuaFunction'
if $I0 goto L2
$I0 = setfenv(f, table)
Modified: trunk/languages/lua/lib/luaos.pir
==============================================================================
--- trunk/languages/lua/lib/luaos.pir (original)
+++ trunk/languages/lua/lib/luaos.pir Mon Apr 16 23:11:07 2007
@@ -202,8 +202,28 @@
ret[$P1] = $P2
.return (ret)
L4:
+ .local string b
+ .local int idx
+ b = ''
+ idx = 0
+ $I1 = length $S1
new $P1, .Lua
- ret = $P1.'strftime'($S1, $P0)
+L5:
+ unless idx < $I1 goto L6
+ $S0 = substr $S1, idx, 1
+ if $S0 != '%' goto L7
+ inc idx
+ if idx == $I1 goto L7
+ $S0 = substr $S1, idx, 1
+ $S2 = '%' . $S0
+ $S0 = $P1.'strftime'($S2, $P0)
+L7:
+ b .= $S0
+ inc idx
+ goto L5
+L6:
+ new ret, .LuaString
+ set ret, b
.return (ret)
.end
Modified: trunk/languages/lua/pmc/lua.pmc
==============================================================================
--- trunk/languages/lua/pmc/lua.pmc (original)
+++ trunk/languages/lua/pmc/lua.pmc Mon Apr 16 23:11:07 2007
@@ -119,15 +119,16 @@
/*
-=item C<PMC* strftime(STRING* fmt, PMC* tm)>
+=item C<STRING* strftime(STRING* fmt, PMC* tm)>
=cut
*/
- METHOD PMC* strftime(STRING* fmt, PMC* tm) {
+ METHOD STRING* strftime(STRING* fmt, PMC* tm) {
PMC *retval = NULL;
struct tm stm;
- char b[256];
+ char b[200];
+ size_t reslen;
const char *s = string_to_cstring(INTERP, fmt);
stm.tm_sec = VTABLE_get_integer_keyed_int(INTERP, tm, 0);
@@ -140,18 +141,8 @@
stm.tm_yday = VTABLE_get_integer_keyed_int(INTERP, tm, 7);
stm.tm_isdst = VTABLE_get_integer_keyed_int(INTERP, tm, 8);
- if (strftime(b, sizeof b, s, &stm)) {
- retval = pmc_new(INTERP, dynpmc_LuaString);
- VTABLE_set_string_native(INTERP, retval,
- string_from_cstring(INTERP, b, 0));
- }
- else {
- PMC* func = Parrot_find_global_cur(INTERP,
- const_string(INTERP, "error"));
- STRING* msg = const_string(INTERP, "'date' format too long");
- (void)Parrot_runops_fromc_args(INTERP, func, "vS", msg);
- }
- return retval;
+ reslen = strftime(b, sizeof b, s, &stm);
+ return string_from_cstring(INTERP, b, reslen);
}
}
Modified: trunk/src/call_list.txt
==============================================================================
--- trunk/src/call_list.txt (original)
+++ trunk/src/call_list.txt Mon Apr 16 23:11:07 2007
@@ -338,7 +338,7 @@
# Make lua stop panic'ing.
P JOI
-P JOSP
+S JOSP
# ParrotThread creation
i JOP@