Page MenuHomeFreeBSD

diff: Fix --expand-tabs and --side-by-side.
ClosedPublic

Authored by des on Feb 21 2024, 7:47 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Jun 25, 2:41 AM
Unknown Object (File)
Thu, Jun 20, 10:20 AM
Unknown Object (File)
Fri, Jun 14, 5:03 AM
Unknown Object (File)
May 21 2024, 4:52 AM
Unknown Object (File)
May 17 2024, 1:25 PM
Unknown Object (File)
May 17 2024, 1:25 PM
Unknown Object (File)
May 17 2024, 8:09 AM
Unknown Object (File)
May 13 2024, 11:03 PM
Subscribers

Details

Summary
  • Overhaul column width and padding calculation.
  • Rewrite print_space() so it is now a) correct and b) understandable.
  • Rewrite tab expansion in fetch() for the same reason.

This brings us in line with GNU diff for all cases I could think of.

Sponsored by: Klara, Inc.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

des requested review of this revision.Feb 21 2024, 7:47 PM

fix tab expansion edge case

markj added inline comments.
usr.bin/diff/diffreg.c
255

The padding is always one space or one tab, depending on whether --expand-tab is set?

267

Do I understand correctly that hw == 0 just means that there's no padding around the change marker?

277

Presumably we should also set hw = 0 if width < 3?

des marked 3 inline comments as done.Feb 21 2024, 9:05 PM
des added inline comments.
usr.bin/diff/diffreg.c
255

No, the padding is variable and print_space() will use tabs and / or spaces as appropriate to reach the correct position.

267

No, hw == 0 means that either we're not in side-by-side mode or we are but the width was set so narrow that there's no room to display anything other than the marker and possibly padding.

277

you're right, --tabsize=1 --width=2 is not covered, I'll update.

des marked 3 inline comments as done.

cover degenerate case where tabsize <= width <= 3

This revision is now accepted and ready to land.Feb 26 2024, 5:50 PM
This revision was automatically updated to reflect the committed changes.