aboutsummaryrefslogtreecommitdiffstats
path: root/src/casefiddle.c
diff options
context:
space:
mode:
authorKenichi Handa <[email protected]>2004-12-06 07:41:56 +0000
committerKenichi Handa <[email protected]>2004-12-06 07:41:56 +0000
commit08588bfa5465b1707ef6f70d312952a4437edcf8 (patch)
treed0717d52c8199e6187f302ec7a2379b3c9b39987 /src/casefiddle.c
parent47735206ffad854dc71a3c264d8c664e31e552a4 (diff)
(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 4b38e441cf..297eb82c15 100644
--- a/src/casefiddle.c
+++ b/src/casefiddle.c
@@ -236,21 +236,29 @@ casify_region (flag, b, e)
}
else if (ASCII_CHAR_P (c2) && ASCII_CHAR_P (c))
FETCH_BYTE (start_byte) = c;
- else if (len == CHAR_BYTES (c))
+ else
{
+ int tolen = CHAR_BYTES (c);
int j;
unsigned char str[MAX_MULTIBYTE_LENGTH];
CHAR_STRING (c, str);
- for (j = 0; j < len; ++j)
- FETCH_BYTE (start_byte + j) = str[j];
- }
- else
- {
- TEMP_SET_PT_BOTH (start, start_byte);
- del_range_2 (start, start_byte, start + 1, start_byte + len, 0);
- insert_char (c);
- len = CHAR_BYTES (c);
+ if (len == tolen)
+ {
+ /* Length is unchanged. */
+ for (j = 0; j < len; ++j)
+ FETCH_BYTE (start_byte + j) = str[j];
+ }
+ else
+ {
+ /* Replace one character with the other,
+ keeping text properties the same. */
+ replace_range_2 (start, start_byte,
+ start + 1, start_byte + len,
+ str, 1, tolen,
+ 0);
+ len = tolen;
+ }
}
}
start++;