aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2015-07-24 14:29:45 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2015-07-31 16:22:09 +0200
commit1ecb996fd2641e6ad3fdf07e78781823c71fcf13 (patch)
tree57dc2275e2eb53c5f24b359dc405d9bf2fd4c3be
parentd542d183e10dde1168fa85751194839c67add7fe (diff)
downloadbusybox-w32-1ecb996fd2641e6ad3fdf07e78781823c71fcf13.tar.gz
busybox-w32-1ecb996fd2641e6ad3fdf07e78781823c71fcf13.tar.bz2
busybox-w32-1ecb996fd2641e6ad3fdf07e78781823c71fcf13.zip
less: allow use of last column of terminal
When read_lines tests whether a character will fit on the current line it checks the *next* character but in case of overflow doesn't display the *current* one. This results in the last column of the terminal never being used. The test in re_wrap (used when the terminal width changes or line numbers are enabled/disabled) is different: it does allow the use of the final column. function old new delta read_lines 764 770 +6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/0 up/down: 6/0) Total: 6 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--miscutils/less.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/miscutils/less.c b/miscutils/less.c
index 5c53cbdbf..b38fcf766 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -512,16 +512,6 @@ static void read_lines(void)
512 *--p = '\0'; 512 *--p = '\0';
513 continue; 513 continue;
514 } 514 }
515 {
516 size_t new_last_line_pos = last_line_pos + 1;
517 if (c == '\t') {
518 new_last_line_pos += 7;
519 new_last_line_pos &= (~7);
520 }
521 if ((int)new_last_line_pos >= w)
522 break;
523 last_line_pos = new_last_line_pos;
524 }
525 /* ok, we will eat this char */ 515 /* ok, we will eat this char */
526 readpos++; 516 readpos++;
527 if (c == '\n') { 517 if (c == '\n') {
@@ -533,6 +523,16 @@ static void read_lines(void)
533 if (c == '\0') c = '\n'; 523 if (c == '\0') c = '\n';
534 *p++ = c; 524 *p++ = c;
535 *p = '\0'; 525 *p = '\0';
526 {
527 size_t new_last_line_pos = last_line_pos + 1;
528 if (c == '\t') {
529 new_last_line_pos += 7;
530 new_last_line_pos &= (~7);
531 }
532 if ((int)new_last_line_pos >= w)
533 break;
534 last_line_pos = new_last_line_pos;
535 }
536 } /* end of "read chars until we have a line" loop */ 536 } /* end of "read chars until we have a line" loop */
537#if 0 537#if 0
538//BUG: also triggers on this: 538//BUG: also triggers on this: