[Toybox] getline() length

Jeroen van Rijn jvrnix at gmail.com
Sun Nov 9 11:48:10 PST 2014


On Sun, Nov 9, 2014 at 8:34 PM, Rob Landley <rob at landley.net> wrote:

> Again, I don't know what the correct response is. Since this is
> something posix-2008 picked up from the gnu/dammit guys, it is of course
> badly specified. (The FSF is a political organization with only a
> vestigial software engineering effort attached, neither programming nor
> documentation are anywhere near their core competency.) Specifically,
> the man page's "ERRORS" section doesn't even mention -ENOMEM (let alone
> -EPIPE or -EIO)... In an out of memory situation or with an input error
> could it return a _short_ line? Discard partially read input if an error
> occurred partway into a line? Wazzit do?
>
> I _suppose_ on a certain level this is really libc's problem. Or at
> least as much libc's problem as the user's. But "juristictional
> arbitrage" does not solve problems.
>


I suppose Toyboy could include in its config an optional safety valve that
defines a GETLINE_MAX_LENGTH of a specified size, with a reasonable
default. Upon setting this to -1, it would effectively default to the
underspecified behaviour we're used to.

What the reasonable default limit should be is a bit of a question, but at
least this way the packagers for a system could set a limit (or its
absence) as makes sense for their requirements. If they can guarantee grep
will never need to work on lines longer than 128kb, they'd specify that as
its limit. Another user might prefer the unbounded case.

- Jeroen

-- 
↑↑↓↓←→←→BA
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20141109/88923cad/attachment-0003.htm>


More information about the Toybox mailing list