freebsd-dev/usr.bin/diff
Kyle Evans 8bf187f35b diff: fix side-by-side output with tabbed input
The previous logic conflated some things... in this block:
- j: input characters rendered so far
- nc: number of characters in the line
- col: columns rendered so far
- hw: column width ((h)ard (w)idth?)

Comparing j to hw or col to nc are naturally wrong, as col and hw are
limits on their respective counters and nc is already brought down to hw
if the input line should be truncated to start with.

Right now, we end up easily truncating lines with tabs in them as we
count each tab for $tabwidth lines in the input line, but we really
should only be accounting for them in the column count.  The problem is
most easily demonstrated by the two input files added for the tests,
the two tabbed lines lose at least a word or two even though there's
plenty of space left in the row for each side.

Reviewed by:	bapt, pstef
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D37676
2022-12-13 19:31:21 -06:00
..
tests diff: fix side-by-side output with tabbed input 2022-12-13 19:31:21 -06:00
diff.1 diff: add support for --help and --version 2022-03-10 16:17:37 +00:00
diff.c diff: Re-add void argument to usage 2022-03-10 16:24:02 +00:00
diff.h diff: add --no-dereference flag 2022-02-18 15:17:13 +00:00
diffdir.c diff: fix failed compare when ignoring file case 2022-02-18 15:51:38 +00:00
diffreg.c diff: fix side-by-side output with tabbed input 2022-12-13 19:31:21 -06:00
Makefile diff: link with libm for sqrt() 2021-09-16 09:31:44 +02:00
pr.c Fix indentation in usr.bin/diff/pr.c 2022-03-04 20:46:56 +01:00
pr.h Isolate the pr(1) related code in its own source files 2018-06-09 20:24:17 +00:00
TODO Update diff(1) TODO removing what has been implemented 2020-02-07 10:18:01 +00:00
xmalloc.c asprintf returns -1, not an arbitrary value < 0. Also upon error the 2020-01-14 08:18:04 +00:00
xmalloc.h