diff options
author | Kenichi Handa <handa@m17n.org> | 2010-02-17 15:47:32 +0900 |
---|---|---|
committer | Kenichi Handa <handa@m17n.org> | 2010-02-17 15:47:32 +0900 |
commit | d0396581d5db3d6fd0b27db3511a281cf50b6bd2 (patch) | |
tree | 432363f3f70fb139ddd97622d230827ca2d43000 /src/coding.c | |
parent | f1e0d763624b7aaecde07611cbe33d189901665b (diff) | |
download | emacs-d0396581d5db3d6fd0b27db3511a281cf50b6bd2.tar.gz |
Fix the ccl decoder for the case that the output buffer is fullfilled.
Diffstat (limited to 'src/coding.c')
-rw-r--r-- | src/coding.c | 52 |
1 files changed, 23 insertions, 29 deletions
diff --git a/src/coding.c b/src/coding.c index 935d32e6a58..879cae56194 100644 --- a/src/coding.c +++ b/src/coding.c @@ -5220,18 +5220,16 @@ decode_coding_ccl (coding) int *charbuf_end = coding->charbuf + coding->charbuf_size; int consumed_chars = 0; int multibytep = coding->src_multibyte; - struct ccl_program ccl; + struct ccl_program *ccl = &coding->spec.ccl->ccl; int source_charbuf[1024]; int source_byteidx[1024]; Lisp_Object attrs, charset_list; CODING_GET_INFO (coding, attrs, charset_list); - setup_ccl_program (&ccl, CODING_CCL_DECODER (coding)); - while (src < src_end) + while (1) { const unsigned char *p = src; - int *source, *source_end; int i = 0; if (multibytep) @@ -5245,37 +5243,26 @@ decode_coding_ccl (coding) source_charbuf[i++] = *p++; if (p == src_end && coding->mode & CODING_MODE_LAST_BLOCK) - ccl.last_block = 1; - - source = source_charbuf; - source_end = source + i; - while (source < source_end) - { - ccl_driver (&ccl, source, charbuf, - source_end - source, charbuf_end - charbuf, - charset_list); - source += ccl.consumed; - charbuf += ccl.produced; - if (ccl.status != CCL_STAT_SUSPEND_BY_DST) - break; - } - if (source < source_end) - src += source_byteidx[source - source_charbuf]; + ccl->last_block = 1; + ccl_driver (ccl, source_charbuf, charbuf, i, charbuf_end - charbuf, + charset_list); + charbuf += ccl->produced; + if (multibytep && ccl->consumed < i) + src += source_byteidx[ccl->consumed]; else - src = p; - consumed_chars += source - source_charbuf; - - if (ccl.status != CCL_STAT_SUSPEND_BY_SRC - && ccl.status != CODING_RESULT_INSUFFICIENT_SRC) + src += ccl->consumed; + consumed_chars += ccl->consumed; + if (p == src_end || ccl->status != CCL_STAT_SUSPEND_BY_SRC) break; } - switch (ccl.status) + switch (ccl->status) { case CCL_STAT_SUSPEND_BY_SRC: record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_SRC); break; case CCL_STAT_SUSPEND_BY_DST: + record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_DST); break; case CCL_STAT_QUIT: case CCL_STAT_INVALID_CMD: @@ -7117,6 +7104,7 @@ decode_coding (coding) Lisp_Object attrs; Lisp_Object undo_list; Lisp_Object translation_table; + struct ccl_spec cclspec; int carryover; int i; @@ -7149,6 +7137,11 @@ decode_coding (coding) translation_table = get_translation_table (attrs, 0, NULL); carryover = 0; + if (coding->decoder == decode_coding_ccl) + { + coding->spec.ccl = &cclspec; + setup_ccl_program (&cclspec.ccl, CODING_CCL_DECODER (coding)); + } do { EMACS_INT pos = coding->dst_pos + coding->produced_char; @@ -7165,9 +7158,10 @@ decode_coding (coding) coding->charbuf[i] = coding->charbuf[coding->charbuf_used - carryover + i]; } - while (coding->consumed < coding->src_bytes - && (coding->result == CODING_RESULT_SUCCESS - || coding->result == CODING_RESULT_INVALID_SRC)); + while (coding->result == CODING_RESULT_INSUFFICIENT_DST + || (coding->consumed < coding->src_bytes + && (coding->result == CODING_RESULT_SUCCESS + || coding->result == CODING_RESULT_INVALID_SRC))); if (carryover > 0) { |