diff options
| author | Kenichi Handa | 2004-04-16 12:51:06 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2004-04-16 12:51:06 +0000 |
| commit | 6b61353c0a0320ee15bb6488149735381fed62ec (patch) | |
| tree | e69adba60e504a5a37beb556ad70084de88a7aab /src/intervals.c | |
| parent | dc6a28319312fe81f7a1015e363174022313f0bd (diff) | |
| download | emacs-6b61353c0a0320ee15bb6488149735381fed62ec.tar.gz emacs-6b61353c0a0320ee15bb6488149735381fed62ec.zip | |
Sync to HEAD
Diffstat (limited to 'src/intervals.c')
| -rw-r--r-- | src/intervals.c | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/src/intervals.c b/src/intervals.c index e19f09609be..d87b361a223 100644 --- a/src/intervals.c +++ b/src/intervals.c | |||
| @@ -1712,6 +1712,7 @@ graft_intervals_into_buffer (source, position, length, buffer, inherit) | |||
| 1712 | { | 1712 | { |
| 1713 | register INTERVAL under, over, this, prev; | 1713 | register INTERVAL under, over, this, prev; |
| 1714 | register INTERVAL tree; | 1714 | register INTERVAL tree; |
| 1715 | int over_used; | ||
| 1715 | 1716 | ||
| 1716 | tree = BUF_INTERVALS (buffer); | 1717 | tree = BUF_INTERVALS (buffer); |
| 1717 | 1718 | ||
| @@ -1745,6 +1746,7 @@ graft_intervals_into_buffer (source, position, length, buffer, inherit) | |||
| 1745 | XSETBUFFER (buf, buffer); | 1746 | XSETBUFFER (buf, buffer); |
| 1746 | BUF_INTERVALS (buffer) = reproduce_tree_obj (source, buf); | 1747 | BUF_INTERVALS (buffer) = reproduce_tree_obj (source, buf); |
| 1747 | BUF_INTERVALS (buffer)->position = BEG; | 1748 | BUF_INTERVALS (buffer)->position = BEG; |
| 1749 | BUF_INTERVALS (buffer)->up_obj = 1; | ||
| 1748 | 1750 | ||
| 1749 | /* Explicitly free the old tree here? */ | 1751 | /* Explicitly free the old tree here? */ |
| 1750 | 1752 | ||
| @@ -1767,6 +1769,7 @@ graft_intervals_into_buffer (source, position, length, buffer, inherit) | |||
| 1767 | { | 1769 | { |
| 1768 | BUF_INTERVALS (buffer) = reproduce_tree (source, INTERVAL_PARENT (tree)); | 1770 | BUF_INTERVALS (buffer) = reproduce_tree (source, INTERVAL_PARENT (tree)); |
| 1769 | BUF_INTERVALS (buffer)->position = BEG; | 1771 | BUF_INTERVALS (buffer)->position = BEG; |
| 1772 | BUF_INTERVALS (buffer)->up_obj = 1; | ||
| 1770 | /* Explicitly free the old tree here. */ | 1773 | /* Explicitly free the old tree here. */ |
| 1771 | 1774 | ||
| 1772 | return; | 1775 | return; |
| @@ -1814,21 +1817,42 @@ graft_intervals_into_buffer (source, position, length, buffer, inherit) | |||
| 1814 | adjust_intervals_for_insertion, so stickiness has | 1817 | adjust_intervals_for_insertion, so stickiness has |
| 1815 | already been taken care of. */ | 1818 | already been taken care of. */ |
| 1816 | 1819 | ||
| 1820 | /* OVER is the interval we are copying from next. | ||
| 1821 | OVER_USED says how many characters' worth of OVER | ||
| 1822 | have already been copied into target intervals. | ||
| 1823 | UNDER is the next interval in the target. */ | ||
| 1824 | over_used = 0; | ||
| 1817 | while (! NULL_INTERVAL_P (over)) | 1825 | while (! NULL_INTERVAL_P (over)) |
| 1818 | { | 1826 | { |
| 1819 | if (LENGTH (over) < LENGTH (under)) | 1827 | /* If UNDER is longer than OVER, split it. */ |
| 1828 | if (LENGTH (over) - over_used < LENGTH (under)) | ||
| 1820 | { | 1829 | { |
| 1821 | this = split_interval_left (under, LENGTH (over)); | 1830 | this = split_interval_left (under, LENGTH (over) - over_used); |
| 1822 | copy_properties (under, this); | 1831 | copy_properties (under, this); |
| 1823 | } | 1832 | } |
| 1824 | else | 1833 | else |
| 1825 | this = under; | 1834 | this = under; |
| 1826 | copy_properties (over, this); | 1835 | |
| 1836 | /* THIS is now the interval to copy or merge into. | ||
| 1837 | OVER covers all of it. */ | ||
| 1827 | if (inherit) | 1838 | if (inherit) |
| 1828 | merge_properties (over, this); | 1839 | merge_properties (over, this); |
| 1829 | else | 1840 | else |
| 1830 | copy_properties (over, this); | 1841 | copy_properties (over, this); |
| 1831 | over = next_interval (over); | 1842 | |
| 1843 | /* If THIS and OVER end at the same place, | ||
| 1844 | advance OVER to a new source interval. */ | ||
| 1845 | if (LENGTH (this) == LENGTH (over) - over_used) | ||
| 1846 | { | ||
| 1847 | over = next_interval (over); | ||
| 1848 | over_used = 0; | ||
| 1849 | } | ||
| 1850 | else | ||
| 1851 | /* Otherwise just record that more of OVER has been used. */ | ||
| 1852 | over_used += LENGTH (this); | ||
| 1853 | |||
| 1854 | /* Always advance to a new target interval. */ | ||
| 1855 | under = next_interval (this); | ||
| 1832 | } | 1856 | } |
| 1833 | 1857 | ||
| 1834 | if (! NULL_INTERVAL_P (BUF_INTERVALS (buffer))) | 1858 | if (! NULL_INTERVAL_P (BUF_INTERVALS (buffer))) |
| @@ -2587,3 +2611,6 @@ set_intervals_multibyte (multi_flag) | |||
| 2587 | set_intervals_multibyte_1 (BUF_INTERVALS (current_buffer), multi_flag, | 2611 | set_intervals_multibyte_1 (BUF_INTERVALS (current_buffer), multi_flag, |
| 2588 | BEG, BEG_BYTE, Z, Z_BYTE); | 2612 | BEG, BEG_BYTE, Z, Z_BYTE); |
| 2589 | } | 2613 | } |
| 2614 | |||
| 2615 | /* arch-tag: 3d402b60-083c-4271-b4a3-ebd9a74bfe27 | ||
| 2616 | (do not change this comment) */ | ||