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)
Wed, May 29, 11:09 PM
Unknown Object (File)
Wed, May 29, 11:09 PM
Unknown Object (File)
Apr 30 2024, 3:42 AM
Unknown Object (File)
Apr 30 2024, 3:42 AM
Unknown Object (File)
Apr 30 2024, 3:41 AM
Unknown Object (File)
Apr 30 2024, 3:40 AM
Unknown Object (File)
Apr 30 2024, 3:40 AM
Unknown Object (File)
Apr 30 2024, 3:40 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 Not Applicable
Unit
Tests Not Applicable

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