This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] libio: Implement internal function __libc_readline_unlocked
- From: Jonathan Nieder <jrnieder at gmail dot com>
- To: Florian Weimer <fweimer at redhat dot com>
- Cc: libc-alpha at sourceware dot org, Carlos O'Donell <carlos at redhat dot com>
- Date: Fri, 6 Jul 2018 11:28:23 -0700
- Subject: Re: [PATCH] libio: Implement internal function __libc_readline_unlocked
- References: <20170901154335.E5819439942E3@oldenburg.str.redhat.com> <4694e740-6bdb-ef22-a945-21359367c788@redhat.com> <ab9faefa-7875-4380-fca0-87767bf271f0@redhat.com> <20171122055001.GC7625@aiede.mtv.corp.google.com> <33d730f8-4ad2-4055-fdcc-98117ecc3f45@redhat.com> <50086f64-2ea0-18ae-60f4-7b149493a79b@redhat.com>
Hi,
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.
Thanks.
[...]
> --- 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.
Likewise.
The rest looks good, too.
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Thanks for your patient work.