diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2015-06-28 22:22:42 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2015-06-28 22:22:42 +0200 |
| commit | 82a10e051c593e133554ce9675169fd68bb02ad7 (patch) | |
| tree | 05be44e9b09275cd496bca8f47b285982537614b | |
| parent | df79bac9f06b6888dd269891b6c33ad6a2e02c21 (diff) | |
| download | vis-82a10e051c593e133554ce9675169fd68bb02ad7.tar.gz vis-82a10e051c593e133554ce9675169fd68bb02ad7.tar.xz | |
Do not take address of variables which go out of scope
This is a bit of a hack, since now the callers range
is modified. The various cmd_* functions should probably
take a const Filerange pointer as argument and modify
a local Filerange variable if needed.
| -rw-r--r-- | vis.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -1573,7 +1573,7 @@ static bool cmd_read(Filerange *range, enum CmdOpt opt, const char *argv[]) { size_t pos = view_cursor_get(vis->win->view); if (!text_range_valid(range)) - range = &(Filerange){ .start = pos, .end = pos }; + *range = (Filerange){ .start = pos, .end = pos }; Filerange delete = *range; range->start = range->end; @@ -1586,7 +1586,7 @@ static bool cmd_read(Filerange *range, enum CmdOpt opt, const char *argv[]) { static bool cmd_substitute(Filerange *range, enum CmdOpt opt, const char *argv[]) { char pattern[255]; if (!text_range_valid(range)) - range = &(Filerange){ .start = 0, .end = text_size(vis->win->file->text) }; + *range = (Filerange){ .start = 0, .end = text_size(vis->win->file->text) }; snprintf(pattern, sizeof pattern, "s%s", argv[1]); return cmd_filter(range, opt, (const char*[]){ argv[0], "sed", pattern, NULL}); } @@ -1636,7 +1636,7 @@ static bool cmd_wq(Filerange *range, enum CmdOpt opt, const char *argv[]) { static bool cmd_write(Filerange *range, enum CmdOpt opt, const char *argv[]) { Text *text = vis->win->file->text; if (!text_range_valid(range)) - range = &(Filerange){ .start = 0, .end = text_size(text) }; + *range = (Filerange){ .start = 0, .end = text_size(text) }; if (!argv[1]) argv[1] = text_filename_get(text); if (!argv[1]) { @@ -1744,7 +1744,7 @@ static bool cmd_filter(Filerange *range, enum CmdOpt opt, const char *argv[]) { fcntl(perr[0], F_SETFL, O_NONBLOCK); if (interactive) - range = &(Filerange){ .start = pos, .end = pos }; + *range = (Filerange){ .start = pos, .end = pos }; /* ranges which are written to the filter and read back in */ Filerange rout = *range; |
