aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
authorKenichi Handa1999-05-10 01:04:01 +0000
committerKenichi Handa1999-05-10 01:04:01 +0000
commit38edf7d458446353dcc75003e46cc3530dfb7950 (patch)
treec78350933470490d44dc4fc2710e9bd0cc6c77b2 /src/coding.c
parent847fb74822ac8959c1ffca36b8cf1adbef9ec609 (diff)
downloademacs-38edf7d458446353dcc75003e46cc3530dfb7950.tar.gz
emacs-38edf7d458446353dcc75003e46cc3530dfb7950.zip
(code_convert_region): If eol format is inconsistent,
change coding->symbol to the sibling coding system of Unix like eol format.
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/coding.c b/src/coding.c
index 8b2bf7cac3d..9b6ff07b255 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -4473,6 +4473,7 @@ code_convert_region (from, from_byte, to, to_byte, coding, encodep, replace)
4473 if (! encodep && result == CODING_FINISH_INCONSISTENT_EOL) 4473 if (! encodep && result == CODING_FINISH_INCONSISTENT_EOL)
4474 { 4474 {
4475 unsigned char *pend = dst, *p = pend - inserted_byte; 4475 unsigned char *pend = dst, *p = pend - inserted_byte;
4476 Lisp_Object eol_type;
4476 4477
4477 /* Encode LFs back to the original eol format (CR or CRLF). */ 4478 /* Encode LFs back to the original eol format (CR or CRLF). */
4478 if (coding->eol_type == CODING_EOL_CR) 4479 if (coding->eol_type == CODING_EOL_CR)
@@ -4486,7 +4487,7 @@ code_convert_region (from, from_byte, to, to_byte, coding, encodep, replace)
4486 while (p < pend) if (*p++ == '\n') count++; 4487 while (p < pend) if (*p++ == '\n') count++;
4487 if (src - dst < count) 4488 if (src - dst < count)
4488 { 4489 {
4489 /* We don't have sufficient room for putting LFs 4490 /* We don't have sufficient room for encoding LFs
4490 back to CRLF. We must record converted and 4491 back to CRLF. We must record converted and
4491 not-yet-converted text back to the buffer 4492 not-yet-converted text back to the buffer
4492 content, enlarge the gap, then record them out of 4493 content, enlarge the gap, then record them out of
@@ -4519,8 +4520,14 @@ code_convert_region (from, from_byte, to, to_byte, coding, encodep, replace)
4519 /* Suppress eol-format conversion in the further conversion. */ 4520 /* Suppress eol-format conversion in the further conversion. */
4520 coding->eol_type = CODING_EOL_LF; 4521 coding->eol_type = CODING_EOL_LF;
4521 4522
4522 /* Restore the original symbol. */ 4523 /* Set the coding system symbol to that for Unix-like EOL. */
4523 coding->symbol = saved_coding_symbol; 4524 eol_type = Fget (saved_coding_symbol, Qeol_type);
4525 if (VECTORP (eol_type)
4526 && XVECTOR (eol_type)->size == 3
4527 && SYMBOLP (XVECTOR (eol_type)->contents[CODING_EOL_LF]))
4528 coding->symbol = XVECTOR (eol_type)->contents[CODING_EOL_LF];
4529 else
4530 coding->symbol = saved_coding_symbol;
4524 4531
4525 continue; 4532 continue;
4526 } 4533 }