aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2014-09-12 14:19:11 +0200
committerMarc André Tanner <mat@brain-dump.org>2014-09-12 14:19:11 +0200
commit7e0a214aae6bb7e91c2711f9e90db5fe146dd9d7 (patch)
treed65f35cffadeaae998477c8171a3ec28679f1fda
parent0ca2d7ab6883abadb244a452525d59ce6d324f82 (diff)
downloadvis-7e0a214aae6bb7e91c2711f9e90db5fe146dd9d7.tar.gz
vis-7e0a214aae6bb7e91c2711f9e90db5fe146dd9d7.tar.xz
Fix loading of not yet existing files
-rw-r--r--editor.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/editor.c b/editor.c
index b3fd1de..bc3cbaa 100644
--- a/editor.c
+++ b/editor.c
@@ -1,6 +1,7 @@
#define _BSD_SOURCE
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "editor.h"
#include "util.h"
@@ -305,9 +306,11 @@ static EditorWin *editor_window_new_text(Editor *ed, Text *text) {
}
bool editor_window_new(Editor *ed, const char *filename) {
- Text *text = text_load(filename);
+ Text *text = text_load(filename && access(filename, R_OK) == 0 ? filename : NULL);
if (!text)
return false;
+ if (filename)
+ text_filename_set(text, filename);
EditorWin *win = editor_window_new_text(ed, text);
if (!win) {