Simplify copy_overlay.

* buffer.c (copy_overlay): Simplify, use build_marker.
* lisp.h (struct Lisp_Overlay): Restore comment with minor tweaks.
This commit is contained in:
Dmitry Antipov 2012-07-24 10:45:44 +04:00
parent ec1b09b123
commit fa691a83f0
3 changed files with 28 additions and 19 deletions

View file

@ -1,3 +1,9 @@
2012-07-24 Dmitry Antipov <dmantipov@yandex.ru>
Simplify copy_overlay.
* buffer.c (copy_overlay): Simplify, use build_marker.
* lisp.h (struct Lisp_Overlay): Restore comment with minor tweaks.
2012-07-23 Eli Zaretskii <eliz@gnu.org>
* print.c (print_object): Don't crash when a frame's name is nil

View file

@ -410,32 +410,24 @@ even if it is dead. The return value is never nil. */)
static struct Lisp_Overlay *
copy_overlays (struct buffer *b, struct Lisp_Overlay *list)
{
Lisp_Object buffer;
struct Lisp_Overlay *result = NULL, *tail = NULL;
XSETBUFFER (buffer, b);
for (; list; list = list->next)
{
Lisp_Object overlay, start, end, old_overlay;
ptrdiff_t charpos;
Lisp_Object overlay, start, end;
struct Lisp_Marker *m;
XSETMISC (old_overlay, list);
charpos = marker_position (OVERLAY_START (old_overlay));
start = Fmake_marker ();
Fset_marker (start, make_number (charpos), buffer);
XMARKER (start)->insertion_type
= XMARKER (OVERLAY_START (old_overlay))->insertion_type;
eassert (MARKERP (list->start));
m = XMARKER (list->start);
start = build_marker (b, m->charpos, m->bytepos);
XMARKER (start)->insertion_type = m->insertion_type;
charpos = marker_position (OVERLAY_END (old_overlay));
end = Fmake_marker ();
Fset_marker (end, make_number (charpos), buffer);
XMARKER (end)->insertion_type
= XMARKER (OVERLAY_END (old_overlay))->insertion_type;
overlay = build_overlay
(start, end, Fcopy_sequence (OVERLAY_PLIST (old_overlay)));
eassert (MARKERP (list->end));
m = XMARKER (list->end);
end = build_marker (b, m->charpos, m->bytepos);
XMARKER (end)->insertion_type = m->insertion_type;
overlay = build_overlay (start, end, Fcopy_sequence (list->plist));
if (tail)
tail = tail->next = XOVERLAY (overlay);
else

View file

@ -1286,6 +1286,17 @@ struct Lisp_Marker
/* START and END are markers in the overlay's buffer, and
PLIST is the overlay's property list. */
struct Lisp_Overlay
/* An overlay's real data content is:
- plist
- buffer (really there are two buffer pointers, one per marker,
and both points to the same buffer)
- insertion type of both ends (per-marker fields)
- start & start byte (of start marker)
- end & end byte (of end marker)
- next (singly linked list of overlays)
- next fields of start and end markers (singly linked list of markers).
I.e. 9words plus 2 bits, 3words of which are for external linked lists.
*/
{
ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_Overlay */
unsigned gcmarkbit : 1;