| 167 | } |
| 168 | |
| 169 | static int sort_comp (lua_State *L, int a, int b) { |
| 170 | if (!lua_isnil(L, 2)) { /* function? */ |
| 171 | int res; |
| 172 | lua_pushvalue(L, 2); |
| 173 | lua_pushvalue(L, a-1); /* -1 to compensate function */ |
| 174 | lua_pushvalue(L, b-2); /* -2 to compensate function and `a' */ |
| 175 | lua_call(L, 2, 1); |
| 176 | res = lua_toboolean(L, -1); |
| 177 | lua_pop(L, 1); |
| 178 | return res; |
| 179 | } |
| 180 | else /* a < b? */ |
| 181 | return lua_compare(L, a, b, LUA_OPLT); |
| 182 | } |
| 183 | |
| 184 | static void auxsort (lua_State *L, int l, int u) { |
| 185 | while (l < u) { /* for tail recursion */ |
no test coverage detected