diff options
| author | Kenichi Handa | 2000-12-22 00:06:52 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2000-12-22 00:06:52 +0000 |
| commit | 17312e44d76f5322d528d5931b87b110a72619c0 (patch) | |
| tree | 06fa66af3daac558b7c15886a4f5353442e384dd /src | |
| parent | 3ad93d8dc4215a48fc3d13b9434d16dd09dcd4f2 (diff) | |
| download | emacs-17312e44d76f5322d528d5931b87b110a72619c0.tar.gz emacs-17312e44d76f5322d528d5931b87b110a72619c0.zip | |
(CCL_WRITE_CHAR): Don't handle EOL conversion here.
(CCL_READ_CHAR): Handle EOL conversion here.
(ccl_driver) <CCL_ReadMultibyteChar2>: Likewise.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ccl.c | 88 |
1 files changed, 57 insertions, 31 deletions
| @@ -701,22 +701,11 @@ static int stack_idx_of_map_multiple; | |||
| 701 | #define CCL_WRITE_CHAR(ch) \ | 701 | #define CCL_WRITE_CHAR(ch) \ |
| 702 | do { \ | 702 | do { \ |
| 703 | int bytes = SINGLE_BYTE_CHAR_P (ch) ? 1: CHAR_BYTES (ch); \ | 703 | int bytes = SINGLE_BYTE_CHAR_P (ch) ? 1: CHAR_BYTES (ch); \ |
| 704 | if (ch == '\n' && ccl->eol_type == CODING_EOL_CRLF) \ | ||
| 705 | bytes++; \ | ||
| 706 | if (!dst) \ | 704 | if (!dst) \ |
| 707 | CCL_INVALID_CMD; \ | 705 | CCL_INVALID_CMD; \ |
| 708 | else if (dst + bytes <= (dst_bytes ? dst_end : src)) \ | 706 | else if (dst + bytes <= (dst_bytes ? dst_end : src)) \ |
| 709 | { \ | 707 | { \ |
| 710 | if (ch == '\n') \ | 708 | if (bytes == 1) \ |
| 711 | { \ | ||
| 712 | if (ccl->eol_type == CODING_EOL_CRLF) \ | ||
| 713 | *dst++ = '\r', *dst++ = '\n'; \ | ||
| 714 | else if (ccl->eol_type == CODING_EOL_CR) \ | ||
| 715 | *dst++ = '\r'; \ | ||
| 716 | else \ | ||
| 717 | *dst++ = '\n'; \ | ||
| 718 | } \ | ||
| 719 | else if (bytes == 1) \ | ||
| 720 | { \ | 709 | { \ |
| 721 | *dst++ = (ch); \ | 710 | *dst++ = (ch); \ |
| 722 | if ((ch) >= 0x80 && (ch) < 0xA0) \ | 711 | if ((ch) >= 0x80 && (ch) < 0xA0) \ |
| @@ -746,24 +735,42 @@ static int stack_idx_of_map_multiple; | |||
| 746 | } while (0) | 735 | } while (0) |
| 747 | 736 | ||
| 748 | /* Read one byte from the current input buffer into Rth register. */ | 737 | /* Read one byte from the current input buffer into Rth register. */ |
| 749 | #define CCL_READ_CHAR(r) \ | 738 | #define CCL_READ_CHAR(r) \ |
| 750 | do { \ | 739 | do { \ |
| 751 | if (!src) \ | 740 | if (!src) \ |
| 752 | CCL_INVALID_CMD; \ | 741 | CCL_INVALID_CMD; \ |
| 753 | else if (src < src_end) \ | 742 | else if (src < src_end) \ |
| 754 | { \ | 743 | { \ |
| 755 | r = *src++; \ | 744 | r = *src++; \ |
| 756 | if (r == LEADING_CODE_8_BIT_CONTROL \ | 745 | if (r == '\n' \ |
| 757 | && ccl->multibyte) \ | 746 | && ccl->eol_type != CODING_EOL_LF) \ |
| 758 | r = *src++ - 0x20; \ | 747 | { \ |
| 759 | } \ | 748 | /* We are encoding. */ \ |
| 760 | else if (ccl->last_block) \ | 749 | if (ccl->eol_type == CODING_EOL_CRLF) \ |
| 761 | { \ | 750 | { \ |
| 762 | ic = ccl->eof_ic; \ | 751 | if (ccl->cr_consumed) \ |
| 763 | goto ccl_repeat; \ | 752 | ccl->cr_consumed = 0; \ |
| 764 | } \ | 753 | else \ |
| 765 | else \ | 754 | { \ |
| 766 | CCL_SUSPEND (CCL_STAT_SUSPEND_BY_SRC); \ | 755 | ccl->cr_consumed = 1; \ |
| 756 | r = '\r'; \ | ||
| 757 | src--; \ | ||
| 758 | } \ | ||
| 759 | } \ | ||
| 760 | else \ | ||
| 761 | r = '\r'; \ | ||
| 762 | } \ | ||
| 763 | if (r == LEADING_CODE_8_BIT_CONTROL \ | ||
| 764 | && ccl->multibyte) \ | ||
| 765 | r = *src++ - 0x20; \ | ||
| 766 | } \ | ||
| 767 | else if (ccl->last_block) \ | ||
| 768 | { \ | ||
| 769 | ic = ccl->eof_ic; \ | ||
| 770 | goto ccl_repeat; \ | ||
| 771 | } \ | ||
| 772 | else \ | ||
| 773 | CCL_SUSPEND (CCL_STAT_SUSPEND_BY_SRC); \ | ||
| 767 | } while (0) | 774 | } while (0) |
| 768 | 775 | ||
| 769 | 776 | ||
| @@ -1209,7 +1216,26 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed) | |||
| 1209 | } | 1216 | } |
| 1210 | 1217 | ||
| 1211 | i = *src++; | 1218 | i = *src++; |
| 1212 | if (i < 0x80) | 1219 | if (i == '\n' && ccl->eol_type != CODING_EOL_LF) |
| 1220 | { | ||
| 1221 | /* We are encoding. */ | ||
| 1222 | if (ccl->eol_type == CODING_EOL_CRLF) | ||
| 1223 | { | ||
| 1224 | if (ccl->cr_consumed) | ||
| 1225 | ccl->cr_consumed = 0; | ||
| 1226 | else | ||
| 1227 | { | ||
| 1228 | ccl->cr_consumed = 1; | ||
| 1229 | i = '\r'; | ||
| 1230 | src--; | ||
| 1231 | } | ||
| 1232 | } | ||
| 1233 | else | ||
| 1234 | i = '\r'; | ||
| 1235 | reg[rrr] = i; | ||
| 1236 | reg[RRR] = CHARSET_ASCII; | ||
| 1237 | } | ||
| 1238 | else if (i < 0x80) | ||
| 1213 | { | 1239 | { |
| 1214 | /* ASCII */ | 1240 | /* ASCII */ |
| 1215 | reg[rrr] = i; | 1241 | reg[rrr] = i; |