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)
Sep 24 2024, 8:51 AM
Unknown Object (File)
Sep 23 2024, 7:41 AM
Unknown Object (File)
Sep 22 2024, 3:19 PM
Unknown Object (File)
Sep 18 2024, 6:21 PM
Unknown Object (File)
Sep 16 2024, 11:57 AM
Unknown Object (File)
Sep 9 2024, 10:13 AM
Unknown Object (File)
Sep 8 2024, 7:07 PM
Unknown Object (File)
Sep 8 2024, 6:32 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.