diff options
| author | Kenichi Handa | 1998-07-06 01:47:34 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1998-07-06 01:47:34 +0000 |
| commit | 18cc260b22f3e6463f23a195840abe220cc6ec4b (patch) | |
| tree | 77ba5ac7b9e77153e6ab4b501afab8af945d2328 /src | |
| parent | 1c87ab3195c32bfabd9533125961eed5f32d8215 (diff) | |
| download | emacs-18cc260b22f3e6463f23a195840abe220cc6ec4b.tar.gz emacs-18cc260b22f3e6463f23a195840abe220cc6ec4b.zip | |
(concat): Pay attention to the byte combining problem.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fns.c | 22 |
1 files changed, 22 insertions, 0 deletions
| @@ -527,6 +527,11 @@ concat (nargs, args, target_type, last_special) | |||
| 527 | Lisp_Object last_tail; | 527 | Lisp_Object last_tail; |
| 528 | Lisp_Object prev; | 528 | Lisp_Object prev; |
| 529 | int some_multibyte; | 529 | int some_multibyte; |
| 530 | /* When we make a multibyte string, we must pay attention to the | ||
| 531 | byte combining problem, i.e., a byte may be combined with a | ||
| 532 | multibyte charcter of the previous string. This flag tells if we | ||
| 533 | must consider such a situation or not. */ | ||
| 534 | int maybe_combine_byte; | ||
| 530 | 535 | ||
| 531 | /* In append, the last arg isn't treated like the others */ | 536 | /* In append, the last arg isn't treated like the others */ |
| 532 | if (last_special && nargs > 0) | 537 | if (last_special && nargs > 0) |
| @@ -636,6 +641,7 @@ concat (nargs, args, target_type, last_special) | |||
| 636 | 641 | ||
| 637 | prev = Qnil; | 642 | prev = Qnil; |
| 638 | 643 | ||
| 644 | maybe_combine_byte = 0; | ||
| 639 | for (argnum = 0; argnum < nargs; argnum++) | 645 | for (argnum = 0; argnum < nargs; argnum++) |
| 640 | { | 646 | { |
| 641 | Lisp_Object thislen; | 647 | Lisp_Object thislen; |
| @@ -659,6 +665,11 @@ concat (nargs, args, target_type, last_special) | |||
| 659 | int thislen_byte = STRING_BYTES (XSTRING (this)); | 665 | int thislen_byte = STRING_BYTES (XSTRING (this)); |
| 660 | bcopy (XSTRING (this)->data, XSTRING (val)->data + toindex_byte, | 666 | bcopy (XSTRING (this)->data, XSTRING (val)->data + toindex_byte, |
| 661 | STRING_BYTES (XSTRING (this))); | 667 | STRING_BYTES (XSTRING (this))); |
| 668 | if (some_multibyte | ||
| 669 | && toindex_byte > 0 | ||
| 670 | && XSTRING (val)->data[toindex_byte - 1] >= 0x80 | ||
| 671 | && XSTRING (this)->data[0] >= 0xA0) | ||
| 672 | maybe_combine_byte = 1; | ||
| 662 | toindex_byte += thislen_byte; | 673 | toindex_byte += thislen_byte; |
| 663 | toindex += thisleni; | 674 | toindex += thisleni; |
| 664 | } | 675 | } |
| @@ -731,6 +742,11 @@ concat (nargs, args, target_type, last_special) | |||
| 731 | CHECK_NUMBER (elt, 0); | 742 | CHECK_NUMBER (elt, 0); |
| 732 | if (SINGLE_BYTE_CHAR_P (XINT (elt))) | 743 | if (SINGLE_BYTE_CHAR_P (XINT (elt))) |
| 733 | { | 744 | { |
| 745 | if (some_multibyte | ||
| 746 | && toindex_byte > 0 | ||
| 747 | && XSTRING (val)->data[toindex_byte - 1] >= 0x80 | ||
| 748 | && XINT (elt) >= 0xA0) | ||
| 749 | maybe_combine_byte = 1; | ||
| 734 | XSTRING (val)->data[toindex_byte++] = XINT (elt); | 750 | XSTRING (val)->data[toindex_byte++] = XINT (elt); |
| 735 | toindex++; | 751 | toindex++; |
| 736 | } | 752 | } |
| @@ -755,6 +771,12 @@ concat (nargs, args, target_type, last_special) | |||
| 755 | if (!NILP (prev)) | 771 | if (!NILP (prev)) |
| 756 | XCONS (prev)->cdr = last_tail; | 772 | XCONS (prev)->cdr = last_tail; |
| 757 | 773 | ||
| 774 | if (maybe_combine_byte) | ||
| 775 | /* Characater counter of the multibyte string VAL may be wrong | ||
| 776 | because of byte combining problem. We must re-calculate it. */ | ||
| 777 | XSTRING (val)->size = multibyte_chars_in_text (XSTRING (val)->data, | ||
| 778 | XSTRING (val)->size_byte); | ||
| 779 | |||
| 758 | return val; | 780 | return val; |
| 759 | } | 781 | } |
| 760 | 782 | ||