summaryrefslogtreecommitdiffstats
path: root/usr.bin/less/line.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* less uses a correct raceless signal method of indicating signal events inderaadt2019-09-031-4/+3
| | | | | | | | a volatile sig_atomic_t variable, and then processing events in the mainloop. But only one variable was used for 3 signals, with |= bit operations which are signal interruptable! Rewrite the code to use 3 independent variables and cleanup how the mainloop observes indications. ok schwarze
* New utility function mbtowc_left() because this functionality -schwarze2019-08-311-45/+8
| | | | | | | decoding a UTF-8 multibyte character to the left of a given byte - is already needed at three places in line.c and will also be needed for cleanup work in cmdbuf.c in the future. OK millert@
* trivial replacement of the home-grown IS_ASCII_OCTET()schwarze2019-05-151-1/+1
| | | | with the standard isascii(3)
* UTF-8 cleanup in the function pshift().schwarze2019-05-091-39/+37
| | | | | | | | | | Use the standard functions mbtowc(3), wcwidth(3), iscntrl(3) instead of bad functions like get_wchar(), utf_len(), is_wide_char(), is_composing_char(), is_combining_char(), control_char(). If only half of a double-width character is shifted off screen, do not inspect anything following it because that clearly remains on-screen. Improve and add comments. OK millert@
* UTF-8 cleanup of the function pappend():schwarze2019-05-071-42/+42
| | | | | | | Use the standard function mbrtowc(3) to distinguish valid, incomplete, and invalid multibyte characters, getting rid of five calls to functions and macros that we want to phase out, and of one goto. Add comments. OK millert@.
* UTF-8 cleanup in do_append() replacing calls to broken functions:schwarze2019-03-131-7/+11
| | | | | | | | * get_wchar() -> mbtowc(3) * is_composing_char() || is_combining_char() -> wcwidth(3) * control_char() -> !isprint(3) * is_ubin_char() -> !iswprint(3) OK millert@
* Clean up UTF-8 handling in backc():schwarze2019-03-121-8/+38
| | | | | | | | | Use wchar_t instead of LWCHAR and mbtowc(3) instead of step_char(). Play it safe and handle all error cases, even in the arguably unlikely case that linebuf[] contains UTF-8 encoding errors. Reset mbtowc(3) internal state after failure for portability, also in one place where mbtowc(3) was already introduced earlier. OK nicm@
* de-obfuscate by expanding three useless macros; no functional change;schwarze2019-03-011-24/+22
| | | | tweak and OK millert@
* Start UTF-8 cleanup of store_char(), in particular getting rid ofschwarze2019-03-011-36/+37
| | | | | | | | | | a call to the flawed function step_char(-1), using the standard function mbtowc(3) instead. Merge in in_ansi_esc_seq(), simplifying the code, and make the related functions is_ansi_end() and is_ascii_char() static because they are used in line.c only. OK nicm@, and no opposition when shown on tech@
* To simplify the upcoming UTF-8 cleanup in less(1), delete supportschwarze2019-02-261-13/+9
| | | | | | | | | | | | | | for ANSI escape sequences introduced by an 8-bit CSI (e.g. "\23343m") because these are neither compatible with UTF-8 nor strictly compatible with pure ASCII and for those introduced by an UTF-8 CSI (e.g. "\302\23343m") because not even xterm(1) supports them at all, not even with a non-default configuration, because both forms are very rarely used, if at all, and because the current code trying to support them doesn't even appear to work according to my tests. Full support for the ESC-[ CSI (e.g. "\033[43m") remains. Tweaks and OK millert@, OK nicm@, and sthen@ agrees with the general direction.
* To measure the display width of a wide character in pwidth(), useschwarze2019-02-241-35/+40
| | | | | | | | | | | | | | | | | the standard function wcwidth(3) instead of several hand-rolled functions accessing outdated local character tables, making this part of the code conform to our in-tree Unicode 10. Of course, with the current hand-rolled (and buggy) UTF-8 parser contained in less(1), this only works if wchar_t stores UCS-4 values and is more than 31 bits wide, but both will always be true on OpenBSD, and ultmately, we shall switch to mbtowc(3) for parsing anyway, lifting these restrictuons. The existence of the outdated character tables was originally called out by Evan Silberman on bugs@. OK stsp@
* The character buffer should be resized using recallocarray()deraadt2017-04-021-2/+2
| | | | ok millert and nicm a while ago
* little bit more KNFderaadt2016-09-171-3/+3
|
* Improve handling of ambiguous overstrike sequences. A sequence of _\b_natano2016-03-261-12/+23
| | | | | | | | | | | can either mean an underlined underscore or a bold underscore. This ambiguity can be 'resolved' by takeing the state of the surrounding text into account. If surrounded by bold text, the result should probably be bold and likewise for underlined. less(1) previously only looked at the preceding text and ul(1) didn't examine the context at all. tweaks and ok schwarze ok tb (on a previous version of the diff)
* style(9) includesmmcc2016-03-161-1/+1
| | | | ok nicm@
* Remove a fancy macro that calculates the necessary buffer size formmcc2016-01-261-1/+1
| | | | | | | | int-to-str conversions and just use constants instead. The only binary change is caused by using an unnecessarily large buffer for an int. This is a consequence of simplifying some code that will be gone soon. ok nicm@
* unify two identical function pairs now that we've removed less's off_tmmcc2016-01-131-1/+1
| | | | | | aliases ok nicm@
* Remove LINUNUM, a needless alias for off_t. Also, remove a redundantmmcc2016-01-121-1/+1
| | | | | | condition. ok nicm@
* Remove NULL-checks before free(), a needless comment, and a needlessmmcc2015-11-091-4/+2
| | | | | | void* cast. ok nicm@
* Garrett D'Amore has agreed to moving his copyright line up above thenicm2015-11-061-4/+2
| | | | | terms with the existing copyright, so it is clear it applies the same terms.
* Replace less with the cleaned-up fork of less 458 maintained by Garrettnicm2015-11-051-408/+255
| | | | | | | | | | | | | D'Amore at https://github.com/gdamore/less-fork. This has significantly less portability goop, has a tidied up code style, uses terminfo instead of termcap, and is has stricter POSIX compliance. Many of our local changes have been accepted upstream: substantial remaining local changes are code to read help files from /usr/share rather than compiling them in, man page and help improvements, and some tweaks to the default options. Review and testing by millert, ok deraadt
* Merge Less 458 plus local patchesshadchin2014-04-251-4/+9
| | | | ok guenther@, ok jmc@ for man bits
* Use volatile sig_atomic_t, not int, for the sigs variable. Alsomillert2011-09-211-1/+1
| | | | | move the call to bell() out of u_interrupt() (a signal handler). OK and with help from deraadt@
* Merge in less 444 plus local changesshadchin2011-09-161-301/+645
| | | | ok nicm@
* Fix recovery of realloc failure, which causes a segv on files withotto2006-01-111-8/+12
| | | | very lone lines, as reported by Steffen Wendzel. ok deraadt@
* Fix off-by-one when moving a line to the end of the buffer. Insteadmillert2005-08-271-6/+1
| | | | | | of doing our own memmove() (incorrectly) just use memmove(). Bug found by Matthias Scheler <tron@zhadum.de>. OK deraadt@ henning@ krw@
* When reallocating the line buffer, double the existing buffermillert2004-04-081-7/+5
| | | | | | size instead of just incrementing it by LINEBUF_SIZE and use realloc() + memset() instead of calloc() + memcpy(). Prevents excessive resource usage when displaying very long lines. OK deraadt@, krw@ and otto@
* Fix sizeof(char *) in snprintf that broke the -N option.millert2003-06-181-1/+1
|
* Merge in less-381 w/ local changes and remove obsolete files.millert2003-04-131-133/+474
|
* more strlcpy/strlcat/snprintf, less strcpy/strcat/sprintfderaadt2003-04-061-2/+2
| | | | | reviewed by tdeval, millert, dhartmei and others. more bits coming here from some of them i think
* kill more registersmpech2001-11-191-15/+15
| | | | millert@ ok
* $OpenBSD$niklas2001-01-291-0/+2
|
* Import of unmolested less-290.etheisen1996-09-211-0/+582