[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: io:lines() and \0
- From: Tim Hill <drtimhill@...>
- Date: Thu, 20 Feb 2014 17:06:02 -0800
On Feb 20, 2014, at 3:50 PM, Cezary H. Noweta <chn@poczta.onet.pl> wrote:
> On 2014-02-20 21:15, René Rebe wrote:
>
>> On Feb 20, 2014, at 21:03 , Dirk Laurie wrote:
>
>>> 1. io.lines operates on text files.
>
>> lines operates on streams, which on most platforms these days only
>> operate in binary mode anyway.
>
> Is there an official standard for this?
>
The entire text/binary mode thing was more-or-less cooked up for CP/M and MSDOS use of CR+LF as a line terminator. It’s a complete mess since it’s not even really a “mode”, just a hack to handle line termination. Prior to this, C runtimes always opened files in one mode: a stream of bytes that could be interpreted as text or not depending on which read/write APIs you called.
The real problem here really is that the ANSI C standard was very late in arriving and by that time it wasn’t so much that they defined a rational runtime design, it was more an attempt to document the lowest-common denominator amongst observed behaviors of the various ad-hoc clones of the Unix runtime. Anyone who has had to deal with the subtleties of realloc() or strncpy() can attest to that.
—Tim
- References:
- io:lines() and \0, René Rebe
- Re: io:lines() and \0, steve donovan
- Re: io:lines() and \0, René Rebe
- Re: io:lines() and \0, Enrico Colombini
- Re: io:lines() and \0, steve donovan
- Re: io:lines() and \0, René Rebe
- Re: io:lines() and \0, Sean Conner
- Re: io:lines() and \0, Roberto Ierusalimschy
- Re: io:lines() and \0, René Rebe
- Re: io:lines() and \0, Cezary H. Noweta
- Re: io:lines() and \0, René Rebe
- Re: io:lines() and \0, Dirk Laurie
- Re: io:lines() and \0, René Rebe
- Re: io:lines() and \0, Cezary H. Noweta