diff options
| author | Eli Zaretskii | 2010-02-20 05:25:57 -0500 |
|---|---|---|
| committer | Eli Zaretskii | 2010-02-20 05:25:57 -0500 |
| commit | d77fbdad04a1e3f8e4fa1038508379a5f5b8e67e (patch) | |
| tree | d20e47abe63806acbc519454e597ab7dc6ced017 /src/coding.c | |
| parent | ae9784892b7c9005b792b026d466af105bcb655f (diff) | |
| parent | 0f00e9485d96c308b126553bd1b90ce4e64f1a1d (diff) | |
| download | emacs-d77fbdad04a1e3f8e4fa1038508379a5f5b8e67e.tar.gz emacs-d77fbdad04a1e3f8e4fa1038508379a5f5b8e67e.zip | |
Merge from mainline.
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/src/coding.c b/src/coding.c index 935d32e6a58..2144fe5fcd4 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -993,6 +993,11 @@ record_conversion_result (struct coding_system *coding, | |||
| 993 | case CODING_RESULT_INSUFFICIENT_MEM: | 993 | case CODING_RESULT_INSUFFICIENT_MEM: |
| 994 | Vlast_code_conversion_error = Qinsufficient_memory; | 994 | Vlast_code_conversion_error = Qinsufficient_memory; |
| 995 | break; | 995 | break; |
| 996 | case CODING_RESULT_INSUFFICIENT_DST: | ||
| 997 | /* Don't record this error in Vlast_code_conversion_error | ||
| 998 | because it happens just temporarily and is resolved when the | ||
| 999 | whole conversion is finished. */ | ||
| 1000 | break; | ||
| 996 | case CODING_RESULT_SUCCESS: | 1001 | case CODING_RESULT_SUCCESS: |
| 997 | break; | 1002 | break; |
| 998 | default: | 1003 | default: |
| @@ -5220,18 +5225,16 @@ decode_coding_ccl (coding) | |||
| 5220 | int *charbuf_end = coding->charbuf + coding->charbuf_size; | 5225 | int *charbuf_end = coding->charbuf + coding->charbuf_size; |
| 5221 | int consumed_chars = 0; | 5226 | int consumed_chars = 0; |
| 5222 | int multibytep = coding->src_multibyte; | 5227 | int multibytep = coding->src_multibyte; |
| 5223 | struct ccl_program ccl; | 5228 | struct ccl_program *ccl = &coding->spec.ccl->ccl; |
| 5224 | int source_charbuf[1024]; | 5229 | int source_charbuf[1024]; |
| 5225 | int source_byteidx[1024]; | 5230 | int source_byteidx[1024]; |
| 5226 | Lisp_Object attrs, charset_list; | 5231 | Lisp_Object attrs, charset_list; |
| 5227 | 5232 | ||
| 5228 | CODING_GET_INFO (coding, attrs, charset_list); | 5233 | CODING_GET_INFO (coding, attrs, charset_list); |
| 5229 | setup_ccl_program (&ccl, CODING_CCL_DECODER (coding)); | ||
| 5230 | 5234 | ||
| 5231 | while (src < src_end) | 5235 | while (1) |
| 5232 | { | 5236 | { |
| 5233 | const unsigned char *p = src; | 5237 | const unsigned char *p = src; |
| 5234 | int *source, *source_end; | ||
| 5235 | int i = 0; | 5238 | int i = 0; |
| 5236 | 5239 | ||
| 5237 | if (multibytep) | 5240 | if (multibytep) |
| @@ -5245,37 +5248,26 @@ decode_coding_ccl (coding) | |||
| 5245 | source_charbuf[i++] = *p++; | 5248 | source_charbuf[i++] = *p++; |
| 5246 | 5249 | ||
| 5247 | if (p == src_end && coding->mode & CODING_MODE_LAST_BLOCK) | 5250 | if (p == src_end && coding->mode & CODING_MODE_LAST_BLOCK) |
| 5248 | ccl.last_block = 1; | 5251 | ccl->last_block = 1; |
| 5249 | 5252 | ccl_driver (ccl, source_charbuf, charbuf, i, charbuf_end - charbuf, | |
| 5250 | source = source_charbuf; | 5253 | charset_list); |
| 5251 | source_end = source + i; | 5254 | charbuf += ccl->produced; |
| 5252 | while (source < source_end) | 5255 | if (multibytep && ccl->consumed < i) |
| 5253 | { | 5256 | 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 | 5257 | else |
| 5265 | src = p; | 5258 | src += ccl->consumed; |
| 5266 | consumed_chars += source - source_charbuf; | 5259 | consumed_chars += ccl->consumed; |
| 5267 | 5260 | 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; | 5261 | break; |
| 5271 | } | 5262 | } |
| 5272 | 5263 | ||
| 5273 | switch (ccl.status) | 5264 | switch (ccl->status) |
| 5274 | { | 5265 | { |
| 5275 | case CCL_STAT_SUSPEND_BY_SRC: | 5266 | case CCL_STAT_SUSPEND_BY_SRC: |
| 5276 | record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_SRC); | 5267 | record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_SRC); |
| 5277 | break; | 5268 | break; |
| 5278 | case CCL_STAT_SUSPEND_BY_DST: | 5269 | case CCL_STAT_SUSPEND_BY_DST: |
| 5270 | record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_DST); | ||
| 5279 | break; | 5271 | break; |
| 5280 | case CCL_STAT_QUIT: | 5272 | case CCL_STAT_QUIT: |
| 5281 | case CCL_STAT_INVALID_CMD: | 5273 | case CCL_STAT_INVALID_CMD: |
| @@ -7117,6 +7109,7 @@ decode_coding (coding) | |||
| 7117 | Lisp_Object attrs; | 7109 | Lisp_Object attrs; |
| 7118 | Lisp_Object undo_list; | 7110 | Lisp_Object undo_list; |
| 7119 | Lisp_Object translation_table; | 7111 | Lisp_Object translation_table; |
| 7112 | struct ccl_spec cclspec; | ||
| 7120 | int carryover; | 7113 | int carryover; |
| 7121 | int i; | 7114 | int i; |
| 7122 | 7115 | ||
| @@ -7149,6 +7142,11 @@ decode_coding (coding) | |||
| 7149 | translation_table = get_translation_table (attrs, 0, NULL); | 7142 | translation_table = get_translation_table (attrs, 0, NULL); |
| 7150 | 7143 | ||
| 7151 | carryover = 0; | 7144 | carryover = 0; |
| 7145 | if (coding->decoder == decode_coding_ccl) | ||
| 7146 | { | ||
| 7147 | coding->spec.ccl = &cclspec; | ||
| 7148 | setup_ccl_program (&cclspec.ccl, CODING_CCL_DECODER (coding)); | ||
| 7149 | } | ||
| 7152 | do | 7150 | do |
| 7153 | { | 7151 | { |
| 7154 | EMACS_INT pos = coding->dst_pos + coding->produced_char; | 7152 | EMACS_INT pos = coding->dst_pos + coding->produced_char; |
| @@ -7165,9 +7163,10 @@ decode_coding (coding) | |||
| 7165 | coding->charbuf[i] | 7163 | coding->charbuf[i] |
| 7166 | = coding->charbuf[coding->charbuf_used - carryover + i]; | 7164 | = coding->charbuf[coding->charbuf_used - carryover + i]; |
| 7167 | } | 7165 | } |
| 7168 | while (coding->consumed < coding->src_bytes | 7166 | while (coding->result == CODING_RESULT_INSUFFICIENT_DST |
| 7169 | && (coding->result == CODING_RESULT_SUCCESS | 7167 | || (coding->consumed < coding->src_bytes |
| 7170 | || coding->result == CODING_RESULT_INVALID_SRC)); | 7168 | && (coding->result == CODING_RESULT_SUCCESS |
| 7169 | || coding->result == CODING_RESULT_INVALID_SRC))); | ||
| 7171 | 7170 | ||
| 7172 | if (carryover > 0) | 7171 | if (carryover > 0) |
| 7173 | { | 7172 | { |
| @@ -7871,7 +7870,7 @@ decode_coding_object (coding, src_object, from, from_byte, to, to_byte, | |||
| 7871 | if (! destination) | 7870 | if (! destination) |
| 7872 | { | 7871 | { |
| 7873 | record_conversion_result (coding, | 7872 | record_conversion_result (coding, |
| 7874 | CODING_RESULT_INSUFFICIENT_DST); | 7873 | CODING_RESULT_INSUFFICIENT_MEM); |
| 7875 | unbind_to (count, Qnil); | 7874 | unbind_to (count, Qnil); |
| 7876 | return; | 7875 | return; |
| 7877 | } | 7876 | } |