all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: jasonr@f2s.com
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Magnus Henoch <mange@freemail.hr>, 716@emacsbugs.donarmstrong.com
Subject: bug#716: Bug in buffer-swap-text
Date: Wed, 24 Dec 2008 01:17:08 +0000	[thread overview]
Message-ID: <1230081428.49518d94a3a08@webmail.freedom2surf.net> (raw)
In-Reply-To: <jwv4p0u24yy.fsf-monnier+emacsbugreports@gnu.org>

Quoting Stefan Monnier <monnier@iro.umontreal.ca>:

> Your analysis sounds right, thank you.  I'd suggest to use another
> r_alloc primitve, something like r_alloc_reset_variable, so you could do

I've adapted your suggestion so it does not remove the consistency check in
find_bloc (instead it does a non-checking find inline):

*** buffer.c.~1.575.~	2008-12-10 21:52:40.562500000 +0800
--- buffer.c	2008-12-24 09:12:15.536522600 +0800
***************
*** 2182,2187 ****
--- 2182,2191 ----
    return byte_pos;
  }

+ #ifdef REL_ALLOC
+ extern void r_alloc_reset_variable P_ ((PTR *));
+ #endif
+
  DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text,
         1, 1, 0,
         doc: /* Swap the text between current buffer and BUFFER.  */)
***************
*** 2223,2228 ****
--- 2227,2237 ----
    swapfield (own_text, struct buffer_text);
    eassert (current_buffer->text == &current_buffer->own_text);
    eassert (other_buffer->text == &other_buffer->own_text);
+ #ifdef REL_ALLOC
+   r_alloc_reset_variable ((PTR *) &current_buffer->own_text.beg);
+   r_alloc_reset_variable ((PTR *) &other_buffer->own_text.beg);
+ #endif
+
    swapfield (pt, EMACS_INT);
    swapfield (pt_byte, EMACS_INT);
    swapfield (begv, EMACS_INT);
*** ralloc.c.~1.69.~	2008-11-23 22:34:01.250000000 +0800
--- ralloc.c	2008-12-24 09:12:35.643967100 +0800
***************
*** 1223,1228 ****
--- 1223,1254 ----

  #endif /* DEBUG */

+ /* Update the internal record of which variable points to some data.
+    Used by buffer-swap-text in Emacs to restore consistency after it
+    swaps the buffer text between two buffer objects.  */
+ void
+ r_alloc_reset_variable (ptr)
+      POINTER *ptr;
+ {
+   bloc_ptr bloc = first_bloc;
+
+   /* Find the bloc that corresponds to the data pointed to by pointer.
+      find_bloc cannot be used, as it has internal consistency checks
+      which fail when the variable needs reseting.  */
+   while (bloc != NIL_BLOC)
+     {
+       if (bloc->data == *ptr)
+ 	break;
+
+       bloc = bloc->next;
+     }
+
+   if (bloc == NIL_BLOC)
+     abort ();
+
+   /* Update variable to point to the new location.  */
+   bloc->variable = ptr;
+ }

  \f
  /***********************************************************************








  parent reply	other threads:[~2008-12-24  1:17 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-08 10:41 bug#716: Bug in buffer-swap-text Geoff Gole
2008-11-08 12:51 ` Magnus Henoch
2008-12-02 22:58 ` Stefan Monnier
2008-12-03  0:11   ` jasonr
2008-12-03  2:44     ` Stefan Monnier
2008-12-03  2:55       ` jasonr
2008-12-23 12:45   ` Jason Rumney
2008-12-23 14:51     ` Jason Rumney
2008-12-23 15:14       ` Jason Rumney
2008-12-23 17:23         ` Stefan Monnier
2008-12-23 23:15           ` Jason Rumney
2008-12-24  1:17           ` jasonr [this message]
2008-12-24  2:41             ` Stefan Monnier
  -- strict thread matches above, loose matches on Subject: below --
2008-12-03 15:25 Geoff Gole
2008-12-03 15:42 ` Jason Rumney
2008-12-03 15:46   ` Geoff Gole
2008-12-03 20:42     ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1230081428.49518d94a3a08@webmail.freedom2surf.net \
    --to=jasonr@f2s.com \
    --cc=716@emacsbugs.donarmstrong.com \
    --cc=mange@freemail.hr \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.