lua-users home
lua-l archive

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


On Feb 18, 2014, at 6:04 AM, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:

>> I woud propose something like:
>> 
>> [...]
> 
> ANSI C says that about text files:
> 
>  Data read in from a text stream will necessarily compare equal to
>  the data that were earlier written out to that stream only if: the
>  data consist only of printing characters and the control characters
>  horizontal tab and new-line; no new-line character is immediately
>  preceded by space characters; and the last character is a new-line
>  character.
> 
> So, there is no garanties that a text file with embedded zeros will be
> read correctly, no matter how we implement it.
> 

Is anyone else uneasy about that “no new-line character is immediately preceded by space characters” bit? I take this to mean trailing space in lines may give unpredictable results in ANSI C, which is pretty eye-brow raising to me.

If this is true, this reads like the ANSI committee bending the standard to meet a (buggy) implementation, as they did with realloc() and a few others.

—Tim