This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] libio: Implement internal function __libc_readline_unlocked


Florian Weimer wrote:
> On 07/06/2018 02:31 PM, Florian Weimer wrote:

>> The caller should not call the function if the stream is in an error
>> condition I added a comment to the header file.


> --- a/include/stdio.h
> +++ b/include/stdio.h
> @@ -127,6 +127,19 @@ extern int __fxprintf (FILE *__fp, const char *__fmt, ...)
>  extern int __fxprintf_nocancel (FILE *__fp, const char *__fmt, ...)
>       __attribute__ ((__format__ (__printf__, 2, 3))) attribute_hidden;
> +/* Read the next line from FP into BUFFER, of LENGTH bytes.  LINE will
> +   include the line terminator and a NUL terminator.  On success,
> +   return the length of the line, including the line terminator, but
> +   excluding the NUL termintor.  On EOF, return zero and write a NUL
> +   terminator.  On error, return -1 and set errno.  If the total byte
> +   count (line and both terminators) exceeds LENGTH, return -1 and set
> +   errno to ERANGE (but do not mark the stream as failed).
> +
> +   The behavior is undefined if FP is not seekable, or if the stream
> +   is already in an error state.  */
> +ssize_t __libc_readline_unlocked (FILE *fp, char *buffer, size_t length);
> +libc_hidden_proto (__libc_readline_unlocked);

Makes sense.

What kind of stability guarantees do we make for this kind of
double-underscored GLIBC_PRIVATE symbol?  E.g. if we decide to remove
it later or change its behavior, is that easy to do?

I'm not looking for any particular answer --- an answer like "see
such-and-such wiki page" or "see such-and-such bug about missing
documentation" would be the ideal.

> --- /dev/null
> +++ b/libio/readline.c
> @@ -0,0 +1,169 @@
> +/* fgets with ERANGE error reporting and size_t buffer length.
> +   Copyright (C) 2017 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.

optional: could put 2018 here, since this will have been first
published as part of glibc in 2018.

> --- /dev/null
> +++ b/libio/tst-readline.c
> @@ -0,0 +1,235 @@
> +/* Test the __libc_readline_unlocked function.
> +   Copyright (C) 2017 Free Software Foundation, Inc.


The rest looks good, too.

Reviewed-by: Jonathan Nieder <>

Thanks for your patient work.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]