]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
cut: use getline() instead of fgetln()
authorMartin Tournoij <martin@arp242.net>
Fri, 19 Apr 2024 21:11:30 +0000 (15:11 -0600)
committerWarner Losh <imp@FreeBSD.org>
Fri, 19 Apr 2024 21:52:21 +0000 (15:52 -0600)
commitb05785953e555e3dd13a162a8854076212026ca5
tree540d4b23c41746a17abf37dd7af49ca281b5c294
parent04e0313a7158f3d8623228f10da969bb21abc568
cut: use getline() instead of fgetln()

This replaces 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 <martin@arp242.net>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/893
usr.bin/cut/cut.c