X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Ftext-coding.c;h=795c1e7010e3ba345b2d5ef2469f797ef1d5559b;hb=2409cab800d46dd20d2ccf674cee3366ea31a72c;hp=796e7576c368c126a71196c9d8696223d9fd441f;hpb=7532868f03090d56d24722bb26f37e3c9a65fe03;p=chise%2Fxemacs-chise.git diff --git a/src/text-coding.c b/src/text-coding.c index 796e757..795c1e7 100644 --- a/src/text-coding.c +++ b/src/text-coding.c @@ -3502,12 +3502,12 @@ char_encode_shift_jis (struct encoding_stream *str, Emchar ch, { unsigned int s1, s2; #ifdef UTF2000 - int code_point = charset_code_point (Vcharset_latin_jisx0201, ch); + int code_point = charset_code_point (Vcharset_latin_jisx0201, ch, 0); if (code_point >= 0) Dynarr_add (dst, code_point); else if ((code_point - = charset_code_point (Vcharset_japanese_jisx0208_1990, ch)) + = charset_code_point (Vcharset_japanese_jisx0208_1990, ch, 0)) >= 0) { ENCODE_SJIS ((code_point >> 8) | 0x80, @@ -3516,11 +3516,11 @@ char_encode_shift_jis (struct encoding_stream *str, Emchar ch, Dynarr_add (dst, s2); } else if ((code_point - = charset_code_point (Vcharset_katakana_jisx0201, ch)) + = charset_code_point (Vcharset_katakana_jisx0201, ch, 0)) >= 0) Dynarr_add (dst, code_point | 0x80); else if ((code_point - = charset_code_point (Vcharset_japanese_jisx0208, ch)) + = charset_code_point (Vcharset_japanese_jisx0208, ch, 0)) >= 0) { ENCODE_SJIS ((code_point >> 8) | 0x80, @@ -3528,7 +3528,7 @@ char_encode_shift_jis (struct encoding_stream *str, Emchar ch, Dynarr_add (dst, s1); Dynarr_add (dst, s2); } - else if ((code_point = charset_code_point (Vcharset_ascii, ch)) + else if ((code_point = charset_code_point (Vcharset_ascii, ch, 0)) >= 0) Dynarr_add (dst, code_point); else @@ -3834,21 +3834,21 @@ char_encode_big5 (struct encoding_stream *str, Emchar ch, Lisp_Object ccs = CODING_SYSTEM_ISO2022_INITIAL_CHARSET (str->codesys, 1); - if ((code_point = charset_code_point (Vcharset_ascii, ch)) >= 0) + if ((code_point = charset_code_point (Vcharset_ascii, ch, 0)) >= 0) Dynarr_add (dst, code_point); - else if ((code_point = charset_code_point (ccs, ch)) >= 0) + else if ((code_point = charset_code_point (ccs, ch, 0)) >= 0) { Dynarr_add (dst, code_point >> 8); Dynarr_add (dst, code_point & 0xFF); } else if ((code_point - = charset_code_point (Vcharset_chinese_big5, ch)) >= 0) + = charset_code_point (Vcharset_chinese_big5, ch, 0)) >= 0) { Dynarr_add (dst, code_point >> 8); Dynarr_add (dst, code_point & 0xFF); } else if ((code_point - = charset_code_point (Vcharset_chinese_big5_1, ch)) >= 0) + = charset_code_point (Vcharset_chinese_big5_1, ch, 0)) >= 0) { unsigned int I = ((code_point >> 8) - 33) * (0xFF - 0xA1) @@ -3861,7 +3861,7 @@ char_encode_big5 (struct encoding_stream *str, Emchar ch, Dynarr_add (dst, b2); } else if ((code_point - = charset_code_point (Vcharset_chinese_big5_2, ch)) >= 0) + = charset_code_point (Vcharset_chinese_big5_2, ch, 0)) >= 0) { unsigned int I = ((code_point >> 8) - 33) * (0xFF - 0xA1) @@ -4164,15 +4164,17 @@ decode_coding_utf8 (Lstream *decoding, const Extbyte *src, { if ( c < ' ' ) { + COMPOSE_FLUSH_CHARS (str, dst); decode_flush_er_chars (str, dst); DECODE_HANDLE_EOL_TYPE (eol_type, c, flags, dst); DECODE_ADD_UCS_CHAR (c, dst); } else if ( c < 0xC0 ) - decode_add_er_char (str, c, dst); + /* decode_add_er_char (str, c, dst); */ + COMPOSE_ADD_CHAR (str, c, dst); else { - decode_flush_er_chars (str, dst); + /* decode_flush_er_chars (str, dst); */ if ( c < 0xE0 ) { cpos = c & 0x1f; @@ -4205,7 +4207,8 @@ decode_coding_utf8 (Lstream *decoding, const Extbyte *src, cpos = ( cpos << 6 ) | ( c & 0x3f ); if (counter == 1) { - DECODE_ADD_UCS_CHAR (cpos, dst); + /* DECODE_ADD_UCS_CHAR (cpos, dst); */ + COMPOSE_ADD_CHAR (str, cpos, dst); cpos = 0; counter = 0; } @@ -4214,6 +4217,8 @@ decode_coding_utf8 (Lstream *decoding, const Extbyte *src, } else { + COMPOSE_FLUSH_CHARS (str, dst); + decode_flush_er_chars (str, dst); decode_output_utf8_partial_char (counter, cpos, dst); DECODE_ADD_BINARY_CHAR (c, dst); cpos = 0; @@ -4224,6 +4229,7 @@ decode_coding_utf8 (Lstream *decoding, const Extbyte *src, if (flags & CODING_STATE_END) { + COMPOSE_FLUSH_CHARS (str, dst); decode_flush_er_chars (str, dst); if (counter > 0) { @@ -4256,7 +4262,7 @@ char_encode_utf8 (struct encoding_stream *str, Emchar ch, } else { - int code_point = charset_code_point (Vcharset_ucs, ch); + int code_point = charset_code_point (Vcharset_ucs, ch, 0); if ( (code_point < 0) || (code_point > 0x10FFFF) ) { @@ -4276,7 +4282,7 @@ char_encode_utf8 (struct encoding_stream *str, Emchar ch, if (!NILP (ccs = Ffind_charset (ccs))) { if ( (code_point - = charset_code_point (ccs, ch)) >= 0 ) + = charset_code_point (ccs, ch, 0)) >= 0 ) { cell = Fcdr (cell); ret = Fcar (cell); @@ -5200,6 +5206,7 @@ decode_coding_iso2022 (Lstream *decoding, const Extbyte *src, case ISO_ESC_LITERAL: COMPOSE_FLUSH_CHARS (str, dst); + decode_flush_er_chars (str, dst); DECODE_ADD_BINARY_CHAR (c, dst); break; @@ -5221,6 +5228,7 @@ decode_coding_iso2022 (Lstream *decoding, const Extbyte *src, /* Output the (possibly invalid) sequence */ int i; COMPOSE_FLUSH_CHARS (str, dst); + decode_flush_er_chars (str, dst); for (i = 0; i < str->iso2022.esc_bytes_index; i++) DECODE_ADD_BINARY_CHAR (str->iso2022.esc_bytes[i], dst); flags &= CODING_STATE_ISO2022_LOCK; @@ -5232,6 +5240,7 @@ decode_coding_iso2022 (Lstream *decoding, const Extbyte *src, escape sequence; it could mess things up anyway. Just add it now. */ COMPOSE_FLUSH_CHARS (str, dst); + decode_flush_er_chars (str, dst); DECODE_ADD_BINARY_CHAR (c, dst); } } @@ -5248,6 +5257,7 @@ decode_coding_iso2022 (Lstream *decoding, const Extbyte *src, if (counter) { COMPOSE_FLUSH_CHARS (str, dst); + decode_flush_er_chars (str, dst); while (counter > 0) { counter--; @@ -5264,12 +5274,14 @@ decode_coding_iso2022 (Lstream *decoding, const Extbyte *src, if (flags & CODING_STATE_SS2) { COMPOSE_FLUSH_CHARS (str, dst); + decode_flush_er_chars (str, dst); DECODE_ADD_BINARY_CHAR (ISO_CODE_SS2, dst); flags &= ~CODING_STATE_SS2; } if (flags & CODING_STATE_SS3) { COMPOSE_FLUSH_CHARS (str, dst); + decode_flush_er_chars (str, dst); DECODE_ADD_BINARY_CHAR (ISO_CODE_SS3, dst); flags &= ~CODING_STATE_SS3; } @@ -5281,6 +5293,7 @@ decode_coding_iso2022 (Lstream *decoding, const Extbyte *src, if (c == '\r') { COMPOSE_FLUSH_CHARS (str, dst); + decode_flush_er_chars (str, dst); if (eol_type == EOL_CR) Dynarr_add (dst, '\n'); else if (eol_type != EOL_CRLF || flags & CODING_STATE_CR) @@ -5304,6 +5317,7 @@ decode_coding_iso2022 (Lstream *decoding, const Extbyte *src, if (!parse_iso2022_esc (coding_system, &str->iso2022, c, &flags, 1)) { COMPOSE_FLUSH_CHARS (str, dst); + decode_flush_er_chars (str, dst); DECODE_ADD_BINARY_CHAR (c, dst); } } @@ -5319,6 +5333,7 @@ decode_coding_iso2022 (Lstream *decoding, const Extbyte *src, if (c == '\r') { COMPOSE_FLUSH_CHARS (str, dst); + decode_flush_er_chars (str, dst); if (eol_type == EOL_CR) Dynarr_add (dst, '\n'); else if (eol_type != EOL_CRLF || flags & CODING_STATE_CR) @@ -5355,6 +5370,7 @@ decode_coding_iso2022 (Lstream *decoding, const Extbyte *src, to preserve it for the output. */ { COMPOSE_FLUSH_CHARS (str, dst); + decode_flush_er_chars (str, dst); while (counter > 0) { counter--; @@ -5458,6 +5474,7 @@ decode_coding_iso2022 (Lstream *decoding, const Extbyte *src, if (flags & CODING_STATE_END) { COMPOSE_FLUSH_CHARS (str, dst); + decode_flush_er_chars (str, dst); DECODE_OUTPUT_PARTIAL_CHAR (cpos); } str->flags = flags; @@ -5636,12 +5653,12 @@ char_encode_iso2022 (struct encoding_stream *str, Emchar ch, for (i = 0; i < 4; i++) { if ((CHARSETP (charset = str->iso2022.charset[i]) - && ((code_point = charset_code_point (charset, ch)) >= 0)) + && ((code_point = charset_code_point (charset, ch, 0)) >= 0)) || (CHARSETP (charset = CODING_SYSTEM_ISO2022_INITIAL_CHARSET (codesys, i)) - && ((code_point = charset_code_point (charset, ch)) >= 0))) + && ((code_point = charset_code_point (charset, ch, 0)) >= 0))) { reg = i; break;