comparison src/coding.c @ 24706:778b3f056f7f

(code_convert_region): If eol format is inconsistent, change coding->symbol to the sibling coding system of Unix like eol format.
author Kenichi Handa <handa@m17n.org>
date Mon, 10 May 1999 01:04:01 +0000
parents 6156dc5f5ce0
children c15dcedcb81c
comparison
equal deleted inserted replaced
24705:af1bca0bf79b 24706:778b3f056f7f
4471 break; 4471 break;
4472 } 4472 }
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)
4479 { 4480 {
4480 while (p < pend) if (*p++ == '\n') p[-1] = '\r'; 4481 while (p < pend) if (*p++ == '\n') p[-1] = '\r';
4484 int count = 0; 4485 int count = 0;
4485 4486
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
4493 the buffer contents again. */ 4494 the buffer contents again. */
4494 int add = len_byte + inserted_byte; 4495 int add = len_byte + inserted_byte;
4517 } 4518 }
4518 4519
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 }
4527 if (len_byte <= 0) 4534 if (len_byte <= 0)
4528 { 4535 {