comparison src/coding.c @ 107507:8960853cf85d

Fix the ccl encoder for the case that the output buffer is fullfilled.
author Kenichi Handa <handa@m17n.org>
date Tue, 16 Mar 2010 14:48:41 +0900
parents cd151730b160
children bef5d1738c0b 62d9702eb261
comparison
equal deleted inserted replaced
107506:cd151730b160 107507:8960853cf85d
5305 5305
5306 static int 5306 static int
5307 encode_coding_ccl (coding) 5307 encode_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;
5314 unsigned char *dst = coding->destination + coding->produced; 5314 unsigned char *dst = coding->destination + coding->produced;
5315 unsigned char *dst_end = coding->destination + coding->dst_bytes; 5315 unsigned char *dst_end = coding->destination + coding->dst_bytes;
5316 int destination_charbuf[1024]; 5316 int destination_charbuf[1024];
5317 int i, produced_chars = 0; 5317 int i, produced_chars = 0;
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);
5353 break; 5352 break;
5354 case CCL_STAT_SUSPEND_BY_DST: 5353 case CCL_STAT_SUSPEND_BY_DST:
7535 struct coding_system *coding; 7534 struct coding_system *coding;
7536 { 7535 {
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)
7543 translation_table = Qnil, max_lookup = 0; 7543 translation_table = Qnil, max_lookup = 0;
7544 else 7544 else
7556 record_conversion_result (coding, CODING_RESULT_SUCCESS); 7556 record_conversion_result (coding, CODING_RESULT_SUCCESS);
7557 coding->errors = 0; 7557 coding->errors = 0;
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);
7564 coding_set_destination (coding); 7569 coding_set_destination (coding);
7565 (*(coding->encoder)) (coding); 7570 (*(coding->encoder)) (coding);