[comp.sys.atari.st] CR/LF issues

piet@cs.ruu.nl (Piet van Oostrum) (02/15/91)

PvO> I see some patch versions on atari.archive.umich.edu, but I don't know if
PvO> they are the same versions or better, or worse. Maybe somebody from the
PvO> archive management can comment?

PvO> atari/gnustuff/tos:
PvO> -rw-rw-r--  1 226        121584 Aug 15  1989 patch.zoo

PvO> atari/utilities:
PvO> -rw-rw-r--  1 226         91023 Apr 12  1989 patch.arc

It seems that the latter one (patch.arc) is a very old one (compiled with
gcc 1.23), and it looks like the one I had.

The patch.zoo file is more recent, ported by bammi, with supposedly is
better (I have not yet tried it).

>>>>> In message <1991Feb13.042250.26102@chinet.chi.il.us>, saj@chinet.chi.il.us (Stephen Jacobs) (SJ) writes:

SJ> I don't know if this is the problem, but the version of patch.ttp that
SJ> I have is definitely sensitive to the difference between lines ending
SJ> in ^J only (UNIX style) and those ending in ^J^M (most ST editors, and
You probably mean ^M^J.
SJ> the desktop).  I haven't characterized the EXACT behavior, but I get
SJ> the best results by putting both main file and patch into UNIX style
SJ> before applying the

Bammi told me to use the -l switch.

By the way, I think that the TOS utilities that deal with text should
generally accept both the LF only (Unix style) and the CR,LF (TOS style) of
line delimiting. I know that the TOS style is THE legal way, but it
generally doesn't harm to accept the Unix style.

This brings me to another question:

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.
-- 
Piet* van Oostrum, Dept of Computer Science, Utrecht University,
Padualaan 14, P.O. Box 80.089, 3508 TB Utrecht, The Netherlands.
Telephone: +31 30 531806   Uucp:   uunet!mcsun!ruuinf!piet
Telefax:   +31 30 513791   Internet:  piet@cs.ruu.nl   (*`Pete')

wallace@ynotme.enet.dec.com (Ray Wallace) (02/16/91)

In article <4865@ruuinf.cs.ruu.nl>, piet@cs.ruu.nl (Piet van Oostrum) writes...
>This brings me to another question:
> 
>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?
			...
>   separator. And there is no way to indicate the ABSENCE of the CR.
The VMS difference program shows "<CR>" (ie: 4 ascii characters) at the end of
the lines if one file has them and the other doesn't.

>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
Most definitly have a switch to disable this feature. The VMS utility does not
and it is a real pain. Yes I want to be able to find out if the files have
different line terminators, but once I know that I want to see the diff's
excluding the terminators (which would be the whole file of course).

---
Ray Wallace		
		(INTERNET,UUCP) wallace@oldtmr.enet.dec.com
		(UUCP)		...!decwrl!oldtmr.enet!wallace
		(INTERNET)	wallace%oldtmr.enet@decwrl.dec.com
---

hyc@math.lsa.umich.edu (Howard Chu) (02/20/91)

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' <file1 >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.