aboutsummaryrefslogtreecommitdiff
path: root/ltm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-09-11 17:29:27 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-09-11 17:29:27 -0300
commit8060193702b21a06af3541555db4cd317c733ce9 (patch)
treed1cfa3a4ac41dc6766188680659c1bd1311e22a8 /ltm.c
parent2779e81fbbdebf8b7cac97c167ff109bad537c4b (diff)
downloadlua-8060193702b21a06af3541555db4cd317c733ce9.tar.gz
lua-8060193702b21a06af3541555db4cd317c733ce9.tar.bz2
lua-8060193702b21a06af3541555db4cd317c733ce9.zip
`lauxlib' is now part of the libraries (not used by core Lua)
Diffstat (limited to 'ltm.c')
-rw-r--r--ltm.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/ltm.c b/ltm.c
index a1ed11dc..ca4ea88d 100644
--- a/ltm.c
+++ b/ltm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltm.c,v 1.47 2000/09/05 19:33:32 roberto Exp roberto $ 2** $Id: ltm.c,v 1.48 2000/09/11 19:45:27 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*/
@@ -10,7 +10,6 @@
10 10
11#include "lua.h" 11#include "lua.h"
12 12
13#include "lauxlib.h"
14#include "ldo.h" 13#include "ldo.h"
15#include "lmem.h" 14#include "lmem.h"
16#include "lobject.h" 15#include "lobject.h"
@@ -26,14 +25,23 @@ const char *const luaT_eventname[] = { /* ORDER IM */
26}; 25};
27 26
28 27
28static int findevent (const char *name) {
29 int i;
30 for (i=0; luaT_eventname[i]; i++)
31 if (strcmp(luaT_eventname[i], name) == 0)
32 return i;
33 return -1; /* name not found */
34}
35
36
29static int luaI_checkevent (lua_State *L, const char *name, int t) { 37static int luaI_checkevent (lua_State *L, const char *name, int t) {
30 int e = luaL_findstring(name, luaT_eventname); 38 int e = findevent(name);
31 if (e >= IM_N) 39 if (e >= IM_N)
32 luaL_verror(L, "event `%.50s' is deprecated", name); 40 luaO_verror(L, "event `%.50s' is deprecated", name);
33 if (e == IM_GC && t == TAG_TABLE) 41 if (e == IM_GC && t == TAG_TABLE)
34 luaL_verror(L, "event `gc' for tables is deprecated"); 42 luaO_verror(L, "event `gc' for tables is deprecated");
35 if (e < 0) 43 if (e < 0)
36 luaL_verror(L, "`%.50s' is not a valid event name", name); 44 luaO_verror(L, "`%.50s' is not a valid event name", name);
37 return e; 45 return e;
38} 46}
39 47
@@ -86,12 +94,12 @@ int lua_newtag (lua_State *L) {
86 94
87static void checktag (lua_State *L, int tag) { 95static void checktag (lua_State *L, int tag) {
88 if (!(0 <= tag && tag <= L->last_tag)) 96 if (!(0 <= tag && tag <= L->last_tag))
89 luaL_verror(L, "%d is not a valid tag", tag); 97 luaO_verror(L, "%d is not a valid tag", tag);
90} 98}
91 99
92void luaT_realtag (lua_State *L, int tag) { 100void luaT_realtag (lua_State *L, int tag) {
93 if (!(NUM_TAGS <= tag && tag <= L->last_tag)) 101 if (!(NUM_TAGS <= tag && tag <= L->last_tag))
94 luaL_verror(L, "tag %d was not created by `newtag'", tag); 102 luaO_verror(L, "tag %d was not created by `newtag'", tag);
95} 103}
96 104
97 105
@@ -140,7 +148,7 @@ void lua_settagmethod (lua_State *L, int t, const char *event) {
140 e = luaI_checkevent(L, event, t); 148 e = luaI_checkevent(L, event, t);
141 checktag(L, t); 149 checktag(L, t);
142 if (!luaT_validevent(t, e)) 150 if (!luaT_validevent(t, e))
143 luaL_verror(L, "cannot change `%.20s' tag method for type `%.20s'%.20s", 151 luaO_verror(L, "cannot change `%.20s' tag method for type `%.20s'%.20s",
144 luaT_eventname[e], luaO_typenames[t], 152 luaT_eventname[e], luaO_typenames[t],
145 (t == TAG_TABLE || t == TAG_USERDATA) ? " with default tag" 153 (t == TAG_TABLE || t == TAG_USERDATA) ? " with default tag"
146 : ""); 154 : "");