diff options
| author | Eli Zaretskii | 2000-10-24 09:04:35 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 2000-10-24 09:04:35 +0000 |
| commit | 4af310dbf1579233db1cf4ed41651b3d93aea5d6 (patch) | |
| tree | 25bb2e12acaa2e3831b2244dd2f0f51e5663a1d7 /src/coding.c | |
| parent | 333526e0f4a3ea95dcc6a98b26238d27670c1818 (diff) | |
| download | emacs-4af310dbf1579233db1cf4ed41651b3d93aea5d6.tar.gz emacs-4af310dbf1579233db1cf4ed41651b3d93aea5d6.zip | |
(decode_coding_emacs_mule): If coding->eol_type is CR
or CRLF, decode EOLs.
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/src/coding.c b/src/coding.c index e833aedf525..3cef86e5cea 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -614,7 +614,45 @@ decode_coding_emacs_mule (coding, source, destination, src_bytes, dst_bytes) | |||
| 614 | unsigned char tmp[MAX_MULTIBYTE_LENGTH], *p; | 614 | unsigned char tmp[MAX_MULTIBYTE_LENGTH], *p; |
| 615 | int bytes; | 615 | int bytes; |
| 616 | 616 | ||
| 617 | if (UNIBYTE_STR_AS_MULTIBYTE_P (src, src_end - src, bytes)) | 617 | if (*src == '\r') |
| 618 | { | ||
| 619 | int c; | ||
| 620 | |||
| 621 | src++; | ||
| 622 | if (coding->eol_type == CODING_EOL_CR) | ||
| 623 | c = '\n'; | ||
| 624 | else if (coding->eol_type == CODING_EOL_CRLF) | ||
| 625 | { | ||
| 626 | ONE_MORE_BYTE (c); | ||
| 627 | if (c != '\n') | ||
| 628 | { | ||
| 629 | if (coding->mode & CODING_MODE_INHIBIT_INCONSISTENT_EOL) | ||
| 630 | { | ||
| 631 | coding->result = CODING_FINISH_INCONSISTENT_EOL; | ||
| 632 | goto label_end_of_loop; | ||
| 633 | } | ||
| 634 | src--; | ||
| 635 | c = '\r'; | ||
| 636 | } | ||
| 637 | } | ||
| 638 | *dst++ = c; | ||
| 639 | coding->produced_char++; | ||
| 640 | continue; | ||
| 641 | } | ||
| 642 | else if (*src == '\n') | ||
| 643 | { | ||
| 644 | if ((coding->eol_type == CODING_EOL_CR | ||
| 645 | || coding->eol_type == CODING_EOL_CRLF) | ||
| 646 | && coding->mode & CODING_MODE_INHIBIT_INCONSISTENT_EOL) | ||
| 647 | { | ||
| 648 | coding->result = CODING_FINISH_INCONSISTENT_EOL; | ||
| 649 | goto label_end_of_loop; | ||
| 650 | } | ||
| 651 | *dst++ = *src++; | ||
| 652 | coding->produced_char++; | ||
| 653 | continue; | ||
| 654 | } | ||
| 655 | else if (UNIBYTE_STR_AS_MULTIBYTE_P (src, src_end - src, bytes)) | ||
| 618 | { | 656 | { |
| 619 | p = src; | 657 | p = src; |
| 620 | src += bytes; | 658 | src += bytes; |
| @@ -633,6 +671,7 @@ decode_coding_emacs_mule (coding, source, destination, src_bytes, dst_bytes) | |||
| 633 | while (bytes--) *dst++ = *p++; | 671 | while (bytes--) *dst++ = *p++; |
| 634 | coding->produced_char++; | 672 | coding->produced_char++; |
| 635 | } | 673 | } |
| 674 | label_end_of_loop: | ||
| 636 | coding->consumed = coding->consumed_char = src_base - source; | 675 | coding->consumed = coding->consumed_char = src_base - source; |
| 637 | coding->produced = dst - destination; | 676 | coding->produced = dst - destination; |
| 638 | } | 677 | } |