Mercurial > emacs
comparison src/casefiddle.c @ 57877:194fa92926e4
(casify_region): Handle changes in byte-length using replace_range_2.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 02 Nov 2004 09:12:51 +0000 |
parents | 66e97a54985f |
children | 75a481e7d8f1 |
comparison
equal
deleted
inserted
replaced
57876:eb20070961bb | 57877:194fa92926e4 |
---|---|
233 if (inword && flag != CASE_CAPITALIZE_UP) | 233 if (inword && flag != CASE_CAPITALIZE_UP) |
234 c = DOWNCASE (c); | 234 c = DOWNCASE (c); |
235 else if (!UPPERCASEP (c) | 235 else if (!UPPERCASEP (c) |
236 && (!inword || flag != CASE_CAPITALIZE_UP)) | 236 && (!inword || flag != CASE_CAPITALIZE_UP)) |
237 c = UPCASE1 (c); | 237 c = UPCASE1 (c); |
238 if (multibyte && c >= 0x80) | |
239 /* A multibyte result character can't be handled in this | |
240 simple loop. */ | |
241 break; | |
238 FETCH_BYTE (i) = c; | 242 FETCH_BYTE (i) = c; |
239 if (c != c2) | 243 if (c != c2) |
240 changed = 1; | 244 changed = 1; |
241 if ((int) flag >= (int) CASE_CAPITALIZE) | 245 if ((int) flag >= (int) CASE_CAPITALIZE) |
242 inword = SYNTAX (c) == Sword && (inword || !SYNTAX_PREFIX (c)); | 246 inword = SYNTAX (c) == Sword && (inword || !SYNTAX_PREFIX (c)); |
270 FETCH_BYTE (i) = c2; | 274 FETCH_BYTE (i) = c2; |
271 else if (fromlen = CHAR_STRING (c, str), | 275 else if (fromlen = CHAR_STRING (c, str), |
272 tolen = CHAR_STRING (c2, str), | 276 tolen = CHAR_STRING (c2, str), |
273 fromlen == tolen) | 277 fromlen == tolen) |
274 { | 278 { |
279 /* Length is unchanged. */ | |
275 for (j = 0; j < tolen; ++j) | 280 for (j = 0; j < tolen; ++j) |
276 FETCH_BYTE (i + j) = str[j]; | 281 FETCH_BYTE (i + j) = str[j]; |
277 } | 282 } |
278 else | 283 else |
279 { | 284 /* Replace one character with the other, |
280 error ("Can't casify letters that change length"); | 285 keeping text properties the same. */ |
281 #if 0 /* This is approximately what we'd like to be able to do here */ | 286 replace_range_2 (start + 1, i + tolen, |
282 if (tolen < fromlen) | 287 start + 2, i + tolen + fromlen, |
283 del_range_1 (i + tolen, i + fromlen, 0, 0); | 288 str, 1, tolen, |
284 else if (tolen > fromlen) | 289 0); |
285 { | |
286 TEMP_SET_PT (i + fromlen); | |
287 insert_1 (str + fromlen, tolen - fromlen, 1, 0, 0); | |
288 } | |
289 #endif | |
290 } | |
291 } | 290 } |
292 if ((int) flag >= (int) CASE_CAPITALIZE) | 291 if ((int) flag >= (int) CASE_CAPITALIZE) |
293 inword = SYNTAX (c2) == Sword; | 292 inword = SYNTAX (c2) == Sword; |
294 INC_BOTH (start, i); | 293 INC_BOTH (start, i); |
295 } | 294 } |