aboutsummaryrefslogtreecommitdiffstats
path: root/src/casefiddle.c
diff options
context:
space:
mode:
authorKenichi Handa2004-12-06 07:41:56 +0000
committerKenichi Handa2004-12-06 07:41:56 +0000
commit08588bfa5465b1707ef6f70d312952a4437edcf8 (patch)
treed0717d52c8199e6187f302ec7a2379b3c9b39987 /src/casefiddle.c
parent47735206ffad854dc71a3c264d8c664e31e552a4 (diff)
downloademacs-08588bfa5465b1707ef6f70d312952a4437edcf8.tar.gz
emacs-08588bfa5465b1707ef6f70d312952a4437edcf8.zip
(casify_region): Handle changes in byte-length
using replace_range_2 (sync to HEAD).
Diffstat (limited to 'src/casefiddle.c')
-rw-r--r--src/casefiddle.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/casefiddle.c b/src/casefiddle.c
index 4b38e441cf3..297eb82c15b 100644
--- a/src/casefiddle.c
+++ b/src/casefiddle.c
@@ -236,21 +236,29 @@ casify_region (flag, b, e)
236 } 236 }
237 else if (ASCII_CHAR_P (c2) && ASCII_CHAR_P (c)) 237 else if (ASCII_CHAR_P (c2) && ASCII_CHAR_P (c))
238 FETCH_BYTE (start_byte) = c; 238 FETCH_BYTE (start_byte) = c;
239 else if (len == CHAR_BYTES (c)) 239 else
240 { 240 {
241 int tolen = CHAR_BYTES (c);
241 int j; 242 int j;
242 unsigned char str[MAX_MULTIBYTE_LENGTH]; 243 unsigned char str[MAX_MULTIBYTE_LENGTH];
243 244
244 CHAR_STRING (c, str); 245 CHAR_STRING (c, str);
245 for (j = 0; j < len; ++j) 246 if (len == tolen)
246 FETCH_BYTE (start_byte + j) = str[j]; 247 {
247 } 248 /* Length is unchanged. */
248 else 249 for (j = 0; j < len; ++j)
249 { 250 FETCH_BYTE (start_byte + j) = str[j];
250 TEMP_SET_PT_BOTH (start, start_byte); 251 }
251 del_range_2 (start, start_byte, start + 1, start_byte + len, 0); 252 else
252 insert_char (c); 253 {
253 len = CHAR_BYTES (c); 254 /* Replace one character with the other,
255 keeping text properties the same. */
256 replace_range_2 (start, start_byte,
257 start + 1, start_byte + len,
258 str, 1, tolen,
259 0);
260 len = tolen;
261 }
254 } 262 }
255 } 263 }
256 start++; 264 start++;