Mercurial > emacs
comparison src/coding.c @ 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 | e4dd62e5d921 |
children | 926174c7283a |
comparison
equal
deleted
inserted
replaced
21061:7813d4b7bea5 | 21062:839b22ad1e42 |
---|---|
4236 dst = GPT_ADDR + inserted_byte; | 4236 dst = GPT_ADDR + inserted_byte; |
4237 } | 4237 } |
4238 } | 4238 } |
4239 if (src - dst > 0) *dst = 0; /* Put an anchor. */ | 4239 if (src - dst > 0) *dst = 0; /* Put an anchor. */ |
4240 | 4240 |
4241 if (multibyte && (fake_multibyte || !encodep && (to - from) != (to_byte - from_byte))) | 4241 if (multibyte) |
4242 inserted = multibyte_chars_in_text (GPT_ADDR, inserted_byte); | 4242 { |
4243 if (fake_multibyte || !encodep && (to - from) != (to_byte - from_byte)) | |
4244 inserted = multibyte_chars_in_text (GPT_ADDR, inserted_byte); | |
4245 | |
4246 if (! CHAR_HEAD_P (*GPT_ADDR) | |
4247 && GPT_BYTE > 1 | |
4248 && from_byte == from_byte_orig) | |
4249 { | |
4250 unsigned char *p0 = GPT_ADDR - 1, *pmin = BEG_ADDR, *p1, *pmax; | |
4251 | |
4252 while (! CHAR_HEAD_P (*p0) && p0 > pmin) p0--; | |
4253 if (BASE_LEADING_CODE_P (*p0)) | |
4254 { | |
4255 /* Codes in the range 0240..0377 were inserted after a | |
4256 multibyte sequence. We must treat those codes as | |
4257 tailing constituents of the multibyte sequence. For | |
4258 that, we increase byte positions of position keepers | |
4259 whose char positions are GPT. */ | |
4260 int byte_increase; | |
4261 p1 = GPT_ADDR + 2, pmax = p0 + 1 + inserted_byte; | |
4262 Lisp_Object tail; | |
4263 | |
4264 while (! CHAR_HEAD_P (*p1) && p1 < pmax) p1++; | |
4265 /* Now, codes from P0 to P1 constitute a single | |
4266 multibyte character. */ | |
4267 | |
4268 byte_increase = p1 - GPT_ADDR; | |
4269 if (PT == GPT) | |
4270 current_buffer->pt_byte += byte_increase; | |
4271 tail = BUF_MARKERS (current_buffer); | |
4272 while (XSYMBOL (tail) != XSYMBOL (Qnil)) | |
4273 { | |
4274 if (XMARKER (tail)->charpos == GPT) | |
4275 XMARKER (tail)->bytepos += byte_increase; | |
4276 tail = XMARKER (tail)->chain; | |
4277 } | |
4278 | |
4279 from_byte += byte_increase; | |
4280 from_byte_orig = from_byte; | |
4281 inserted -= byte_increase; | |
4282 } | |
4283 } | |
4284 } | |
4243 | 4285 |
4244 /* Update various buffer positions for the new text. */ | 4286 /* Update various buffer positions for the new text. */ |
4245 GAP_SIZE -= inserted_byte; | 4287 GAP_SIZE -= inserted_byte; |
4246 ZV += inserted; Z+= inserted; | 4288 ZV += inserted; Z+= inserted; |
4247 ZV_BYTE += inserted_byte; Z_BYTE += inserted_byte; | 4289 ZV_BYTE += inserted_byte; Z_BYTE += inserted_byte; |