less: improvements to verbose status messages
authorRon Yorston <rmy@pobox.com>
Tue, 21 Jul 2015 20:28:09 +0000 (22:28 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Tue, 21 Jul 2015 20:28:09 +0000 (22:28 +0200)
commit193ba408a4fd3313b1dc2eb5eb25885cfa4363f6
tree1062a000b0d330756ec8e88e14052d803634f2a9
parent35ae2ccb40924efcd0fd0c873cc9e56c58851222
less: improvements to verbose status messages

Make verbose status messages (-m/-M flags) behave more like the
real `less` command:

- fix display of line numbers so they're correct whether lines are
  being truncated (-S flag) or wrapped.
- don't display total lines or percentage when lines are read from
  stdin:  we don't have that information until we reach EOF.  When
  we do reach EOF the additional information is displayed.
- when lines are read from a file count the total number of lines
  so that we can display percentages.  Counting lines is avoided
  until the information is actually needed.  If the user pages to
  EOF the separate read pass can be avoided entirely.

Fixes Bug 7586

function                                             old     new   delta
m_status_print                                       195     382    +187
safe_lineno                                            -      35     +35
reinitialize                                         172     182     +10
read_lines                                           675     685     +10
buffer_fill_and_print                                178     169      -9
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/1 up/down: 242/-9)            Total: 233 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
miscutils/less.c