aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-06-18 13:57:03 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-06-18 13:57:03 -0300
commitc9902be294f5c2dca8a67a67fd324f91e4352c0a (patch)
tree3f3ef43d231334ee60c13bf310f7995845e97cab
parent112c9d53ab47e77fd09d4ecb9b11d432ed906c88 (diff)
downloadlua-c9902be294f5c2dca8a67a67fd324f91e4352c0a.tar.gz
lua-c9902be294f5c2dca8a67a67fd324f91e4352c0a.tar.bz2
lua-c9902be294f5c2dca8a67a67fd324f91e4352c0a.zip
"findname" moved from lobject.c to lauxlib.c (so libraries may use it).
-rw-r--r--lauxlib.c11
-rw-r--r--lauxlib.h3
-rw-r--r--llex.c6
-rw-r--r--lobject.c13
-rw-r--r--lobject.h3
-rw-r--r--ltm.c8
6 files changed, 21 insertions, 23 deletions
diff --git a/lauxlib.c b/lauxlib.c
index 0a7475b1..0fa745e4 100644
--- a/lauxlib.c
+++ b/lauxlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.c,v 1.9 1998/03/06 16:54:42 roberto Exp roberto $ 2** $Id: lauxlib.c,v 1.10 1998/03/06 18:47:42 roberto Exp roberto $
3** Auxiliar functions for building Lua libraries 3** Auxiliar functions for building Lua libraries
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -7,6 +7,7 @@
7 7
8#include <stdarg.h> 8#include <stdarg.h>
9#include <stdio.h> 9#include <stdio.h>
10#include <string.h>
10 11
11/* Please Notice: This file uses only the oficial API of Lua 12/* Please Notice: This file uses only the oficial API of Lua
12** Any function declared here could be written as an application 13** Any function declared here could be written as an application
@@ -18,6 +19,14 @@
18 19
19 20
20 21
22int luaL_findstring (char *name, char *list[]) {
23 int i;
24 for (i=0; list[i]; i++)
25 if (strcmp(list[i], name) == 0)
26 return i;
27 return -1; /* name not found */
28}
29
21void luaL_argerror (int numarg, char *extramsg) 30void luaL_argerror (int numarg, char *extramsg)
22{ 31{
23 char *funcname; 32 char *funcname;
diff --git a/lauxlib.h b/lauxlib.h
index 0e150d25..572db923 100644
--- a/lauxlib.h
+++ b/lauxlib.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.h,v 1.6 1998/01/09 15:06:07 roberto Exp roberto $ 2** $Id: lauxlib.h,v 1.7 1998/03/06 16:54:42 roberto Exp roberto $
3** Auxiliar functions for building Lua libraries 3** Auxiliar functions for building Lua libraries
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -41,6 +41,7 @@ void luaL_addsize (int n);
41int luaL_newbuffer (int size); 41int luaL_newbuffer (int size);
42void luaL_oldbuffer (int old); 42void luaL_oldbuffer (int old);
43char *luaL_buffer (void); 43char *luaL_buffer (void);
44int luaL_findstring (char *name, char *list[]);
44 45
45 46
46#endif 47#endif
diff --git a/llex.c b/llex.c
index 75c1c28b..8bd60aaf 100644
--- a/llex.c
+++ b/llex.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: llex.c,v 1.19 1998/05/27 13:03:40 roberto Exp roberto $ 2** $Id: llex.c,v 1.20 1998/06/06 20:44:05 roberto Exp roberto $
3** Lexical Analizer 3** Lexical Analizer
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -118,7 +118,7 @@ static void skipspace (LexState *LS)
118static int checkcond (LexState *LS, char *buff) 118static int checkcond (LexState *LS, char *buff)
119{ 119{
120 static char *opts[] = {"nil", "1", NULL}; 120 static char *opts[] = {"nil", "1", NULL};
121 int i = luaO_findstring(buff, opts); 121 int i = luaL_findstring(buff, opts);
122 if (i >= 0) return i; 122 if (i >= 0) return i;
123 else if (isalpha((unsigned char)buff[0]) || buff[0] == '_') 123 else if (isalpha((unsigned char)buff[0]) || buff[0] == '_')
124 return luaS_globaldefined(buff); 124 return luaS_globaldefined(buff);
@@ -172,7 +172,7 @@ static void inclinenumber (LexState *LS)
172 int skip = LS->ifstate[LS->iflevel].skip; 172 int skip = LS->ifstate[LS->iflevel].skip;
173 next(LS); /* skip $ */ 173 next(LS); /* skip $ */
174 readname(LS, buff); 174 readname(LS, buff);
175 switch (luaO_findstring(buff, pragmas)) { 175 switch (luaL_findstring(buff, pragmas)) {
176 case 0: /* debug */ 176 case 0: /* debug */
177 if (!skip) lua_debug = 1; 177 if (!skip) lua_debug = 1;
178 break; 178 break;
diff --git a/lobject.c b/lobject.c
index e70d50ba..99c76233 100644
--- a/lobject.c
+++ b/lobject.c
@@ -1,11 +1,10 @@
1/* 1/*
2** $Id: lobject.c,v 1.10 1998/01/09 14:44:55 roberto Exp roberto $ 2** $Id: lobject.c,v 1.11 1998/03/09 21:49:52 roberto Exp roberto $
3** Some generic functions over Lua objects 3** Some generic functions over Lua objects
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
6 6
7#include <stdlib.h> 7#include <stdlib.h>
8#include <string.h>
9 8
10#include "lobject.h" 9#include "lobject.h"
11#include "lua.h" 10#include "lua.h"
@@ -58,16 +57,6 @@ int luaO_equalObj (TObject *t1, TObject *t2)
58} 57}
59 58
60 59
61int luaO_findstring (char *name, char *list[])
62{
63 int i;
64 for (i=0; list[i]; i++)
65 if (strcmp(list[i], name) == 0)
66 return i;
67 return -1; /* name not found */
68}
69
70
71void luaO_insertlist (GCnode *root, GCnode *node) 60void luaO_insertlist (GCnode *root, GCnode *node)
72{ 61{
73 node->next = root->next; 62 node->next = root->next;
diff --git a/lobject.h b/lobject.h
index c2fa373a..18cf2097 100644
--- a/lobject.h
+++ b/lobject.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.h,v 1.19 1998/05/18 22:26:03 roberto Exp roberto $ 2** $Id: lobject.h,v 1.20 1998/06/11 18:21:37 roberto Exp roberto $
3** Type definitions for Lua objects 3** Type definitions for Lua objects
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -196,7 +196,6 @@ extern TObject luaO_nilobject;
196 196
197int luaO_equalObj (TObject *t1, TObject *t2); 197int luaO_equalObj (TObject *t1, TObject *t2);
198int luaO_redimension (int oldsize); 198int luaO_redimension (int oldsize);
199int luaO_findstring (char *name, char *list[]);
200void luaO_insertlist (GCnode *root, GCnode *node); 199void luaO_insertlist (GCnode *root, GCnode *node);
201 200
202#ifdef OLD_ANSI 201#ifdef OLD_ANSI
diff --git a/ltm.c b/ltm.c
index 724fee76..cc290dde 100644
--- a/ltm.c
+++ b/ltm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltm.c,v 1.14 1998/03/09 21:49:52 roberto Exp roberto $ 2** $Id: ltm.c,v 1.15 1998/03/11 13:59:50 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*/
@@ -24,7 +24,7 @@ char *luaT_eventname[] = { /* ORDER IM */
24 24
25static int luaI_checkevent (char *name, char *list[]) 25static int luaI_checkevent (char *name, char *list[])
26{ 26{
27 int e = luaO_findstring(name, list); 27 int e = luaL_findstring(name, list);
28 if (e < 0) 28 if (e < 0)
29 luaL_verror("`%.50s' is not a valid event name", name); 29 luaL_verror("`%.50s' is not a valid event name", name);
30 return e; 30 return e;
@@ -214,7 +214,7 @@ void luaT_setfallback (void)
214 char *name = luaL_check_string(1); 214 char *name = luaL_check_string(1);
215 lua_Object func = lua_getparam(2); 215 lua_Object func = lua_getparam(2);
216 luaL_arg_check(lua_isfunction(func), 2, "function expected"); 216 luaL_arg_check(lua_isfunction(func), 2, "function expected");
217 switch (luaO_findstring(name, oldnames)) { 217 switch (luaL_findstring(name, oldnames)) {
218 case 0: /* old error fallback */ 218 case 0: /* old error fallback */
219 oldfunc = L->errorim; 219 oldfunc = L->errorim;
220 L->errorim = *luaA_Address(func); 220 L->errorim = *luaA_Address(func);
@@ -243,7 +243,7 @@ void luaT_setfallback (void)
243 } 243 }
244 default: { 244 default: {
245 int e; 245 int e;
246 if ((e = luaO_findstring(name, luaT_eventname)) >= 0) { 246 if ((e = luaL_findstring(name, luaT_eventname)) >= 0) {
247 oldfunc = *luaT_getim(LUA_T_NIL, e); 247 oldfunc = *luaT_getim(LUA_T_NIL, e);
248 fillvalids(e, luaA_Address(func)); 248 fillvalids(e, luaA_Address(func));
249 replace = (e == IM_GC || e == IM_INDEX) ? nilFB : typeFB; 249 replace = (e == IM_GC || e == IM_INDEX) ? nilFB : typeFB;