changeset 17034:02f6d66c3a4b

Include charset.h. (gap_left, gap_right): Put an anchor `\0' at the end of GAP. (adjust_markers_for_insert): If any markers are adjusted, check and fix the order of overlays in overlays_before. (make_gap): Allocate an extra byte and set to `\0' for anchoring. (insert1, insert_from_buffer_1): Put an anchor `\0' at the head of GAP.
author Karl Heuer <kwzh@gnu.org>
date Thu, 20 Feb 1997 06:50:03 +0000
parents ffd6878cae02
children 275c20d27886
files src/insdel.c
diffstat 1 files changed, 26 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/insdel.c	Thu Feb 20 06:49:29 1997 +0000
+++ b/src/insdel.c	Thu Feb 20 06:50:03 1997 +0000
@@ -23,6 +23,7 @@
 #include "lisp.h"
 #include "intervals.h"
 #include "buffer.h"
+#include "charset.h"
 #include "window.h"
 #include "blockinput.h"
 
@@ -153,6 +154,7 @@
      or may be where a quit was detected.  */
   adjust_markers (pos + 1, GPT, GAP_SIZE);
   GPT = pos + 1;
+  if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor.  */
   QUIT;
 }
 
@@ -231,6 +233,7 @@
 
   adjust_markers (GPT + GAP_SIZE, pos + 1 + GAP_SIZE, - GAP_SIZE);
   GPT = pos + 1;
+  if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor.  */
   QUIT;
 }
 
@@ -290,6 +293,7 @@
      register int pos, amount;
 {
   Lisp_Object marker;
+  int adjusted = 0;
 
   marker = BUF_MARKERS (current_buffer);
 
@@ -297,9 +301,16 @@
     {
       register struct Lisp_Marker *m = XMARKER (marker);
       if (m->insertion_type && m->bufpos == pos)
-	m->bufpos += amount;
+	{
+	  m->bufpos += amount;
+	  adjusted = 1;
+	}
       marker = m->chain;
     }
+  if (adjusted)
+    /* Adjusting only markers whose insertion-type is t may result in
+       disordered overlays in the slot `overlays_before'.  */
+    fix_overlays_before (current_buffer, pos, pos + amount);
 }
 
 /* Add the specified amount to point.  This is used only when the value
@@ -339,7 +350,8 @@
     error ("Buffer exceeds maximum size");
 
   BLOCK_INPUT;
-  result = BUFFER_REALLOC (BEG_ADDR, (Z - BEG + GAP_SIZE + increment));
+  /* We allocate extra 1-byte `\0' at the tail for anchoring a search.  */
+  result = BUFFER_REALLOC (BEG_ADDR, (Z - BEG + GAP_SIZE + increment + 1));
 
   if (result == 0)
     {
@@ -370,6 +382,9 @@
   GAP_SIZE += old_gap_size;
   GPT = real_gap_loc;
 
+  /* Put an anchor.  */
+  *(Z_ADDR) = 0;
+
   Vinhibit_quit = tem;
 }
 
@@ -432,6 +447,7 @@
   GPT += length;
   ZV += length;
   Z += length;
+  if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor.  */
   adjust_overlays_for_insert (PT, length);
   adjust_markers_for_insert (PT, length);
   adjust_point (length);
@@ -500,6 +516,7 @@
   GPT += length;
   ZV += length;
   Z += length;
+  if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor.  */
   adjust_overlays_for_insert (PT, length);
   adjust_markers_for_insert (PT, length);
 
@@ -576,6 +593,7 @@
   GPT += length;
   ZV += length;
   Z += length;
+  if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor.  */
   adjust_overlays_for_insert (PT, length);
   adjust_markers_for_insert (PT, length);
   adjust_point (length);
@@ -590,9 +608,12 @@
 
 void
 insert_char (c)
-     unsigned char c;
+     int c;
 {
-  insert (&c, 1);
+  unsigned char workbuf[4], *str;
+  int len = CHAR_STRING (c, workbuf, str);
+
+  insert (str, len);
 }
 
 /* Insert the null-terminated string S before point */
@@ -714,6 +735,7 @@
   ZV -= numdel;
   Z -= numdel;
   GPT = from;
+  *(GPT_ADDR) = 0;		/* Put an anchor.  */
 
   if (GPT - BEG < beg_unchanged)
     beg_unchanged = GPT - BEG;