0.52: Small fixes for closer conformance with regular Lua.

This commit is contained in:
Ian Farmer
2008-09-04 17:24:57 +00:00
parent 0808aa3791
commit a0b1aef0b1
4 changed files with 22 additions and 7 deletions

View File

@@ -262,8 +262,7 @@ public class BaseLib extends LFunction {
vm.checkany(2); vm.checkany(2);
LValue v = vm.tolnumber(2); LValue v = vm.tolnumber(2);
vm.resettop(); vm.resettop();
if ( ! v.isNil() ) vm.pushlvalue(v);
vm.pushlvalue(v);
} else { } else {
if ( base < 2 || base > 36 ) if ( base < 2 || base > 36 )
vm.typerror(3, "base out of range"); vm.typerror(3, "base out of range");
@@ -338,7 +337,7 @@ public class BaseLib extends LFunction {
break; break;
} }
case COLLECTGARBAGE: { case COLLECTGARBAGE: {
String s = vm.checkstring(2); String s = vm.optstring(2, "collect");
int result = 0; int result = 0;
vm.resettop(); vm.resettop();
if ( "collect".equals(s) ) if ( "collect".equals(s) )

View File

@@ -1084,7 +1084,9 @@ public class StringLib extends LFunction {
case ')': case ')':
return end_capture( soffset, poffset + 1 ); return end_capture( soffset, poffset + 1 );
case L_ESC: case L_ESC:
switch ( p.luaByte( poffset+1 ) ) { if ( poffset + 1 == p.length() )
vm.error("malformed pattern (ends with '%')");
switch ( p.luaByte( poffset + 1 ) ) {
case 'b': case 'b':
soffset = matchbalance( soffset, poffset + 2 ); soffset = matchbalance( soffset, poffset + 2 );
if ( soffset == -1 ) return -1; if ( soffset == -1 ) return -1;

View File

@@ -152,3 +152,17 @@ for i,letter in ipairs(letters) do
end end
end end
--]] --]]
local function fmterr(...)
local r, s = pcall(...)
if r then
return s
else
s = string.gsub(s, "stdin:%d+:%s*", "")
return s
end
end
print(fmterr(string.find, "ab%c)0(", "%"))
print(fmterr(string.find, "ab%c)0(", "("))
print(pcall(string.find, "ab%c)0(", ")"))

View File

@@ -1 +1 @@
version: 0.51 version: 0.52