aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
authorKenichi Handa2010-03-16 14:48:41 +0900
committerKenichi Handa2010-03-16 14:48:41 +0900
commitfb608df3c662538c90a9a5ad0b3d13f39a3b395e (patch)
tree66ac1604d85869efef908196d4a712b0d4c80f36 /src/coding.c
parentfbdc17211b56572046387d5fd9e80d96e3d07af4 (diff)
downloademacs-fb608df3c662538c90a9a5ad0b3d13f39a3b395e.tar.gz
emacs-fb608df3c662538c90a9a5ad0b3d13f39a3b395e.zip
Fix the ccl encoder for the case that the output buffer is fullfilled.
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/src/coding.c b/src/coding.c
index a464950e8d1..bdc37cb7c53 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -5307,7 +5307,7 @@ static int
5307encode_coding_ccl (coding) 5307encode_coding_ccl (coding)
5308 struct coding_system *coding; 5308 struct coding_system *coding;
5309{ 5309{
5310 struct ccl_program ccl; 5310 struct ccl_program *ccl = &coding->spec.ccl->ccl;
5311 int multibytep = coding->dst_multibyte; 5311 int multibytep = coding->dst_multibyte;
5312 int *charbuf = coding->charbuf; 5312 int *charbuf = coding->charbuf;
5313 int *charbuf_end = charbuf + coding->charbuf_used; 5313 int *charbuf_end = charbuf + coding->charbuf_used;
@@ -5318,35 +5318,34 @@ encode_coding_ccl (coding)
5318 Lisp_Object attrs, charset_list; 5318 Lisp_Object attrs, charset_list;
5319 5319
5320 CODING_GET_INFO (coding, attrs, charset_list); 5320 CODING_GET_INFO (coding, attrs, charset_list);
5321 setup_ccl_program (&ccl, CODING_CCL_ENCODER (coding)); 5321 if (coding->consumed_char == coding->src_chars
5322 5322 && coding->mode & CODING_MODE_LAST_BLOCK)
5323 ccl.last_block = coding->mode & CODING_MODE_LAST_BLOCK; 5323 ccl->last_block = 1;
5324 ccl.dst_multibyte = coding->dst_multibyte;
5325 5324
5326 while (charbuf < charbuf_end) 5325 while (charbuf < charbuf_end)
5327 { 5326 {
5328 ccl_driver (&ccl, charbuf, destination_charbuf, 5327 ccl_driver (ccl, charbuf, destination_charbuf,
5329 charbuf_end - charbuf, 1024, charset_list); 5328 charbuf_end - charbuf, 1024, charset_list);
5330 if (multibytep) 5329 if (multibytep)
5331 { 5330 {
5332 ASSURE_DESTINATION (ccl.produced * 2); 5331 ASSURE_DESTINATION (ccl->produced * 2);
5333 for (i = 0; i < ccl.produced; i++) 5332 for (i = 0; i < ccl->produced; i++)
5334 EMIT_ONE_BYTE (destination_charbuf[i] & 0xFF); 5333 EMIT_ONE_BYTE (destination_charbuf[i] & 0xFF);
5335 } 5334 }
5336 else 5335 else
5337 { 5336 {
5338 ASSURE_DESTINATION (ccl.produced); 5337 ASSURE_DESTINATION (ccl->produced);
5339 for (i = 0; i < ccl.produced; i++) 5338 for (i = 0; i < ccl->produced; i++)
5340 *dst++ = destination_charbuf[i] & 0xFF; 5339 *dst++ = destination_charbuf[i] & 0xFF;
5341 produced_chars += ccl.produced; 5340 produced_chars += ccl->produced;
5342 } 5341 }
5343 charbuf += ccl.consumed; 5342 charbuf += ccl->consumed;
5344 if (ccl.status == CCL_STAT_QUIT 5343 if (ccl->status == CCL_STAT_QUIT
5345 || ccl.status == CCL_STAT_INVALID_CMD) 5344 || ccl->status == CCL_STAT_INVALID_CMD)
5346 break; 5345 break;
5347 } 5346 }
5348 5347
5349 switch (ccl.status) 5348 switch (ccl->status)
5350 { 5349 {
5351 case CCL_STAT_SUSPEND_BY_SRC: 5350 case CCL_STAT_SUSPEND_BY_SRC:
5352 record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_SRC); 5351 record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_SRC);
@@ -7537,6 +7536,7 @@ encode_coding (coding)
7537 Lisp_Object attrs; 7536 Lisp_Object attrs;
7538 Lisp_Object translation_table; 7537 Lisp_Object translation_table;
7539 int max_lookup; 7538 int max_lookup;
7539 struct ccl_spec cclspec;
7540 7540
7541 attrs = CODING_ID_ATTRS (coding->id); 7541 attrs = CODING_ID_ATTRS (coding->id);
7542 if (coding->encoder == encode_coding_raw_text) 7542 if (coding->encoder == encode_coding_raw_text)
@@ -7558,6 +7558,11 @@ encode_coding (coding)
7558 7558
7559 ALLOC_CONVERSION_WORK_AREA (coding); 7559 ALLOC_CONVERSION_WORK_AREA (coding);
7560 7560
7561 if (coding->encoder == encode_coding_ccl)
7562 {
7563 coding->spec.ccl = &cclspec;
7564 setup_ccl_program (&cclspec.ccl, CODING_CCL_ENCODER (coding));
7565 }
7561 do { 7566 do {
7562 coding_set_source (coding); 7567 coding_set_source (coding);
7563 consume_chars (coding, translation_table, max_lookup); 7568 consume_chars (coding, translation_table, max_lookup);