diff options
| author | Kenichi Handa | 2000-12-28 07:03:05 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2000-12-28 07:03:05 +0000 |
| commit | a37520c6767b258fd1619300baa82ae81f13a3e6 (patch) | |
| tree | c1e8eed18c8f61e474fd19ef44b0570b17c7fed2 /src | |
| parent | 9371f8312a873619a44b4d6ea0f4334138c08822 (diff) | |
| download | emacs-a37520c6767b258fd1619300baa82ae81f13a3e6.tar.gz emacs-a37520c6767b258fd1619300baa82ae81f13a3e6.zip | |
(CCL_WRITE_CHAR): Check variable `extra_bytes'.
(ccl_driver): New local variable `extra_bytes'.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ccl.c | 45 |
1 files changed, 25 insertions, 20 deletions
| @@ -698,26 +698,26 @@ static int stack_idx_of_map_multiple; | |||
| 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 |
| @@ -840,6 +840,11 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed) | |||
| 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; |