comparison src/coding.c @ 89373:4cc9e57fcabc

(decode_coding_ccl, encode_coding_ccl): Call ccl_driver with the last arg charset_list acquired from coding. (Fdefine_coding_system_internal): For ccl-based coding system, fix the attribute coding_attr_ccl_valids.
author Kenichi Handa <handa@m17n.org>
date Thu, 30 Jan 2003 02:23:12 +0000
parents 1892a75ffcac
children 6ffca50f25b9
comparison
equal deleted inserted replaced
89372:95c081cdbd5f 89373:4cc9e57fcabc
4300 int consumed_chars = 0; 4300 int consumed_chars = 0;
4301 int multibytep = coding->src_multibyte; 4301 int multibytep = coding->src_multibyte;
4302 struct ccl_program ccl; 4302 struct ccl_program ccl;
4303 int source_charbuf[1024]; 4303 int source_charbuf[1024];
4304 int source_byteidx[1024]; 4304 int source_byteidx[1024];
4305 4305 Lisp_Object attrs, eol_type, charset_list, valids;
4306
4307 CODING_GET_INFO (coding, attrs, eol_type, charset_list);
4306 setup_ccl_program (&ccl, CODING_CCL_DECODER (coding)); 4308 setup_ccl_program (&ccl, CODING_CCL_DECODER (coding));
4307 4309
4308 while (src < src_end) 4310 while (src < src_end)
4309 { 4311 {
4310 const unsigned char *p = src; 4312 const unsigned char *p = src;
4327 source = source_charbuf; 4329 source = source_charbuf;
4328 source_end = source + i; 4330 source_end = source + i;
4329 while (source < source_end) 4331 while (source < source_end)
4330 { 4332 {
4331 ccl_driver (&ccl, source, charbuf, 4333 ccl_driver (&ccl, source, charbuf,
4332 source_end - source, charbuf_end - charbuf); 4334 source_end - source, charbuf_end - charbuf,
4335 charset_list);
4333 source += ccl.consumed; 4336 source += ccl.consumed;
4334 charbuf += ccl.produced; 4337 charbuf += ccl.produced;
4335 if (ccl.status != CCL_STAT_SUSPEND_BY_DST) 4338 if (ccl.status != CCL_STAT_SUSPEND_BY_DST)
4336 break; 4339 break;
4337 } 4340 }
4377 unsigned char *dst = coding->destination + coding->produced; 4380 unsigned char *dst = coding->destination + coding->produced;
4378 unsigned char *dst_end = coding->destination + coding->dst_bytes; 4381 unsigned char *dst_end = coding->destination + coding->dst_bytes;
4379 unsigned char *adjusted_dst_end = dst_end - 1; 4382 unsigned char *adjusted_dst_end = dst_end - 1;
4380 int destination_charbuf[1024]; 4383 int destination_charbuf[1024];
4381 int i, produced_chars = 0; 4384 int i, produced_chars = 0;
4382 4385 Lisp_Object attrs, eol_type, charset_list;
4386
4387 CODING_GET_INFO (coding, attrs, eol_type, charset_list);
4383 setup_ccl_program (&ccl, CODING_CCL_ENCODER (coding)); 4388 setup_ccl_program (&ccl, CODING_CCL_ENCODER (coding));
4384 4389
4385 ccl.last_block = coding->mode & CODING_MODE_LAST_BLOCK; 4390 ccl.last_block = coding->mode & CODING_MODE_LAST_BLOCK;
4386 ccl.dst_multibyte = coding->dst_multibyte; 4391 ccl.dst_multibyte = coding->dst_multibyte;
4387 4392
4390 int dst_bytes = dst_end - dst; 4395 int dst_bytes = dst_end - dst;
4391 if (dst_bytes > 1024) 4396 if (dst_bytes > 1024)
4392 dst_bytes = 1024; 4397 dst_bytes = 1024;
4393 4398
4394 ccl_driver (&ccl, charbuf, destination_charbuf, 4399 ccl_driver (&ccl, charbuf, destination_charbuf,
4395 charbuf_end - charbuf, dst_bytes); 4400 charbuf_end - charbuf, dst_bytes, charset_list);
4396 charbuf += ccl.consumed; 4401 charbuf += ccl.consumed;
4397 if (multibytep) 4402 if (multibytep)
4398 for (i = 0; i < ccl.produced; i++) 4403 for (i = 0; i < ccl.produced; i++)
4399 EMIT_ONE_BYTE (destination_charbuf[i] & 0xFF); 4404 EMIT_ONE_BYTE (destination_charbuf[i] & 0xFF);
4400 else 4405 else
7907 7912
7908 val = args[coding_arg_ccl_valids]; 7913 val = args[coding_arg_ccl_valids];
7909 valids = Fmake_string (make_number (256), make_number (0)); 7914 valids = Fmake_string (make_number (256), make_number (0));
7910 for (tail = val; !NILP (tail); tail = Fcdr (tail)) 7915 for (tail = val; !NILP (tail); tail = Fcdr (tail))
7911 { 7916 {
7917 int from, to;
7918
7912 val = Fcar (tail); 7919 val = Fcar (tail);
7913 if (INTEGERP (val)) 7920 if (INTEGERP (val))
7914 ASET (valids, XINT (val), make_number (1)); 7921 {
7922 from = to = XINT (val);
7923 if (from < 0 || from > 255)
7924 args_out_of_range_3 (val, make_number (0), make_number (255));
7925 }
7915 else 7926 else
7916 { 7927 {
7917 int from, to;
7918
7919 CHECK_CONS (val); 7928 CHECK_CONS (val);
7920 CHECK_NUMBER (XCAR (val)); 7929 CHECK_NUMBER (XCAR (val));
7921 CHECK_NUMBER (XCDR (val)); 7930 CHECK_NUMBER (XCDR (val));
7922 from = XINT (XCAR (val)); 7931 from = XINT (XCAR (val));
7932 if (from < 0 || from > 255)
7933 args_out_of_range_3 (XCAR (val),
7934 make_number (0), make_number (255));
7923 to = XINT (XCDR (val)); 7935 to = XINT (XCDR (val));
7924 for (i = from; i <= to; i++) 7936 if (to < from || to > 255)
7925 ASET (valids, i, make_number (1)); 7937 args_out_of_range_3 (XCDR (val),
7938 XCAR (val), make_number (255));
7926 } 7939 }
7940 for (i = from; i <= to; i++)
7941 XSTRING (valids)->data[i] = 1;
7927 } 7942 }
7928 ASET (attrs, coding_attr_ccl_valids, valids); 7943 ASET (attrs, coding_attr_ccl_valids, valids);
7929 7944
7930 category = coding_category_ccl; 7945 category = coding_category_ccl;
7931 } 7946 }