emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/buffer.c


From: Ken Raeburn
Subject: [Emacs-diffs] Changes to emacs/src/buffer.c
Date: Sun, 19 May 2002 19:12:30 -0400

Index: emacs/src/buffer.c
diff -c emacs/src/buffer.c:1.383 emacs/src/buffer.c:1.384
*** emacs/src/buffer.c:1.383    Tue Apr 23 16:23:46 2002
--- emacs/src/buffer.c  Sun May 19 19:12:30 2002
***************
*** 3228,3245 ****
  {
    Lisp_Object overlay;
    Lisp_Object before_list, after_list;
!   Lisp_Object *ptail, *pbefore = &before_list, *pafter = &after_list;
    int startpos, endpos;
  
    /* This algorithm shifts links around instead of consing and GCing.
       The loop invariant is that before_list (resp. after_list) is a
!      well-formed list except that its last element, the one that
!      *pbefore (resp. *pafter) points to, is still uninitialized.
!      So it's not a bug that before_list isn't initialized, although
!      it may look strange.  */
!   for (ptail = &current_buffer->overlays_before; CONSP (*ptail);)
      {
!       overlay = XCAR (*ptail);
        endpos = OVERLAY_POSITION (OVERLAY_END (overlay));
        if (endpos < start)
        break;
--- 3228,3253 ----
  {
    Lisp_Object overlay;
    Lisp_Object before_list, after_list;
!   /* These are either nil, indicating that before_list or after_list
!      should be assigned, or the cons cell the cdr of which should be
!      assigned.  */
!   Lisp_Object beforep = Qnil, afterp = Qnil;
!   /* 'Parent', likewise, indicates a cons cell or
!      current_buffer->overlays_before or overlays_after, depending
!      which loop we're in.  */
!   Lisp_Object tail, parent;
    int startpos, endpos;
  
    /* This algorithm shifts links around instead of consing and GCing.
       The loop invariant is that before_list (resp. after_list) is a
!      well-formed list except that its last element, the CDR of beforep
!      (resp. afterp) if beforep (afterp) isn't nil or before_list
!      (after_list) if it is, is still uninitialized.  So it's not a bug
!      that before_list isn't initialized, although it may look
!      strange.  */
!   for (parent = Qnil, tail = current_buffer->overlays_before; CONSP (tail);)
      {
!       overlay = XCAR (tail);
        endpos = OVERLAY_POSITION (OVERLAY_END (overlay));
        if (endpos < start)
        break;
***************
*** 3261,3282 ****
             recenter_overlay_lists will move it to the right place.  */
          if (endpos < XINT (current_buffer->overlay_center))
            {
!             *pafter = *ptail;
!             pafter = &XCDR (*ptail);
            }
          else
            {
!             *pbefore = *ptail;
!             pbefore = &XCDR (*ptail);
            }
!         *ptail = XCDR (*ptail);
        }
        else
!       ptail = &XCDR (*ptail);
      }
!   for (ptail = &current_buffer->overlays_after; CONSP (*ptail);)
      {
!       overlay = XCAR (*ptail);
        startpos = OVERLAY_POSITION (OVERLAY_START (overlay));
        if (startpos >= end)
        break;
--- 3269,3300 ----
             recenter_overlay_lists will move it to the right place.  */
          if (endpos < XINT (current_buffer->overlay_center))
            {
!             if (NILP (afterp))
!               after_list = tail;
!             else
!               XSETCDR (afterp, tail);
!             afterp = tail;
            }
          else
            {
!             if (NILP (beforep))
!               before_list = tail;
!             else
!               XSETCDR (beforep, tail);
!             beforep = tail;
            }
!         if (NILP (parent))
!           current_buffer->overlays_before = XCDR (tail);
!         else
!           XSETCDR (parent, XCDR (tail));
!         tail = XCDR (tail);
        }
        else
!       parent = tail, tail = XCDR (parent);
      }
!   for (parent = Qnil, tail = current_buffer->overlays_after; CONSP (tail);)
      {
!       overlay = XCAR (tail);
        startpos = OVERLAY_POSITION (OVERLAY_START (overlay));
        if (startpos >= end)
        break;
***************
*** 3295,3323 ****
            }
          if (endpos < XINT (current_buffer->overlay_center))
            {
!             *pafter = *ptail;
!             pafter = &XCDR (*ptail);
            }
          else
            {
!             *pbefore = *ptail;
!             pbefore = &XCDR (*ptail);
            }
!         *ptail = XCDR (*ptail);
        }
        else
!       ptail = &XCDR (*ptail);
      }
  
    /* Splice the constructed (wrong) lists into the buffer's lists,
       and let the recenter function make it sane again.  */
!   *pbefore = current_buffer->overlays_before;
!   current_buffer->overlays_before = before_list;
    recenter_overlay_lists (current_buffer,
                          XINT (current_buffer->overlay_center));
  
!   *pafter = current_buffer->overlays_after;
!   current_buffer->overlays_after = after_list;
    recenter_overlay_lists (current_buffer,
                          XINT (current_buffer->overlay_center));
  }
--- 3313,3357 ----
            }
          if (endpos < XINT (current_buffer->overlay_center))
            {
!             if (NILP (afterp))
!               after_list = tail;
!             else
!               XSETCDR (afterp, tail);
!             afterp = tail;
            }
          else
            {
!             if (NILP (beforep))
!               before_list = tail;
!             else
!               XSETCDR (beforep, tail);
!             beforep = tail;
            }
!         if (NILP (parent))
!           current_buffer->overlays_after = XCDR (tail);
!         else
!           XSETCDR (parent, XCDR (tail));
!         tail = XCDR (tail);
        }
        else
!       parent = tail, tail = XCDR (parent);
      }
  
    /* Splice the constructed (wrong) lists into the buffer's lists,
       and let the recenter function make it sane again.  */
!   if (!NILP (beforep))
!     {
!       XSETCDR (beforep, current_buffer->overlays_before);
!       current_buffer->overlays_before = before_list;
!     }
    recenter_overlay_lists (current_buffer,
                          XINT (current_buffer->overlay_center));
  
!   if (!NILP (afterp))
!     {
!       XSETCDR (afterp, current_buffer->overlays_after);
!       current_buffer->overlays_after = after_list;
!     }
    recenter_overlay_lists (current_buffer,
                          XINT (current_buffer->overlay_center));
  }
***************
*** 3339,3346 ****
       struct buffer *bp;
       int prev, pos;
  {
!   Lisp_Object *tailp = &bp->overlays_before;
!   Lisp_Object *right_place;
    int end;
  
    /* After the insertion, the several overlays may be in incorrect
--- 3373,3381 ----
       struct buffer *bp;
       int prev, pos;
  {
!   /* If parent is nil, replace overlays_before; otherwise, XCDR(parent).  */
!   Lisp_Object tail = bp->overlays_before, parent = Qnil;
!   Lisp_Object right_pair;
    int end;
  
    /* After the insertion, the several overlays may be in incorrect
***************
*** 3354,3398 ****
       in.  It is where an overlay which end before POS exists. (i.e. an
       overlay whose ending marker is after-insertion-marker if disorder
       exists).  */
!   while (!NILP (*tailp)
!        && ((end = OVERLAY_POSITION (OVERLAY_END (XCAR (*tailp))))
             >= pos))
!     tailp = &XCDR (*tailp);
  
    /* If we don't find such an overlay,
       or the found one ends before PREV,
       or the found one is the last one in the list,
       we don't have to fix anything.  */
!   if (NILP (*tailp)
        || end < prev
!       || NILP (XCDR (*tailp)))
      return;
  
!   right_place = tailp;
!   tailp = &XCDR (*tailp);
  
!   /* Now, end position of overlays in the list *TAILP should be before
       or equal to PREV.  In the loop, an overlay which ends at POS is
!      moved ahead to the place pointed by RIGHT_PLACE.  If we found an
!      overlay which ends before PREV, the remaining overlays are in
!      correct order.  */
!   while (!NILP (*tailp))
      {
!       end = OVERLAY_POSITION (OVERLAY_END (XCAR (*tailp)));
  
        if (end == pos)
        {                       /* This overlay is disordered. */
!         Lisp_Object found = *tailp;
  
          /* Unlink the found overlay.  */
!         *tailp = XCDR (found);
!         /* Move an overlay at RIGHT_PLACE to the next of the found one.  */
!         XCDR (found) = *right_place;
!         /* Link it into the right place.  */
!         *right_place = found;
        }
        else if (end == prev)
!       tailp = &XCDR (*tailp);
        else                    /* No more disordered overlay. */
        break;
      }
--- 3389,3448 ----
       in.  It is where an overlay which end before POS exists. (i.e. an
       overlay whose ending marker is after-insertion-marker if disorder
       exists).  */
!   while (!NILP (tail)
!        && ((end = OVERLAY_POSITION (OVERLAY_END (XCAR (tail))))
             >= pos))
!     {
!       parent = tail;
!       tail = XCDR (tail);
!     }
  
    /* If we don't find such an overlay,
       or the found one ends before PREV,
       or the found one is the last one in the list,
       we don't have to fix anything.  */
!   if (NILP (tail)
        || end < prev
!       || NILP (XCDR (tail)))
      return;
  
!   right_pair = parent;
!   parent = tail;
!   tail = XCDR (tail);
  
!   /* Now, end position of overlays in the list TAIL should be before
       or equal to PREV.  In the loop, an overlay which ends at POS is
!      moved ahead to the place indicated by the CDR of RIGHT_PAIR.  If
!      we found an overlay which ends before PREV, the remaining
!      overlays are in correct order.  */
!   while (!NILP (tail))
      {
!       end = OVERLAY_POSITION (OVERLAY_END (XCAR (tail)));
  
        if (end == pos)
        {                       /* This overlay is disordered. */
!         Lisp_Object found = tail;
  
          /* Unlink the found overlay.  */
!         XSETCDR (parent, XCDR (found));
!         /* Move an overlay at RIGHT_PLACE to the next of the found one,
!            and link it into the right place.  */
!         if (NILP (right_pair))
!           {
!             XSETCDR (found, bp->overlays_before);
!             bp->overlays_before = found;
!           }
!         else
!           {
!             XSETCDR (found, XCDR (right_pair));
!             XSETCDR (right_pair, found);
!           }
        }
        else if (end == prev)
!       {
!         parent = tail;
!         tail = XCDR (tail);
!       }
        else                    /* No more disordered overlay. */
        break;
      }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]