handle non-existent file

This commit is contained in:
Kartik K. Agaram 2021-12-11 14:01:34 -08:00
parent d25c37f86b
commit 5c68906303
1 changed files with 5 additions and 1 deletions

View File

@ -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;