This is the mail archive of the libc-alpha@sourceware.org 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


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


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