diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1998-06-18 13:57:03 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1998-06-18 13:57:03 -0300 |
| commit | c9902be294f5c2dca8a67a67fd324f91e4352c0a (patch) | |
| tree | 3f3ef43d231334ee60c13bf310f7995845e97cab | |
| parent | 112c9d53ab47e77fd09d4ecb9b11d432ed906c88 (diff) | |
| download | lua-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.c | 11 | ||||
| -rw-r--r-- | lauxlib.h | 3 | ||||
| -rw-r--r-- | llex.c | 6 | ||||
| -rw-r--r-- | lobject.c | 13 | ||||
| -rw-r--r-- | lobject.h | 3 | ||||
| -rw-r--r-- | ltm.c | 8 |
6 files changed, 21 insertions, 23 deletions
| @@ -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 | ||
| 22 | int 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 | |||
| 21 | void luaL_argerror (int numarg, char *extramsg) | 30 | void luaL_argerror (int numarg, char *extramsg) |
| 22 | { | 31 | { |
| 23 | char *funcname; | 32 | char *funcname; |
| @@ -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); | |||
| 41 | int luaL_newbuffer (int size); | 41 | int luaL_newbuffer (int size); |
| 42 | void luaL_oldbuffer (int old); | 42 | void luaL_oldbuffer (int old); |
| 43 | char *luaL_buffer (void); | 43 | char *luaL_buffer (void); |
| 44 | int luaL_findstring (char *name, char *list[]); | ||
| 44 | 45 | ||
| 45 | 46 | ||
| 46 | #endif | 47 | #endif |
| @@ -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) | |||
| 118 | static int checkcond (LexState *LS, char *buff) | 118 | static 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; |
| @@ -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 | ||
| 61 | int 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 | |||
| 71 | void luaO_insertlist (GCnode *root, GCnode *node) | 60 | void luaO_insertlist (GCnode *root, GCnode *node) |
| 72 | { | 61 | { |
| 73 | node->next = root->next; | 62 | node->next = root->next; |
| @@ -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 | ||
| 197 | int luaO_equalObj (TObject *t1, TObject *t2); | 197 | int luaO_equalObj (TObject *t1, TObject *t2); |
| 198 | int luaO_redimension (int oldsize); | 198 | int luaO_redimension (int oldsize); |
| 199 | int luaO_findstring (char *name, char *list[]); | ||
| 200 | void luaO_insertlist (GCnode *root, GCnode *node); | 199 | void luaO_insertlist (GCnode *root, GCnode *node); |
| 201 | 200 | ||
| 202 | #ifdef OLD_ANSI | 201 | #ifdef OLD_ANSI |
| @@ -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 | ||
| 25 | static int luaI_checkevent (char *name, char *list[]) | 25 | static 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; |
