vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 52da02c65651f708abc1fea69bbcb2d1f9791179 parent 2f6b6105be79abeb53cc9d001e0632b30b4549a0 Author: Marc André Tanner <mat@brain-dump.org> Date: Thu, 28 Jan 2016 22:06:18 +0100 vis: factor out common code to create internal file Diffstat:
| M | vis.c | | | 17 | +++++++++++------ |
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/vis.c b/vis.c @@ -112,6 +112,15 @@ static File *file_new(Vis *vis, const char *filename) { return file; } +static File *file_new_internal(Vis *vis, const char *filename) { + File *file = file_new(vis, filename); + if (file) { + file->refcount = 1; + file->internal = true; + } + return file; +} + void vis_window_name(Win *win, const char *filename) { File *file = win->file; if (filename != file->name) { @@ -309,14 +318,10 @@ Vis *vis_new(Ui *ui, VisEvent *event) { action_reset(&vis->action); if (!(vis->search_pattern = text_regex_new())) goto err; - if (!(vis->command_file = file_new(vis, NULL))) + if (!(vis->command_file = file_new_internal(vis, NULL))) goto err; - vis->command_file->refcount = 1; - vis->command_file->internal = true; - if (!(vis->search_file = file_new(vis, NULL))) + if (!(vis->search_file = file_new_internal(vis, NULL))) goto err; - vis->search_file->refcount = 1; - vis->search_file->internal = true; vis->mode_prev = vis->mode = &vis_modes[VIS_MODE_NORMAL]; vis->event = event; return vis;