diff options
| author | Kenichi Handa | 1998-02-04 11:23:28 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1998-02-04 11:23:28 +0000 |
| commit | 84246b955eac2fc5a8531096b09e798bfb98e31f (patch) | |
| tree | f2adaa5d8cc64e8c87fac0d0d24742bf919e9454 | |
| parent | 2b71bb78b8292478916a5b1698d5056eb2db3411 (diff) | |
| download | emacs-84246b955eac2fc5a8531096b09e798bfb98e31f.tar.gz emacs-84246b955eac2fc5a8531096b09e798bfb98e31f.zip | |
(Fsubst_char_in_region): Handle character-base
position and byte-base position correctly.
(Fstring_to_char): Give byte size to STRING_CHAR.
| -rw-r--r-- | src/editfns.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/editfns.c b/src/editfns.c index b588d413d4b..e5b9d54344e 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -146,7 +146,7 @@ A multibyte character is handled correctly.") | |||
| 146 | CHECK_STRING (string, 0); | 146 | CHECK_STRING (string, 0); |
| 147 | p = XSTRING (string); | 147 | p = XSTRING (string); |
| 148 | if (p->size) | 148 | if (p->size) |
| 149 | XSETFASTINT (val, STRING_CHAR (p->data, p->size)); | 149 | XSETFASTINT (val, STRING_CHAR (p->data, p->size_byte)); |
| 150 | else | 150 | else |
| 151 | XSETFASTINT (val, 0); | 151 | XSETFASTINT (val, 0); |
| 152 | return val; | 152 | return val; |
| @@ -1741,7 +1741,7 @@ Both characters must have the same length of multi-byte form.") | |||
| 1741 | (start, end, fromchar, tochar, noundo) | 1741 | (start, end, fromchar, tochar, noundo) |
| 1742 | Lisp_Object start, end, fromchar, tochar, noundo; | 1742 | Lisp_Object start, end, fromchar, tochar, noundo; |
| 1743 | { | 1743 | { |
| 1744 | register int pos, stop, i, len, end_byte; | 1744 | register int pos, pos_byte, stop, i, len, end_byte; |
| 1745 | int changed = 0; | 1745 | int changed = 0; |
| 1746 | unsigned char fromwork[4], *fromstr, towork[4], *tostr, *p; | 1746 | unsigned char fromwork[4], *fromstr, towork[4], *tostr, *p; |
| 1747 | int count = specpdl_ptr - specpdl; | 1747 | int count = specpdl_ptr - specpdl; |
| @@ -1763,7 +1763,8 @@ Both characters must have the same length of multi-byte form.") | |||
| 1763 | towork[0] = XFASTINT (tochar), tostr = towork; | 1763 | towork[0] = XFASTINT (tochar), tostr = towork; |
| 1764 | } | 1764 | } |
| 1765 | 1765 | ||
| 1766 | pos = CHAR_TO_BYTE (XINT (start)); | 1766 | pos = XINT (start); |
| 1767 | pos_byte = CHAR_TO_BYTE (pos); | ||
| 1767 | stop = CHAR_TO_BYTE (XINT (end)); | 1768 | stop = CHAR_TO_BYTE (XINT (end)); |
| 1768 | end_byte = stop; | 1769 | end_byte = stop; |
| 1769 | 1770 | ||
| @@ -1782,17 +1783,16 @@ Both characters must have the same length of multi-byte form.") | |||
| 1782 | current_buffer->filename = Qnil; | 1783 | current_buffer->filename = Qnil; |
| 1783 | } | 1784 | } |
| 1784 | 1785 | ||
| 1785 | if (pos < GPT_BYTE) | 1786 | if (pos_byte < GPT_BYTE) |
| 1786 | stop = min (stop, GPT_BYTE); | 1787 | stop = min (stop, GPT_BYTE); |
| 1787 | p = BYTE_POS_ADDR (pos); | ||
| 1788 | while (1) | 1788 | while (1) |
| 1789 | { | 1789 | { |
| 1790 | if (pos >= stop) | 1790 | if (pos_byte >= stop) |
| 1791 | { | 1791 | { |
| 1792 | if (pos >= end_byte) break; | 1792 | if (pos_byte >= end_byte) break; |
| 1793 | stop = end_byte; | 1793 | stop = end_byte; |
| 1794 | p = BYTE_POS_ADDR (pos); | ||
| 1795 | } | 1794 | } |
| 1795 | p = BYTE_POS_ADDR (pos_byte); | ||
| 1796 | if (p[0] == fromstr[0] | 1796 | if (p[0] == fromstr[0] |
| 1797 | && (len == 1 | 1797 | && (len == 1 |
| 1798 | || (p[1] == fromstr[1] | 1798 | || (p[1] == fromstr[1] |
| @@ -1815,17 +1815,17 @@ Both characters must have the same length of multi-byte form.") | |||
| 1815 | } | 1815 | } |
| 1816 | 1816 | ||
| 1817 | if (NILP (noundo)) | 1817 | if (NILP (noundo)) |
| 1818 | record_change (pos, len); | 1818 | record_change (pos, 1); |
| 1819 | for (i = 0; i < len; i++) *p++ = tostr[i]; | 1819 | for (i = 0; i < len; i++) *p++ = tostr[i]; |
| 1820 | pos += len; | 1820 | pos++; |
| 1821 | pos_byte += len; | ||
| 1821 | } | 1822 | } |
| 1822 | else | 1823 | INC_BOTH (pos, pos_byte); |
| 1823 | pos++, p++; | ||
| 1824 | } | 1824 | } |
| 1825 | 1825 | ||
| 1826 | if (changed) | 1826 | if (changed) |
| 1827 | signal_after_change (XINT (start), | 1827 | signal_after_change (XINT (start), |
| 1828 | stop - XINT (start), stop - XINT (start)); | 1828 | XINT (end) - XINT (start), XINT (end) - XINT (start)); |
| 1829 | 1829 | ||
| 1830 | unbind_to (count, Qnil); | 1830 | unbind_to (count, Qnil); |
| 1831 | return Qnil; | 1831 | return Qnil; |