Mercurial > emacs
changeset 21062:839b22ad1e42
(code_convert_region): Handle the case that codes
0240..0377 are generated just after a multibyte character.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Wed, 04 Mar 1998 07:41:41 +0000 |
parents | 7813d4b7bea5 |
children | 44845df088bc |
files | src/coding.c |
diffstat | 1 files changed, 44 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/coding.c Tue Mar 03 22:33:15 1998 +0000 +++ b/src/coding.c Wed Mar 04 07:41:41 1998 +0000 @@ -4238,8 +4238,50 @@ } if (src - dst > 0) *dst = 0; /* Put an anchor. */ - if (multibyte && (fake_multibyte || !encodep && (to - from) != (to_byte - from_byte))) - inserted = multibyte_chars_in_text (GPT_ADDR, inserted_byte); + if (multibyte) + { + if (fake_multibyte || !encodep && (to - from) != (to_byte - from_byte)) + inserted = multibyte_chars_in_text (GPT_ADDR, inserted_byte); + + if (! CHAR_HEAD_P (*GPT_ADDR) + && GPT_BYTE > 1 + && from_byte == from_byte_orig) + { + unsigned char *p0 = GPT_ADDR - 1, *pmin = BEG_ADDR, *p1, *pmax; + + while (! CHAR_HEAD_P (*p0) && p0 > pmin) p0--; + if (BASE_LEADING_CODE_P (*p0)) + { + /* Codes in the range 0240..0377 were inserted after a + multibyte sequence. We must treat those codes as + tailing constituents of the multibyte sequence. For + that, we increase byte positions of position keepers + whose char positions are GPT. */ + int byte_increase; + p1 = GPT_ADDR + 2, pmax = p0 + 1 + inserted_byte; + Lisp_Object tail; + + while (! CHAR_HEAD_P (*p1) && p1 < pmax) p1++; + /* Now, codes from P0 to P1 constitute a single + multibyte character. */ + + byte_increase = p1 - GPT_ADDR; + if (PT == GPT) + current_buffer->pt_byte += byte_increase; + tail = BUF_MARKERS (current_buffer); + while (XSYMBOL (tail) != XSYMBOL (Qnil)) + { + if (XMARKER (tail)->charpos == GPT) + XMARKER (tail)->bytepos += byte_increase; + tail = XMARKER (tail)->chain; + } + + from_byte += byte_increase; + from_byte_orig = from_byte; + inserted -= byte_increase; + } + } + } /* Update various buffer positions for the new text. */ GAP_SIZE -= inserted_byte;