Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/tup/luaparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -815,9 +815,10 @@ int tup_lua_parser_new_state(void)

int parse_lua_include_rules(struct tupfile *tf)
{
int top = lua_gettop(gls);
if(parser_include_rules(tf, "Tuprules.lua") < 0) {
if(tf->luaerror == TUPLUA_PENDINGERROR) {
assert(lua_gettop(gls) == 2);
assert(lua_gettop(gls) == top + 2);
fprintf(tf->f, "tup error %s\n", tuplua_tostring(gls, -1));
lua_pop(gls, 1);
tf->luaerror = TUPLUA_ERRORSHOWN;
Expand All @@ -830,13 +831,14 @@ int parse_lua_include_rules(struct tupfile *tf)
int parse_lua_tupfile(struct tupfile *tf, struct buf *b, const char *name)
{
struct tuplua_reader_data lrd = {b, 0};
int top = lua_gettop(gls);

lua_getfield(gls, LUA_REGISTRYINDEX, "tup_traceback");

if(lua_load(gls, &tuplua_reader, &lrd, name, 0) != LUA_OK) {
fprintf(tf->f, "tup error %s\n", tuplua_tostring(gls, -1));
tf->luaerror = TUPLUA_PENDINGERROR;
assert(lua_gettop(gls) == 2);
assert(lua_gettop(gls) == top + 2);
return -1;
}

Expand All @@ -849,7 +851,7 @@ int parse_lua_tupfile(struct tupfile *tf, struct buf *b, const char *name)
fprintf(tf->f, "tup error %s\n", tuplua_tostring(gls, -1));
tf->luaerror = TUPLUA_ERRORSHOWN;
lua_pop(gls, 2);
assert(lua_gettop(gls) == 0);
assert(lua_gettop(gls) == top);
return -1;
}

Expand Down