From fc9a17bcf7fdb1aca3b2ecec7e6d36c138907ef4 Mon Sep 17 00:00:00 2001 From: Kenichi Handa Date: Tue, 2 Mar 2010 13:44:28 +0900 Subject: [PATCH] Fix handling of the multibyte form of raw-bytes in unibyte->multibyte conversion. --- src/ChangeLog | 4 ++++ src/character.c | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index cb9b2d85d11..aec692b39ed 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,9 @@ 2010-03-02 Kenichi Handa + * character.c (parse_str_as_multibyte): Fix handling of the + multibyte form of raw-bytes. + (str_as_multibyte): Likewise. + * buffer.c (Fset_buffer_multibyte): Fix handling of the multibyte form of raw-bytes. diff --git a/src/character.c b/src/character.c index 583602fccb7..5912a70d0ce 100644 --- a/src/character.c +++ b/src/character.c @@ -630,7 +630,8 @@ parse_str_as_multibyte (str, len, nchars, nbytes) const unsigned char *adjusted_endp = endp - MAX_MULTIBYTE_LENGTH; while (str < adjusted_endp) { - if ((n = MULTIBYTE_LENGTH_NO_CHECK (str)) > 0) + if (! CHAR_BYTE8_HEAD_P (*str) + && (n = MULTIBYTE_LENGTH_NO_CHECK (str)) > 0) str += n, bytes += n; else str++, bytes += 2; @@ -639,7 +640,8 @@ parse_str_as_multibyte (str, len, nchars, nbytes) } while (str < endp) { - if ((n = MULTIBYTE_LENGTH (str, endp)) > 0) + if (! CHAR_BYTE8_HEAD_P (*str) + && (n = MULTIBYTE_LENGTH (str, endp)) > 0) str += n, bytes += n; else str++, bytes += 2; @@ -673,10 +675,13 @@ str_as_multibyte (str, len, nbytes, nchars) { unsigned char *adjusted_endp = endp - MAX_MULTIBYTE_LENGTH; while (p < adjusted_endp + && ! CHAR_BYTE8_HEAD_P (*p) && (n = MULTIBYTE_LENGTH_NO_CHECK (p)) > 0) p += n, chars++; } - while ((n = MULTIBYTE_LENGTH (p, endp)) > 0) + while (p < endp + && ! CHAR_BYTE8_HEAD_P (*p) + && (n = MULTIBYTE_LENGTH (p, endp)) > 0) p += n, chars++; if (nchars) *nchars = chars; @@ -694,7 +699,8 @@ str_as_multibyte (str, len, nbytes, nchars) unsigned char *adjusted_endp = endp - MAX_MULTIBYTE_LENGTH; while (p < adjusted_endp) { - if ((n = MULTIBYTE_LENGTH_NO_CHECK (p)) > 0) + if (! CHAR_BYTE8_HEAD_P (*p) + && (n = MULTIBYTE_LENGTH_NO_CHECK (p)) > 0) { while (n--) *to++ = *p++; @@ -710,7 +716,8 @@ str_as_multibyte (str, len, nbytes, nchars) } while (p < endp) { - if ((n = MULTIBYTE_LENGTH (p, endp)) > 0) + if (! CHAR_BYTE8_HEAD_P (*p) + && (n = MULTIBYTE_LENGTH (p, endp)) > 0) { while (n--) *to++ = *p++; -- 2.39.2