From: handa Date: Mon, 22 Aug 2005 05:05:26 +0000 (+0000) Subject: (MConverterStatus): Change the member buf to union. X-Git-Tag: REL-1-3-0~245 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dbfc7124601f450eeee11e41b78655f4c884f100;p=m17n%2Fm17n-lib.git (MConverterStatus): Change the member buf to union. (mconv_buffer_converter): Add const to the arg buf. (mconv_decode_buffer, mconv_rebind_buffer): Likewise. (mconv_decode): Adjusted for the change of MConverterStatus. (mconv_encode_range): Likewise. --- diff --git a/src/coding.c b/src/coding.c index 3a7bfc1..4a21ee5 100644 --- a/src/coding.c +++ b/src/coding.c @@ -155,7 +155,10 @@ typedef struct { Beginning of the byte sequence bound to this converter. */ /**ja ¤³¤Î¥³¥ó¥Ð¡¼¥¿¤Ë·ë¤ÓÉÕ¤±¤é¤ì¤¿¥Ð¥¤¥ÈÎó¤ÎÀèƬ°ÌÃÖ */ - unsigned char *buf; + union { + const unsigned char *in; + unsigned char *out; + } buf; /**en Size of buf. */ @@ -4081,7 +4084,7 @@ mconv_list_codings (MSymbol **symbols) mconv_stream_converter () */ MConverter * -mconv_buffer_converter (MSymbol name, unsigned char *buf, int n) +mconv_buffer_converter (MSymbol name, const unsigned char *buf, int n) { MCodingSystem *coding; MConverter *converter; @@ -4107,7 +4110,7 @@ mconv_buffer_converter (MSymbol name, unsigned char *buf, int n) internal->unread = mtext (); internal->work_mt = mtext (); mtext__enlarge (internal->work_mt, MAX_UTF8_CHAR_BYTES); - internal->buf = buf; + internal->buf.in = buf; internal->used = 0; internal->bufsize = n; internal->binding = BINDING_BUFFER; @@ -4296,11 +4299,11 @@ mconv_free_converter (MConverter *converter) mconv_rebind_stream () */ MConverter * -mconv_rebind_buffer (MConverter *converter, unsigned char *buf, int n) +mconv_rebind_buffer (MConverter *converter, const unsigned char *buf, int n) { MConverterStatus *internal = (MConverterStatus *) converter->internal_info; - internal->buf = buf; + internal->buf.in = buf; internal->used = 0; internal->bufsize = n; internal->binding = BINDING_BUFFER; @@ -4429,7 +4432,7 @@ mconv_decode (MConverter *converter, MText *mt) if (internal->binding == BINDING_BUFFER) { - (*internal->coding->decoder) (internal->buf + internal->used, + (*internal->coding->decoder) (internal->buf.in + internal->used, internal->bufsize - internal->used, mt, converter); internal->used += converter->nbytes; @@ -4530,7 +4533,7 @@ mconv_decode (MConverter *converter, MText *mt) mconv_decode (), mconv_decode_stream () */ MText * -mconv_decode_buffer (MSymbol name, unsigned char *buf, int n) +mconv_decode_buffer (MSymbol name, const unsigned char *buf, int n) { MConverter *converter = mconv_buffer_converter (name, buf, n); MText *mt; @@ -4692,7 +4695,7 @@ mconv_encode_range (MConverter *converter, MText *mt, int from, int to) if (internal->binding == BINDING_BUFFER) { (*internal->coding->encoder) (mt, from, to, - internal->buf + internal->used, + internal->buf.out + internal->used, internal->bufsize - internal->used, converter); internal->used += converter->nbytes;