bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gnulib] getline & getline_safe


From: Bruno Haible
Subject: Re: [Bug-gnulib] getline & getline_safe
Date: Fri, 25 Jul 2003 19:43:55 +0200
User-agent: KMail/1.5

Derek Robert Price wrote:

> Now that you point it out however, I think I may make maxing the
> allocation an error here to avoid even a chance of attempting a username
> and password that were not intentionally presented as such.

Yes, seems wise to me.

And when all you getnline calls are handled like this:

    if (getnline (...) < 0)  error(1, 0, ...);

then the semantic difference between our two approaches is not important
any more.

> I don't think this is strictly a matter of taste.  The pattern has
> already been established in the previous functions:
>
> extern ssize_t getline (char **_lineptr, size_t *_linesize, FILE *_stream);
>
> extern ssize_t getdelim (char **_lineptr, size_t *_linesize, int
> _delimiter, FILE *_stream);
>
> extern ssize_t getnline (char **lineptr, size_t *linesize, size_t nmax,
>                          FILE *stream);
>
> extern ssize_t getndelim (char **lineptr, size_t *linesize, size_t nmax,
>                           int delimiter, FILE *stream);
>
>
> Note that the FILE * keeps being pushed out by new arguments.  The same
> goes for the delimiter arguments relative to the size_t nmax (which
> should be limit) argument.  In contrast, getndelim2 suddenly reshuffles
> all the arguments:
>
> extern ssize_t getndelim2 (char **lineptr, size_t *linesize, size_t nmax,
>                            FILE *stream, int delim1, int delim2,
>                            size_t offset);
>
>
> I am arguing in favor of consistency to make the function more easily
> accessible to humans who are familiar with its sister functions.  I also
> think that the grouping of related arguments make the function API more
> accessible to humans.

I'm neutral on this. What do the others think? Jim, Paul?

Bruno





reply via email to

[Prev in Thread] Current Thread [Next in Thread]