OpenBSD CVS

CVS log for src/usr.bin/less/line.c


[BACK] Up to [local] / src / usr.bin / less

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.35 / (download) - annotate - [select for diffs], Sat Jan 8 11:07:51 2022 UTC (2 years, 4 months ago) by tobias
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, OPENBSD_7_4_BASE, OPENBSD_7_4, OPENBSD_7_3_BASE, OPENBSD_7_3, OPENBSD_7_2_BASE, OPENBSD_7_2, OPENBSD_7_1_BASE, OPENBSD_7_1, HEAD
Changes since 1.34: +9 -9 lines
Diff to previous 1.34 (colored)

Fix possible use after free with long lines

Files with very long lines on machines with tight memory restrictions
can provoke a failing realloc in expand_linebuf. This error condition
was improperly handled, which could lead to a user after free bug by
using the already freed linebuf variable again.

with input by and okay guenther@

Revision 1.34 / (download) - annotate - [select for diffs], Mon Oct 25 19:54:29 2021 UTC (2 years, 6 months ago) by kn
Branch: MAIN
Changes since 1.33: +1 -1 lines
Diff to previous 1.33 (colored)

Zap unused variables/functions under /usr/src/*bin/

OK deraadt

Revision 1.33 / (download) - annotate - [select for diffs], Tue Sep 3 23:08:42 2019 UTC (4 years, 8 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE, OPENBSD_7_0, OPENBSD_6_9_BASE, OPENBSD_6_9, OPENBSD_6_8_BASE, OPENBSD_6_8, OPENBSD_6_7_BASE, OPENBSD_6_7, OPENBSD_6_6_BASE, OPENBSD_6_6
Changes since 1.32: +3 -4 lines
Diff to previous 1.32 (colored)

less uses a correct raceless signal method of indicating signal events in
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

Revision 1.32 / (download) - annotate - [select for diffs], Sat Aug 31 13:44:29 2019 UTC (4 years, 8 months ago) by schwarze
Branch: MAIN
Changes since 1.31: +8 -45 lines
Diff to previous 1.31 (colored)

New utility function mbtowc_left() because this functionality -
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@

Revision 1.31 / (download) - annotate - [select for diffs], Wed May 15 19:06:01 2019 UTC (5 years ago) by schwarze
Branch: MAIN
Changes since 1.30: +1 -1 lines
Diff to previous 1.30 (colored)

trivial replacement of the home-grown IS_ASCII_OCTET()
with the standard isascii(3)

Revision 1.30 / (download) - annotate - [select for diffs], Thu May 9 10:35:59 2019 UTC (5 years ago) by schwarze
Branch: MAIN
Changes since 1.29: +37 -39 lines
Diff to previous 1.29 (colored)

UTF-8 cleanup in the function pshift().
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@

Revision 1.29 / (download) - annotate - [select for diffs], Tue May 7 14:16:16 2019 UTC (5 years ago) by schwarze
Branch: MAIN
Changes since 1.28: +42 -42 lines
Diff to previous 1.28 (colored)

UTF-8 cleanup of the function pappend():
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@.

Revision 1.28 / (download) - annotate - [select for diffs], Wed Mar 13 11:22:56 2019 UTC (5 years, 2 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_6_5_BASE, OPENBSD_6_5
Changes since 1.27: +11 -7 lines
Diff to previous 1.27 (colored)

UTF-8 cleanup in do_append() replacing calls to broken functions:
* get_wchar() -> mbtowc(3)
* is_composing_char() || is_combining_char() -> wcwidth(3)
* control_char() -> !isprint(3)
* is_ubin_char() -> !iswprint(3)
OK millert@

Revision 1.27 / (download) - annotate - [select for diffs], Tue Mar 12 11:59:24 2019 UTC (5 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.26: +38 -8 lines
Diff to previous 1.26 (colored)

Clean up UTF-8 handling in backc():
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@

Revision 1.26 / (download) - annotate - [select for diffs], Fri Mar 1 16:41:37 2019 UTC (5 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.25: +22 -24 lines
Diff to previous 1.25 (colored)

de-obfuscate by expanding three useless macros; no functional change;
tweak and OK millert@

Revision 1.25 / (download) - annotate - [select for diffs], Fri Mar 1 14:31:34 2019 UTC (5 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.24: +37 -36 lines
Diff to previous 1.24 (colored)

Start UTF-8 cleanup of store_char(), in particular getting rid of
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@

Revision 1.24 / (download) - annotate - [select for diffs], Tue Feb 26 11:01:54 2019 UTC (5 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.23: +9 -13 lines
Diff to previous 1.23 (colored)

To simplify the upcoming UTF-8 cleanup in less(1), delete support
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.

Revision 1.23 / (download) - annotate - [select for diffs], Sun Feb 24 04:54:36 2019 UTC (5 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.22: +40 -35 lines
Diff to previous 1.22 (colored)

To measure the display width of a wide character in pwidth(), use
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@

Revision 1.22 / (download) - annotate - [select for diffs], Sun Apr 2 23:02:06 2017 UTC (7 years, 1 month ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_6_4_BASE, OPENBSD_6_4, OPENBSD_6_3_BASE, OPENBSD_6_3, OPENBSD_6_2_BASE, OPENBSD_6_2
Changes since 1.21: +2 -2 lines
Diff to previous 1.21 (colored)

The character buffer should be resized using recallocarray()
ok millert and nicm a while ago

Revision 1.21 / (download) - annotate - [select for diffs], Sat Sep 17 15:06:41 2016 UTC (7 years, 8 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.20: +3 -3 lines
Diff to previous 1.20 (colored)

little bit more KNF

Revision 1.20 / (download) - annotate - [select for diffs], Sat Mar 26 08:59:29 2016 UTC (8 years, 1 month ago) by natano
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE, OPENBSD_6_0
Changes since 1.19: +23 -12 lines
Diff to previous 1.19 (colored)

Improve handling of ambiguous overstrike sequences. A sequence of _\b_
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)

Revision 1.19 / (download) - annotate - [select for diffs], Wed Mar 16 15:36:26 2016 UTC (8 years, 2 months ago) by mmcc
Branch: MAIN
Changes since 1.18: +1 -1 lines
Diff to previous 1.18 (colored)

style(9) includes

ok nicm@

Revision 1.18 / (download) - annotate - [select for diffs], Tue Jan 26 01:51:06 2016 UTC (8 years, 3 months ago) by mmcc
Branch: MAIN
CVS Tags: OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.17: +1 -1 lines
Diff to previous 1.17 (colored)

Remove a fancy macro that calculates the necessary buffer size for
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@

Revision 1.17 / (download) - annotate - [select for diffs], Wed Jan 13 22:47:45 2016 UTC (8 years, 4 months ago) by mmcc
Branch: MAIN
Changes since 1.16: +1 -1 lines
Diff to previous 1.16 (colored)

unify two identical function pairs now that we've removed less's off_t
aliases

ok nicm@

Revision 1.16 / (download) - annotate - [select for diffs], Tue Jan 12 17:48:04 2016 UTC (8 years, 4 months ago) by mmcc
Branch: MAIN
Changes since 1.15: +1 -1 lines
Diff to previous 1.15 (colored)

Remove LINUNUM, a needless alias for off_t. Also, remove a redundant
condition.

ok nicm@

Revision 1.15 / (download) - annotate - [select for diffs], Mon Nov 9 14:25:32 2015 UTC (8 years, 6 months ago) by mmcc
Branch: MAIN
Changes since 1.14: +2 -4 lines
Diff to previous 1.14 (colored)

Remove NULL-checks before free(), a needless comment, and a needless
void* cast.

ok nicm@

Revision 1.14 / (download) - annotate - [select for diffs], Fri Nov 6 15:50:33 2015 UTC (8 years, 6 months ago) by nicm
Branch: MAIN
Changes since 1.13: +2 -4 lines
Diff to previous 1.13 (colored)

Garrett D'Amore has agreed to moving his copyright line up above the
terms with the existing copyright, so it is clear it applies the same
terms.

Revision 1.13 / (download) - annotate - [select for diffs], Thu Nov 5 22:08:44 2015 UTC (8 years, 6 months ago) by nicm
Branch: MAIN
Changes since 1.12: +259 -412 lines
Diff to previous 1.12 (colored)

Replace less with the cleaned-up fork of less 458 maintained by Garrett
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

Revision 1.12 / (download) - annotate - [select for diffs], Fri Apr 25 13:38:21 2014 UTC (10 years ago) by shadchin
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_8, OPENBSD_5_7_BASE, OPENBSD_5_7, OPENBSD_5_6_BASE, OPENBSD_5_6
Changes since 1.11: +9 -4 lines
Diff to previous 1.11 (colored)

Merge Less 458 plus local patches

ok guenther@, ok jmc@ for man bits

Revision 1.1.1.4 / (download) - annotate - [select for diffs] (vendor branch), Fri Apr 25 13:33:49 2014 UTC (10 years ago) by shadchin
Branch: markn, MARK_NUDELMAN
CVS Tags: LESS_458
Changes since 1.1.1.3: +68 -41 lines
Diff to previous 1.1.1.3 (colored)

Import of Less 458

ok guenther@

Revision 1.11 / (download) - annotate - [select for diffs], Wed Sep 21 19:01:49 2011 UTC (12 years, 8 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_5_5_BASE, OPENBSD_5_5, OPENBSD_5_4_BASE, OPENBSD_5_4, OPENBSD_5_3_BASE, OPENBSD_5_3, OPENBSD_5_2_BASE, OPENBSD_5_2, OPENBSD_5_1_BASE, OPENBSD_5_1
Changes since 1.10: +1 -1 lines
Diff to previous 1.10 (colored)

Use volatile sig_atomic_t, not int, for the sigs variable.  Also
move the call to bell() out of u_interrupt() (a signal handler).
OK and with help from deraadt@

Revision 1.10 / (download) - annotate - [select for diffs], Fri Sep 16 18:12:09 2011 UTC (12 years, 8 months ago) by shadchin
Branch: MAIN
Changes since 1.9: +648 -304 lines
Diff to previous 1.9 (colored)

Merge in less 444 plus local changes

ok nicm@

Revision 1.1.1.3 / (download) - annotate - [select for diffs] (vendor branch), Fri Sep 16 17:47:06 2011 UTC (12 years, 8 months ago) by shadchin
Branch: markn, MARK_NUDELMAN
CVS Tags: LESS_444
Changes since 1.1.1.2: +627 -308 lines
Diff to previous 1.1.1.2 (colored)

Import of Less 444

ok nicm@

Revision 1.9 / (download) - annotate - [select for diffs], Wed Jan 11 19:20:10 2006 UTC (18 years, 4 months ago) by otto
Branch: MAIN
CVS Tags: OPENBSD_5_0_BASE, OPENBSD_5_0, OPENBSD_4_9_BASE, OPENBSD_4_9, OPENBSD_4_8_BASE, OPENBSD_4_8, OPENBSD_4_7_BASE, OPENBSD_4_7, OPENBSD_4_6_BASE, OPENBSD_4_6, OPENBSD_4_5_BASE, OPENBSD_4_5, OPENBSD_4_4_BASE, OPENBSD_4_4, OPENBSD_4_3_BASE, OPENBSD_4_3, OPENBSD_4_2_BASE, OPENBSD_4_2, OPENBSD_4_1_BASE, OPENBSD_4_1, OPENBSD_4_0_BASE, OPENBSD_4_0, OPENBSD_3_9_BASE, OPENBSD_3_9
Changes since 1.8: +12 -8 lines
Diff to previous 1.8 (colored)

Fix recovery of realloc failure, which causes a segv on files with
very lone lines, as reported by Steffen Wendzel.  ok deraadt@

Revision 1.8 / (download) - annotate - [select for diffs], Sat Aug 27 17:17:54 2005 UTC (18 years, 8 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_3_8_BASE, OPENBSD_3_8
Changes since 1.7: +1 -6 lines
Diff to previous 1.7 (colored)

Fix off-by-one when moving a line to the end of the buffer.  Instead
of doing our own memmove() (incorrectly) just use memmove().
Bug found by Matthias Scheler <tron@zhadum.de>.
OK deraadt@ henning@ krw@

Revision 1.7 / (download) - annotate - [select for diffs], Thu Apr 8 15:18:28 2004 UTC (20 years, 1 month ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_3_7_BASE, OPENBSD_3_7, OPENBSD_3_6_BASE, OPENBSD_3_6
Changes since 1.6: +5 -7 lines
Diff to previous 1.6 (colored)

When reallocating the line buffer, double the existing buffer
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@

Revision 1.6 / (download) - annotate - [select for diffs], Wed Jun 18 18:39:52 2003 UTC (20 years, 11 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_3_5_BASE, OPENBSD_3_5, OPENBSD_3_4_BASE, OPENBSD_3_4
Changes since 1.5: +1 -1 lines
Diff to previous 1.5 (colored)

Fix sizeof(char *) in snprintf that broke the -N option.

Revision 1.5 / (download) - annotate - [select for diffs], Sun Apr 13 18:26:26 2003 UTC (21 years, 1 month ago) by millert
Branch: MAIN
Changes since 1.4: +473 -132 lines
Diff to previous 1.4 (colored)

Merge in less-381 w/ local changes and remove obsolete files.

Revision 1.1.1.2 / (download) - annotate - [select for diffs] (vendor branch), Sun Apr 13 18:21:21 2003 UTC (21 years, 1 month ago) by millert
Branch: markn, MARK_NUDELMAN
CVS Tags: LESS_381
Changes since 1.1.1.1: +463 -120 lines
Diff to previous 1.1.1.1 (colored)

Stock less-390 with some unneeded DOS/Windoze files removed

Revision 1.4 / (download) - annotate - [select for diffs], Sun Apr 6 23:38:07 2003 UTC (21 years, 1 month ago) by deraadt
Branch: MAIN
Changes since 1.3: +2 -2 lines
Diff to previous 1.3 (colored)

more strlcpy/strlcat/snprintf, less strcpy/strcat/sprintf
reviewed by tdeval, millert, dhartmei and others.  more bits coming here
from some of them i think

Revision 1.3 / (download) - annotate - [select for diffs], Mon Nov 19 19:02:14 2001 UTC (22 years, 6 months ago) by mpech
Branch: MAIN
CVS Tags: OPENBSD_3_3_BASE, OPENBSD_3_3, OPENBSD_3_2_BASE, OPENBSD_3_2, OPENBSD_3_1_BASE, OPENBSD_3_1
Changes since 1.2: +15 -15 lines
Diff to previous 1.2 (colored)

kill more registers

millert@ ok

Revision 1.2 / (download) - annotate - [select for diffs], Mon Jan 29 01:58:02 2001 UTC (23 years, 3 months ago) by niklas
Branch: MAIN
CVS Tags: OPENBSD_3_0_BASE, OPENBSD_3_0, OPENBSD_2_9_BASE, OPENBSD_2_9
Changes since 1.1: +2 -0 lines
Diff to previous 1.1 (colored)

$OpenBSD$

Revision 1.1.1.1 / (download) - annotate - [select for diffs] (vendor branch), Sat Sep 21 05:39:42 1996 UTC (27 years, 8 months ago) by etheisen
Branch: markn, MARK_NUDELMAN
CVS Tags: less_290, OPENBSD_2_8_BASE, OPENBSD_2_8, OPENBSD_2_7_BASE, OPENBSD_2_7, OPENBSD_2_6_BASE, OPENBSD_2_6, OPENBSD_2_5_BASE, OPENBSD_2_5, OPENBSD_2_4_BASE, OPENBSD_2_4, OPENBSD_2_3_BASE, OPENBSD_2_3, OPENBSD_2_2_BASE, OPENBSD_2_2, OPENBSD_2_1_BASE, OPENBSD_2_1, OPENBSD_2_0_BASE, OPENBSD_2_0
Changes since 1.1: +0 -0 lines
Diff to previous 1.1 (colored)

Import of unmolested less-290.

Revision 1.1 / (download) - annotate - [select for diffs], Sat Sep 21 05:39:42 1996 UTC (27 years, 8 months ago) by etheisen
Branch: MAIN

Initial revision

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.