comparison src/ccl.c @ 34890:f203e7623af7

(CCL_WRITE_CHAR): Check variable `extra_bytes'. (ccl_driver): New local variable `extra_bytes'.
author Kenichi Handa <handa@m17n.org>
date Thu, 28 Dec 2000 07:03:05 +0000
parents f998b856d92b
children a16dc29a46c7
comparison
equal deleted inserted replaced
34889:883267e75fbb 34890:f203e7623af7
696 goto ccl_error_handler; \ 696 goto ccl_error_handler; \
697 } while (0) 697 } while (0)
698 698
699 /* Encode one character CH to multibyte form and write to the current 699 /* Encode one character CH to multibyte form and write to the current
700 output buffer. If CH is less than 256, CH is written as is. */ 700 output buffer. If CH is less than 256, CH is written as is. */
701 #define CCL_WRITE_CHAR(ch) \ 701 #define CCL_WRITE_CHAR(ch) \
702 do { \ 702 do { \
703 int bytes = SINGLE_BYTE_CHAR_P (ch) ? 1: CHAR_BYTES (ch); \ 703 int bytes = SINGLE_BYTE_CHAR_P (ch) ? 1: CHAR_BYTES (ch); \
704 if (!dst) \ 704 if (!dst) \
705 CCL_INVALID_CMD; \ 705 CCL_INVALID_CMD; \
706 else if (dst + bytes <= (dst_bytes ? dst_end : src)) \ 706 else if (dst + bytes + extra_bytes < (dst_bytes ? dst_end : src)) \
707 { \ 707 { \
708 if (bytes == 1) \ 708 if (bytes == 1) \
709 { \ 709 { \
710 *dst++ = (ch); \ 710 *dst++ = (ch); \
711 if ((ch) >= 0x80 && (ch) < 0xA0) \ 711 if ((ch) >= 0x80 && (ch) < 0xA0) \
712 /* We may have to convert this eight-bit char to \ 712 /* We may have to convert this eight-bit char to \
713 multibyte form later. */ \ 713 multibyte form later. */ \
714 dst_end--; \ 714 extra_bytes++; \
715 } \ 715 } \
716 else \ 716 else \
717 dst += CHAR_STRING (ch, dst); \ 717 dst += CHAR_STRING (ch, dst); \
718 } \ 718 } \
719 else \ 719 else \
720 CCL_SUSPEND (CCL_STAT_SUSPEND_BY_DST); \ 720 CCL_SUSPEND (CCL_STAT_SUSPEND_BY_DST); \
721 } while (0) 721 } while (0)
722 722
723 /* Write a string at ccl_prog[IC] of length LEN to the current output 723 /* Write a string at ccl_prog[IC] of length LEN to the current output
724 buffer. */ 724 buffer. */
725 #define CCL_WRITE_STRING(len) \ 725 #define CCL_WRITE_STRING(len) \
838 int jump_address; 838 int jump_address;
839 int i, j, op; 839 int i, j, op;
840 int stack_idx = ccl->stack_idx; 840 int stack_idx = ccl->stack_idx;
841 /* Instruction counter of the current CCL code. */ 841 /* Instruction counter of the current CCL code. */
842 int this_ic; 842 int this_ic;
843 /* CCL_WRITE_CHAR will produce 8-bit code of range 0x80..0x9F. But,
844 each of them will be converted to multibyte form of 2-byte
845 sequence. For that conversion, we remember how many more bytes
846 we must keep in DESTINATION in this variable. */
847 int extra_bytes = 0;
843 848
844 if (ic >= ccl->eof_ic) 849 if (ic >= ccl->eof_ic)
845 ic = CCL_HEADER_MAIN; 850 ic = CCL_HEADER_MAIN;
846 851
847 if (ccl->buf_magnification ==0) /* We can't produce any bytes. */ 852 if (ccl->buf_magnification ==0) /* We can't produce any bytes. */