diff options
author | Richard M. Stallman <rms@gnu.org> | 1998-01-05 17:15:53 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 1998-01-05 17:15:53 +0000 |
commit | 43d27a7200666ad48dc94c98647e945e9900c6c4 (patch) | |
tree | 6bb180d9a74ad0068c19ad1a5e8a1a810692954a | |
parent | 82d6226f4e92fb6635ca19a6f4667340dadcdb0f (diff) |
(record_overlay_string): Totalize sizes assuming
strings are converted to match buffer in multibyteness.
(overlay_strings): Convert strings to match buffer in multibyteness.
-rw-r--r-- | src/buffer.c | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/src/buffer.c b/src/buffer.c index 27e3cc0c44b..dd5026cf6e4 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -2186,6 +2186,8 @@ record_overlay_string (ssl, str, str2, pri, size) Lisp_Object str, str2, pri; int size; { + int nbytes; + if (ssl->used == ssl->size) { if (ssl->buf) @@ -2200,9 +2202,29 @@ record_overlay_string (ssl, str, str2, pri, size) ssl->buf[ssl->used].size = size; ssl->buf[ssl->used].priority = (INTEGERP (pri) ? XINT (pri) : 0); ssl->used++; - ssl->bytes += XSTRING (str)->size; + + if (NILP (current_buffer->enable_multibyte_characters)) + nbytes = XSTRING (str)->size; + else if (! STRING_MULTIBYTE (str)) + nbytes = count_size_as_multibyte (XSTRING (str)->data, + XSTRING (str)->size_byte); + else + nbytes = XSTRING (str)->size_byte; + + ssl->bytes += nbytes; + if (STRINGP (str2)) - ssl->bytes += XSTRING (str2)->size; + { + if (NILP (current_buffer->enable_multibyte_characters)) + nbytes = XSTRING (str2)->size; + else if (! STRING_MULTIBYTE (str2)) + nbytes = count_size_as_multibyte (XSTRING (str2)->data, + XSTRING (str2)->size_byte); + else + nbytes = XSTRING (str2)->size_byte; + + ssl->bytes += nbytes; + } } /* Return the concatenation of the strings associated with overlays that @@ -2225,6 +2247,7 @@ overlay_strings (pos, w, pstr) { Lisp_Object ov, overlay, window, str; int startpos, endpos; + int multibyte = ! NILP (current_buffer->enable_multibyte_characters); overlay_heads.used = overlay_heads.bytes = 0; overlay_tails.used = overlay_tails.bytes = 0; @@ -2308,20 +2331,26 @@ overlay_strings (pos, w, pstr) p = overlay_str_buf; for (i = overlay_tails.used; --i >= 0;) { + int nbytes; tem = overlay_tails.buf[i].string; - bcopy (XSTRING (tem)->data, p, XSTRING (tem)->size); - p += XSTRING (tem)->size; + nbytes = copy_text (XSTRING (tem)->data, p, XSTRING (tem)->size_byte, + STRING_MULTIBYTE (tem), multibyte); + p += nbytes; } for (i = 0; i < overlay_heads.used; ++i) { + int nbytes; tem = overlay_heads.buf[i].string; - bcopy (XSTRING (tem)->data, p, XSTRING (tem)->size); - p += XSTRING (tem)->size; + nbytes = copy_text (XSTRING (tem)->data, p, XSTRING (tem)->size_byte, + STRING_MULTIBYTE (tem), multibyte); + p += nbytes; tem = overlay_heads.buf[i].string2; if (STRINGP (tem)) { - bcopy (XSTRING (tem)->data, p, XSTRING (tem)->size); - p += XSTRING (tem)->size; + nbytes = copy_text (XSTRING (tem)->data, p, + XSTRING (tem)->size_byte, + STRING_MULTIBYTE (tem), multibyte); + p += nbytes; } } if (p != overlay_str_buf + total) |