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

View File

@@ -661,7 +661,7 @@ public class StringLib extends LFunction {
* changed to lowercase. All other characters are left unchanged.
* The definition of what an uppercase letter is depends on the current locale.
*/
static void lower( LuaState vm ) {
static void lower( LuaState vm ) {
String s = vm.checkstring(2).toLowerCase();
vm.resettop();
vm.pushstring( s );
@@ -1084,7 +1084,9 @@ public class StringLib extends LFunction {
case ')':
return end_capture( soffset, poffset + 1 );
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':
soffset = matchbalance( soffset, poffset + 2 );
if ( soffset == -1 ) return -1;

View File

@@ -151,4 +151,18 @@ for i,letter in ipairs(letters) do
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