summaryrefslogtreecommitdiff
path: root/src/coding.c
diff options
context:
space:
mode:
authorKenichi Handa <handa@m17n.org>1998-12-15 04:35:38 +0000
committerKenichi Handa <handa@m17n.org>1998-12-15 04:35:38 +0000
commit944bd420048ab53a7c30ecd6a3d7c8cfa516e60e (patch)
treea776e524317eb0dfa015eaab99776be28176878c /src/coding.c
parent02a08df0ab3cfbbba735993bd1bb94d02b1fd827 (diff)
downloademacs-944bd420048ab53a7c30ecd6a3d7c8cfa516e60e.tar.gz
(DECODE_DESIGNATION): Jump to label_invalid_code if
final_char is invalid. (decode_coding): If coding->type is coding_type_ccl, call ccl_coding_driver even if SRC_BYTES is zero. (code_convert_region): Update `inserted' correctly after calling coding->post_read_conversion. Even after the code converter consumed all source text, call it once more if it is coding_type_ccl to flush out data.
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/coding.c b/src/coding.c
index e9d9b16ba10..5be7095189e 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -937,9 +937,13 @@ detect_coding_iso2022 (src, src_end)
/* Set designation state into CODING. */
#define DECODE_DESIGNATION(reg, dimension, chars, final_char) \
do { \
- int charset = ISO_CHARSET_TABLE (make_number (dimension), \
- make_number (chars), \
- make_number (final_char)); \
+ int charset; \
+ \
+ if (final_char < '0' || final_char >= 128) \
+ goto label_invalid_code; \
+ charset = ISO_CHARSET_TABLE (make_number (dimension), \
+ make_number (chars), \
+ make_number (final_char)); \
if (charset >= 0 \
&& (CODING_SPEC_ISO_REQUESTED_DESIGNATION (coding, charset) == reg \
|| coding->safe_charsets[charset])) \
@@ -3694,6 +3698,7 @@ decode_coding (coding, source, destination, src_bytes, dst_bytes)
int result;
if (src_bytes <= 0
+ && coding->type != coding_type_ccl
&& ! (coding->mode & CODING_MODE_LAST_BLOCK
&& CODING_REQUIRE_FLUSHING (coding)))
{
@@ -4310,6 +4315,7 @@ code_convert_region (from, from_byte, to, to_byte, coding, encodep, replace)
move_gap_both (from, from_byte);
SHRINK_CONVERSION_REGION (&from_byte, &to_byte, coding, NULL, encodep);
if (from_byte == to_byte
+ && coding->type != coding_type_ccl
&& ! (coding->mode & CODING_MODE_LAST_BLOCK
&& CODING_REQUIRE_FLUSHING (coding)))
{
@@ -4452,7 +4458,13 @@ code_convert_region (from, from_byte, to, to_byte, coding, encodep, replace)
continue;
}
if (len_byte <= 0)
- break;
+ {
+ if (coding->type != coding_type_ccl
+ || coding->mode & CODING_MODE_LAST_BLOCK)
+ break;
+ coding->mode |= CODING_MODE_LAST_BLOCK;
+ continue;
+ }
if (result == CODING_FINISH_INSUFFICIENT_SRC)
{
/* The source text ends in invalid codes. Let's just
@@ -4547,7 +4559,7 @@ code_convert_region (from, from_byte, to, to_byte, coding, encodep, replace)
prev_Z = Z;
val = call1 (coding->post_read_conversion, make_number (inserted));
CHECK_NUMBER (val, 0);
- inserted = Z - prev_Z;
+ inserted += Z - prev_Z;
}
if (orig_point >= from)