Commit Graph

128 Commits

Author SHA1 Message Date
Ron Yorston
193ba408a4 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>
2015-07-21 22:28:09 +02:00
Ron Yorston
78cfa00154 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>
2015-07-19 22:50:25 +02:00
Ron Yorston
f06386ad4f less: fix display of line numbers
Line numbers are displayed incorrectly on lines that have a search
pattern highlighted.  The problem can be fixed by moving the call to
lineno_str in print_found above the while loop that alters the value
of the line pointer.  However, a more substantial rewrite results in
savings.

function                                             old     new   delta
buffer_print                                         688     697      +9
.rodata                                           156077  156045     -32
lineno_str                                            85       -     -85
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/1 up/down: 9/-117)           Total: -108 bytes

Signed-off-by: Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-07-19 22:48:05 +02:00
Ron Yorston
51aa861843 less: document -S flag and make it independently configurable
The -S flag, to cause long lines to be truncated, was enabled by
FEATURE_LESS_DASHCMD.  This is non-obvious and -S is useful even
if the '-' command isn't enabled.

function                                             old     new   delta
.rodata                                           156045  156077     +32
packed_usage                                       30223   30244     +21
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 53/0)               Total: 53 bytes

Signed-off-by: Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-07-19 22:34:13 +02:00
Maninder Singh
97c6491b4e typo fixes
Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-05-25 13:46:36 +02:00
Aaro Koskinen
307d26c0eb less: make -E work
function                                             old     new   delta
buffer_print                                          71     104     +33

Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-09-23 22:58:18 +02:00
Denys Vlasenko
865814a617 less: trivial code shrink
function                                             old     new   delta
read_lines                                           715     695     -20

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-09-22 21:17:24 +02:00
Denys Vlasenko
d6e7672545 less: move "retry-on-EAGAIN" logic closer to read ops
This makes "G" (goto end of input) command work as well as
/search_for_nonexistent_string: both will read to EOF now
even from somewhat slow input (such as kernel's "git log").

function                                             old     new   delta
ndelay_on                                             35      43      +8
ndelay_off                                            35      43      +8
read_lines                                           695     691      -4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 16/-4)              Total: 12 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-09-22 21:14:02 +02:00
Denys Vlasenko
15943c886d less: disable "suppress empty wraparound" optimization
It is buggy wrt another use case...

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-09-21 22:10:55 +02:00
Denys Vlasenko
fe33683c8b Fix compile failures
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-05-02 07:18:55 +02:00
Denys Vlasenko
69b114fb8a less: fix bugs discovered with "git log -p | less -m" on kernel tree
function                                             old     new   delta
read_lines                                           685     733     +48

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-04-13 16:02:59 +02:00
Denys Vlasenko
821e64316a less: accept and ignore -s
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-01-22 16:36:22 +01:00
Denys Vlasenko
cc1c9ca6f8 less: support "less 1<>TTY"
function                                             old     new   delta
less_main                                           2466    2507     +41
xmalloc_ttyname                                       46      42      -4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-08-04 17:41:19 +02:00
Denys Vlasenko
6830ade6aa whitespace fixes. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-15 13:58:01 +01:00
Denys Vlasenko
53772869bc who,less: tweaked help text
function                                             old     new   delta
packed_usage                                       29176   29173      -3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-17 16:11:25 +02:00
Denys Vlasenko
24915117a2 Fixes for warnings in FreeBSD build
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-08-28 05:31:49 +02:00
Denys Vlasenko
4f54168ea2 less: fix for screen size detection
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-08-16 01:53:12 +02:00
Denys Vlasenko
2ef4214dd9 less: add a TODO comment
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-07-25 15:23:52 +02:00
Denys Vlasenko
4e552a70ec less: optionally query terminal size via "ESC [ 6 n". Closes bug 2659.
+7 bytes is not selected, +100 if selected.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-07-25 15:18:20 +02:00
Denys Vlasenko
66426760be *: remove "Options:" string from help texts
function                                             old     new   delta
packed_usage                                       28706   28623     -83

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-06-05 03:58:28 +02:00
Pere Orga
5bc8c005a8 move remaining help text from include/usage.src.h
Signed-off-by: Pere Orga <gotrunks@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-04-11 03:29:49 +02:00
Marek Polacek
7b18107384 *: use _exit() in sighandlers; showkey: do not use exit-thru-sighandler
While at it, make ESC sequences more readable; and removed check for
isatty(stdin) in reset. Code shrink:

   text    data     bss     dec     hex filename
 884771     936   17216  902923   dc70b busybox_old
 884723     936   17216  902875   dc6db busybox_unstripped

Signed-off-by: Marek Polacek <mmpolacek@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-10-28 21:34:56 +02:00
Denys Vlasenko
e4dcba1c10 *: whitespace fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-10-28 18:57:19 +02:00
Denys Vlasenko
0ef64bdb40 *: make GNU licensing statement forms more regular
This change retains "or later" state! No licensing _changes_ here,
only form is adjusted (article, space between "GPL" and "v2" and so on).

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-16 20:14:46 +02:00
Denys Vlasenko
ea8b252cb3 *: better string sharing
text   data    bss    dec    hex filename
 849427    441   7556 857424  d1550 busybox_old
 849355    441   7556 857352  d1508 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-02 12:57:26 +02:00
Denys Vlasenko
d9a3e89f50 consolidate ESC sequences
function                                             old     new   delta
bell                                                   2       -      -2
CMdown                                                 2       -      -2
Ceos                                                   4       -      -4
Ceol                                                   4       -      -4
CMup                                                   4       -      -4
SOs                                                    5       -      -5
SOn                                                    5       -      -5
CMrc                                                   9       -      -9

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-16 23:42:13 +02:00
Denys Vlasenko
58f108eb33 lineedit: fix another corner case with bad unicode input
function                                             old     new   delta
read_key                                             607     646     +39
readit                                                50      55      +5
getch_nowait                                         290     295      +5
hash_find                                            233     234      +1
xstrtoul_range_sfx                                   231     230      -1
passwd_main                                         1058    1056      -2
builtin_exit                                          45      43      -2
cmp_main                                             649     645      -4
lineedit_read_key                                    257     245     -12
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/5 up/down: 50/-21)             Total: 29 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-11 21:17:55 +01:00
Denys Vlasenko
ecd90fd488 fix Unicode config option limits and some comments in less
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-30 18:09:18 +01:00
Denys Vlasenko
8131eea3dc *: introduce and use ffulsh_all()
function                                             old     new   delta
buffer_fill_and_print                                179     196     +17
fflush_all                                             -       9      +9
spawn                                                 87      92      +5
rtcwake_main                                         455     453      -2
...
alarm_intr                                            93      84      -9
readcmd                                             1072    1062     -10
bb_ask                                               345     333     -12
more_main                                            845     832     -13
flush_stdout_stderr                                   42      23     -19
xfflush_stdout                                        27       -     -27
flush_stderr                                          30       -     -30
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 2/50 up/down: 31/-397)         Total: -366 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-02 14:19:51 +01:00
Denys Vlasenko
90a9904e9e remove some GNUisms. by Dan Fandrich (dan AT coneharvesters.com)
function                                             old     new   delta
logdirs_reopen                                      1310    1308      -2
read_line_input                                     4757    4753      -4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-6)               Total: -6 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-06 02:36:23 +02:00
Denys Vlasenko
020f40693a line editing: add an option to emit ESC [ 6 n and use results
This makes line editing able to recognize case when
cursor was not at the beginning of the line. It may also
be adapted later to find out display size (serial line users
would love it).

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-17 16:44:54 +02:00
Denis Vlasenko
5e34ff29bc *: mass renaming of USE_XXXX to IF_XXXX
and SKIP_XXXX to IF_NOT_XXXX - the second one was especially
badly named. It was not skipping anything!
2009-04-21 11:09:40 +00:00
Denis Vlasenko
12abcb36c8 libiproute: fix buggy open check: s/if (fd)/if (fd >= 0)/
less: small optimization -15 bytes
2008-12-10 14:14:09 +00:00
Denis Vlasenko
c51457ca5b less: fix pasting into search line ('/' cmd) -
it was mishandled because pasting "types" very fast
 and read_key eats many chars. +30 bytes.
2008-11-02 00:55:41 +00:00
Denis Vlasenko
64974793b9 less: fix newly-introduced case of less spinning forever
on pty's closed etc
2008-10-31 03:04:55 +00:00
Denis Vlasenko
31d58e58d2 randomconfig fixes 2008-10-29 13:16:28 +00:00
Denis Vlasenko
e1ef89abad less: correctly wrap lines with tabs 2008-10-26 16:30:09 +00:00
Denis Vlasenko
f3dcd3c30a less: FEATURE_LESS_LINENUMS depends on FEATURE_LESS_DASHCMD 2008-10-26 00:24:38 +00:00
Denis Vlasenko
7b32e8f0bf less: disable _ command, it's useless bloat 2008-10-26 00:15:36 +00:00
Denis Vlasenko
5f6aaf39cf less: reuse former vi's key reading code. Improve SIGWINCH handling.
function                                             old     new   delta
less_main                                           2056    2097     +41
getch_nowait                                         248     273     +25
read_key                                             310     321     +11
static.esccmds                                        61      69      +8
count_lines                                           72      74      +2
less_gets                                            166     142     -24
less_getch                                           172      43    -129
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 6/5 up/down: 91/-170)           Total: -79 bytes
   text    data     bss     dec     hex filename
2008-10-25 23:27:29 +00:00
Denis Vlasenko
53c80f0972 less: add optional line number toggle and resizing on SIGWINCH. 2008-10-24 22:43:27 +00:00
Denis Vlasenko
e8efe81abf less: add less v.418 help text doc. No code changes. 2008-10-24 11:07:20 +00:00
Denis Vlasenko
d908395eae less: experimental code to enable wrap/no-wrap
and adapting to resized xterm windows. disabled for now.
2008-10-24 10:42:21 +00:00
Denis Vlasenko
8f39b72aba less: more sane way of line numbering. Prepares for
wrap/unwrap and line numbers to be toggleable.
2008-10-23 22:02:30 +00:00
Bernhard Reutner-Fischer
48a6773b3a - add less -I to be able to search case-insensitively
+17b, but the helptext is quite elaborate, thus:
function                                             old     new   delta
.rodata                                           118995  119032     +37
packed_usage                                       24731   24767     +36
regex_process                                        284     300     +16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 89/0)               Total: 89 bytes
2008-09-26 14:10:17 +00:00
Denis Vlasenko
5415c856ea libbb: [x]fopen_for_{read,write} introduced and used.
(by Valdimir)

function                                             old     new   delta
config_open2                                           -      41     +41
config_read                                          507     542     +35
find_pair                                            169     187     +18
fopen_for_write                                        -      14     +14
fopen_for_read                                         -      14     +14
find_main                                            406     418     +12
xfopen_for_write                                       -      10     +10
xfopen_for_read                                        -      10     +10
popstring                                            134     140      +6
parse_inittab                                        396     401      +5
next_token                                           923     928      +5
pack_gzip                                           1659    1661      +2
bb__parsespent                                       117     119      +2
fallbackSort                                        1719    1717      -2
evalvar                                             1376    1374      -2
qrealloc                                              36      33      -3
...
...
...
...
singlemount                                         4579    4569     -10
process_stdin                                        443     433     -10
patch_main                                          1111    1101     -10
ifupdown_main                                       2175    2165     -10
file_action_grep                                      90      80     -10
uuidcache_init                                       649     637     -12
hush_main                                            797     785     -12
read_config                                          230     217     -13
dpkg_main                                           3835    3820     -15
read_line_input                                     3134    3110     -24
sysctl_main                                          232     203     -29
config_open                                           40      10     -30
WARN_BAD_LINE                                         44       -     -44
login_main                                          1714    1575    -139
------------------------------------------------------------------------------
(add/remove: 5/1 grow/shrink: 8/74 up/down: 174/-737)        Total: -563 bytes
2008-07-21 23:05:26 +00:00
Denis Vlasenko
deeed59de0 libbb: introduce and use xrealloc_vector
function                                             old     new   delta
xrealloc_vector_helper                                 -      51     +51
create_list                                           84      99     +15
getopt_main                                          690     695      +5
passwd_main                                         1049    1053      +4
get_cached                                            85      89      +4
msh_main                                            1377    1380      +3
add_match                                             42      41      -1
read_lines                                           720     718      -2
grave                                               1068    1066      -2
fill_match_lines                                     143     141      -2
add_to_dirlist                                        67      65      -2
add_input_file                                        49      47      -2
act                                                  252     250      -2
fsck_main                                           2252    2246      -6
man_main                                             765     757      -8
bb_internal_initgroups                               228     220      -8
cut_main                                            1052    1041     -11
add_edge_to_node                                      55      43     -12
dpkg_main                                           3851    3835     -16
ifupdown_main                                       2202    2178     -24
sort_main                                            838     812     -26
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 5/15 up/down: 82/-124)          Total: -42 bytes
2008-07-08 05:14:36 +00:00
Denis Vlasenko
3fe4f986a0 less: fix a case when regexp matches ""
hush: remove wrong comment, expand another one
2008-06-09 16:02:39 +00:00
Bernhard Reutner-Fischer
5e25ddb7d3 - use STD*_FILENO some more. No object-code changes 2008-05-19 09:48:17 +00:00
Bernhard Reutner-Fischer
636a1f85e8 - use EXIT_{SUCCESS,FAILURE}. No object-code changes 2008-05-19 09:29:47 +00:00