diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-07-23 16:56:00 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-07-23 16:56:00 -0300 |
| commit | 767abdfdc0bb9c98d1f0cc6aac0cdc72d4713d65 (patch) | |
| tree | 427f4dff865594d19c057e22a4ecb33ce162cd17 | |
| parent | 45b173cbf89597123267a69bace778cf498d6c98 (diff) | |
| download | lua-767abdfdc0bb9c98d1f0cc6aac0cdc72d4713d65.tar.gz lua-767abdfdc0bb9c98d1f0cc6aac0cdc72d4713d65.tar.bz2 lua-767abdfdc0bb9c98d1f0cc6aac0cdc72d4713d65.zip | |
`newtype' returns old tag when given an old name
Diffstat (limited to '')
| -rw-r--r-- | ltm.c | 10 |
1 files changed, 4 insertions, 6 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltm.c,v 1.73 2001/06/15 20:36:57 roberto Exp roberto $ | 2 | ** $Id: ltm.c,v 1.74 2001/07/12 18:11:58 roberto Exp roberto $ |
| 3 | ** Tag methods | 3 | ** Tag methods |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -82,17 +82,15 @@ void luaT_init (lua_State *L) { | |||
| 82 | int luaT_newtag (lua_State *L, const l_char *name, int basictype) { | 82 | int luaT_newtag (lua_State *L, const l_char *name, int basictype) { |
| 83 | int tag; | 83 | int tag; |
| 84 | int i; | 84 | int i; |
| 85 | TString *ts; | 85 | TString *ts = NULL; |
| 86 | luaM_growvector(L, G(L)->TMtable, G(L)->ntag, G(L)->sizeTM, struct TM, | 86 | luaM_growvector(L, G(L)->TMtable, G(L)->ntag, G(L)->sizeTM, struct TM, |
| 87 | MAX_INT, l_s("tag table overflow")); | 87 | MAX_INT, l_s("tag table overflow")); |
| 88 | tag = G(L)->ntag; | 88 | tag = G(L)->ntag; |
| 89 | if (name == NULL) | 89 | if (name) { |
| 90 | ts = NULL; | ||
| 91 | else { | ||
| 92 | TObject *v; | 90 | TObject *v; |
| 93 | ts = luaS_new(L, name); | 91 | ts = luaS_new(L, name); |
| 94 | v = luaH_setstr(L, G(L)->type2tag, ts); | 92 | v = luaH_setstr(L, G(L)->type2tag, ts); |
| 95 | if (ttype(v) != LUA_TNIL) return LUA_TNONE; /* invalid name */ | 93 | if (ttype(v) == LUA_TNUMBER) return (int)nvalue(v); |
| 96 | setnvalue(v, tag); | 94 | setnvalue(v, tag); |
| 97 | } | 95 | } |
| 98 | for (i=0; i<TM_N; i++) | 96 | for (i=0; i<TM_N; i++) |
