mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-19 20:30:29 -08:00
(detect_eol, decode_eol): Handle text with DOS-style EOLs that also has
stray ^M characters.
This commit is contained in:
parent
3951477883
commit
75f4f1ac04
2 changed files with 35 additions and 8 deletions
38
src/coding.c
38
src/coding.c
|
|
@ -5819,16 +5819,26 @@ detect_eol (source, src_bytes, category)
|
|||
|| src[lsb + 2] != '\n')
|
||||
this_eol = EOL_SEEN_CR;
|
||||
else
|
||||
this_eol = EOL_SEEN_CRLF;
|
||||
{
|
||||
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. */
|
||||
eol_seen = EOL_SEEN_LF;
|
||||
break;
|
||||
/* 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,9 +5867,16 @@ detect_eol (source, src_bytes, category)
|
|||
eol_seen = this_eol;
|
||||
else if (eol_seen != this_eol)
|
||||
{
|
||||
/* The found type is different from what found before. */
|
||||
eol_seen = EOL_SEEN_LF;
|
||||
break;
|
||||
/* 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 @@ decode_eol (coding)
|
|||
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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue