Path: utzoo!utgpu!watmath!clyde!att!rutgers!mcnc!rti!sas!toebes From: toebes@sas.UUCP (John Toebes) Newsgroups: comp.sys.amiga.tech Subject: Re: fopen() modes in Lattice C Message-ID: <727@sas.UUCP> Date: 30 Nov 88 17:03:18 GMT References: <8811280644.AA14253@postgres.Berkeley.EDU> Reply-To: toebes@sas.UUCP (John Toebes) Organization: SAS Institute Inc, Cary NC Lines: 39 In article <8811280644.AA14253@postgres.Berkeley.EDU> dillon@POSTGRES.BERKELEY.EDU (Matt Dillon) writes: > On an IBM-PC, yes. The IBM-PC uses the CR-LF combinations instead >of just an LF. Since STDIO defines the 'new line' to be just an LF, >C implementations on the IBM's must filter out the CR's when reading and >add them when writing. Unfortunetly, the idiots (not just Lattice, but >essentially ALL the IBM-PC implementations) made the default 'text'. Well, for almost ALL the programs that one finds in K&R (or Software Tools), this is a reasonable default. The correct solution could have been to make all files on the IBM have only a LF (actually a New-Line) at the end and then all would be fine. Personally, I think that the odds of this happening are about 0 (and maybe a little less) > A simple fopen("blah", "r") on an IBM *assumes* translation, which is stupid. >The default can usually be changed by modifying a global variable, but it >doesn't make porting much easier. > > Even worse, the low-level IO routines as implemented on most >C compilers on IBM's also do translation! This is because you must be able to SEEK on the file AS IF there were no CR/LF sequence. This causes much trouble when it comes to implementation. Oh yes, did I mention that people expect open, read and write as shown in K&R to work on MS-DOS with their standard text files with NO change? > > On the Amiga, no. There is no translation done. There had better >NOT be any translation! On the Amiga a 'new line' is a single LF which is >compatible with STDIO (i.e. UNIX, which was what stdio was built on). A >simple fopen("blah", "r") on the Amiga is 'binary', and there is no >difference between binary and text. > -Matt Have you looked at the implementation on the Amiga? If you did then you would see that there is not a translation. However, there are -people that expect, no make that DEMAND that the files they transferred over with XMODEM from a PC be readable on the Amiga in the same manner that they could be read under MS-DOS - WITHOUT them having to translate the file in the slightest. There is NO solution that satisfies everyone - only compromises. One should take the best default for the appropriate system to make the most people happy. /*---------------------All standard Disclaimers apply---------------------*/ /*----Working for but not officially representing SAS or Lattice Inc.-----*/ /*----John A. Toebes, VIII usenet:...!mcnc!rti!sas!toebes-----*/ /*------------------------------------------------------------------------*/