lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

since there were some requests for it, here it is:

This is a cumulative patch that fixes all known issues with
Lua 5.1-work6 up to now (well, at least those known to me).
It doesn't contain any new features (except maybe for #obj).

Here is the change list:
- MSVC number2int fix.
- #s performance improvement.
- Remove undefined lua_checkpc assertion.
- One-off error in NUM_TAGS. Avoid crash on thread metatable access.
- Check for __ELF__ before using hidden visibility symbols.
- Avoid unneeded stack slot if LUA_COMPAT_VARARG is 0.
- Assertion in ldebug.c may fail if LUA_COMPAT_VARARGS is 0.
- Fix the bytecode verifier for OP_TFORLOOP.
- Correct error parsing for standalone (no escape after isolated end).
- _LOADED[name] = nil missing if package fails to load.
- ar->lastlinedefined not set for C functions.
- Upvalue GC bug fixed.

Not really a bug. But since the final syntax has been confirmed:
- Change size operator from '*obj' to '#obj'.

[
Anyway, this is completely unofficial and only a stopgap
measure before the next work version. It saves you going
through 2-3 months worth of the mailing list and collecting
all these little things.

There is no guarantee that any or all of this will be in the
exact same shape in the next release. I have no intention to
interfere with the release cycle of the Lua authors. I will
immediately cease posting it, if they don't like it.
]

Bye,
     Mike
diff -ur lua-5.1-work6/src/lua.h lua51w6-cumulative/src/lua.h
--- lua-5.1-work6/src/lua.h	2005-05-18 15:13:39 +0200
+++ lua51w6-cumulative/src/lua.h	2005-08-01 17:38:16 +0200
@@ -18,5 +18,5 @@
 
 
-#define LUA_VERSION	"Lua 5.1 (work6)"
+#define LUA_VERSION	"Lua 5.1 (work6-cumulative1)"
 #define LUA_VERSION_NUM	501
 #define LUA_COPYRIGHT	"Copyright (C) 1994-2005 Tecgraf, PUC-Rio"
diff -ur lua-5.1-work6/src/luaconf.h lua51w6-cumulative/src/luaconf.h
--- lua-5.1-work6/src/luaconf.h	2005-05-17 21:49:15 +0200
+++ lua51w6-cumulative/src/luaconf.h	2005-08-03 21:25:21 +0200
@@ -125,5 +125,6 @@
 #if defined(luaall_c)
 #define LUAI_FUNC	static
-#elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302)
+#elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
+      defined(__ELF__)
 #define LUAI_FUNC	__attribute__((visibility("hidden")))
 #else
@@ -438,6 +439,6 @@
 #elif !defined(__STRICT_ANSI__) && defined(_MSC_VER) && defined(_M_IX86)
 #define lua_number2int(i,d)	\
-	__asm fld d; \
-	__asm fistp i;
+	__asm fld d \
+	__asm fistp i
 
 
diff -ur lua-5.1-work6/src/ldebug.c lua51w6-cumulative/src/ldebug.c
--- lua-5.1-work6/src/ldebug.c	2005-05-17 21:49:15 +0200
+++ lua51w6-cumulative/src/ldebug.c	2005-08-03 21:13:51 +0200
@@ -153,4 +153,5 @@
     ar->source = "=[C]";
     ar->linedefined = -1;
+    ar->lastlinedefined = -1;
     ar->what = "C";
   }
@@ -277,5 +278,5 @@
   check(pt->maxstacksize <= MAXSTACK);
   check(pt->sizelineinfo == pt->sizecode || pt->sizelineinfo == 0);
-  lua_assert(pt->numparams+pt->is_vararg <= pt->maxstacksize);
+  lua_assert(pt->numparams+LUA_COMPAT_VARARG*pt->is_vararg <= pt->maxstacksize);
   check(GET_OPCODE(pt->code[pt->sizecode-1]) == OP_RETURN);
   return 1;
@@ -390,5 +391,5 @@
       case OP_TFORLOOP: {
         check(c >= 1);  /* at least one result (control variable) */
-        checkreg(pt, a+3+c);  /* space for results */
+        checkreg(pt, a+2+c);  /* space for results */
         if (reg >= a+3) last = pc;  /* affect all regs above its call base */
         break;
diff -ur lua-5.1-work6/src/ldo.c lua51w6-cumulative/src/ldo.c
--- lua-5.1-work6/src/ldo.c	2005-05-03 21:01:17 +0200
+++ lua51w6-cumulative/src/ldo.c	2005-07-31 12:56:40 +0200
@@ -117,5 +117,4 @@
     ci->base = (ci->base - oldstack) + L->stack;
     ci->func = (ci->func - oldstack) + L->stack;
-    lua_assert(lua_checkpc(L, ci));
   }
   L->base = L->ci->base;
diff -ur lua-5.1-work6/src/lgc.c lua51w6-cumulative/src/lgc.c
--- lua-5.1-work6/src/lgc.c	2005-05-05 17:34:03 +0200
+++ lua51w6-cumulative/src/lgc.c	2005-08-03 21:15:24 +0200
@@ -529,8 +529,8 @@
   global_State *g = G(L);
   size_t udsize;  /* total size of userdata to be finalized */
-  /* remark objects cautch by write barrier */
-  propagateall(g);
   /* remark occasional upvalues of (maybe) dead threads */
   remarkupvals(g);
+  /* remark objects caught by write barrier */
+  propagateall(g);
   /* remark weak tables */
   g->gray = g->weak;
diff -ur lua-5.1-work6/src/loadlib.c lua51w6-cumulative/src/loadlib.c
--- lua-5.1-work6/src/loadlib.c	2005-05-17 21:49:15 +0200
+++ lua51w6-cumulative/src/loadlib.c	2005-08-03 21:14:39 +0200
@@ -384,6 +384,8 @@
   for (i=1;; i++) {
     lua_rawgeti(L, -1, i);  /* get a loader */
-    if (lua_isnil(L, -1))
+    if (lua_isnil(L, -1)) {
+      lua_setfield(L, 2, name);  /* _LOADED[name] = nil */
       return luaL_error(L, "package " LUA_QS " not found", name);
+    }
     lua_pushstring(L, name);
     lua_call(L, 1, 1);  /* call it */
diff -ur lua-5.1-work6/src/lobject.h lua51w6-cumulative/src/lobject.h
--- lua-5.1-work6/src/lobject.h	2005-05-05 22:47:02 +0200
+++ lua51w6-cumulative/src/lobject.h	2005-07-31 12:56:40 +0200
@@ -18,5 +18,5 @@
 
 /* tags for values visible from Lua */
-#define NUM_TAGS	LUA_TTHREAD
+#define NUM_TAGS	(LUA_TTHREAD+1)
 
 
@@ -24,7 +24,7 @@
 ** Extra tags for non-values
 */
-#define LUA_TPROTO	(NUM_TAGS+1)
-#define LUA_TUPVAL	(NUM_TAGS+2)
-#define LUA_TDEADKEY	(NUM_TAGS+3)
+#define LUA_TPROTO	NUM_TAGS
+#define LUA_TUPVAL	(NUM_TAGS+1)
+#define LUA_TDEADKEY	(NUM_TAGS+2)
 
 
diff -ur lua-5.1-work6/src/lparser.c lua51w6-cumulative/src/lparser.c
--- lua-5.1-work6/src/lparser.c	2005-05-17 21:49:15 +0200
+++ lua51w6-cumulative/src/lparser.c	2005-07-31 12:56:40 +0200
@@ -573,6 +573,8 @@
         case TK_DOTS: {  /* param -> `...' */
           next(ls);
+#if LUA_COMPAT_VARARG
           /* use `arg' as default name */
           new_localvarliteral(ls, "arg", nparams++);
+#endif
           f->is_vararg = 1;
           break;
@@ -583,5 +585,9 @@
   }
   adjustlocalvars(ls, nparams);
+#if LUA_COMPAT_VARARG
   f->numparams = fs->nactvar - f->is_vararg;
+#else
+  f->numparams = fs->nactvar;
+#endif
   luaK_reserveregs(fs, fs->nactvar);  /* reserve register for parameters */
 }
@@ -793,5 +799,5 @@
     case TK_NOT: return OPR_NOT;
     case '-': return OPR_MINUS;
-    case '*': return OPR_SIZE;
+    case '#': return OPR_SIZE;
     default: return OPR_NOUNOPR;
   }
diff -ur lua-5.1-work6/src/lua.c lua51w6-cumulative/src/lua.c
--- lua-5.1-work6/src/lua.c	2005-05-17 21:49:15 +0200
+++ lua51w6-cumulative/src/lua.c	2005-07-31 12:56:40 +0200
@@ -150,5 +150,5 @@
 static int incomplete (lua_State *L, int status) {
   if (status == LUA_ERRSYNTAX &&
-         strstr(lua_tostring(L, -1), "<eof>") != NULL) {
+         strstr(lua_tostring(L, -1), "near " LUA_QL("<eof>")) != NULL) {
     lua_pop(L, 1);
     return 1;
diff -ur lua-5.1-work6/src/lvm.c lua51w6-cumulative/src/lvm.c
--- lua-5.1-work6/src/lvm.c	2005-05-17 21:49:15 +0200
+++ lua51w6-cumulative/src/lvm.c	2005-08-02 02:15:10 +0200
@@ -550,4 +550,7 @@
           setnvalue(ra, cast(lua_Number, luaH_getn(hvalue(rb))));
         }
+	else if (ttype(rb) == LUA_TSTRING) {
+	  setnvalue(ra, cast(lua_Number, tsvalue(rb)->len));
+	}
         else {  /* try metamethod */
           Protect(