From dd91d6c72625cc7ed2ec5954a5cbca35fd7655d4 Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Thu, 21 Jan 2021 11:50:51 -0500 Subject: split file selector into its own thing --- ted-base.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'ted-base.c') diff --git a/ted-base.c b/ted-base.c index 2eac197..c3aff0e 100644 --- a/ted-base.c +++ b/ted-base.c @@ -86,17 +86,15 @@ static void ted_load_font(Ted *ted) { } } -// returns buffer of new file -static TextBuffer *ted_open_file(Ted *ted, char const *filename) { +// returns buffer of new file, or NULL on failure +static WarnUnusedResult TextBuffer *ted_open_file(Ted *ted, char const *filename) { TextBuffer *open_to = &ted->main_buffer; - buffer_load_file(open_to, filename); - if (buffer_haserr(open_to)) { - // @TODO: something - ted_seterr_to_buferr(ted, open_to); - return NULL; - } else { + if (buffer_load_file(open_to, filename)) { ted->active_buffer = open_to; return open_to; + } else { + ted_seterr_to_buferr(ted, open_to); + return NULL; } } -- cgit v1.2.3