bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Inconsistent line endings


From: Barry
Subject: Re: Inconsistent line endings
Date: Wed, 25 Jan 2006 21:00:31 -0500

----- Original Message ----- From: "Paul Eggert" <address@hidden>


"Barry" <address@hidden> writes:

I'll create short sample files to demonstrate this
if necessary.

Yes please.  I didn't quite follow the explanation.

I did a "diff -y -W 40" on the files http://www.polisource.com/PublicMisc/File1.txt and http://www.polisource.com/PublicMisc/File2.txt .

File1.txt contains the text between the lines:
--------------
Line 1
Line 2

Line 3
--------------

File1.txt was created with a Perl script. This is the variable that was saved to file1.txt:

$File1 = "Line 1\nLine 2\n\r\nLine 3";

File2.txt is empty.

The diff command produces the expected output, but if you view the ASCII code of each character of the diff results, you'll see the following:

76 105 110 101 32 49 9 9 32 32 32 60 10 76 105 110 101 32 50 9 9 32 32 32 60 10 13 9 9 32 32 32 60 10 76 105 110 101 32 51 9 9 32 32 32 60

There are two interpretations of where the lines break. At first, I thought the separate lines were:

76 105 110 101 32 49 9 9 32 32 32 60 10
76 105 110 101 32 50 9 9 32 32 32 60 10 13
9 9 32 32 32 60 10
76 105 110 101 32 51 9 9 32 32 32 60

That would mean the ASCII 13 (carriage return) was being used as the line ending for line 2, but I think the correct interpretation is:

76 105 110 101 32 49 9 9 32 32 32 60 10
76 105 110 101 32 50 9 9 32 32 32 60 10
13 9 9 32 32 32 60 10
76 105 110 101 32 51 9 9 32 32 32 60

In which the carriage return is seen as the first character of the third line.

Is there some value in including an invisible ASCII 13 in the diff results, when it's not even rendered as a carriage return? I think such characters should be rendered in the diff results with some special, visible code to indicate what's there. Is it there for some terminal that somehow renders it?




--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.14.21/236 - Release Date: 1/20/2006





reply via email to

[Prev in Thread] Current Thread [Next in Thread]