diff options
| author | Kenichi Handa | 2009-01-14 12:51:06 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2009-01-14 12:51:06 +0000 |
| commit | 220eeac9e440b45cfe79d4441c26e51f8890c556 (patch) | |
| tree | fffff13aef634e8d0489293b613bcac62e5ca009 /src/coding.c | |
| parent | f56a4450912fa06401b13e6631313fe17bed006f (diff) | |
| download | emacs-220eeac9e440b45cfe79d4441c26e51f8890c556.tar.gz emacs-220eeac9e440b45cfe79d4441c26e51f8890c556.zip | |
Fix previous changes.
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 72 |
1 files changed, 35 insertions, 37 deletions
diff --git a/src/coding.c b/src/coding.c index 9a94bc6fb2a..21c59454346 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -744,44 +744,42 @@ static struct coding_system coding_categories[coding_category_max]; | |||
| 744 | } while (0) | 744 | } while (0) |
| 745 | 745 | ||
| 746 | /* Safely get two bytes from the source text pointed by SRC which ends | 746 | /* Safely get two bytes from the source text pointed by SRC which ends |
| 747 | at SRC_END, and set C1 and C2 to those bytes. If there are not | 747 | at SRC_END, and set C1 and C2 to those bytes while skipping the |
| 748 | enough bytes in the source for C1, it jumps to `no_more_source'. | 748 | heading multibyte characters. If there are not enough bytes in the |
| 749 | If there are not enough bytes in the source for C2, set C2 to -1. | 749 | source, it jumps to `no_more_source'. If multibytep is nonzero and |
| 750 | If multibytep is nonzero and a multibyte character is found at SRC, | 750 | a multibyte character is found for C2, set C2 to the negative value |
| 751 | set C1 and/or C2 to the negative value of the character code. The | 751 | of the character code. The caller should declare and set these |
| 752 | caller should declare and set these variables appropriately in | 752 | variables appropriately in advance: |
| 753 | advance: | ||
| 754 | src, src_end, multibytep | 753 | src, src_end, multibytep |
| 755 | It is intended that this macro is used in detect_coding_utf_16. */ | 754 | It is intended that this macro is used in detect_coding_utf_16. */ |
| 756 | 755 | ||
| 757 | #define TWO_MORE_BYTES(c1, c2) \ | 756 | #define TWO_MORE_BYTES(c1, c2) \ |
| 758 | do { \ | 757 | do { \ |
| 759 | if (src == src_end) \ | 758 | do { \ |
| 760 | goto no_more_source; \ | 759 | if (src == src_end) \ |
| 761 | c1 = *src++; \ | 760 | goto no_more_source; \ |
| 762 | if (multibytep && (c1 & 0x80)) \ | 761 | c1 = *src++; \ |
| 763 | { \ | 762 | if (multibytep && (c1 & 0x80)) \ |
| 764 | if ((c1 & 0xFE) == 0xC0) \ | 763 | { \ |
| 765 | c1 = ((c1 & 1) << 6) | *src++; \ | 764 | if ((c1 & 0xFE) == 0xC0) \ |
| 766 | else \ | 765 | c1 = ((c1 & 1) << 6) | *src++; \ |
| 767 | { \ | 766 | else \ |
| 768 | c1 = c2 = -1; \ | 767 | { \ |
| 769 | break; \ | 768 | src += BYTES_BY_CHAR_HEAD (c1) - 1; \ |
| 770 | } \ | 769 | c1 = -1; \ |
| 771 | } \ | 770 | } \ |
| 772 | if (src == src_end) \ | 771 | } \ |
| 773 | c2 = -1; \ | 772 | } while (c1 < 0); \ |
| 774 | else \ | 773 | if (src == src_end) \ |
| 775 | { \ | 774 | goto no_more_source; \ |
| 776 | c2 = *src++; \ | 775 | c2 = *src++; \ |
| 777 | if (multibytep && (c2 & 0x80)) \ | 776 | if (multibytep && (c2 & 0x80)) \ |
| 778 | { \ | 777 | { \ |
| 779 | if ((c2 & 0xFE) == 0xC0) \ | 778 | if ((c2 & 0xFE) == 0xC0) \ |
| 780 | c2 = ((c2 & 1) << 6) | *src++; \ | 779 | c2 = ((c2 & 1) << 6) | *src++; \ |
| 781 | else \ | 780 | else \ |
| 782 | c2 = -1; \ | 781 | c2 = -1; \ |
| 783 | } \ | 782 | } \ |
| 784 | } \ | ||
| 785 | } while (0) | 783 | } while (0) |
| 786 | 784 | ||
| 787 | 785 | ||
| @@ -1633,7 +1631,7 @@ detect_coding_utf_16 (coding, detect_info) | |||
| 1633 | | CATEGORY_MASK_UTF_16_BE_NOSIG | 1631 | | CATEGORY_MASK_UTF_16_BE_NOSIG |
| 1634 | | CATEGORY_MASK_UTF_16_LE_NOSIG); | 1632 | | CATEGORY_MASK_UTF_16_LE_NOSIG); |
| 1635 | } | 1633 | } |
| 1636 | else if (c1 < 0 || c2 < 0) | 1634 | else if (c2 < 0) |
| 1637 | { | 1635 | { |
| 1638 | detect_info->rejected |= CATEGORY_MASK_UTF_16; | 1636 | detect_info->rejected |= CATEGORY_MASK_UTF_16; |
| 1639 | return 0; | 1637 | return 0; |
| @@ -1656,7 +1654,7 @@ detect_coding_utf_16 (coding, detect_info) | |||
| 1656 | while (1) | 1654 | while (1) |
| 1657 | { | 1655 | { |
| 1658 | TWO_MORE_BYTES (c1, c2); | 1656 | TWO_MORE_BYTES (c1, c2); |
| 1659 | if (c1 < 0 || c2 < 0) | 1657 | if (c2 < 0) |
| 1660 | break; | 1658 | break; |
| 1661 | if (! e[c1]) | 1659 | if (! e[c1]) |
| 1662 | { | 1660 | { |