[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: CCL_WRITE_CHAR and CCL_WRITE_MULTIBYTE_CHAR
From: |
Kenichi Handa |
Subject: |
Re: CCL_WRITE_CHAR and CCL_WRITE_MULTIBYTE_CHAR |
Date: |
Thu, 31 Jan 2008 20:35:34 +0900 |
User-agent: |
SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/23.0.60 (i686-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) |
In article <address@hidden>, YAMAMOTO Mitsuharu <address@hidden> writes:
> I suspect the boundary checking in CCL_WRITE_CHAR and
> CCL_WRITE_MULTIBYTE_CHAR can be relaxed by 1. I mean,
> else if (dst + bytes + extra_bytes <= (dst_bytes ? dst_end : src))
> \
> instead of
> else if (dst + bytes + extra_bytes < (dst_bytes ? dst_end : src)) \
At least, in CCL_WRITE_CHAR, that change is not safe because
extra_bytes will be incremented after that check. I've just
installed the attached change to the main trunk. I dared
not install that change to EMACS_22_BASE because I'm still
not that confident about the change. In addition the
problem has not been revealed so long, and it can be avoided
by giving a bigger BUFFER_MAGNIFICATION in
define-ccl-program.
---
Kenichi Handa
address@hidden
Index: ccl.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/ccl.c,v
retrieving revision 1.102
retrieving revision 1.103
diff -u -r1.102 -r1.103
--- ccl.c 8 Jan 2008 20:44:20 -0000 1.102
+++ ccl.c 31 Jan 2008 11:27:46 -0000 1.103
@@ -748,16 +748,13 @@
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 (ccl->eight_bit_control \
+ && bytes == 1 && (ch) >= 0x80 && (ch) < 0xA0) \
+ extra_bytes++; \
+ if (dst + bytes + extra_bytes <= (dst_bytes ? dst_end : src)) \
{
\
if (bytes == 1) \
- { \
- *dst++ = (ch); \
- if (extra_bytes && (ch) >= 0x80 && (ch) < 0xA0) \
- /* We may have to convert this eight-bit char to \
- multibyte form later. */ \
- extra_bytes++; \
- } \
+ *dst++ = (ch); \
else if (CHAR_VALID_P (ch, 0)) \
dst += CHAR_STRING (ch, dst); \
else \
@@ -775,7 +772,7 @@
int bytes = CHAR_BYTES (ch); \
if (!dst) \
CCL_INVALID_CMD; \
- else if (dst + bytes + extra_bytes < (dst_bytes ? dst_end : src)) \
+ else if (dst + bytes + extra_bytes <= (dst_bytes ? dst_end : src)) \
{
\
if (CHAR_VALID_P ((ch), 0)) \
dst += CHAR_STRING ((ch), dst); \
@@ -919,7 +916,7 @@
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 = ccl->eight_bit_control;
+ int extra_bytes = 0;
int eof_ic = ccl->eof_ic;
int eof_hit = 0;
> I have a situation where the destination buffer size is tight and the
> last byte is not filled.