X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/59d360666731e862157766646d732b73f19295d2..3c9dc1cf0d6be64608cd309ad042d74e4fc02049:/src/marker.c diff --git a/src/marker.c b/src/marker.c index 8b96414203..b91609ca08 100644 --- a/src/marker.c +++ b/src/marker.c @@ -49,7 +49,7 @@ clear_charpos_cache (b) /* Converting between character positions and byte positions. */ /* There are several places in the buffer where we know - the corrspondence: BEG, BEGV, PT, GPT, ZV and Z, + the correspondence: BEG, BEGV, PT, GPT, ZV and Z, and everywhere there is a marker. So we find the one of these places that is closest to the specified position, and scan from there. */ @@ -252,6 +252,24 @@ buf_charpos_to_bytepos (b, charpos) } #undef CONSIDER + +/* Used for debugging: recompute the bytepos corresponding to CHARPOS + in the simplest, most reliable way. */ + +int +verify_bytepos (charpos) +{ + int below = 1; + int below_byte = 1; + + while (below != charpos) + { + below++; + BUF_INC_POS (current_buffer, below_byte); + } + + return below_byte; +} /* bytepos_to_charpos returns the char position corresponding to BYTEPOS. */ @@ -531,14 +549,14 @@ Returns MARKER. */) m->chain = BUF_MARKERS (b); BUF_MARKERS (b) = marker; } - + return marker; } /* This version of Fset_marker won't let the position be outside the visible part. */ -Lisp_Object +Lisp_Object set_marker_restricted (marker, pos, buffer) Lisp_Object marker, pos, buffer; { @@ -607,14 +625,14 @@ set_marker_restricted (marker, pos, buffer) m->chain = BUF_MARKERS (b); BUF_MARKERS (b) = marker; } - + return marker; } /* Set the position of MARKER, specifying both the character position and the corresponding byte position. */ -Lisp_Object +Lisp_Object set_marker_both (marker, buffer, charpos, bytepos) Lisp_Object marker, buffer; int charpos, bytepos; @@ -658,14 +676,14 @@ set_marker_both (marker, buffer, charpos, bytepos) m->chain = BUF_MARKERS (b); BUF_MARKERS (b) = marker; } - + return marker; } /* This version of set_marker_both won't let the position be outside the visible part. */ -Lisp_Object +Lisp_Object set_marker_restricted_both (marker, buffer, charpos, bytepos) Lisp_Object marker, buffer; int charpos, bytepos; @@ -718,7 +736,7 @@ set_marker_restricted_both (marker, buffer, charpos, bytepos) m->chain = BUF_MARKERS (b); BUF_MARKERS (b) = marker; } - + return marker; }