aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c52
1 files changed, 30 insertions, 22 deletions
diff --git a/src/coding.c b/src/coding.c
index df81eaba16e..bdc37cb7c53 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -5245,7 +5245,7 @@ decode_coding_ccl (coding)
5245 int multibytep = coding->src_multibyte; 5245 int multibytep = coding->src_multibyte;
5246 struct ccl_program *ccl = &coding->spec.ccl->ccl; 5246 struct ccl_program *ccl = &coding->spec.ccl->ccl;
5247 int source_charbuf[1024]; 5247 int source_charbuf[1024];
5248 int source_byteidx[1024]; 5248 int source_byteidx[1025];
5249 Lisp_Object attrs, charset_list; 5249 Lisp_Object attrs, charset_list;
5250 5250
5251 CODING_GET_INFO (coding, attrs, charset_list); 5251 CODING_GET_INFO (coding, attrs, charset_list);
@@ -5256,11 +5256,14 @@ decode_coding_ccl (coding)
5256 int i = 0; 5256 int i = 0;
5257 5257
5258 if (multibytep) 5258 if (multibytep)
5259 while (i < 1024 && p < src_end) 5259 {
5260 { 5260 while (i < 1024 && p < src_end)
5261 source_byteidx[i] = p - src; 5261 {
5262 source_charbuf[i++] = STRING_CHAR_ADVANCE (p); 5262 source_byteidx[i] = p - src;
5263 } 5263 source_charbuf[i++] = STRING_CHAR_ADVANCE (p);
5264 }
5265 source_byteidx[i] = p - src;
5266 }
5264 else 5267 else
5265 while (i < 1024 && p < src_end) 5268 while (i < 1024 && p < src_end)
5266 source_charbuf[i++] = *p++; 5269 source_charbuf[i++] = *p++;
@@ -5270,7 +5273,7 @@ decode_coding_ccl (coding)
5270 ccl_driver (ccl, source_charbuf, charbuf, i, charbuf_end - charbuf, 5273 ccl_driver (ccl, source_charbuf, charbuf, i, charbuf_end - charbuf,
5271 charset_list); 5274 charset_list);
5272 charbuf += ccl->produced; 5275 charbuf += ccl->produced;
5273 if (multibytep && ccl->consumed < i) 5276 if (multibytep)
5274 src += source_byteidx[ccl->consumed]; 5277 src += source_byteidx[ccl->consumed];
5275 else 5278 else
5276 src += ccl->consumed; 5279 src += ccl->consumed;
@@ -5304,7 +5307,7 @@ static int
5304encode_coding_ccl (coding) 5307encode_coding_ccl (coding)
5305 struct coding_system *coding; 5308 struct coding_system *coding;
5306{ 5309{
5307 struct ccl_program ccl; 5310 struct ccl_program *ccl = &coding->spec.ccl->ccl;
5308 int multibytep = coding->dst_multibyte; 5311 int multibytep = coding->dst_multibyte;
5309 int *charbuf = coding->charbuf; 5312 int *charbuf = coding->charbuf;
5310 int *charbuf_end = charbuf + coding->charbuf_used; 5313 int *charbuf_end = charbuf + coding->charbuf_used;
@@ -5315,35 +5318,34 @@ encode_coding_ccl (coding)
5315 Lisp_Object attrs, charset_list; 5318 Lisp_Object attrs, charset_list;
5316 5319
5317 CODING_GET_INFO (coding, attrs, charset_list); 5320 CODING_GET_INFO (coding, attrs, charset_list);
5318 setup_ccl_program (&ccl, CODING_CCL_ENCODER (coding)); 5321 if (coding->consumed_char == coding->src_chars
5319 5322 && coding->mode & CODING_MODE_LAST_BLOCK)
5320 ccl.last_block = coding->mode & CODING_MODE_LAST_BLOCK; 5323 ccl->last_block = 1;
5321 ccl.dst_multibyte = coding->dst_multibyte;
5322 5324
5323 while (charbuf < charbuf_end) 5325 while (charbuf < charbuf_end)
5324 { 5326 {
5325 ccl_driver (&ccl, charbuf, destination_charbuf, 5327 ccl_driver (ccl, charbuf, destination_charbuf,
5326 charbuf_end - charbuf, 1024, charset_list); 5328 charbuf_end - charbuf, 1024, charset_list);
5327 if (multibytep) 5329 if (multibytep)
5328 { 5330 {
5329 ASSURE_DESTINATION (ccl.produced * 2); 5331 ASSURE_DESTINATION (ccl->produced * 2);
5330 for (i = 0; i < ccl.produced; i++) 5332 for (i = 0; i < ccl->produced; i++)
5331 EMIT_ONE_BYTE (destination_charbuf[i] & 0xFF); 5333 EMIT_ONE_BYTE (destination_charbuf[i] & 0xFF);
5332 } 5334 }
5333 else 5335 else
5334 { 5336 {
5335 ASSURE_DESTINATION (ccl.produced); 5337 ASSURE_DESTINATION (ccl->produced);
5336 for (i = 0; i < ccl.produced; i++) 5338 for (i = 0; i < ccl->produced; i++)
5337 *dst++ = destination_charbuf[i] & 0xFF; 5339 *dst++ = destination_charbuf[i] & 0xFF;
5338 produced_chars += ccl.produced; 5340 produced_chars += ccl->produced;
5339 } 5341 }
5340 charbuf += ccl.consumed; 5342 charbuf += ccl->consumed;
5341 if (ccl.status == CCL_STAT_QUIT 5343 if (ccl->status == CCL_STAT_QUIT
5342 || ccl.status == CCL_STAT_INVALID_CMD) 5344 || ccl->status == CCL_STAT_INVALID_CMD)
5343 break; 5345 break;
5344 } 5346 }
5345 5347
5346 switch (ccl.status) 5348 switch (ccl->status)
5347 { 5349 {
5348 case CCL_STAT_SUSPEND_BY_SRC: 5350 case CCL_STAT_SUSPEND_BY_SRC:
5349 record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_SRC); 5351 record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_SRC);
@@ -7534,6 +7536,7 @@ encode_coding (coding)
7534 Lisp_Object attrs; 7536 Lisp_Object attrs;
7535 Lisp_Object translation_table; 7537 Lisp_Object translation_table;
7536 int max_lookup; 7538 int max_lookup;
7539 struct ccl_spec cclspec;
7537 7540
7538 attrs = CODING_ID_ATTRS (coding->id); 7541 attrs = CODING_ID_ATTRS (coding->id);
7539 if (coding->encoder == encode_coding_raw_text) 7542 if (coding->encoder == encode_coding_raw_text)
@@ -7555,6 +7558,11 @@ encode_coding (coding)
7555 7558
7556 ALLOC_CONVERSION_WORK_AREA (coding); 7559 ALLOC_CONVERSION_WORK_AREA (coding);
7557 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 }
7558 do { 7566 do {
7559 coding_set_source (coding); 7567 coding_set_source (coding);
7560 consume_chars (coding, translation_table, max_lookup); 7568 consume_chars (coding, translation_table, max_lookup);