| 99 | |
| 100 | |
| 101 | static int countlevels (lua_State *L) { |
| 102 | lua_Debug ar; |
| 103 | int li = 1, le = 1; |
| 104 | /* find an upper bound */ |
| 105 | while (lua_getstack(L, le, &ar)) { li = le; le *= 2; } |
| 106 | /* do a binary search */ |
| 107 | while (li < le) { |
| 108 | int m = (li + le)/2; |
| 109 | if (lua_getstack(L, m, &ar)) li = m + 1; |
| 110 | else le = m; |
| 111 | } |
| 112 | return le - 1; |
| 113 | } |
| 114 | |
| 115 | |
| 116 | LUALIB_API void luaL_traceback (lua_State *L, lua_State *L1, |
no test coverage detected