lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi:

On Thu, Feb 20, 2014 at 8:15 PM, René Rebe <rene@exactcode.de> wrote:
> This gets is a plain and simple getchar loop:
> http://www.opensource.apple.com/source/Libc/Libc-167/stdio.subproj/gets.c

Who would bother optimizing gets? It's for toys.

> The (latest) glibc has reads the first with getchar (EOF optimization I
> guess) and the rest with a call to an internal __iogetline.

One of the reason for this I've found previously is ungetc(). You can
have a single ungot char, calling getchar first insure you can dive
into a unget unaware function.

Francisco Olarte.