[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs/src coding.c
From: |
Eli Zaretskii |
Subject: |
[Emacs-diffs] emacs/src coding.c |
Date: |
Fri, 30 Jan 2009 15:45:35 +0000 |
CVSROOT: /cvsroot/emacs
Module name: emacs
Changes by: Eli Zaretskii <eliz> 09/01/30 15:45:35
Modified files:
src : coding.c
Log message:
(detect_eol, decode_eol): Handle text with DOS-style EOLs that also has
stray ^M characters.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/src/coding.c?cvsroot=emacs&r1=1.409&r2=1.410
Patches:
Index: coding.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/coding.c,v
retrieving revision 1.409
retrieving revision 1.410
diff -u -b -r1.409 -r1.410
--- coding.c 15 Jan 2009 07:09:26 -0000 1.409
+++ coding.c 30 Jan 2009 15:45:34 -0000 1.410
@@ -5819,17 +5819,27 @@
|| src[lsb + 2] != '\n')
this_eol = EOL_SEEN_CR;
else
+ {
this_eol = EOL_SEEN_CRLF;
+ src += 2;
+ }
if (eol_seen == EOL_SEEN_NONE)
/* This is the first end-of-line. */
eol_seen = this_eol;
else if (eol_seen != this_eol)
{
- /* The found type is different from what found before. */
+ /* The found type is different from what found before.
+ Allow for stray ^M characters in DOS EOL files. */
+ if (eol_seen == EOL_SEEN_CR && this_eol == EOL_SEEN_CRLF
+ || eol_seen == EOL_SEEN_CRLF && this_eol == EOL_SEEN_CR)
+ eol_seen = EOL_SEEN_CRLF;
+ else
+ {
eol_seen = EOL_SEEN_LF;
break;
}
+ }
if (++total == MAX_EOL_CHECK_COUNT)
break;
}
@@ -5857,10 +5867,17 @@
eol_seen = this_eol;
else if (eol_seen != this_eol)
{
- /* The found type is different from what found before. */
+ /* The found type is different from what found before.
+ Allow for stray ^M characters in DOS EOL files. */
+ if (eol_seen == EOL_SEEN_CR && this_eol == EOL_SEEN_CRLF
+ || eol_seen == EOL_SEEN_CRLF && this_eol == EOL_SEEN_CR)
+ eol_seen = EOL_SEEN_CRLF;
+ else
+ {
eol_seen = EOL_SEEN_LF;
break;
}
+ }
if (++total == MAX_EOL_CHECK_COUNT)
break;
}
@@ -6114,7 +6131,12 @@
eol_seen |= EOL_SEEN_CR;
}
}
- if (eol_seen != EOL_SEEN_NONE
+ /* Handle DOS-style EOLs in a file with stray ^M characters. */
+ if ((eol_seen & EOL_SEEN_CRLF) != 0
+ && (eol_seen & EOL_SEEN_CR) != 0
+ && (eol_seen & EOL_SEEN_LF) == 0)
+ eol_seen = EOL_SEEN_CRLF;
+ else if (eol_seen != EOL_SEEN_NONE
&& eol_seen != EOL_SEEN_LF
&& eol_seen != EOL_SEEN_CRLF
&& eol_seen != EOL_SEEN_CR)