delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/26/03:20:16

Date: Tue, 26 Aug 1997 10:14:30 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: firewind <firewind AT metroid DOT dyn DOT ml DOT org>
cc: djgpp AT delorie DOT com
Subject: Re: Writing a struct to disk
In-Reply-To: <5tt2p5$o6s@dfw-ixnews5.ix.netcom.com>
Message-ID: <Pine.SUN.3.91.970826101010.5294G-100000@is>
MIME-Version: 1.0

On 25 Aug 1997, firewind wrote:

> Cesar Scarpini Rabak <csrabak AT dce03 DOT ipt DOT br> wrote:
> 
> > Text format is not _that_ highly portable! When one switches from
> > environment the way the end of line is marked varies, and filters or
> > converting programms may be needed...
> 
> Unlike some fortunate people, I don't have a copy of the ANSI standard handy,
> but in K&R2, chapter 7, section 1, is is said:
> 
> "A text stream consists of a sequence of lines; each line ends with a newline
> character. If the system doesn't operate that way, the library does whatever
> is necessary to make it appear as if it does. For instance, the library might
> convert carriage return and linefeed to newline on input and back again on
> output."

Correct, but not quite to the point.

The problem here is that if you create a text file on DOS then move it to 
Unix, the programs there will have difficulties handling it.  Since Unix 
*does* ``operate that way'' (i.e., its native text files *do* end with 
the newline alone), libc on Unix doesn't do any conversions, and the CRs 
stay.

ANSI only makes the behavior consistent as long as you stay on the same 
platform, but it doesn't tell anything about moving files between 
different platforms.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019