diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2014-09-12 14:18:22 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2014-09-12 14:18:22 +0200 |
| commit | 0ca2d7ab6883abadb244a452525d59ce6d324f82 (patch) | |
| tree | a0d12b750566b0c739ede0e6030ef645df574d53 /text.c | |
| parent | 50813b0e99321ba5c60ea4bc8c16d19519801446 (diff) | |
| download | vis-0ca2d7ab6883abadb244a452525d59ce6d324f82.tar.gz vis-0ca2d7ab6883abadb244a452525d59ce6d324f82.tar.xz | |
Introduce text_filename_set
This can be used to associate a given filename to a currently unnamed
text.
Diffstat (limited to 'text.c')
| -rw-r--r-- | text.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -617,7 +617,7 @@ int text_save(Text *txt, const char *filename) { txt->saved_action = txt->undo; text_snapshot(txt); if (!txt->filename) - txt->filename = strdup(filename); + text_filename_set(txt, filename); return 0; err: close(fd); @@ -637,7 +637,7 @@ Text *text_load(const char *filename) { piece_init(&txt->end, &txt->begin, NULL, NULL, 0); lineno_cache_invalidate(&txt->lines); if (filename) { - txt->filename = strdup(filename); + text_filename_set(txt, filename); txt->fd = open(filename, O_RDONLY); if (txt->fd == -1) goto out; @@ -1053,6 +1053,10 @@ const char *text_filename_get(Text *txt) { return txt->filename; } +void text_filename_set(Text *txt, const char *filename) { + txt->filename = strdup(filename); +} + Regex *text_regex_new(void) { Regex *r = calloc(1, sizeof(Regex)); if (!r) |
