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
F165689949: D44014.id134808.diff
Sun, Aug 9, 7:04 AM
F165675091: D44014.id134811.diff
Sun, Aug 9, 4:16 AM
F165669223: D44014.id134810.diff
Sun, Aug 9, 3:10 AM
F165664632: D44014.id134807.diff
Sun, Aug 9, 2:17 AM
F165661770: D44014.id.diff
Sun, Aug 9, 1:45 AM
F165659915: D44014.id135019.diff
Sun, Aug 9, 1:27 AM
F165584749: D44014.diff
Sat, Aug 8, 5:55 PM
Unknown Object (File)
Sat, Aug 8, 6:07 AM
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.