Mercurial > emacs
changeset 90354:450fb16a4bf4
(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.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Tue, 07 Mar 2006 08:15:33 +0000 |
parents | 6e94ff6be848 |
children | 272bc1a789ee |
files | src/coding.c |
diffstat | 1 files changed, 25 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/coding.c Tue Mar 07 04:13:56 2006 +0000 +++ b/src/coding.c Tue Mar 07 08:15:33 2006 +0000 @@ -1702,6 +1702,18 @@ } else { + if (c >= 0xA0) + { + /* Old style component character of a compostion. */ + if (c == 0xA0) + { + ONE_MORE_BYTE (c); + c -= 0x80; + } + else + c -= 0x20; + } + switch (emacs_mule_bytes[c]) { case 2: @@ -1912,7 +1924,7 @@ if (src >= src_end) \ goto invalid_code; \ ONE_MORE_BYTE_NO_CHECK (c); \ - c -= 0x20; \ + c -= 0xA0; \ if (c < 0 || c >= 81) \ goto invalid_code; \ \ @@ -2010,23 +2022,28 @@ /* Emacs 20 style format for rule-base composition. */ \ /* Store multibyte form of characters to be composed. */ \ enum composition_method method = COMPOSITION_WITH_RULE; \ + int *charbuf_base = charbuf; \ int components[MAX_COMPOSITION_COMPONENTS * 2 - 1]; \ int *buf = components; \ int i, j; \ - \ + \ DECODE_EMACS_MULE_COMPOSITION_CHAR (buf); \ - for (i = 0; i < MAX_COMPOSITION_COMPONENTS; i++) \ + for (i = 1; i < MAX_COMPOSITION_COMPONENTS; i++) \ { \ + if (*src < 0xA0) \ + break; \ DECODE_EMACS_MULE_COMPOSITION_RULE_20 (buf); \ DECODE_EMACS_MULE_COMPOSITION_CHAR (buf); \ } \ - if (i < 1 || (buf - components) % 2 == 0) \ + if (i <= 1 || (buf - components) % 2 == 0) \ goto invalid_code; \ - if (charbuf + i + (i / 2) + 1 < charbuf_end) \ + if (charbuf + i + (i / 2) + 1 >= charbuf_end) \ goto no_more_source; \ - ADD_COMPOSITION_DATA (buf, i, method); \ + ADD_COMPOSITION_DATA (charbuf, i, method); \ + i = i * 2 - 1; \ for (j = 0; j < i; j++) \ *charbuf++ = components[j]; \ + charbuf_base[0] -= i; \ for (j = 0; j < i; j += 2) \ *charbuf++ = components[j]; \ } while (0) @@ -2113,6 +2130,8 @@ consumed_chars += nchars; char_offset++; } + else + goto invalid_code; continue; invalid_code: