From 9a49b92703e565957d360d6dacc0753019dbf28d Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 10 Nov 2021 22:15:13 -0800 Subject: . --- src/lua.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'src/lua.c') diff --git a/src/lua.c b/src/lua.c index 94a9509..2600f44 100644 --- a/src/lua.c +++ b/src/lua.c @@ -75,29 +75,6 @@ static int report (lua_State *L, int status) { } -/* death and rebirth */ -char *Script_name = NULL; -char **Argv = NULL; -extern void edit(char *filename, const char *status); -void switch_to_editor(const char *message) { - endwin(); - edit(Script_name, message); - execv(Argv[0], Argv); - /* never returns */ -} - - -const char *Previous_error = NULL; -static int show_error_in_editor (lua_State *L, int status) { - if (status && !lua_isnil(L, -1)) { - Previous_error = lua_tostring(L, -1); - if (Previous_error == NULL) Previous_error = "(error object is not a string)"; - switch_to_editor(Previous_error); - } - return status; -} - - static int traceback (lua_State *L) { if (!lua_isstring(L, 1)) /* 'message' not a string? */ return 1; /* keep it intact */ @@ -329,6 +306,29 @@ static int handle_image (lua_State *L, char **argv, int n) { } +/* death and rebirth */ +char *Script_name = NULL; +char **Argv = NULL; +extern void edit(char *filename, const char *status); +void switch_to_editor(const char *message) { + endwin(); + edit(Script_name, message); + execv(Argv[0], Argv); + /* never returns */ +} + + +const char *Previous_error = NULL; +static int show_error_in_editor (lua_State *L, int status) { + if (status && !lua_isnil(L, -1)) { + Previous_error = lua_tostring(L, -1); + if (Previous_error == NULL) Previous_error = "(error object is not a string)"; + switch_to_editor(Previous_error); + } + return status; +} + + static int handle_script (lua_State *L, char **argv, int n) { if (has_extension(argv[n], "tlv")) return handle_image(L, argv, n); -- cgit 1.4.1-2-gfad0