[PATCH] libio: Implement internal function __libc_readline_unlocked

Florian Weimer fweimer@redhat.com
Fri Sep 1 18:00:00 GMT 2017


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



More information about the Libc-alpha mailing list