freebsd-src icon indicating copy to clipboard operation
freebsd-src copied to clipboard

{cut,diff,head,join,patch,xargs}: use getline() instead of fgetln()

Open arp242 opened this issue 2 years ago • 3 comments

This replaces various uses of fgetln() with getline(). The main reason for this is portability, making things easier for people who want to compile these tools on non-FreeBSD systems.

I appreciate that's probably not the top concern for FreeBSD base tools, but fgetln() is impossible to port to most platforms, as concurrent access is essentially impossible to implement fully correct without the line buffer on the FILE struct. Other than this, many generic FreeBSD tools compile fairly cleanly on Linux with a few small changes.

Most uses of fgetln() pre-date getline() support (added in 2009 with 69099ba2ec8b), and there's been some previous patches (ee3ca711a898 8c98e6b1a7f3 1a2a4fc8ce1b) for other tools.

Obtained from: https://github.com/dcantrell/bsdutils and https://github.com/chimera-linux/chimerautils Signed-off-by: Martin Tournoij [email protected]

arp242 avatar Nov 09 '23 14:11 arp242

Sure – I changed it!

arp242 avatar Nov 10 '23 21:11 arp242

So these changes look good.

I'm none-the-less nervous about them. What is the useage of the altenrative bsd tools that you pointed me to? Have you run the kyua tests on these programs before/after to make sure that there's no subtle regressions?

bsdimp avatar Dec 26 '23 23:12 bsdimp

Have you run the kyua tests on these programs before/after to make sure that there's no subtle regressions?

I had assumed the CI would run this, but I gather it doesn't?

I've had great difficulty actually running the atf/kyua tests; it's been a while and I don't quite recall if I managed to get it working – I just remember a great deal of frustration.

arp242 avatar Dec 30 '23 15:12 arp242

Have you run the kyua tests on these programs before/after to make sure that there's no subtle regressions?

I had assumed the CI would run this, but I gather it doesn't?

I've had great difficulty actually running the atf/kyua tests; it's been a while and I don't quite recall if I managed to get it working – I just remember a great deal of frustration.

(sorry missed this) I'll see if I can run kyua for these tests to see if there's no change.

bsdimp avatar Apr 17 '24 16:04 bsdimp

ci run results: all specific tests in /usr/tests/usr.sbin/{head,cut,diff,patch,join,xargs} pass

bsdimp avatar Apr 19 '24 21:04 bsdimp

5fbdcd65fe5c pushed

bsdimp avatar Apr 19 '24 21:04 bsdimp