Page MenuHomeFreeBSD

sort: replace home made line reader by getline(3)
ClosedPublic

Authored by bapt on Oct 12 2022, 1:36 PM.
Tags
None
Referenced Files
Unknown Object (File)
Nov 12 2024, 9:33 PM
Unknown Object (File)
Nov 7 2024, 11:16 PM
Unknown Object (File)
Oct 6 2024, 6:36 PM
Unknown Object (File)
Sep 16 2024, 4:22 PM
Unknown Object (File)
Sep 12 2024, 10:40 PM
Unknown Object (File)
Sep 8 2024, 2:41 PM
Unknown Object (File)
Sep 8 2024, 10:05 AM
Unknown Object (File)
Sep 5 2024, 6:28 AM
Subscribers

Details

Summary

The previous code had bug when reading lines with an unexpected
encoding, returning without the full line being captured.
This result in sort complaining with "sort: Illegal byte sequence"

Using getline(3) instead of the home made code, fixes the situation.

PR: 241679

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 47788
Build 44675: arc lint + arc unit

Event Timeline

bapt requested review of this revision.Oct 12 2022, 1:36 PM
usr.bin/sort/file.c
790

how is sort_opts_vals.zflag == 1 handled?

use getdelim(3) to be able to respect the -z flag

bapt marked an inline comment as done.Oct 12 2022, 3:05 PM

Seems ok, I wrote a regression test case based on the PR. I'll commit it after this lands.

usr.bin/sort/file.c
78

Indentation is off.

788–797

I thought this would break -z, but I wrote a test case and it seems to work with this patch. I don't understand why.

bapt marked 2 inline comments as done.Oct 12 2022, 3:08 PM
usr.bin/sort/file.c
795

Do you need to do this when using the -z flag?

bapt marked an inline comment as done.Oct 12 2022, 3:19 PM
markj added inline comments.
usr.bin/sort/file.c
788–797
This revision is now accepted and ready to land.Oct 12 2022, 3:28 PM