# HG changeset patch # User Kenichi Handa # Date 983244528 0 # Node ID 120891909abe76f25708c48e869a6d048c13bcee # Parent 27b5c760df319fc5a29d3cdaf303a9e155254bd4 (CCL_WRITE_MULTIBYTE_CHAR): New macro. (ccl_driver) : Use CCL_WRITE_MULTIBYTE_CHAR instead of CCL_WRITE_CHAR. : Set ccl->eight_bit_control properly. diff -r 27b5c760df31 -r 120891909abe src/ccl.c --- a/src/ccl.c Tue Feb 27 03:27:20 2001 +0000 +++ b/src/ccl.c Tue Feb 27 03:28:48 2001 +0000 @@ -730,6 +730,25 @@ CCL_SUSPEND (CCL_STAT_SUSPEND_BY_DST); \ } while (0) +/* Encode one character CH to multibyte form and write to the current + output buffer. The output bytes always forms a valid multibyte + sequence. */ +#define CCL_WRITE_MULTIBYTE_CHAR(ch) \ + do { \ + int bytes = CHAR_BYTES (ch); \ + if (!dst) \ + CCL_INVALID_CMD; \ + else if (dst + bytes + extra_bytes < (dst_bytes ? dst_end : src)) \ + { \ + if (CHAR_VALID_P ((ch), 0)) \ + dst += CHAR_STRING ((ch), dst); \ + else \ + CCL_INVALID_CMD; \ + } \ + else \ + CCL_SUSPEND (CCL_STAT_SUSPEND_BY_DST); \ + } while (0) + /* Write a string at ccl_prog[IC] of length LEN to the current output buffer. */ #define CCL_WRITE_STRING(len) \ @@ -1340,7 +1359,7 @@ else i = ((i - 0xE0) << 14) | reg[rrr]; - CCL_WRITE_CHAR (i); + CCL_WRITE_MULTIBYTE_CHAR (i); break; @@ -1805,6 +1824,7 @@ ccl->ic = ic; ccl->stack_idx = stack_idx; ccl->prog = ccl_prog; + ccl->eight_bit_control = (extra_bytes > 0); if (consumed) *consumed = src - source; return (dst ? dst - destination : 0); }