diff --git a/deps/rcheevos/CHANGELOG.md b/deps/rcheevos/CHANGELOG.md index c65c4945eb..8d5a48ea9e 100644 --- a/deps/rcheevos/CHANGELOG.md +++ b/deps/rcheevos/CHANGELOG.md @@ -1,3 +1,13 @@ +# v7.0.2 + +* Make sure the code is C89-compliant +* Use 32-bit types in Lua +* Only evaluate Lua operands when the Lua state is not `NULL` + +# v7.0.1 + +* Fix the alignment of memory allocations + # v7.0.0 * Removed **rjson** diff --git a/deps/rcheevos/src/rcheevos/operand.c b/deps/rcheevos/src/rcheevos/operand.c index a1d96733ce..bbf53fdc19 100644 --- a/deps/rcheevos/src/rcheevos/operand.c +++ b/deps/rcheevos/src/rcheevos/operand.c @@ -319,27 +319,27 @@ unsigned rc_evaluate_operand(rc_operand_t* self, rc_peek_t peek, void* ud, lua_S return 0; case RC_OPERAND_LUA: - lua_rawgeti(L, LUA_REGISTRYINDEX, self->function_ref); - lua_pushcfunction(L, rc_luapeek); + if (L != 0) { + lua_rawgeti(L, LUA_REGISTRYINDEX, self->function_ref); + lua_pushcfunction(L, rc_luapeek); - luapeek.peek = peek; - luapeek.ud = ud; + luapeek.peek = peek; + luapeek.ud = ud; - lua_pushlightuserdata(L, &luapeek); - - if (lua_pcall(L, 2, 1, 0) == LUA_OK) { - if (lua_isboolean(L, -1)) { - value = lua_toboolean(L, -1); + lua_pushlightuserdata(L, &luapeek); + + if (lua_pcall(L, 2, 1, 0) == LUA_OK) { + if (lua_isboolean(L, -1)) { + value = lua_toboolean(L, -1); + } + else { + value = (unsigned)lua_tonumber(L, -1); + } } - else { - value = (unsigned)lua_tonumber(L, -1); - } - } - else { - value = 0; + + lua_pop(L, 1); } - lua_pop(L, 1); break; case RC_OPERAND_ADDRESS: diff --git a/deps/rcheevos/test/Makefile b/deps/rcheevos/test/Makefile index d8dafce6ec..b83fa786b6 100644 --- a/deps/rcheevos/test/Makefile +++ b/deps/rcheevos/test/Makefile @@ -19,7 +19,7 @@ OBJ=$(RC_SRC)/trigger.o $(RC_SRC)/condset.o $(RC_SRC)/condition.o $(RC_SRC)/oper all: test %.o: %.c - gcc -Wall -O0 -g -I../include -I$(RC_SRC) -I$(LUA_SRC) -c $< -o $@ + gcc -Wall -O0 -g -std=c89 -ansi -Wno-long-long -DLUA_32BITS -I../include -I$(RC_SRC) -I$(LUA_SRC) -c $< -o $@ test: $(OBJ) gcc -o $@ $+ -lm