Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!ccu.umanitoba.ca!herald.usask.ca!alberta!ubc-cs!uw-beaver!milton!dali.cs.montana.edu!uakari.primate.wisc.edu!caen!math.lsa.umich.edu!math.lsa.umich.edu!hyc From: hyc@math.lsa.umich.edu (Howard Chu) Newsgroups: comp.sys.atari.st Subject: Re: CR/LF issues (was: PATCH utility needed) Message-ID: <1991Feb19.223730.11109@math.lsa.umich.edu> Date: 19 Feb 91 22:37:30 GMT References: <1991Feb3.132030.6405@tertius.in-berlin.de> <4823@ruuinf.cs.ruu.nl> <4865@ruuinf.cs.ruu.nl> Sender: usenet@math.lsa.umich.edu Organization: University of Michigan Math Dept., Ann Arbor Lines: 32 In article <4865@ruuinf.cs.ruu.nl> piet@cs.ruu.nl (Piet van Oostrum) writes: >I am porting the GNU diff(3) programs and now I come to an intersting >problem: What to do when comparing two files that differ only in the CR? >I.e. one file is a TOS style, and the other is a Unix style text file, with >the same contents. My initial solution was to disregard the CR completely. >But somebody who tested the thing complained about that. But how do you >output the differences if you want to consider them different? > >1. If you take the "official" TOS stand the Unix style file is just a > single line. But this seems impractical. >2. Print a warning but no diffs >3. consider the files to be completely different. But then there is no way > to indicate what the difference is. You cannot put the CR in the diff > because the CR is not part of the line, it belongs to the line > separator. And there is no way to indicate the ABSENCE of the CR. > >GNU diff has a -a (ASCII) option. I think I will consider the files the >same if -a is given, and different otherwise. But still the above mentioned >problem remains. Well, when you try to diff these files on a Unix box, you'll get that a difference exists, but no indication of what the difference is. Even if you specify "-w" to ignore whitespace; I guess Unix doesn't recognize CR as a whitespace character. Whenever I've had this problem on a Unix box I just delete all the CR characters. (BSD - tr -d '\015' file2) Since CR *is* whitespace for TOS, I'd just use the -w flag when diff'ing the files and leave it at that. -- -- Howard Chu @ University of Michigan Flame all you want - we'll take more.