From d72eae59784e8da00c7fe00539b1095e1f8ccaf4 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 11 Nov 2021 17:41:37 -0800 Subject: create empty file when navigating to empty definition --- src/lua.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/lua.c') diff --git a/src/lua.c b/src/lua.c index 9b7cd76..08c5f92 100644 --- a/src/lua.c +++ b/src/lua.c @@ -323,9 +323,9 @@ void write_definition_to_file (lua_State *L, char *name, char *outfilename) { lua_getfield(L, -1, name); const char *contents = lua_tostring(L, -1); lua_pop(L, 1); - if (contents == NULL) return; int outfd = open(outfilename, O_WRONLY|O_CREAT|O_TRUNC, 0644); - write(outfd, contents, strlen(contents)); + if (contents != NULL) + write(outfd, contents, strlen(contents)); close(outfd); } @@ -372,7 +372,7 @@ void switch_to_editor (lua_State *L, const char *message) { else { Current_definition = "main"; write_definition_to_file(L, Current_definition, "teliva_editbuffer"); - edit(L, "teliva_editbuffer", ""); + edit(L, "teliva_editbuffer", /*status message*/ ""); char new_contents[8192] = {0}; read_contents(L, "teliva_editbuffer", new_contents); update_definition(L, Current_definition, new_contents); -- cgit 1.4.1-2-gfad0