about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-12-11 14:01:34 -0800
committerKartik K. Agaram <vc@akkartik.com>2021-12-11 14:01:34 -0800
commit5c689063033d5e078079eba95d9bcd564810c81e (patch)
tree211c7261e66e63f711eea2ebb7163d3a9d21086d
parentd25c37f86b64309618a255c26c6e8647841f675f (diff)
downloadteliva-5c689063033d5e078079eba95d9bcd564810c81e.tar.gz
handle non-existent file
-rw-r--r--src/tlv.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/tlv.c b/src/tlv.c
index 5800418..ed149ee 100644
--- a/src/tlv.c
+++ b/src/tlv.c
@@ -107,10 +107,14 @@ static void teliva_load_definition(lua_State* L, FILE* in) {
 }
 
 void load_tlv(lua_State* L, char* filename) {
-  endwin();
   lua_newtable(L);
   int history_array = lua_gettop(L);
   FILE* in = fopen(filename, "r");
+  if (in == NULL) {
+    endwin();
+    fprintf(stderr, "no such file\n");
+    exit(1);
+  }
   for (int i = 1; !feof(in); ++i) {
     teliva_load_definition(L, in);
     if (lua_isnil(L, -1)) break;