aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/marker.c46
1 files changed, 9 insertions, 37 deletions
diff --git a/src/marker.c b/src/marker.c
index 2bccb7400f5..7d601eea70f 100644
--- a/src/marker.c
+++ b/src/marker.c
@@ -127,11 +127,7 @@ buf_charpos_to_bytepos (b, charpos)
127 tail = BUF_MARKERS (b); 127 tail = BUF_MARKERS (b);
128 while (XSYMBOL (tail) != XSYMBOL (Qnil)) 128 while (XSYMBOL (tail) != XSYMBOL (Qnil))
129 { 129 {
130 int i = XMARKER (tail)->bufpos; 130 CONSIDER (XMARKER (tail)->charpos, XMARKER (tail)->bytepos);
131 CONSIDER (XMARKER (tail)->charpos,
132 (i > gapend_byte ? i - BUF_GAP_SIZE (b)
133 : i > BUF_GPT_BYTE (b) ? BUF_GPT_BYTE (b)
134 : i));
135 131
136 /* If we are down to a range of 50 chars, 132 /* If we are down to a range of 50 chars,
137 don't bother checking any other markers; 133 don't bother checking any other markers;
@@ -281,14 +277,7 @@ buf_bytepos_to_charpos (b, bytepos)
281 tail = BUF_MARKERS (b); 277 tail = BUF_MARKERS (b);
282 while (XSYMBOL (tail) != XSYMBOL (Qnil)) 278 while (XSYMBOL (tail) != XSYMBOL (Qnil))
283 { 279 {
284 int marker_bytepos = XMARKER (tail)->bufpos; 280 CONSIDER (XMARKER (tail)->bytepos, XMARKER (tail)->charpos);
285
286 if (marker_bytepos > BUF_GPT_BYTE (b) + BUF_GAP_SIZE (b))
287 marker_bytepos -= BUF_GAP_SIZE (b);
288 else if (marker_bytepos > BUF_GPT_BYTE (b))
289 marker_bytepos = BUF_GPT_BYTE (b);
290
291 CONSIDER (marker_bytepos, XMARKER (tail)->charpos);
292 281
293 /* If we are down to a range of 50 chars, 282 /* If we are down to a range of 50 chars,
294 don't bother checking any other markers; 283 don't bother checking any other markers;
@@ -441,7 +430,7 @@ Returns MARKER.")
441 if (MARKERP (position) && b == XMARKER (position)->buffer 430 if (MARKERP (position) && b == XMARKER (position)->buffer
442 && b == m->buffer) 431 && b == m->buffer)
443 { 432 {
444 m->bufpos = XMARKER (position)->bufpos; 433 m->bytepos = XMARKER (position)->bytepos;
445 m->charpos = XMARKER (position)->charpos; 434 m->charpos = XMARKER (position)->charpos;
446 return marker; 435 return marker;
447 } 436 }
@@ -461,10 +450,7 @@ Returns MARKER.")
461 if (charno > bytepos) 450 if (charno > bytepos)
462 abort (); 451 abort ();
463 452
464 if (bytepos > BUF_GPT_BYTE (b)) 453 m->bytepos = bytepos;
465 bytepos += BUF_GAP_SIZE (b);
466
467 m->bufpos = bytepos;
468 m->charpos = charno; 454 m->charpos = charno;
469 455
470 if (m->buffer != b) 456 if (m->buffer != b)
@@ -520,7 +506,7 @@ set_marker_restricted (marker, pos, buffer)
520 if (MARKERP (pos) && b == XMARKER (pos)->buffer 506 if (MARKERP (pos) && b == XMARKER (pos)->buffer
521 && b == m->buffer) 507 && b == m->buffer)
522 { 508 {
523 m->bufpos = XMARKER (pos)->bufpos; 509 m->bytepos = XMARKER (pos)->bytepos;
524 m->charpos = XMARKER (pos)->charpos; 510 m->charpos = XMARKER (pos)->charpos;
525 return marker; 511 return marker;
526 } 512 }
@@ -540,10 +526,7 @@ set_marker_restricted (marker, pos, buffer)
540 if (charno > bytepos) 526 if (charno > bytepos)
541 abort (); 527 abort ();
542 528
543 if (bytepos > BUF_GPT_BYTE (b)) 529 m->bytepos = bytepos;
544 bytepos += BUF_GAP_SIZE (b);
545
546 m->bufpos = bytepos;
547 m->charpos = charno; 530 m->charpos = charno;
548 531
549 if (m->buffer != b) 532 if (m->buffer != b)
@@ -603,10 +586,7 @@ set_marker_both (marker, buffer, charpos, bytepos)
603 if (charpos > bytepos) 586 if (charpos > bytepos)
604 abort (); 587 abort ();
605 588
606 if (bytepos > BUF_GPT_BYTE (b)) 589 m->bytepos = bytepos;
607 bytepos += BUF_GAP_SIZE (b);
608
609 m->bufpos = bytepos;
610 m->charpos = charpos; 590 m->charpos = charpos;
611 591
612 if (m->buffer != b) 592 if (m->buffer != b)
@@ -666,10 +646,7 @@ set_marker_restricted_both (marker, buffer, charpos, bytepos)
666 if (charpos > bytepos) 646 if (charpos > bytepos)
667 abort (); 647 abort ();
668 648
669 if (bytepos > BUF_GPT_BYTE (b)) 649 m->bytepos = bytepos;
670 bytepos += BUF_GAP_SIZE (b);
671
672 m->bufpos = bytepos;
673 m->charpos = charpos; 650 m->charpos = charpos;
674 651
675 if (m->buffer != b) 652 if (m->buffer != b)
@@ -759,16 +736,11 @@ marker_byte_position (marker)
759{ 736{
760 register struct Lisp_Marker *m = XMARKER (marker); 737 register struct Lisp_Marker *m = XMARKER (marker);
761 register struct buffer *buf = m->buffer; 738 register struct buffer *buf = m->buffer;
762 register int i = m->bufpos; 739 register int i = m->bytepos;
763 740
764 if (!buf) 741 if (!buf)
765 error ("Marker does not point anywhere"); 742 error ("Marker does not point anywhere");
766 743
767 if (i > BUF_GPT_BYTE (buf) + BUF_GAP_SIZE (buf))
768 i -= BUF_GAP_SIZE (buf);
769 else if (i > BUF_GPT_BYTE (buf))
770 i = BUF_GPT_BYTE (buf);
771
772 if (i < BUF_BEG_BYTE (buf) || i > BUF_Z_BYTE (buf)) 744 if (i < BUF_BEG_BYTE (buf) || i > BUF_Z_BYTE (buf))
773 abort (); 745 abort ();
774 746