about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-11-24 07:53:58 -0800
committerKartik K. Agaram <vc@akkartik.com>2021-11-24 07:54:48 -0800
commitb670747d9e565d76e7becd7b30ba803b8c47b470 (patch)
tree5ef607701e2a9a9ef65b4b70561f225fa4a26a78 /src
parentaff8afa12d062ceb86ef7c1d1d42b960647162cf (diff)
downloadteliva-b670747d9e565d76e7becd7b30ba803b8c47b470.tar.gz
consistent file ops
Now we're down to 1 real warning and 1 false positive.
Diffstat (limited to 'src')
-rw-r--r--src/lua.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/lua.c b/src/lua.c
index 3c97ce5..e983879 100644
--- a/src/lua.c
+++ b/src/lua.c
@@ -318,18 +318,18 @@ void save_to_current_definition_and_editor_buffer (lua_State *L, const char *def
   lua_getfield(L, -1, Current_definition);
   const char *contents = lua_tostring(L, -1);
   lua_pop(L, 1);
-  int outfd = open("teliva_editbuffer", O_WRONLY|O_CREAT|O_TRUNC, 0644);
+  FILE *out = fopen("teliva_editbuffer", "w");
   if (contents != NULL)
-    write(outfd, contents, strlen(contents));
-  close(outfd);
+    fprintf(out, "%s", contents);
+  fclose(out);
   lua_settop(L, 0);
 }
 
 
 static void read_contents (char *filename, char *out) {
-  int infd = open(filename, O_RDONLY);
-  read(infd, out, 8190);  /* TODO: handle overly large file */
-  close(infd);
+  FILE *in = fopen(filename, "r");
+  fread(out, 8190, 1, in);  /* TODO: handle overly large file */
+  fclose(in);
 }