summaryrefslogtreecommitdiff
path: root/src/ccl.c
diff options
context:
space:
mode:
authorKenichi Handa <handa@m17n.org>2000-12-28 07:03:05 +0000
committerKenichi Handa <handa@m17n.org>2000-12-28 07:03:05 +0000
commita37520c6767b258fd1619300baa82ae81f13a3e6 (patch)
treec1e8eed18c8f61e474fd19ef44b0570b17c7fed2 /src/ccl.c
parent9371f8312a873619a44b4d6ea0f4334138c08822 (diff)
downloademacs-a37520c6767b258fd1619300baa82ae81f13a3e6.tar.gz
(CCL_WRITE_CHAR): Check variable `extra_bytes'.
(ccl_driver): New local variable `extra_bytes'.
Diffstat (limited to 'src/ccl.c')
-rw-r--r--src/ccl.c45
1 files changed, 25 insertions, 20 deletions
diff --git a/src/ccl.c b/src/ccl.c
index 0a710252ab8..2be97ba88af 100644
--- a/src/ccl.c
+++ b/src/ccl.c
@@ -698,26 +698,26 @@ static int stack_idx_of_map_multiple;
/* Encode one character CH to multibyte form and write to the current
output buffer. If CH is less than 256, CH is written as is. */
-#define CCL_WRITE_CHAR(ch) \
- do { \
- int bytes = SINGLE_BYTE_CHAR_P (ch) ? 1: CHAR_BYTES (ch); \
- if (!dst) \
- CCL_INVALID_CMD; \
- else if (dst + bytes <= (dst_bytes ? dst_end : src)) \
- { \
- if (bytes == 1) \
- { \
- *dst++ = (ch); \
- if ((ch) >= 0x80 && (ch) < 0xA0) \
- /* We may have to convert this eight-bit char to \
- multibyte form later. */ \
- dst_end--; \
- } \
- else \
- dst += CHAR_STRING (ch, dst); \
- } \
- else \
- CCL_SUSPEND (CCL_STAT_SUSPEND_BY_DST); \
+#define CCL_WRITE_CHAR(ch) \
+ do { \
+ int bytes = SINGLE_BYTE_CHAR_P (ch) ? 1: CHAR_BYTES (ch); \
+ if (!dst) \
+ CCL_INVALID_CMD; \
+ else if (dst + bytes + extra_bytes < (dst_bytes ? dst_end : src)) \
+ { \
+ if (bytes == 1) \
+ { \
+ *dst++ = (ch); \
+ if ((ch) >= 0x80 && (ch) < 0xA0) \
+ /* We may have to convert this eight-bit char to \
+ multibyte form later. */ \
+ extra_bytes++; \
+ } \
+ else \
+ dst += CHAR_STRING (ch, dst); \
+ } \
+ else \
+ CCL_SUSPEND (CCL_STAT_SUSPEND_BY_DST); \
} while (0)
/* 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)
int stack_idx = ccl->stack_idx;
/* Instruction counter of the current CCL code. */
int this_ic;
+ /* CCL_WRITE_CHAR will produce 8-bit code of range 0x80..0x9F. But,
+ each of them will be converted to multibyte form of 2-byte
+ sequence. For that conversion, we remember how many more bytes
+ we must keep in DESTINATION in this variable. */
+ int extra_bytes = 0;
if (ic >= ccl->eof_ic)
ic = CCL_HEADER_MAIN;