diff options
| author | Richard M. Stallman | 1998-05-11 01:11:02 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-05-11 01:11:02 +0000 |
| commit | 7693a579bda7d7d158e5e9ed056800039efa61a3 (patch) | |
| tree | effacc37bf57ccd9e669cb6900626a26dbc255eb /src | |
| parent | 95fb069bc962b6104d33e859404b2efc0cd2b92d (diff) | |
| download | emacs-7693a579bda7d7d158e5e9ed056800039efa61a3.tar.gz emacs-7693a579bda7d7d158e5e9ed056800039efa61a3.zip | |
(unchain_marker): Abort if the marker is not in its buffer's chain.
(buf_bytepos_to_charpos): Fix assignment of `record'
when scanning from below.
Don't create a marker if buffer's marker chain is empty.
Diffstat (limited to 'src')
| -rw-r--r-- | src/marker.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/marker.c b/src/marker.c index 0cb6d3979a1..ae6b2e5eb6d 100644 --- a/src/marker.c +++ b/src/marker.c | |||
| @@ -355,7 +355,7 @@ buf_bytepos_to_charpos (b, bytepos) | |||
| 355 | 355 | ||
| 356 | if (bytepos - best_below_byte < best_above_byte - bytepos) | 356 | if (bytepos - best_below_byte < best_above_byte - bytepos) |
| 357 | { | 357 | { |
| 358 | int record = best_above_byte - bytepos > 5000; | 358 | int record = bytepos - best_below_byte > 5000; |
| 359 | 359 | ||
| 360 | while (best_below_byte < bytepos) | 360 | while (best_below_byte < bytepos) |
| 361 | { | 361 | { |
| @@ -365,8 +365,10 @@ buf_bytepos_to_charpos (b, bytepos) | |||
| 365 | 365 | ||
| 366 | /* If this position is quite far from the nearest known position, | 366 | /* If this position is quite far from the nearest known position, |
| 367 | cache the correspondence by creating a marker here. | 367 | cache the correspondence by creating a marker here. |
| 368 | It will last until the next GC. */ | 368 | It will last until the next GC. |
| 369 | if (record) | 369 | But don't do it if BUF_MARKERS is nil; |
| 370 | that is a signal from Fset_buffer_multibyte. */ | ||
| 371 | if (record && ! NILP (BUF_MARKERS (b))) | ||
| 370 | { | 372 | { |
| 371 | Lisp_Object marker, buffer; | 373 | Lisp_Object marker, buffer; |
| 372 | marker = Fmake_marker (); | 374 | marker = Fmake_marker (); |
| @@ -396,8 +398,10 @@ buf_bytepos_to_charpos (b, bytepos) | |||
| 396 | 398 | ||
| 397 | /* If this position is quite far from the nearest known position, | 399 | /* If this position is quite far from the nearest known position, |
| 398 | cache the correspondence by creating a marker here. | 400 | cache the correspondence by creating a marker here. |
| 399 | It will last until the next GC. */ | 401 | It will last until the next GC. |
| 400 | if (record) | 402 | But don't do it if BUF_MARKERS is nil; |
| 403 | that is a signal from Fset_buffer_multibyte. */ | ||
| 404 | if (record && ! NILP (BUF_MARKERS (b))) | ||
| 401 | { | 405 | { |
| 402 | Lisp_Object marker, buffer; | 406 | Lisp_Object marker, buffer; |
| 403 | marker = Fmake_marker (); | 407 | marker = Fmake_marker (); |
| @@ -739,6 +743,8 @@ unchain_marker (marker) | |||
| 739 | if (EQ (b->name, Qnil)) | 743 | if (EQ (b->name, Qnil)) |
| 740 | abort (); | 744 | abort (); |
| 741 | 745 | ||
| 746 | XMARKER (marker)->buffer = 0; | ||
| 747 | |||
| 742 | tail = BUF_MARKERS (b); | 748 | tail = BUF_MARKERS (b); |
| 743 | prev = Qnil; | 749 | prev = Qnil; |
| 744 | while (XSYMBOL (tail) != XSYMBOL (Qnil)) | 750 | while (XSYMBOL (tail) != XSYMBOL (Qnil)) |
| @@ -764,13 +770,17 @@ unchain_marker (marker) | |||
| 764 | XMARKER (prev)->chain = next; | 770 | XMARKER (prev)->chain = next; |
| 765 | XSETMARKBIT (XMARKER (prev)->chain, omark); | 771 | XSETMARKBIT (XMARKER (prev)->chain, omark); |
| 766 | } | 772 | } |
| 767 | break; | 773 | /* We have removed the marker from the chain; |
| 774 | no need to scan the rest of the chain. */ | ||
| 775 | return; | ||
| 768 | } | 776 | } |
| 769 | else | 777 | else |
| 770 | prev = tail; | 778 | prev = tail; |
| 771 | tail = next; | 779 | tail = next; |
| 772 | } | 780 | } |
| 773 | XMARKER (marker)->buffer = 0; | 781 | |
| 782 | /* Marker was not in its chain. */ | ||
| 783 | abort (); | ||
| 774 | } | 784 | } |
| 775 | 785 | ||
| 776 | /* Return the char position of marker MARKER, as a C integer. */ | 786 | /* Return the char position of marker MARKER, as a C integer. */ |