lua-users home
lua-l archive

Re: 5.1 __usedindex patch available somewhere?

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


Am 06.06.2012 12:03, schrieb Nicolas:
> Hi
>
> To debug some very weird bug in my game I need to be able to detect where
> a value is being overridden, but due to the structure of the code proxy tables
> just will not work (I use some rawgets/sets and my serialization will bork on them).
> The link to the patch on the lua wiki is dead:
> http://blua.leet.cz/sep/USEDINDEX_PATCH.patch
>
> Anybody got a copy of it ?
>
> Thanks
>
I belive that it's this one you wanted?
diff -urN lua/src/ltm.c lua_new/src/ltm.c
--- lua/src/ltm.c	Thu Apr 3 07:35:34 2003
+++ lua_new/src/ltm.c	Sun Feb 29 17:26:13 2004
@@ -27,7 +27,7 @@
 
 void luaT_init (lua_State *L) {
 static const char *const luaT_eventname[] = { /* ORDER TM */
- "__index", "__newindex",
+ "__index", "__newindex", "__usedindex",
 "__gc", "__mode", "__eq",
 "__add", "__sub", "__mul", "__div",
 "__pow", "__unm", "__lt", "__le",
diff -urN lua/src/ltm.h lua_new/src/ltm.h
--- lua/src/ltm.h	Thu Nov 14 05:51:50 2002
+++ lua_new/src/ltm.h	Sun Feb 29 17:19:38 2004
@@ -18,6 +18,7 @@
 typedef enum {
 TM_INDEX,
 TM_NEWINDEX,
+ TM_USEDINDEX,
 TM_GC,
 TM_MODE,
 TM_EQ, /* last tag method with `fast' access */
diff -urN lua/src/lvm.c lua_new/src/lvm.c
--- lua/src/lvm.c	Thu Apr 3 07:35:34 2003
+++ lua_new/src/lvm.c	Sun Feb 29 17:23:44 2004
@@ -173,14 +173,24 @@
 if (ttistable(t)) { /* `t' is a table? */
 Table *h = hvalue(t);
 TObject *oldval = luaH_set(L, h, key); /* do a primitive set */
- if (!ttisnil(oldval) || /* result is no nil? */
- (tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */
- setobj2t(oldval, val); /* write barrier */
- return;
+ if (!ttisnil(oldval)) /* old is not nil? */ {
+	if ((tm = fasttm(L, h->metatable, TM_USEDINDEX)) == NULL) /* and no TM? */{
+	 setobj2t(oldval, val); /* write barrier */
+	 return;
+	} else {
+	 /* else will try the tag method */
+	}
+ } else /* old is nil? */ {
+	if ((tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* and no TM? */
+	 setobj2t(oldval, val); /* write barrier */
+	 return;
+	} else {
+	 /* else will try the tag method */
+	}
 }
 /* else will try the tag method */
 }
- else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX)))
+ else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX))) /*Not sure here*/
 luaG_typeerror(L, t, "index");
 if (ttisfunction(tm)) {
 callTM(L, tm, t, key, val);

Attachment: smime.p7s
Description: S/MIME Kryptografische Unterschrift


AltStyle によって変換されたページ (->オリジナル) /