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: Florian Weimer <fweimer at redhat dot com>
- To: libc-alpha at sourceware dot org
- Date: Fri, 1 Sep 2017 20:00:02 +0200
- Subject: Re: [PATCH] libio: Implement internal function __libc_readline_unlocked
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=fweimer at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4145F7E454
- References: <20170901154335.E5819439942E3@oldenburg.str.redhat.com>
On 09/01/2017 05:43 PM, Florian Weimer wrote:
> + int ch = __uflow (fp);
> + if (ch == EOF)
> + {
> + if (_IO_ferror_unlocked (fp))
> + /* If the EOF was caused by a read error, report it. */
> + return fail_no_erange ();
> + *buffer = '\0';
> + /* Do not include the NULL terminator. */
> + return buffer - start;
> + }
> +
> + /* Save the character just read. */
> + *buffer = ch;
> + ++buffer;
> +
> + if (ch == '\n')
> + {
> + if (buffer == buffer_end)
> + /* Not enough room in the caller-supplied buffer. */
> + break;
> + *buffer = '\0';
> + /* Do not include the NULL terminator. */
> + return buffer - start;
> + }
This should use __underflow instead of __uflow, so that the need for the
special handling for '\n' goes away.
However, it turns out that this does not actually solve anything on the
NSS, so I'm not going to commit this.
Florian