[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: io:lines() and \0
- From: Tim Hill <drtimhill@...>
- Date: Tue, 18 Feb 2014 23:53:38 -0800
On Feb 18, 2014, at 10:50 AM, Francisco Olarte <firstname.lastname@example.org> wrote:
> On Tue, Feb 18, 2014 at 7:35 PM, Tim Hill <email@example.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
> 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.