Commit 22dddc2e authored by Sergey Lyubka's avatar Sergey Lyubka

Merge pull request #124 from abadc0de/lua_err

Lua page error handling cleanup
parents daab5277 aa37b728
...@@ -3978,12 +3978,11 @@ static int lsp(struct mg_connection *conn, const char *path, ...@@ -3978,12 +3978,11 @@ static int lsp(struct mg_connection *conn, const char *path,
if (p[j] == '\n') ++lualines; if (p[j] == '\n') ++lualines;
if (p[j] == '?' && p[j + 1] == '>') { if (p[j] == '?' && p[j + 1] == '>') {
mg_write(conn, p + pos, i - pos); mg_write(conn, p + pos, i - pos);
// lua_settop(L, 0);
lua_pushlightuserdata(L, conn); lua_pushlightuserdata(L, conn);
lua_pushcclosure(L, lsp_mg_error, 1); lua_pushcclosure(L, lsp_mg_error, 1);
snprintf (chunkname, sizeof(chunkname), "@%s+%i", path, lines); snprintf (chunkname, sizeof(chunkname), "@%s+%i", path, lines);
if (luaL_loadbuffer(L, p + (i + 2), j - (i + 2), chunkname)) { if (luaL_loadbuffer(L, p + (i + 2), j - (i + 2), chunkname)) {
lua_pcall(L, 1, 0, 0); lua_pcall(L, 1, 1, 0);
result = lua_tointeger(L, -1); result = lua_tointeger(L, -1);
if (result) return result; if (result) return result;
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment