diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-01-28 22:06:18 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-01-28 22:06:18 +0100 |
| commit | 5f3ad60675c5962e1fb003105ceaeed17a622ed3 (patch) | |
| tree | 3a7facede84ac9498c26ab986d9189db99deab2c /vis.c | |
| parent | 5dad27d80e537fce2e93a01242f6f7e63e113aec (diff) | |
| download | vis-5f3ad60675c5962e1fb003105ceaeed17a622ed3.tar.gz vis-5f3ad60675c5962e1fb003105ceaeed17a622ed3.tar.xz | |
vis: factor out common code to create internal file
Diffstat (limited to 'vis.c')
| -rw-r--r-- | vis.c | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -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; |
