aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Innes2001-12-05 21:37:11 +0000
committerAndrew Innes2001-12-05 21:37:11 +0000
commit8af5b8e71f0f24a486efd7b9e4713ce44629df2e (patch)
tree9f50bb687a0aa71ee6afbd16eaba677dcc3a9b38
parent4e72858007331f2e5866907e20a236afe49174ce (diff)
downloademacs-8af5b8e71f0f24a486efd7b9e4713ce44629df2e.tar.gz
emacs-8af5b8e71f0f24a486efd7b9e4713ce44629df2e.zip
(make_gap_larger): New function.
(make_gap_smaller): New function. (make_gap) [USE_MMAP_FOR_BUFFERS || REL_ALLOC]: Call make_gap_smaller if arg is negative.
-rw-r--r--src/insdel.c71
1 files changed, 70 insertions, 1 deletions
diff --git a/src/insdel.c b/src/insdel.c
index a6953ad9bfc..db5cd98a487 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -520,7 +520,7 @@ adjust_markers_for_replace (from, from_byte, old_chars, old_bytes,
520/* Make the gap NBYTES_ADDED bytes longer. */ 520/* Make the gap NBYTES_ADDED bytes longer. */
521 521
522void 522void
523make_gap (nbytes_added) 523make_gap_larger (nbytes_added)
524 int nbytes_added; 524 int nbytes_added;
525{ 525{
526 Lisp_Object tem; 526 Lisp_Object tem;
@@ -568,6 +568,75 @@ make_gap (nbytes_added)
568 568
569 Vinhibit_quit = tem; 569 Vinhibit_quit = tem;
570} 570}
571
572
573/* Make the gap NBYTES_REMOVED bytes shorted. */
574
575void
576make_gap_smaller (nbytes_removed)
577 int nbytes_removed;
578{
579 Lisp_Object tem;
580 int real_gap_loc;
581 int real_gap_loc_byte;
582 int real_Z;
583 int real_Z_byte;
584 int old_gap_size;
585
586 /* Make sure the gap is at least 20 bytes. */
587 if (GAP_SIZE - nbytes_removed < 20)
588 nbytes_removed = GAP_SIZE - 20;
589
590 /* Prevent quitting in move_gap. */
591 tem = Vinhibit_quit;
592 Vinhibit_quit = Qt;
593
594 real_gap_loc = GPT;
595 real_gap_loc_byte = GPT_BYTE;
596 old_gap_size = GAP_SIZE;
597 real_Z = Z;
598 real_Z_byte = Z_BYTE;
599
600 /* Pretend that the last unwanted part of the gap is the entire gap,
601 and that the first desired part of the gap is part of the buffer
602 text. */
603 bzero (GPT_ADDR, GAP_SIZE - nbytes_removed);
604 GPT += GAP_SIZE - nbytes_removed;
605 GPT_BYTE += GAP_SIZE - nbytes_removed;
606 Z += GAP_SIZE - nbytes_removed;
607 Z_BYTE += GAP_SIZE - nbytes_removed;
608 GAP_SIZE = nbytes_removed;
609
610 /* Move the unwanted pretend gap to the end of the buffer. This
611 adjusts the markers properly too. */
612 gap_right (Z, Z_BYTE);
613
614 enlarge_buffer_text (current_buffer, -nbytes_removed);
615
616 /* Now restore the desired gap. */
617 GAP_SIZE = old_gap_size - nbytes_removed;
618 GPT = real_gap_loc;
619 GPT_BYTE = real_gap_loc_byte;
620 Z = real_Z;
621 Z_BYTE = real_Z_byte;
622
623 /* Put an anchor. */
624 *(Z_ADDR) = 0;
625
626 Vinhibit_quit = tem;
627}
628
629void
630make_gap (nbytes_added)
631 int nbytes_added;
632{
633 if (nbytes_added >= 0)
634 make_gap_larger (nbytes_added);
635#if defined (USE_MMAP_FOR_BUFFERS) || defined (REL_ALLOC)
636 else
637 make_gap_smaller (-nbytes_added);
638#endif
639}
571 640
572/* Copy NBYTES bytes of text from FROM_ADDR to TO_ADDR. 641/* Copy NBYTES bytes of text from FROM_ADDR to TO_ADDR.
573 FROM_MULTIBYTE says whether the incoming text is multibyte. 642 FROM_MULTIBYTE says whether the incoming text is multibyte.