diff src/insdel.c @ 183:e121b013d1f0 r20-3b18

Import from CVS: tag r20-3b18
author cvs
date Mon, 13 Aug 2007 09:54:23 +0200
parents 85ec50267440
children 3d6bfa290dbd
line wrap: on
line diff
--- a/src/insdel.c	Mon Aug 13 09:53:23 2007 +0200
+++ b/src/insdel.c	Mon Aug 13 09:54:23 2007 +0200
@@ -2678,15 +2678,12 @@
       BUF_MODIFF (buf)++;
       MARK_BUFFERS_CHANGED;
 
-      /* Relocate point as if it were a marker.  */
-      if (bi_from < BI_BUF_PT (buf))
-	{
-	  if (BI_BUF_PT (buf) < bi_to)
-	    JUST_SET_POINT (buf, from, bi_from);
-	  else
-	    JUST_SET_POINT (buf, BUF_PT (buf) - numdel,
-			    BI_BUF_PT (buf) - bc_numdel);
-	}
+      /* ### Point used to be modified here, but this causes problems with MULE,
+	 as point is used to calculate bytinds, and if the offset in bc_numdel causes
+	 point to move to a non first-byte location, causing some other function to 
+	 throw an assertion in ASSERT_VALID_BYTIND. I've moved the code to right after
+	  the other movements and adjustments, but before the gap is moved.
+	  -- jh 970813 */
 
       /* Detach any extents that are completely within the range [FROM, TO],
 	 if the extents are detachable.
@@ -2707,6 +2704,16 @@
       adjust_extents_for_deletion (bufobj, bi_from, bi_to, BUF_GAP_SIZE (buf),
 				   bc_numdel, BUF_GAP_SIZE (buf));
 
+      /* Relocate point as if it were a marker.  */
+      if (bi_from < BI_BUF_PT (buf))
+	{
+	  if (BI_BUF_PT (buf) < bi_to)
+	    JUST_SET_POINT (buf, from, bi_from);
+	  else
+	    JUST_SET_POINT (buf, BUF_PT (buf) - numdel,
+			    BI_BUF_PT (buf) - bc_numdel);
+	}
+
       SET_BUF_GAP_SIZE (buf, BUF_GAP_SIZE (buf) + bc_numdel);
       SET_BOTH_BUF_ZV (buf, BUF_ZV (buf) - numdel, BI_BUF_ZV (buf) - bc_numdel);
       SET_BOTH_BUF_Z (buf, BUF_Z (buf) - numdel, BI_BUF_Z (buf) - bc_numdel);
@@ -2997,12 +3004,11 @@
 					  bufbyte_dynarr *dyn)
 {
   Bufbyte str[MAX_EMCHAR_LEN];
-  Bytecount len;
   int i;
 
   for (i = 0; i < nels; i++)
     {
-      len = set_charptr_emchar (str, arr[i]);
+      Bytecount len = set_charptr_emchar (str, arr[i]);
       Dynarr_add_many (dyn, str, len);
     }
 }
@@ -3058,8 +3064,7 @@
   if (!indirect_p)
     {
       SET_BUF_GAP_SIZE (b, 20);
-      (void) BUFFER_ALLOC (b->text->beg,
-			   BUF_GAP_SIZE (b) + BUF_END_SENTINEL_SIZE);
+      BUFFER_ALLOC (b->text->beg, BUF_GAP_SIZE (b) + BUF_END_SENTINEL_SIZE);
       if (! BUF_BEG_ADDR (b))
 	memory_full ();
 
@@ -3083,7 +3088,7 @@
 	    b->text->mule_bytind_cache[i] = 1;
 	  }
       }
-#endif
+#endif /* MULE */
 
       BUF_MODIFF (b) = 1;
       BUF_SAVE_MODIFF (b) = 1;