diff options
| author | Kenichi Handa | 1998-03-04 07:41:41 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1998-03-04 07:41:41 +0000 |
| commit | 4b5ce591343f51796b5844c770a27c21eaa16307 (patch) | |
| tree | 31d6d4b3e00b71ecb2cacebc01500aac3ce4974a /src/coding.c | |
| parent | 29fddfff61158ca810a0b497f9751fda96c0dddc (diff) | |
| download | emacs-4b5ce591343f51796b5844c770a27c21eaa16307.tar.gz emacs-4b5ce591343f51796b5844c770a27c21eaa16307.zip | |
(code_convert_region): Handle the case that codes
0240..0377 are generated just after a multibyte character.
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/src/coding.c b/src/coding.c index 2c1364d540d..bf5677b8a43 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -4238,8 +4238,50 @@ code_convert_region (from, from_byte, to, to_byte, coding, encodep, adjust) | |||
| 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; |