From 9864ebcee4638bddc1f0ffb4a0742713c5024318 Mon Sep 17 00:00:00 2001 From: Kenichi Handa Date: Fri, 18 Sep 1998 13:10:40 +0000 Subject: [PATCH] (ccl_coding_driver): If ccl_driver is interrupted by a user or the CCL program executed an invalid command, return CODING_FINISH_INTERRUPT. (code_convert_region): Pay attention to the converters return value CODING_FINISH_NORMAL and CODING_FINISH_INTERRUPT. --- src/coding.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/coding.c b/src/coding.c index bc6035eb25b..47268d340bf 100644 --- a/src/coding.c +++ b/src/coding.c @@ -3625,6 +3625,10 @@ ccl_coding_driver (coding, source, destination, src_bytes, dst_bytes, encodep) case CCL_STAT_SUSPEND_BY_DST: result = CODING_FINISH_INSUFFICIENT_DST; break; + case CCL_STAT_QUIT: + case CCL_STAT_INVALID_CMD: + result = CODING_FINISH_INTERRUPT; + break; default: result = CODING_FINISH_NORMAL; break; @@ -4253,6 +4257,11 @@ code_convert_region (from, from_byte, to, to_byte, coding, encodep, replace) src += coding->consumed; dst += inserted_byte; + if (result == CODING_FINISH_NORMAL) + { + src += len_byte; + break; + } if (! encodep && result == CODING_FINISH_INCONSISTENT_EOL) { unsigned char *pend = dst, *p = pend - inserted_byte; @@ -4320,6 +4329,20 @@ code_convert_region (from, from_byte, to, to_byte, coding, encodep, replace) fake_multibyte = 1; break; } + if (result == CODING_FINISH_INTERRUPT) + { + /* The conversion procedure was interrupted by a user. */ + fake_multibyte = 1; + break; + } + /* Now RESULT == CODING_FINISH_INSUFFICIENT_DST */ + if (coding->consumed < 1) + { + /* It's quite strange to require more memory without + consuming any bytes. Perhaps CCL program bug. */ + fake_multibyte = 1; + break; + } if (first) { /* We have just done the first batch of conversion which was