Date: Sun, 1 Feb 1998 18:41:26 -0800 (PST) Message-Id: <199802020241.SAA16006@adit.ap.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" To: Noam Rotem , djgpp AT delorie DOT com From: Nate Eldredge Subject: Re: Text / binary implementation differences Precedence: bulk At 11:09 2/1/1998 PST, Noam Rotem wrote: >Hi, > >What is the difference, from the implementation side, between a text file and a binary >one? The major reason for the distinction is that C defines that lines are broken by the '\n' character, ASCII LF. Under Unix, this is how files actually are written. But under DOS, by convention, lines are broken by ASCII CR/LF (C "\r\n"). Thus a file which is to be interpreted as "text" gets CR/LF translated to LF on input, and vice versa on output. This would be bad for a binary file, so in that case the translation is not done. >Does djgpp mark EOF differently in a text file and a binary file? Yes, that too. Many programs use a ^Z character to mark the end of a file, and I think this is, or has been, something of a de facto standard on DOS. So text files will be considered to end when a ^Z is read. For a binary file, EOF happens only when the end of the file has physically been reached (all the bytes have been read). >Is there any >difference in the way the stream is buffered or treated? No. >And, BTW, are stdin / stdout >*text* streams? Yes, although you can change this with `setmode'. >(I understand the logical differences between the two kinds, but not the >actual compiler job around each one). It's not the compiler's job, but the library's. Btw, you may be more enlightened on implementation issues by looking at the source. DJGPP's library source (`djlsr201.zip') is, I have found, quite easy to read. Nate Eldredge eldredge AT ap DOT net