Mercurial > emacs
comparison src/editfns.c @ 29008:939760ef7379
(Fformat): Be sure to convert 8-bit characters to
multibyte form.
(Ftranspose_region) [BYTE_COMBINING_DEBUG]: Abort if byte
combining occurs.
(Ftranspose_region): Delete codes for handling byte combining.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Fri, 19 May 2000 23:59:04 +0000 |
parents | 19535c629080 |
children | ec25786e4705 |
comparison
equal
deleted
inserted
replaced
29007:180a8014aa14 | 29008:939760ef7379 |
---|---|
3129 && multibyte | 3129 && multibyte |
3130 && !ASCII_BYTE_P (*((unsigned char *) p - 1)) | 3130 && !ASCII_BYTE_P (*((unsigned char *) p - 1)) |
3131 && !CHAR_HEAD_P (*((unsigned char *) p))) | 3131 && !CHAR_HEAD_P (*((unsigned char *) p))) |
3132 maybe_combine_byte = 1; | 3132 maybe_combine_byte = 1; |
3133 this_nchars = strlen (p); | 3133 this_nchars = strlen (p); |
3134 p += this_nchars; | 3134 if (multibyte) |
3135 p += str_to_multibyte (p, buf + total - p, this_nchars); | |
3136 else | |
3137 p += this_nchars; | |
3135 nchars += this_nchars; | 3138 nchars += this_nchars; |
3136 } | 3139 } |
3137 } | 3140 } |
3138 else if (STRING_MULTIBYTE (args[0])) | 3141 else if (STRING_MULTIBYTE (args[0])) |
3139 { | 3142 { |
3357 { | 3360 { |
3358 register int start1, end1, start2, end2; | 3361 register int start1, end1, start2, end2; |
3359 int start1_byte, start2_byte, len1_byte, len2_byte; | 3362 int start1_byte, start2_byte, len1_byte, len2_byte; |
3360 int gap, len1, len_mid, len2; | 3363 int gap, len1, len_mid, len2; |
3361 unsigned char *start1_addr, *start2_addr, *temp; | 3364 unsigned char *start1_addr, *start2_addr, *temp; |
3362 int combined_before_bytes_1, combined_after_bytes_1; | |
3363 int combined_before_bytes_2, combined_after_bytes_2; | |
3364 struct gcpro gcpro1, gcpro2; | 3365 struct gcpro gcpro1, gcpro2; |
3365 | 3366 |
3366 INTERVAL cur_intv, tmp_interval1, tmp_interval_mid, tmp_interval2; | 3367 INTERVAL cur_intv, tmp_interval1, tmp_interval_mid, tmp_interval2; |
3367 cur_intv = BUF_INTERVALS (current_buffer); | 3368 cur_intv = BUF_INTERVALS (current_buffer); |
3368 | 3369 |
3429 start1_byte = CHAR_TO_BYTE (start1); | 3430 start1_byte = CHAR_TO_BYTE (start1); |
3430 start2_byte = CHAR_TO_BYTE (start2); | 3431 start2_byte = CHAR_TO_BYTE (start2); |
3431 len1_byte = CHAR_TO_BYTE (end1) - start1_byte; | 3432 len1_byte = CHAR_TO_BYTE (end1) - start1_byte; |
3432 len2_byte = CHAR_TO_BYTE (end2) - start2_byte; | 3433 len2_byte = CHAR_TO_BYTE (end2) - start2_byte; |
3433 | 3434 |
3435 #ifdef BYTE_COMBINING_DEBUG | |
3434 if (end1 == start2) | 3436 if (end1 == start2) |
3435 { | 3437 { |
3436 combined_before_bytes_2 | 3438 if (count_combining_before (BYTE_POS_ADDR (start2_byte), |
3437 = count_combining_before (BYTE_POS_ADDR (start2_byte), | 3439 len2_byte, start1, start1_byte) |
3438 len2_byte, start1, start1_byte); | 3440 || count_combining_before (BYTE_POS_ADDR (start1_byte), |
3439 combined_before_bytes_1 | 3441 len1_byte, end2, start2_byte + len2_byte) |
3440 = count_combining_before (BYTE_POS_ADDR (start1_byte), | 3442 || count_combining_after (BYTE_POS_ADDR (start1_byte), |
3441 len1_byte, end2, start2_byte + len2_byte); | 3443 len1_byte, end2, start2_byte + len2_byte)) |
3442 combined_after_bytes_1 | 3444 abort (); |
3443 = count_combining_after (BYTE_POS_ADDR (start1_byte), | |
3444 len1_byte, end2, start2_byte + len2_byte); | |
3445 combined_after_bytes_2 = 0; | |
3446 } | 3445 } |
3447 else | 3446 else |
3448 { | 3447 { |
3449 combined_before_bytes_2 | 3448 if (count_combining_before (BYTE_POS_ADDR (start2_byte), |
3450 = count_combining_before (BYTE_POS_ADDR (start2_byte), | 3449 len2_byte, start1, start1_byte) |
3451 len2_byte, start1, start1_byte); | 3450 || count_combining_before (BYTE_POS_ADDR (start1_byte), |
3452 combined_before_bytes_1 | 3451 len1_byte, start2, start2_byte) |
3453 = count_combining_before (BYTE_POS_ADDR (start1_byte), | 3452 || count_combining_after (BYTE_POS_ADDR (start2_byte), |
3454 len1_byte, start2, start2_byte); | 3453 len2_byte, end1, start1_byte + len1_byte) |
3455 combined_after_bytes_2 | 3454 || count_combining_after (BYTE_POS_ADDR (start1_byte), |
3456 = count_combining_after (BYTE_POS_ADDR (start2_byte), | 3455 len1_byte, end2, start2_byte + len2_byte)) |
3457 len2_byte, end1, start1_byte + len1_byte); | 3456 abort (); |
3458 combined_after_bytes_1 | 3457 } |
3459 = count_combining_after (BYTE_POS_ADDR (start1_byte), | 3458 #endif |
3460 len1_byte, end2, start2_byte + len2_byte); | 3459 |
3461 } | |
3462 | |
3463 /* If any combining is going to happen, do this the stupid way, | |
3464 because replace handles combining properly. */ | |
3465 if (combined_before_bytes_1 || combined_before_bytes_2 | |
3466 || combined_after_bytes_1 || combined_after_bytes_2) | |
3467 { | |
3468 Lisp_Object text1, text2; | |
3469 | |
3470 text1 = text2 = Qnil; | |
3471 GCPRO2 (text1, text2); | |
3472 | |
3473 text1 = make_buffer_string_both (start1, start1_byte, | |
3474 end1, start1_byte + len1_byte, 1); | |
3475 text2 = make_buffer_string_both (start2, start2_byte, | |
3476 end2, start2_byte + len2_byte, 1); | |
3477 | |
3478 transpose_markers (start1, end1, start2, end2, | |
3479 start1_byte, start1_byte + len1_byte, | |
3480 start2_byte, start2_byte + len2_byte); | |
3481 | |
3482 replace_range (start2, end2, text1, 1, 0, 0); | |
3483 replace_range (start1, end1, text2, 1, 0, 0); | |
3484 | |
3485 UNGCPRO; | |
3486 return Qnil; | |
3487 } | |
3488 | |
3489 /* Hmmm... how about checking to see if the gap is large | 3460 /* Hmmm... how about checking to see if the gap is large |
3490 enough to use as the temporary storage? That would avoid an | 3461 enough to use as the temporary storage? That would avoid an |
3491 allocation... interesting. Later, don't fool with it now. */ | 3462 allocation... interesting. Later, don't fool with it now. */ |
3492 | 3463 |
3493 /* Working without memmove, for portability (sigh), so must be | 3464 /* Working without memmove, for portability (sigh), so must be |