aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-01-14 20:46:49 +0100
committerMarc André Tanner <mat@brain-dump.org>2016-01-14 20:50:17 +0100
commit0ade88d86e4fdfca01c0ff48fe82e2aa46c6130d (patch)
treebbd8f79307cc5d487d28dfc5bc28dbb6dd283a2c
parentfd340d7c5eb12b79139b5ea6e3f3f187783bf9f2 (diff)
downloadvis-0ade88d86e4fdfca01c0ff48fe82e2aa46c6130d.tar.gz
vis-0ade88d86e4fdfca01c0ff48fe82e2aa46c6130d.tar.xz
vis: inline expand_tab
-rw-r--r--vis-operators.c6
-rw-r--r--vis.c11
2 files changed, 4 insertions, 13 deletions
diff --git a/vis-operators.c b/vis-operators.c
index 7148b8c..1d288ff 100644
--- a/vis-operators.c
+++ b/vis-operators.c
@@ -82,9 +82,11 @@ static size_t op_put(Vis *vis, Text *txt, OperatorContext *c) {
}
static size_t op_shift_right(Vis *vis, Text *txt, OperatorContext *c) {
- size_t pos = text_line_begin(txt, c->range.end), prev_pos;
- const char *tab = expandtab(vis);
+ char spaces[9] = " ";
+ spaces[MIN(vis->tabwidth, LENGTH(spaces) - 1)] = '\0';
+ const char *tab = vis->expandtab ? spaces : "\t";
size_t tablen = strlen(tab);
+ size_t pos = text_line_begin(txt, c->range.end), prev_pos;
/* if range ends at the begin of a line, skip line break */
if (pos == c->range.end)
diff --git a/vis.c b/vis.c
index d681574..788095f 100644
--- a/vis.c
+++ b/vis.c
@@ -46,17 +46,6 @@
static Macro *macro_get(Vis *vis, enum VisMacro m);
static void macro_replay(Vis *vis, const Macro *macro);
-const char *expandtab(Vis *vis) {
- static char spaces[9];
- int tabwidth = vis->tabwidth;
- tabwidth = MIN(tabwidth, LENGTH(spaces) - 1);
- for (int i = 0; i < tabwidth; i++)
- spaces[i] = ' ';
- spaces[tabwidth] = '\0';
- return vis->expandtab ? spaces : "\t";
-}
-
-
/** window / file handling */
static void file_free(Vis *vis, File *file) {