comparison src/insdel.c @ 440:8de8e3f6228a r21-2-28

Import from CVS: tag r21-2-28
author cvs
date Mon, 13 Aug 2007 11:33:38 +0200
parents 84b14dcb0985
children abe6d1db359e
comparison
equal deleted inserted replaced
439:357dd071b03c 440:8de8e3f6228a
1603 1603
1604 static void 1604 static void
1605 adjust_markers (struct buffer *buf, Memind from, Memind to, 1605 adjust_markers (struct buffer *buf, Memind from, Memind to,
1606 Bytecount amount) 1606 Bytecount amount)
1607 { 1607 {
1608 struct Lisp_Marker *m; 1608 Lisp_Marker *m;
1609 1609
1610 for (m = BUF_MARKERS (buf); m; m = marker_next (m)) 1610 for (m = BUF_MARKERS (buf); m; m = marker_next (m))
1611 m->memind = do_marker_adjustment (m->memind, from, to, amount); 1611 m->memind = do_marker_adjustment (m->memind, from, to, amount);
1612 } 1612 }
1613 1613
1615 for an insertion of AMOUNT characters at POS. */ 1615 for an insertion of AMOUNT characters at POS. */
1616 1616
1617 static void 1617 static void
1618 adjust_markers_for_insert (struct buffer *buf, Memind ind, Bytecount amount) 1618 adjust_markers_for_insert (struct buffer *buf, Memind ind, Bytecount amount)
1619 { 1619 {
1620 struct Lisp_Marker *m; 1620 Lisp_Marker *m;
1621 1621
1622 for (m = BUF_MARKERS (buf); m; m = marker_next (m)) 1622 for (m = BUF_MARKERS (buf); m; m = marker_next (m))
1623 { 1623 {
1624 if (m->insertion_type && m->memind == ind) 1624 if (m->insertion_type && m->memind == ind)
1625 m->memind += amount; 1625 m->memind += amount;
1628 1628
1629 1629
1630 /************************************************************************/ 1630 /************************************************************************/
1631 /* Routines for dealing with the gap */ 1631 /* Routines for dealing with the gap */
1632 /************************************************************************/ 1632 /************************************************************************/
1633
1634 /* XEmacs requires an ANSI C compiler, and it damn well better have a
1635 working memmove() */
1636 #define GAP_USE_BCOPY
1637 #ifdef BCOPY_UPWARD_SAFE
1638 # undef BCOPY_UPWARD_SAFE
1639 #endif
1640 #ifdef BCOPY_DOWNWARD_SAFE
1641 # undef BCOPY_DOWNWARD_SAFE
1642 #endif
1643 #define BCOPY_UPWARD_SAFE 1
1644 #define BCOPY_DOWNWARD_SAFE 1
1645 1633
1646 /* maximum amount of memory moved in a single chunk. Increasing this 1634 /* maximum amount of memory moved in a single chunk. Increasing this
1647 value improves gap-motion efficiency but decreases QUIT responsiveness 1635 value improves gap-motion efficiency but decreases QUIT responsiveness
1648 time. Was 32000 but today's processors are faster and files are 1636 time. Was 32000 but today's processors are faster and files are
1649 bigger. --ben */ 1637 bigger. --ben */
1681 break; 1669 break;
1682 } 1670 }
1683 /* Move at most GAP_MOVE_CHUNK chars before checking again for a quit. */ 1671 /* Move at most GAP_MOVE_CHUNK chars before checking again for a quit. */
1684 if (i > GAP_MOVE_CHUNK) 1672 if (i > GAP_MOVE_CHUNK)
1685 i = GAP_MOVE_CHUNK; 1673 i = GAP_MOVE_CHUNK;
1686 #ifdef GAP_USE_BCOPY 1674
1687 if (i >= 128 1675 if (i >= 128)
1688 /* bcopy is safe if the two areas of memory do not overlap 1676 {
1689 or on systems where bcopy is always safe for moving upward. */
1690 && (BCOPY_UPWARD_SAFE
1691 || to - from >= 128))
1692 {
1693 /* If overlap is not safe, avoid it by not moving too many
1694 characters at once. */
1695 if (!BCOPY_UPWARD_SAFE && i > to - from)
1696 i = to - from;
1697 new_s1 -= i; 1677 new_s1 -= i;
1698 from -= i, to -= i; 1678 from -= i;
1679 to -= i;
1699 memmove (to, from, i); 1680 memmove (to, from, i);
1700 } 1681 }
1701 else 1682 else
1702 #endif
1703 { 1683 {
1704 new_s1 -= i; 1684 new_s1 -= i;
1705 while (--i >= 0) 1685 while (--i >= 0)
1706 *--to = *--from; 1686 *--to = *--from;
1707 } 1687 }
1760 break; 1740 break;
1761 } 1741 }
1762 /* Move at most GAP_MOVE_CHUNK chars before checking again for a quit. */ 1742 /* Move at most GAP_MOVE_CHUNK chars before checking again for a quit. */
1763 if (i > GAP_MOVE_CHUNK) 1743 if (i > GAP_MOVE_CHUNK)
1764 i = GAP_MOVE_CHUNK; 1744 i = GAP_MOVE_CHUNK;
1765 #ifdef GAP_USE_BCOPY 1745
1766 if (i >= 128 1746 if (i >= 128)
1767 /* bcopy is safe if the two areas of memory do not overlap 1747 {
1768 or on systems where bcopy is always safe for moving downward. */
1769 && (BCOPY_DOWNWARD_SAFE
1770 || from - to >= 128))
1771 {
1772 /* If overlap is not safe, avoid it by not moving too many
1773 characters at once. */
1774 if (!BCOPY_DOWNWARD_SAFE && i > from - to)
1775 i = from - to;
1776 new_s1 += i; 1748 new_s1 += i;
1777 memmove (to, from, i); 1749 memmove (to, from, i);
1778 from += i, to += i; 1750 from += i;
1751 to += i;
1779 } 1752 }
1780 else 1753 else
1781 #endif
1782 { 1754 {
1783 new_s1 += i; 1755 new_s1 += i;
1784 while (--i >= 0) 1756 while (--i >= 0)
1785 *to++ = *from++; 1757 *to++ = *from++;
1786 } 1758 }