From 767abdfdc0bb9c98d1f0cc6aac0cdc72d4713d65 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 23 Jul 2001 16:56:00 -0300 Subject: [PATCH] `newtype' returns old tag when given an old name --- ltm.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ltm.c b/ltm.c index 38b74db9..55705da7 100644 --- a/ltm.c +++ b/ltm.c @@ -1,5 +1,5 @@ /* -** $Id: ltm.c,v 1.73 2001/06/15 20:36:57 roberto Exp roberto $ +** $Id: ltm.c,v 1.74 2001/07/12 18:11:58 roberto Exp roberto $ ** Tag methods ** See Copyright Notice in lua.h */ @@ -82,17 +82,15 @@ void luaT_init (lua_State *L) { int luaT_newtag (lua_State *L, const l_char *name, int basictype) { int tag; int i; - TString *ts; + TString *ts = NULL; luaM_growvector(L, G(L)->TMtable, G(L)->ntag, G(L)->sizeTM, struct TM, MAX_INT, l_s("tag table overflow")); tag = G(L)->ntag; - if (name == NULL) - ts = NULL; - else { + if (name) { TObject *v; ts = luaS_new(L, name); v = luaH_setstr(L, G(L)->type2tag, ts); - if (ttype(v) != LUA_TNIL) return LUA_TNONE; /* invalid name */ + if (ttype(v) == LUA_TNUMBER) return (int)nvalue(v); setnvalue(v, tag); } for (i=0; i