aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2006-03-07 08:15:33 +0000
committerKenichi Handa2006-03-07 08:15:33 +0000
commit4d41e8b7ab7a5d4f0f943009b46350df4d0cf661 (patch)
treeefdbd752c3fdc083a2f155d41b4ed724528bf0ba /src
parentff5584634e38564635be5e55dbc7925867aa9283 (diff)
downloademacs-4d41e8b7ab7a5d4f0f943009b46350df4d0cf661.tar.gz
emacs-4d41e8b7ab7a5d4f0f943009b46350df4d0cf661.zip
(DECODE_COMPOSITION_START): If the source is short, set
coding->result to CODING_RESULT_INSUFFICIENT_SRC. (decode_coding_gap): Set CODING_MODE_LAST_BLOCK after the call of detect_coding. (emacs_mule_char): Handle old style (Emacs 20) component character of a composition. (DECODE_EMACS_MULE_COMPOSITION_RULE_20): Fix parsing a composition rule. (DECODE_EMACS_MULE_20_RULEBASE_COMPOSITION): Likewise. (decode_coding_emacs_mule): Handle invalid bytes correctly.
Diffstat (limited to 'src')
-rw-r--r--src/coding.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/coding.c b/src/coding.c
index 5d92b7803c1..05d2a06843b 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -1702,6 +1702,18 @@ emacs_mule_char (coding, src, nbytes, nchars, id)
1702 } 1702 }
1703 else 1703 else
1704 { 1704 {
1705 if (c >= 0xA0)
1706 {
1707 /* Old style component character of a compostion. */
1708 if (c == 0xA0)
1709 {
1710 ONE_MORE_BYTE (c);
1711 c -= 0x80;
1712 }
1713 else
1714 c -= 0x20;
1715 }
1716
1705 switch (emacs_mule_bytes[c]) 1717 switch (emacs_mule_bytes[c])
1706 { 1718 {
1707 case 2: 1719 case 2:
@@ -1912,7 +1924,7 @@ detect_coding_emacs_mule (coding, detect_info)
1912 if (src >= src_end) \ 1924 if (src >= src_end) \
1913 goto invalid_code; \ 1925 goto invalid_code; \
1914 ONE_MORE_BYTE_NO_CHECK (c); \ 1926 ONE_MORE_BYTE_NO_CHECK (c); \
1915 c -= 0x20; \ 1927 c -= 0xA0; \
1916 if (c < 0 || c >= 81) \ 1928 if (c < 0 || c >= 81) \
1917 goto invalid_code; \ 1929 goto invalid_code; \
1918 \ 1930 \
@@ -2010,23 +2022,28 @@ detect_coding_emacs_mule (coding, detect_info)
2010 /* Emacs 20 style format for rule-base composition. */ \ 2022 /* Emacs 20 style format for rule-base composition. */ \
2011 /* Store multibyte form of characters to be composed. */ \ 2023 /* Store multibyte form of characters to be composed. */ \
2012 enum composition_method method = COMPOSITION_WITH_RULE; \ 2024 enum composition_method method = COMPOSITION_WITH_RULE; \
2025 int *charbuf_base = charbuf; \
2013 int components[MAX_COMPOSITION_COMPONENTS * 2 - 1]; \ 2026 int components[MAX_COMPOSITION_COMPONENTS * 2 - 1]; \
2014 int *buf = components; \ 2027 int *buf = components; \
2015 int i, j; \ 2028 int i, j; \
2016 \ 2029 \
2017 DECODE_EMACS_MULE_COMPOSITION_CHAR (buf); \ 2030 DECODE_EMACS_MULE_COMPOSITION_CHAR (buf); \
2018 for (i = 0; i < MAX_COMPOSITION_COMPONENTS; i++) \ 2031 for (i = 1; i < MAX_COMPOSITION_COMPONENTS; i++) \
2019 { \ 2032 { \
2033 if (*src < 0xA0) \
2034 break; \
2020 DECODE_EMACS_MULE_COMPOSITION_RULE_20 (buf); \ 2035 DECODE_EMACS_MULE_COMPOSITION_RULE_20 (buf); \
2021 DECODE_EMACS_MULE_COMPOSITION_CHAR (buf); \ 2036 DECODE_EMACS_MULE_COMPOSITION_CHAR (buf); \
2022 } \ 2037 } \
2023 if (i < 1 || (buf - components) % 2 == 0) \ 2038 if (i <= 1 || (buf - components) % 2 == 0) \
2024 goto invalid_code; \ 2039 goto invalid_code; \
2025 if (charbuf + i + (i / 2) + 1 < charbuf_end) \ 2040 if (charbuf + i + (i / 2) + 1 >= charbuf_end) \
2026 goto no_more_source; \ 2041 goto no_more_source; \
2027 ADD_COMPOSITION_DATA (buf, i, method); \ 2042 ADD_COMPOSITION_DATA (charbuf, i, method); \
2043 i = i * 2 - 1; \
2028 for (j = 0; j < i; j++) \ 2044 for (j = 0; j < i; j++) \
2029 *charbuf++ = components[j]; \ 2045 *charbuf++ = components[j]; \
2046 charbuf_base[0] -= i; \
2030 for (j = 0; j < i; j += 2) \ 2047 for (j = 0; j < i; j += 2) \
2031 *charbuf++ = components[j]; \ 2048 *charbuf++ = components[j]; \
2032 } while (0) 2049 } while (0)
@@ -2113,6 +2130,8 @@ decode_coding_emacs_mule (coding)
2113 consumed_chars += nchars; 2130 consumed_chars += nchars;
2114 char_offset++; 2131 char_offset++;
2115 } 2132 }
2133 else
2134 goto invalid_code;
2116 continue; 2135 continue;
2117 2136
2118 invalid_code: 2137 invalid_code: