lua-users home
lua-l archive

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


On Feb 18, 2014, at 10:50 AM, Francisco Olarte <folarte@peoplecall.com> wrote:

> Hi:
> 
> On Tue, Feb 18, 2014 at 7:35 PM, Tim Hill <drtimhill@gmail.com> wrote:
>> 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.
> 
> I think they put it there to be able to cover every strange OS out
> there. Some of them use fixed record length files, space padded, for
> text ( I used one of them, it did that for hollerith punch cards
> compatibility ). OS have evolved a lot, and become more uniform, but I
> don not want to think which kind of things the IBM mainframes with
> their backward compatibility are supporting. You are not likely to
> find many implementation where the space stuff matters, but if you
> meet one you maybe lucky to be able to have thar thing on the
> implementation.
> 
> Francisco Olarte.
> 

OK except my reading of the ANSI text is that reading lines is *not* guaranteed to work if the newline is preceded by spaces, i.e. it may fail if the line has trailing whitespace. Which is the opposite of allowing for fixed-wdith punched cards.

Now, I very much doubt if any real-world C runtime would behave like that, but it is a bit odd.

—Tim