mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-01-20 18:17:20 +00:00
Make parse-partial-sexp signal an error if TO is smaller than FROM
* src/syntax.c (Fparse_partial_sexp): Signal an error if TO is smaller than FROM (bug#49944).
This commit is contained in:
parent
3de577ad00
commit
cabd22f5c6
6
etc/NEWS
6
etc/NEWS
@ -3108,6 +3108,12 @@ This is to keep the same behavior as Eshell.
|
||||
|
||||
* Incompatible Lisp Changes in Emacs 28.1
|
||||
|
||||
---
|
||||
** 'parse-partial-sexp' now signals an error it TO is smaller than FROM.
|
||||
Previously this would lead to the function interpreting FROM as TO and
|
||||
vice versa, which would be confusing when passing in OLDSTATE, which
|
||||
refers to the old state at FROM.
|
||||
|
||||
+++
|
||||
** 'overlays-in' now handles zero-length overlays slightly differently.
|
||||
Previosly, zero-length overlays at the end of the buffer were included
|
||||
|
@ -3547,8 +3547,10 @@ DEFUN ("parse-partial-sexp", Fparse_partial_sexp, Sparse_partial_sexp, 2, 6, 0,
|
||||
doc: /* Parse Lisp syntax starting at FROM until TO; return status of parse at TO.
|
||||
Parsing stops at TO or when certain criteria are met;
|
||||
point is set to where parsing stops.
|
||||
If fifth arg OLDSTATE is omitted or nil,
|
||||
parsing assumes that FROM is the beginning of a function.
|
||||
|
||||
If OLDSTATE is omitted or nil, parsing assumes that FROM is the
|
||||
beginning of a function. If not, OLDSTATE should be the state at
|
||||
FROM.
|
||||
|
||||
Value is a list of elements describing final state of parsing:
|
||||
0. depth in parens.
|
||||
@ -3594,6 +3596,9 @@ Sixth arg COMMENTSTOP non-nil means stop after the start of a comment.
|
||||
else
|
||||
target = TYPE_MINIMUM (EMACS_INT); /* We won't reach this depth. */
|
||||
|
||||
if (XFIXNUM (to) < XFIXNUM (from))
|
||||
error ("End position should be larger than start position.");
|
||||
|
||||
validate_region (&from, &to);
|
||||
internalize_parse_state (oldstate, &state);
|
||||
scan_sexps_forward (&state, XFIXNUM (from), CHAR_TO_BYTE (XFIXNUM (from)),
|
||||
|
@ -500,4 +500,10 @@ the `parse-partial-sexp's are expected to stop. See
|
||||
(syntax-pps-comments /* 56 76 77 58)
|
||||
(syntax-pps-comments /* 60 78 79)
|
||||
|
||||
(ert-deftest test-from-to-parse-partial-sexp ()
|
||||
(with-temp-buffer
|
||||
(insert "foo")
|
||||
(should (parse-partial-sexp 1 1))
|
||||
(should-error (parse-partial-sexp 2 1))))
|
||||
|
||||
;;; syntax-tests.el ends here
|
||||
|
Loading…
Reference in New Issue
Block a user