lua-users home
lua-l archive

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


On Mon, 11 Jan 2010, Roberto Ierusalimschy wrote:
>
> This bug is caused by a really dirty trick. Lua are using the third
> letter of the type name to distinguish between type names.

Er why? Surely the straightforward code is better in every respect?

--- ldebug.c~   2010-01-06 14:42:35.000000000 +0000
+++ ldebug.c    2010-01-11 19:07:38.000000000 +0000
@@ -444,12 +444,13 @@


 int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) {
-  const char *t1 = luaT_typenames[ttype(p1)];
-  const char *t2 = luaT_typenames[ttype(p2)];
-  if (t1[2] == t2[2])
-    luaG_runerror(L, "attempt to compare two %s values", t1);
+  int t1 = ttype(p1);
+  int t2 = ttype(p2);
+  if (t1 == t2)
+    luaG_runerror(L, "attempt to compare two %s values", luaT_typenames[t1]);
   else
-    luaG_runerror(L, "attempt to compare %s with %s", t1, t2);
+    luaG_runerror(L, "attempt to compare %s with %s",
+        luaT_typenames[t1], luaT_typenames[t2]);
   return 0;
 }


Tony.
-- 
f.anthony.n.finch  <dot@dotat.at>  http://dotat.at/
GERMAN BIGHT HUMBER: SOUTHWEST 5 TO 7. MODERATE OR ROUGH. SQUALLY SHOWERS.
MODERATE OR GOOD.