diff --git a/src/string.c b/src/string.c index 4b8378275..92a36ef33 100644 --- a/src/string.c +++ b/src/string.c @@ -101,7 +101,7 @@ string_expand(char *dst, size_t dstlen, const char *src, int srclen, int tabsize if (expanded + size >= dstlen - 1) expanded = dstlen - size - 1; - memcpy(dst + size, " ", expanded); + memset(dst + size, ' ', expanded); size += expanded; } else if (isspace((unsigned char)c) || iscntrl((unsigned char)c)) { dst[size++] = ' '; diff --git a/test/tigrc/tab-size-test b/test/tigrc/tab-size-test new file mode 100755 index 000000000..c519a2c46 --- /dev/null +++ b/test/tigrc/tab-size-test @@ -0,0 +1,47 @@ +#!/bin/sh + +. libtest.sh + +export LINES=8 + +printf 'left\tright\n\tleading\none\t\ttwo\n12345678\tboundary\n' > stdin + +steps ':save-display tabs.screen' + +for tab_size in 8 9 16 32; do + tigrc < "tabs-$tab_size" + assert_equals stderr < /dev/null +done + +assert_equals tabs-8 strict <