get build working on Windows following cd9f145d
The code prior to cd9f145d would have returned 0 on an argc other
than 2 or 3 so this just does the same.
This commit is contained in:
55
src/nhlua.c
55
src/nhlua.c
@@ -1519,34 +1519,35 @@ nhl_callback(lua_State *L)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc == 2) {
|
if (argc == 2 || argc == 3) {
|
||||||
rm = FALSE;
|
if (argc == 2) {
|
||||||
fn = luaL_checkstring(L, -1);
|
rm = FALSE;
|
||||||
cb = luaL_checkstring(L, -2);
|
fn = luaL_checkstring(L, -1);
|
||||||
} else if (argc == 3) {
|
cb = luaL_checkstring(L, -2);
|
||||||
rm = lua_toboolean(L, -1);
|
} else {
|
||||||
fn = luaL_checkstring(L, -2);
|
rm = lua_toboolean(L, -1);
|
||||||
cb = luaL_checkstring(L, -3);
|
fn = luaL_checkstring(L, -2);
|
||||||
|
cb = luaL_checkstring(L, -3);
|
||||||
|
}
|
||||||
|
for (i = 0; i < NUM_NHCB; i++)
|
||||||
|
if (!strcmp(cb, nhcb_name[i]))
|
||||||
|
break;
|
||||||
|
if (i >= NUM_NHCB)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (rm) {
|
||||||
|
nhcb_counts[i]--;
|
||||||
|
if (nhcb_counts[i] < 0)
|
||||||
|
impossible("nh.callback counts are wrong");
|
||||||
|
} else {
|
||||||
|
nhcb_counts[i]++;
|
||||||
|
}
|
||||||
|
|
||||||
|
lua_getglobal(gl.luacore, rm ? "nh_callback_rm" : "nh_callback_set");
|
||||||
|
lua_pushstring(gl.luacore, cb);
|
||||||
|
lua_pushstring(gl.luacore, fn);
|
||||||
|
nhl_pcall(gl.luacore, 2, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < NUM_NHCB; i++)
|
|
||||||
if (!strcmp(cb, nhcb_name[i]))
|
|
||||||
break;
|
|
||||||
if (i >= NUM_NHCB)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (rm) {
|
|
||||||
nhcb_counts[i]--;
|
|
||||||
if (nhcb_counts[i] < 0)
|
|
||||||
impossible("nh.callback counts are wrong");
|
|
||||||
} else {
|
|
||||||
nhcb_counts[i]++;
|
|
||||||
}
|
|
||||||
|
|
||||||
lua_getglobal(gl.luacore, rm ? "nh_callback_rm" : "nh_callback_set");
|
|
||||||
lua_pushstring(gl.luacore, cb);
|
|
||||||
lua_pushstring(gl.luacore, fn);
|
|
||||||
nhl_pcall(gl.luacore, 2, 0);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user