Roberto Ierusalimschy 23 年之前
父節點
當前提交
c194a46bc5
共有 1 個文件被更改,包括 5 次插入3 次删除
  1. 5 3
      ldebug.c

+ 5 - 3
ldebug.c

@@ -1,5 +1,5 @@
 /*
-** $Id: ldebug.c,v 1.138 2002/11/21 15:16:04 roberto Exp roberto $
+** $Id: ldebug.c,v 1.139 2002/11/25 17:47:13 roberto Exp roberto $
 ** Debug Interface
 ** See Copyright Notice in lua.h
 */
@@ -91,10 +91,12 @@ LUA_API int lua_gethookcount (lua_State *L) {
 
 LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) {
   int status;
+  int ci;
   lua_lock(L);
-  if (L->ci - L->base_ci <= level) status = 0;  /* there is no such level */
+  ci = (L->ci - L->base_ci) - level;
+  if (ci <= 0) status = 0;  /* there is no such level */
   else {
-    ar->i_ci = (L->ci - L->base_ci) - level;
+    ar->i_ci = ci;
     status = 1;
   }
   lua_unlock(L);