aboutsummaryrefslogtreecommitdiff
path: root/miscutils/less.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@frippery.org>2015-07-19 21:41:09 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2015-07-19 22:50:25 +0200
commit78cfa00154dca18a1326d2064121bf65cd081781 (patch)
tree6594491f559a06370f6fd455bc336e7c2c695c3e /miscutils/less.c
parentf06386ad4f5e1e5b5a3aea71ac757d5be8574067 (diff)
downloadbusybox-w32-78cfa00154dca18a1326d2064121bf65cd081781.tar.gz
busybox-w32-78cfa00154dca18a1326d2064121bf65cd081781.tar.bz2
busybox-w32-78cfa00154dca18a1326d2064121bf65cd081781.zip
less: correctly account for tabs when rewrapping lines
Lines are rewrapped when the terminal width changes or line numbers are enabled/disabled. The current calculation always adds eight to the line length for a tab whereas it should only add enough to move to the next tab stop. This doesn't affect the display of lines, which is handled elsewhere and gets tab stops right, but it does cause lines to be wrapped at the wrong position. Signed-off-by: Ron Yorston <rmy@frippery.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils/less.c')
-rw-r--r--miscutils/less.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/miscutils/less.c b/miscutils/less.c
index 7c46ba5cc..90c103888 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -331,8 +331,10 @@ static void re_wrap(void)
331 *d = *s; 331 *d = *s;
332 if (*d != '\0') { 332 if (*d != '\0') {
333 new_line_pos++; 333 new_line_pos++;
334 if (*d == '\t') /* tab */ 334 if (*d == '\t') { /* tab */
335 new_line_pos += 7; 335 new_line_pos += 7;
336 new_line_pos &= (~7);
337 }
336 s++; 338 s++;
337 d++; 339 d++;
338 if (new_line_pos >= w) { 340 if (new_line_pos >= w) {