瀏覽代碼

avoid the identifier `index' (clashes with BSD `index' function)

Roberto Ierusalimschy 22 年之前
父節點
當前提交
e1a424e8a3
共有 4 個文件被更改,包括 98 次插入98 次删除
  1. 79 79
      lapi.c
  2. 5 5
      lcode.c
  3. 9 9
      ltests.c
  4. 5 5
      lvm.c

+ 79 - 79
lapi.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lapi.c,v 1.230 2003/02/20 19:33:23 roberto Exp roberto $
+** $Id: lapi.c,v 1.231 2003/02/24 16:54:20 roberto Exp roberto $
 ** Lua API
 ** Lua API
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -45,43 +45,43 @@ const char lua_ident[] =
 
 
 
 
 
 
-static TObject *negindex (lua_State *L, int index) {
-  if (index > LUA_REGISTRYINDEX) {
-    api_check(L, index != 0 && -index <= L->top - L->base);
-    return L->top+index;
+static TObject *negindex (lua_State *L, int idx) {
+  if (idx > LUA_REGISTRYINDEX) {
+    api_check(L, idx != 0 && -idx <= L->top - L->base);
+    return L->top+idx;
   }
   }
-  else switch (index) {  /* pseudo-indices */
+  else switch (idx) {  /* pseudo-indices */
     case LUA_REGISTRYINDEX: return registry(L);
     case LUA_REGISTRYINDEX: return registry(L);
     case LUA_GLOBALSINDEX: return gt(L);
     case LUA_GLOBALSINDEX: return gt(L);
     default: {
     default: {
       TObject *func = (L->base - 1);
       TObject *func = (L->base - 1);
-      index = LUA_GLOBALSINDEX - index;
-      api_check(L, iscfunction(func) && index <= clvalue(func)->c.nupvalues);
-      return &clvalue(func)->c.upvalue[index-1];
+      idx = LUA_GLOBALSINDEX - idx;
+      api_check(L, iscfunction(func) && idx <= clvalue(func)->c.nupvalues);
+      return &clvalue(func)->c.upvalue[idx-1];
     }
     }
   }
   }
 }
 }
 
 
 
 
-static TObject *luaA_index (lua_State *L, int index) {
-  if (index > 0) {
-    api_check(L, index <= L->top - L->base);
-    return L->base + index - 1;
+static TObject *luaA_index (lua_State *L, int idx) {
+  if (idx > 0) {
+    api_check(L, idx <= L->top - L->base);
+    return L->base + idx - 1;
   }
   }
   else
   else
-    return negindex(L, index);
+    return negindex(L, idx);
 }
 }
 
 
 
 
-static TObject *luaA_indexAcceptable (lua_State *L, int index) {
-  if (index > 0) {
-    TObject *o = L->base+(index-1);
-    api_check(L, index <= L->stack_last - L->base);
+static TObject *luaA_indexAcceptable (lua_State *L, int idx) {
+  if (idx > 0) {
+    TObject *o = L->base+(idx-1);
+    api_check(L, idx <= L->stack_last - L->base);
     if (o >= L->top) return NULL;
     if (o >= L->top) return NULL;
     else return o;
     else return o;
   }
   }
   else
   else
-    return negindex(L, index);
+    return negindex(L, idx);
 }
 }
 
 
 
 
@@ -154,55 +154,55 @@ LUA_API int lua_gettop (lua_State *L) {
 }
 }
 
 
 
 
-LUA_API void lua_settop (lua_State *L, int index) {
+LUA_API void lua_settop (lua_State *L, int idx) {
   lua_lock(L);
   lua_lock(L);
-  if (index >= 0) {
-    api_check(L, index <= L->stack_last - L->base);
-    while (L->top < L->base + index)
+  if (idx >= 0) {
+    api_check(L, idx <= L->stack_last - L->base);
+    while (L->top < L->base + idx)
       setnilvalue(L->top++);
       setnilvalue(L->top++);
-    L->top = L->base + index;
+    L->top = L->base + idx;
   }
   }
   else {
   else {
-    api_check(L, -(index+1) <= (L->top - L->base));
-    L->top += index+1;  /* `subtract' index (index is negative) */
+    api_check(L, -(idx+1) <= (L->top - L->base));
+    L->top += idx+1;  /* `subtract' index (index is negative) */
   }
   }
   lua_unlock(L);
   lua_unlock(L);
 }
 }
 
 
 
 
-LUA_API void lua_remove (lua_State *L, int index) {
+LUA_API void lua_remove (lua_State *L, int idx) {
   StkId p;
   StkId p;
   lua_lock(L);
   lua_lock(L);
-  p = luaA_index(L, index);
+  p = luaA_index(L, idx);
   while (++p < L->top) setobjs2s(p-1, p);
   while (++p < L->top) setobjs2s(p-1, p);
   L->top--;
   L->top--;
   lua_unlock(L);
   lua_unlock(L);
 }
 }
 
 
 
 
-LUA_API void lua_insert (lua_State *L, int index) {
+LUA_API void lua_insert (lua_State *L, int idx) {
   StkId p;
   StkId p;
   StkId q;
   StkId q;
   lua_lock(L);
   lua_lock(L);
-  p = luaA_index(L, index);
+  p = luaA_index(L, idx);
   for (q = L->top; q>p; q--) setobjs2s(q, q-1);
   for (q = L->top; q>p; q--) setobjs2s(q, q-1);
   setobjs2s(p, L->top);
   setobjs2s(p, L->top);
   lua_unlock(L);
   lua_unlock(L);
 }
 }
 
 
 
 
-LUA_API void lua_replace (lua_State *L, int index) {
+LUA_API void lua_replace (lua_State *L, int idx) {
   lua_lock(L);
   lua_lock(L);
   api_checknelems(L, 1);
   api_checknelems(L, 1);
-  setobj(luaA_index(L, index), L->top - 1);  /* write barrier */
+  setobj(luaA_index(L, idx), L->top - 1);  /* write barrier */
   L->top--;
   L->top--;
   lua_unlock(L);
   lua_unlock(L);
 }
 }
 
 
 
 
-LUA_API void lua_pushvalue (lua_State *L, int index) {
+LUA_API void lua_pushvalue (lua_State *L, int idx) {
   lua_lock(L);
   lua_lock(L);
-  setobj2s(L->top, luaA_index(L, index));
+  setobj2s(L->top, luaA_index(L, idx));
   api_incr_top(L);
   api_incr_top(L);
   lua_unlock(L);
   lua_unlock(L);
 }
 }
@@ -214,8 +214,8 @@ LUA_API void lua_pushvalue (lua_State *L, int index) {
 */
 */
 
 
 
 
-LUA_API int lua_type (lua_State *L, int index) {
-  StkId o = luaA_indexAcceptable(L, index);
+LUA_API int lua_type (lua_State *L, int idx) {
+  StkId o = luaA_indexAcceptable(L, idx);
   return (o == NULL) ? LUA_TNONE : ttype(o);
   return (o == NULL) ? LUA_TNONE : ttype(o);
 }
 }
 
 
@@ -226,27 +226,27 @@ LUA_API const char *lua_typename (lua_State *L, int t) {
 }
 }
 
 
 
 
-LUA_API int lua_iscfunction (lua_State *L, int index) {
-  StkId o = luaA_indexAcceptable(L, index);
+LUA_API int lua_iscfunction (lua_State *L, int idx) {
+  StkId o = luaA_indexAcceptable(L, idx);
   return (o == NULL) ? 0 : iscfunction(o);
   return (o == NULL) ? 0 : iscfunction(o);
 }
 }
 
 
 
 
-LUA_API int lua_isnumber (lua_State *L, int index) {
+LUA_API int lua_isnumber (lua_State *L, int idx) {
   TObject n;
   TObject n;
-  const TObject *o = luaA_indexAcceptable(L, index);
+  const TObject *o = luaA_indexAcceptable(L, idx);
   return (o != NULL && tonumber(o, &n));
   return (o != NULL && tonumber(o, &n));
 }
 }
 
 
 
 
-LUA_API int lua_isstring (lua_State *L, int index) {
-  int t = lua_type(L, index);
+LUA_API int lua_isstring (lua_State *L, int idx) {
+  int t = lua_type(L, idx);
   return (t == LUA_TSTRING || t == LUA_TNUMBER);
   return (t == LUA_TSTRING || t == LUA_TNUMBER);
 }
 }
 
 
 
 
-LUA_API int lua_isuserdata (lua_State *L, int index) {
-  const TObject *o = luaA_indexAcceptable(L, index);
+LUA_API int lua_isuserdata (lua_State *L, int idx) {
+  const TObject *o = luaA_indexAcceptable(L, idx);
   return (o != NULL && (ttisuserdata(o) || ttislightuserdata(o)));
   return (o != NULL && (ttisuserdata(o) || ttislightuserdata(o)));
 }
 }
 
 
@@ -286,9 +286,9 @@ LUA_API int lua_lessthan (lua_State *L, int index1, int index2) {
 
 
 
 
 
 
-LUA_API lua_Number lua_tonumber (lua_State *L, int index) {
+LUA_API lua_Number lua_tonumber (lua_State *L, int idx) {
   TObject n;
   TObject n;
-  const TObject *o = luaA_indexAcceptable(L, index);
+  const TObject *o = luaA_indexAcceptable(L, idx);
   if (o != NULL && tonumber(o, &n))
   if (o != NULL && tonumber(o, &n))
     return nvalue(o);
     return nvalue(o);
   else
   else
@@ -296,14 +296,14 @@ LUA_API lua_Number lua_tonumber (lua_State *L, int index) {
 }
 }
 
 
 
 
-LUA_API int lua_toboolean (lua_State *L, int index) {
-  const TObject *o = luaA_indexAcceptable(L, index);
+LUA_API int lua_toboolean (lua_State *L, int idx) {
+  const TObject *o = luaA_indexAcceptable(L, idx);
   return (o != NULL) && !l_isfalse(o);
   return (o != NULL) && !l_isfalse(o);
 }
 }
 
 
 
 
-LUA_API const char *lua_tostring (lua_State *L, int index) {
-  StkId o = luaA_indexAcceptable(L, index);
+LUA_API const char *lua_tostring (lua_State *L, int idx) {
+  StkId o = luaA_indexAcceptable(L, idx);
   if (o == NULL)
   if (o == NULL)
     return NULL;
     return NULL;
   else if (ttisstring(o))
   else if (ttisstring(o))
@@ -319,8 +319,8 @@ LUA_API const char *lua_tostring (lua_State *L, int index) {
 }
 }
 
 
 
 
-LUA_API size_t lua_strlen (lua_State *L, int index) {
-  StkId o = luaA_indexAcceptable(L, index);
+LUA_API size_t lua_strlen (lua_State *L, int idx) {
+  StkId o = luaA_indexAcceptable(L, idx);
   if (o == NULL)
   if (o == NULL)
     return 0;
     return 0;
   else if (ttisstring(o))
   else if (ttisstring(o))
@@ -335,14 +335,14 @@ LUA_API size_t lua_strlen (lua_State *L, int index) {
 }
 }
 
 
 
 
-LUA_API lua_CFunction lua_tocfunction (lua_State *L, int index) {
-  StkId o = luaA_indexAcceptable(L, index);
+LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) {
+  StkId o = luaA_indexAcceptable(L, idx);
   return (o == NULL || !iscfunction(o)) ? NULL : clvalue(o)->c.f;
   return (o == NULL || !iscfunction(o)) ? NULL : clvalue(o)->c.f;
 }
 }
 
 
 
 
-LUA_API void *lua_touserdata (lua_State *L, int index) {
-  StkId o = luaA_indexAcceptable(L, index);
+LUA_API void *lua_touserdata (lua_State *L, int idx) {
+  StkId o = luaA_indexAcceptable(L, idx);
   if (o == NULL) return NULL;
   if (o == NULL) return NULL;
   switch (ttype(o)) {
   switch (ttype(o)) {
     case LUA_TUSERDATA: return (uvalue(o) + 1);
     case LUA_TUSERDATA: return (uvalue(o) + 1);
@@ -352,14 +352,14 @@ LUA_API void *lua_touserdata (lua_State *L, int index) {
 }
 }
 
 
 
 
-LUA_API lua_State *lua_tothread (lua_State *L, int index) {
-  StkId o = luaA_indexAcceptable(L, index);
+LUA_API lua_State *lua_tothread (lua_State *L, int idx) {
+  StkId o = luaA_indexAcceptable(L, idx);
   return (o == NULL || !ttisthread(o)) ? NULL : thvalue(o);
   return (o == NULL || !ttisthread(o)) ? NULL : thvalue(o);
 }
 }
 
 
 
 
-LUA_API const void *lua_topointer (lua_State *L, int index) {
-  StkId o = luaA_indexAcceptable(L, index);
+LUA_API const void *lua_topointer (lua_State *L, int idx) {
+  StkId o = luaA_indexAcceptable(L, idx);
   if (o == NULL) return NULL;
   if (o == NULL) return NULL;
   else {
   else {
     switch (ttype(o)) {
     switch (ttype(o)) {
@@ -367,7 +367,7 @@ LUA_API const void *lua_topointer (lua_State *L, int index) {
       case LUA_TFUNCTION: return clvalue(o);
       case LUA_TFUNCTION: return clvalue(o);
       case LUA_TUSERDATA:
       case LUA_TUSERDATA:
       case LUA_TLIGHTUSERDATA:
       case LUA_TLIGHTUSERDATA:
-        return lua_touserdata(L, index);
+        return lua_touserdata(L, idx);
       default: return NULL;
       default: return NULL;
     }
     }
   }
   }
@@ -475,29 +475,29 @@ LUA_API void lua_pushlightuserdata (lua_State *L, void *p) {
 */
 */
 
 
 
 
-LUA_API void lua_gettable (lua_State *L, int index) {
+LUA_API void lua_gettable (lua_State *L, int idx) {
   StkId t;
   StkId t;
   lua_lock(L);
   lua_lock(L);
-  t = luaA_index(L, index);
+  t = luaA_index(L, idx);
   setobj2s(L->top - 1, luaV_gettable(L, t, L->top - 1, 0));
   setobj2s(L->top - 1, luaV_gettable(L, t, L->top - 1, 0));
   lua_unlock(L);
   lua_unlock(L);
 }
 }
 
 
 
 
-LUA_API void lua_rawget (lua_State *L, int index) {
+LUA_API void lua_rawget (lua_State *L, int idx) {
   StkId t;
   StkId t;
   lua_lock(L);
   lua_lock(L);
-  t = luaA_index(L, index);
+  t = luaA_index(L, idx);
   api_check(L, ttistable(t));
   api_check(L, ttistable(t));
   setobj2s(L->top - 1, luaH_get(hvalue(t), L->top - 1));
   setobj2s(L->top - 1, luaH_get(hvalue(t), L->top - 1));
   lua_unlock(L);
   lua_unlock(L);
 }
 }
 
 
 
 
-LUA_API void lua_rawgeti (lua_State *L, int index, int n) {
+LUA_API void lua_rawgeti (lua_State *L, int idx, int n) {
   StkId o;
   StkId o;
   lua_lock(L);
   lua_lock(L);
-  o = luaA_index(L, index);
+  o = luaA_index(L, idx);
   api_check(L, ttistable(o));
   api_check(L, ttistable(o));
   setobj2s(L->top, luaH_getnum(hvalue(o), n));
   setobj2s(L->top, luaH_getnum(hvalue(o), n));
   api_incr_top(L);
   api_incr_top(L);
@@ -542,10 +542,10 @@ LUA_API int lua_getmetatable (lua_State *L, int objindex) {
 }
 }
 
 
 
 
-LUA_API void lua_getfenv (lua_State *L, int index) {
+LUA_API void lua_getfenv (lua_State *L, int idx) {
   StkId o;
   StkId o;
   lua_lock(L);
   lua_lock(L);
-  o = luaA_index(L, index);
+  o = luaA_index(L, idx);
   setobj2s(L->top, isLfunction(o) ? &clvalue(o)->l.g : gt(L));
   setobj2s(L->top, isLfunction(o) ? &clvalue(o)->l.g : gt(L));
   api_incr_top(L);
   api_incr_top(L);
   lua_unlock(L);
   lua_unlock(L);
@@ -557,22 +557,22 @@ LUA_API void lua_getfenv (lua_State *L, int index) {
 */
 */
 
 
 
 
-LUA_API void lua_settable (lua_State *L, int index) {
+LUA_API void lua_settable (lua_State *L, int idx) {
   StkId t;
   StkId t;
   lua_lock(L);
   lua_lock(L);
   api_checknelems(L, 2);
   api_checknelems(L, 2);
-  t = luaA_index(L, index);
+  t = luaA_index(L, idx);
   luaV_settable(L, t, L->top - 2, L->top - 1);
   luaV_settable(L, t, L->top - 2, L->top - 1);
   L->top -= 2;  /* pop index and value */
   L->top -= 2;  /* pop index and value */
   lua_unlock(L);
   lua_unlock(L);
 }
 }
 
 
 
 
-LUA_API void lua_rawset (lua_State *L, int index) {
+LUA_API void lua_rawset (lua_State *L, int idx) {
   StkId t;
   StkId t;
   lua_lock(L);
   lua_lock(L);
   api_checknelems(L, 2);
   api_checknelems(L, 2);
-  t = luaA_index(L, index);
+  t = luaA_index(L, idx);
   api_check(L, ttistable(t));
   api_check(L, ttistable(t));
   setobj2t(luaH_set(L, hvalue(t), L->top-2), L->top-1);  /* write barrier */
   setobj2t(luaH_set(L, hvalue(t), L->top-2), L->top-1);  /* write barrier */
   L->top -= 2;
   L->top -= 2;
@@ -580,11 +580,11 @@ LUA_API void lua_rawset (lua_State *L, int index) {
 }
 }
 
 
 
 
-LUA_API void lua_rawseti (lua_State *L, int index, int n) {
+LUA_API void lua_rawseti (lua_State *L, int idx, int n) {
   StkId o;
   StkId o;
   lua_lock(L);
   lua_lock(L);
   api_checknelems(L, 1);
   api_checknelems(L, 1);
-  o = luaA_index(L, index);
+  o = luaA_index(L, idx);
   api_check(L, ttistable(o));
   api_check(L, ttistable(o));
   setobj2t(luaH_setnum(L, hvalue(o), n), L->top-1);  /* write barrier */
   setobj2t(luaH_setnum(L, hvalue(o), n), L->top-1);  /* write barrier */
   L->top--;
   L->top--;
@@ -620,12 +620,12 @@ LUA_API int lua_setmetatable (lua_State *L, int objindex) {
 }
 }
 
 
 
 
-LUA_API int lua_setfenv (lua_State *L, int index) {
+LUA_API int lua_setfenv (lua_State *L, int idx) {
   StkId o;
   StkId o;
   int res = 0;
   int res = 0;
   lua_lock(L);
   lua_lock(L);
   api_checknelems(L, 1);
   api_checknelems(L, 1);
-  o = luaA_index(L, index);
+  o = luaA_index(L, idx);
   L->top--;
   L->top--;
   api_check(L, ttistable(L->top));
   api_check(L, ttistable(L->top));
   if (isLfunction(o)) {
   if (isLfunction(o)) {
@@ -803,11 +803,11 @@ LUA_API int lua_error (lua_State *L) {
 }
 }
 
 
 
 
-LUA_API int lua_next (lua_State *L, int index) {
+LUA_API int lua_next (lua_State *L, int idx) {
   StkId t;
   StkId t;
   int more;
   int more;
   lua_lock(L);
   lua_lock(L);
-  t = luaA_index(L, index);
+  t = luaA_index(L, idx);
   api_check(L, ttistable(t));
   api_check(L, ttistable(t));
   more = luaH_next(L, hvalue(t), L->top - 1);
   more = luaH_next(L, hvalue(t), L->top - 1);
   if (more) {
   if (more) {

+ 5 - 5
lcode.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lcode.c,v 1.114 2002/12/04 17:38:31 roberto Exp roberto $
+** $Id: lcode.c,v 1.115 2002/12/11 12:34:22 roberto Exp roberto $
 ** Code generator for Lua
 ** Code generator for Lua
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -207,10 +207,10 @@ static void freeexp (FuncState *fs, expdesc *e) {
 
 
 
 
 static int addk (FuncState *fs, TObject *k, TObject *v) {
 static int addk (FuncState *fs, TObject *k, TObject *v) {
-  const TObject *index = luaH_get(fs->h, k);
-  if (ttisnumber(index)) {
-    lua_assert(luaO_rawequalObj(&fs->f->k[cast(int, nvalue(index))], v));
-    return cast(int, nvalue(index));
+  const TObject *idx = luaH_get(fs->h, k);
+  if (ttisnumber(idx)) {
+    lua_assert(luaO_rawequalObj(&fs->f->k[cast(int, nvalue(idx))], v));
+    return cast(int, nvalue(idx));
   }
   }
   else {  /* constant not found; create a new entry */
   else {  /* constant not found; create a new entry */
     Proto *f = fs->f;
     Proto *f = fs->f;

+ 9 - 9
ltests.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: ltests.c,v 1.152 2003/02/10 17:31:13 roberto Exp roberto $
+** $Id: ltests.c,v 1.153 2003/02/18 16:02:56 roberto Exp roberto $
 ** Internal Module for Debugging of the Lua Implementation
 ** Internal Module for Debugging of the Lua Implementation
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -41,7 +41,7 @@ static lua_State *lua_state = NULL;
 int islocked = 0;
 int islocked = 0;
 
 
 
 
-#define index(L,k)	(L->ci->base+(k) - 1)
+#define func_at(L,k)	(L->ci->base+(k) - 1)
 
 
 
 
 static void setnameval (lua_State *L, const char *name, int val) {
 static void setnameval (lua_State *L, const char *name, int val) {
@@ -190,7 +190,7 @@ static int listcode (lua_State *L) {
   Proto *p;
   Proto *p;
   luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1),
   luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1),
                  1, "Lua function expected");
                  1, "Lua function expected");
-  p = clvalue(index(L, 1))->l.p;
+  p = clvalue(func_at(L, 1))->l.p;
   lua_newtable(L);
   lua_newtable(L);
   setnameval(L, "maxstack", p->maxstacksize);
   setnameval(L, "maxstack", p->maxstacksize);
   setnameval(L, "numparams", p->numparams);
   setnameval(L, "numparams", p->numparams);
@@ -209,7 +209,7 @@ static int listk (lua_State *L) {
   int i;
   int i;
   luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1),
   luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1),
                  1, "Lua function expected");
                  1, "Lua function expected");
-  p = clvalue(index(L, 1))->l.p;
+  p = clvalue(func_at(L, 1))->l.p;
   lua_newtable(L);
   lua_newtable(L);
   for (i=0; i<p->sizek; i++) {
   for (i=0; i<p->sizek; i++) {
     lua_pushnumber(L, i+1);
     lua_pushnumber(L, i+1);
@@ -227,7 +227,7 @@ static int listlocals (lua_State *L) {
   const char *name;
   const char *name;
   luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1),
   luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1),
                  1, "Lua function expected");
                  1, "Lua function expected");
-  p = clvalue(index(L, 1))->l.p;
+  p = clvalue(func_at(L, 1))->l.p;
   while ((name = luaF_getlocalname(p, ++i, pc)) != NULL)
   while ((name = luaF_getlocalname(p, ++i, pc)) != NULL)
     lua_pushstring(L, name);
     lua_pushstring(L, name);
   return i-1;
   return i-1;
@@ -267,13 +267,13 @@ static int mem_query (lua_State *L) {
 static int hash_query (lua_State *L) {
 static int hash_query (lua_State *L) {
   if (lua_isnone(L, 2)) {
   if (lua_isnone(L, 2)) {
     luaL_argcheck(L, lua_type(L, 1) == LUA_TSTRING, 1, "string expected");
     luaL_argcheck(L, lua_type(L, 1) == LUA_TSTRING, 1, "string expected");
-    lua_pushnumber(L, tsvalue(index(L, 1))->tsv.hash);
+    lua_pushnumber(L, tsvalue(func_at(L, 1))->tsv.hash);
   }
   }
   else {
   else {
-    TObject *o = index(L, 1);
+    TObject *o = func_at(L, 1);
     Table *t;
     Table *t;
     luaL_checktype(L, 2, LUA_TTABLE);
     luaL_checktype(L, 2, LUA_TTABLE);
-    t = hvalue(index(L, 2));
+    t = hvalue(func_at(L, 2));
     lua_pushnumber(L, luaH_mainposition(t, o) - t->node);
     lua_pushnumber(L, luaH_mainposition(t, o) - t->node);
   }
   }
   return 1;
   return 1;
@@ -295,7 +295,7 @@ static int table_query (lua_State *L) {
   const Table *t;
   const Table *t;
   int i = luaL_optint(L, 2, -1);
   int i = luaL_optint(L, 2, -1);
   luaL_checktype(L, 1, LUA_TTABLE);
   luaL_checktype(L, 1, LUA_TTABLE);
-  t = hvalue(index(L, 1));
+  t = hvalue(func_at(L, 1));
   if (i == -1) {
   if (i == -1) {
     lua_pushnumber(L, t->sizearray);
     lua_pushnumber(L, t->sizearray);
     lua_pushnumber(L, sizenode(t));
     lua_pushnumber(L, sizenode(t));

+ 5 - 5
lvm.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lvm.c,v 1.276 2003/02/18 16:02:56 roberto Exp roberto $
+** $Id: lvm.c,v 1.277 2003/02/27 11:52:30 roberto Exp roberto $
 ** Lua virtual machine
 ** Lua virtual machine
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -680,7 +680,7 @@ StkId luaV_execute (lua_State *L) {
         }
         }
       }
       }
       case OP_FORLOOP: {
       case OP_FORLOOP: {
-        lua_Number step, index, limit;
+        lua_Number step, idx, limit;
         const TObject *plimit = ra+1;
         const TObject *plimit = ra+1;
         const TObject *pstep = ra+2;
         const TObject *pstep = ra+2;
         if (!ttisnumber(ra))
         if (!ttisnumber(ra))
@@ -690,11 +690,11 @@ StkId luaV_execute (lua_State *L) {
         if (!tonumber(pstep, ra+2))
         if (!tonumber(pstep, ra+2))
           luaG_runerror(L, "`for' step must be a number");
           luaG_runerror(L, "`for' step must be a number");
         step = nvalue(pstep);
         step = nvalue(pstep);
-        index = nvalue(ra) + step;  /* increment index */
+        idx = nvalue(ra) + step;  /* increment index */
         limit = nvalue(plimit);
         limit = nvalue(plimit);
-        if (step > 0 ? index <= limit : index >= limit) {
+        if (step > 0 ? idx <= limit : idx >= limit) {
           dojump(pc, GETARG_sBx(i));  /* jump back */
           dojump(pc, GETARG_sBx(i));  /* jump back */
-          chgnvalue(ra, index);  /* update index */
+          chgnvalue(ra, idx);  /* update index */
         }
         }
         break;
         break;
       }
       }