aboutsummaryrefslogtreecommitdiff
path: root/miscutils/less.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* | less: fix bugs in terminal width handlingRon Yorston2015-08-061-14/+14
| |
* | less: port to WIN32 and enable by defaultRon Yorston2015-08-061-0/+84
|/
* less: further tweaks to regular file detectionRon Yorston2015-08-031-11/+5
| | | | | | | | | | | | Test explicitly for REOPEN flags: update_num_lines is called unconditionally so (num_lines != NOT_REGULAR_FILE) is also true when num_lines contains a valid number of lines. The call to fstat doesn't need to be in #if ENABLE_FEATURE_LESS_FLAGS: the whole function is already in such a test. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* less: improve regular file detection in line counting codeDenys Vlasenko2015-07-311-19/+28
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* less: allow use of last column of terminalRon Yorston2015-07-311-10/+10
| | | | | | | | | | | | | | | | | | | 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>
* less: fix line number confusionRon Yorston2015-07-311-37/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | Much of the code refers to lines using indices into the flines array (which splits lines into portions that fit on the terminal). In some cases this is wrong and actual line numbers should be used: - when lines are being truncated rather than wrapped (-S flag) - when line numbers have been entered by the user Also fix a bug in numeric input and improve the display at EOF. function old new delta goto_lineno - 111 +111 cap_cur_fline - 101 +101 buffer_to_line - 56 +56 buffer_up 35 66 +31 less_main 2606 2615 +9 goto_match 125 127 +2 buffer_down 81 56 -25 buffer_line 64 - -64 ------------------------------------------------------------------------------ (add/remove: 3/1 grow/shrink: 3/1 up/down: 310/-89) Total: 221 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* less: add a function to detect when display is at end of fileRon Yorston2015-07-311-13/+12
| | | | | | | | | | | | | | | | | | | | Add a function to package the test that detects whether enough has been read from the file to allow a screenful to be displayed. Also use this to determine when to display '(END)' in the status line. The previous code was incomplete and didn't handle truncated lines (-S flag) properly. function old new delta at_end - 63 +63 status_print 111 109 -2 read_lines 819 764 -55 getch_nowait 319 264 -55 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/3 up/down: 63/-112) Total: -49 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* less: rearrange detection of non-regular filesRon Yorston2015-07-311-8/+15
| | | | | | | | | | | | | | | | | | | Move the code to detect non-regular files to the point where the file is being opened. If num_lines == READING_FILE guarantees that the file is regular. Detect when a file becomes unreadable between it first being opened and the call to update_num_lines. Mark the file as being non-regular so we don't try that again. function old new delta reinitialize 197 245 +48 update_num_lines 159 127 -32 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 48/-32) Total: 16 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* less: move code to count lines into a separate functionRon Yorston2015-07-311-24/+28
| | | | | | | | | | | function old new delta update_num_lines - 159 +159 m_status_print 409 266 -143 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/1 up/down: 159/-143) Total: 16 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* less: fix numeric inputRon Yorston2015-07-311-1/+1
| | | | | Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* less: improvements to verbose status messagesRon Yorston2015-07-211-14/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* less: correctly account for tabs when rewrapping linesRon Yorston2015-07-191-1/+3
| | | | | | | | | | | | | | 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>
* less: fix display of line numbersRon Yorston2015-07-191-24/+11
| | | | | | | | | | | | | | | | | | 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>
* less: document -S flag and make it independently configurableRon Yorston2015-07-191-4/+18
| | | | | | | | | | | | | | | 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>
* typo fixesManinder Singh2015-05-251-1/+1
| | | | | Signed-off-by: Maninder Singh <maninder1.s@samsung.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* less: make -E workAaro Koskinen2014-09-231-1/+8
| | | | | | | | 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>
* less: trivial code shrinkDenys Vlasenko2014-09-221-4/+3
| | | | | | | function old new delta read_lines 715 695 -20 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* less: move "retry-on-EAGAIN" logic closer to read opsDenys Vlasenko2014-09-221-26/+21
| | | | | | | | | | | | | | | 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>
* less: disable "suppress empty wraparound" optimizationDenys Vlasenko2014-09-211-0/+6
| | | | | | It is buggy wrt another use case... Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* Fix compile failuresDenys Vlasenko2014-05-021-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* less: fix bugs discovered with "git log -p | less -m" on kernel treeDenys Vlasenko2014-04-131-14/+24
| | | | | | | function old new delta read_lines 685 733 +48 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* less: accept and ignore -sDenys Vlasenko2014-01-221-6/+11
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* less: support "less 1<>TTY"Denys Vlasenko2013-08-041-4/+25
| | | | | | | | function old new delta less_main 2466 2507 +41 xmalloc_ttyname 46 42 -4 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* whitespace fixes. no code changesDenys Vlasenko2013-01-151-3/+3
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* who,less: tweaked help textDenys Vlasenko2012-04-171-7/+6
| | | | | | | function old new delta packed_usage 29176 29173 -3 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* Fixes for warnings in FreeBSD buildDenys Vlasenko2011-08-281-2/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* less: fix for screen size detectionDenys Vlasenko2011-08-161-1/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* less: add a TODO commentDenys Vlasenko2011-07-251-0/+3
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* less: optionally query terminal size via "ESC [ 6 n". Closes bug 2659.Denys Vlasenko2011-07-251-15/+117
| | | | | | +7 bytes is not selected, +100 if selected. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* *: remove "Options:" string from help textsDenys Vlasenko2011-06-051-1/+0
| | | | | | | function old new delta packed_usage 28706 28623 -83 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* move remaining help text from include/usage.src.hPere Orga2011-04-111-0/+12
| | | | | Signed-off-by: Pere Orga <gotrunks@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* *: use _exit() in sighandlers; showkey: do not use exit-thru-sighandlerMarek Polacek2010-10-281-6/+8
| | | | | | | | | | | | 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>
* *: whitespace fixesDenys Vlasenko2010-10-281-3/+3
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* *: make GNU licensing statement forms more regularDenys Vlasenko2010-08-161-1/+1
| | | | | | | 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>
* *: better string sharingDenys Vlasenko2010-06-021-1/+1
| | | | | | | | 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>
* consolidate ESC sequencesDenys Vlasenko2010-05-161-5/+5
| | | | | | | | | | | | | | 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>
* lineedit: fix another corner case with bad unicode inputDenys Vlasenko2010-03-111-1/+1
| | | | | | | | | | | | | | | | | 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>
* fix Unicode config option limits and some comments in lessDenys Vlasenko2010-01-301-2/+3
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* *: introduce and use ffulsh_all()Denys Vlasenko2009-11-021-2/+2
| | | | | | | | | | | | | | | | | | | | 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>
* remove some GNUisms. by Dan Fandrich (dan AT coneharvesters.com)Denys Vlasenko2009-09-061-1/+1
| | | | | | | | | | 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>
* line editing: add an option to emit ESC [ 6 n and use resultsDenys Vlasenko2009-05-171-8/+6
| | | | | | | | | 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>
* *: mass renaming of USE_XXXX to IF_XXXXDenis Vlasenko2009-04-211-3/+3
| | | | | | and SKIP_XXXX to IF_NOT_XXXX - the second one was especially badly named. It was not skipping anything!
* libiproute: fix buggy open check: s/if (fd)/if (fd >= 0)/Denis Vlasenko2008-12-101-3/+1
| | | | | less: small optimization -15 bytes
* less: fix pasting into search line ('/' cmd) -Denis Vlasenko2008-11-021-11/+17
| | | | | | it was mishandled because pasting "types" very fast and read_key eats many chars. +30 bytes.
* less: fix newly-introduced case of less spinning foreverDenis Vlasenko2008-10-311-6/+10
| | | | | on pty's closed etc
* randomconfig fixesDenis Vlasenko2008-10-291-0/+2
|
* less: correctly wrap lines with tabsDenis Vlasenko2008-10-261-27/+27
|
* less: FEATURE_LESS_LINENUMS depends on FEATURE_LESS_DASHCMDDenis Vlasenko2008-10-261-1/+2
|
* less: disable _ command, it's useless bloatDenis Vlasenko2008-10-261-0/+5
|
* less: reuse former vi's key reading code. Improve SIGWINCH handling.Denis Vlasenko2008-10-251-84/+53
| | | | | | | | | | | | | | | 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