aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
authorKenichi Handa2010-02-17 15:47:32 +0900
committerKenichi Handa2010-02-17 15:47:32 +0900
commitd0396581d5db3d6fd0b27db3511a281cf50b6bd2 (patch)
tree432363f3f70fb139ddd97622d230827ca2d43000 /src/coding.c
parentf1e0d763624b7aaecde07611cbe33d189901665b (diff)
downloademacs-d0396581d5db3d6fd0b27db3511a281cf50b6bd2.tar.gz
emacs-d0396581d5db3d6fd0b27db3511a281cf50b6bd2.zip
Fix the ccl decoder for the case that the output buffer is fullfilled.
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c52
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)
5220 int *charbuf_end = coding->charbuf + coding->charbuf_size; 5220 int *charbuf_end = coding->charbuf + coding->charbuf_size;
5221 int consumed_chars = 0; 5221 int consumed_chars = 0;
5222 int multibytep = coding->src_multibyte; 5222 int multibytep = coding->src_multibyte;
5223 struct ccl_program ccl; 5223 struct ccl_program *ccl = &coding->spec.ccl->ccl;
5224 int source_charbuf[1024]; 5224 int source_charbuf[1024];
5225 int source_byteidx[1024]; 5225 int source_byteidx[1024];
5226 Lisp_Object attrs, charset_list; 5226 Lisp_Object attrs, charset_list;
5227 5227
5228 CODING_GET_INFO (coding, attrs, charset_list); 5228 CODING_GET_INFO (coding, attrs, charset_list);
5229 setup_ccl_program (&ccl, CODING_CCL_DECODER (coding));
5230 5229
5231 while (src < src_end) 5230 while (1)
5232 { 5231 {
5233 const unsigned char *p = src; 5232 const unsigned char *p = src;
5234 int *source, *source_end;
5235 int i = 0; 5233 int i = 0;
5236 5234
5237 if (multibytep) 5235 if (multibytep)
@@ -5245,37 +5243,26 @@ decode_coding_ccl (coding)
5245 source_charbuf[i++] = *p++; 5243 source_charbuf[i++] = *p++;
5246 5244
5247 if (p == src_end && coding->mode & CODING_MODE_LAST_BLOCK) 5245 if (p == src_end && coding->mode & CODING_MODE_LAST_BLOCK)
5248 ccl.last_block = 1; 5246 ccl->last_block = 1;
5249 5247 ccl_driver (ccl, source_charbuf, charbuf, i, charbuf_end - charbuf,
5250 source = source_charbuf; 5248 charset_list);
5251 source_end = source + i; 5249 charbuf += ccl->produced;
5252 while (source < source_end) 5250 if (multibytep && ccl->consumed < i)
5253 { 5251 src += source_byteidx[ccl->consumed];
5254 ccl_driver (&ccl, source, charbuf,
5255 source_end - source, charbuf_end - charbuf,
5256 charset_list);
5257 source += ccl.consumed;
5258 charbuf += ccl.produced;
5259 if (ccl.status != CCL_STAT_SUSPEND_BY_DST)
5260 break;
5261 }
5262 if (source < source_end)
5263 src += source_byteidx[source - source_charbuf];
5264 else 5252 else
5265 src = p; 5253 src += ccl->consumed;
5266 consumed_chars += source - source_charbuf; 5254 consumed_chars += ccl->consumed;
5267 5255 if (p == src_end || ccl->status != CCL_STAT_SUSPEND_BY_SRC)
5268 if (ccl.status != CCL_STAT_SUSPEND_BY_SRC
5269 && ccl.status != CODING_RESULT_INSUFFICIENT_SRC)
5270 break; 5256 break;
5271 } 5257 }
5272 5258
5273 switch (ccl.status) 5259 switch (ccl->status)
5274 { 5260 {
5275 case CCL_STAT_SUSPEND_BY_SRC: 5261 case CCL_STAT_SUSPEND_BY_SRC:
5276 record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_SRC); 5262 record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_SRC);
5277 break; 5263 break;
5278 case CCL_STAT_SUSPEND_BY_DST: 5264 case CCL_STAT_SUSPEND_BY_DST:
5265 record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_DST);
5279 break; 5266 break;
5280 case CCL_STAT_QUIT: 5267 case CCL_STAT_QUIT:
5281 case CCL_STAT_INVALID_CMD: 5268 case CCL_STAT_INVALID_CMD:
@@ -7117,6 +7104,7 @@ decode_coding (coding)
7117 Lisp_Object attrs; 7104 Lisp_Object attrs;
7118 Lisp_Object undo_list; 7105 Lisp_Object undo_list;
7119 Lisp_Object translation_table; 7106 Lisp_Object translation_table;
7107 struct ccl_spec cclspec;
7120 int carryover; 7108 int carryover;
7121 int i; 7109 int i;
7122 7110
@@ -7149,6 +7137,11 @@ decode_coding (coding)
7149 translation_table = get_translation_table (attrs, 0, NULL); 7137 translation_table = get_translation_table (attrs, 0, NULL);
7150 7138
7151 carryover = 0; 7139 carryover = 0;
7140 if (coding->decoder == decode_coding_ccl)
7141 {
7142 coding->spec.ccl = &cclspec;
7143 setup_ccl_program (&cclspec.ccl, CODING_CCL_DECODER (coding));
7144 }
7152 do 7145 do
7153 { 7146 {
7154 EMACS_INT pos = coding->dst_pos + coding->produced_char; 7147 EMACS_INT pos = coding->dst_pos + coding->produced_char;
@@ -7165,9 +7158,10 @@ decode_coding (coding)
7165 coding->charbuf[i] 7158 coding->charbuf[i]
7166 = coding->charbuf[coding->charbuf_used - carryover + i]; 7159 = coding->charbuf[coding->charbuf_used - carryover + i];
7167 } 7160 }
7168 while (coding->consumed < coding->src_bytes 7161 while (coding->result == CODING_RESULT_INSUFFICIENT_DST
7169 && (coding->result == CODING_RESULT_SUCCESS 7162 || (coding->consumed < coding->src_bytes
7170 || coding->result == CODING_RESULT_INVALID_SRC)); 7163 && (coding->result == CODING_RESULT_SUCCESS
7164 || coding->result == CODING_RESULT_INVALID_SRC)));
7171 7165
7172 if (carryover > 0) 7166 if (carryover > 0)
7173 { 7167 {