aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Ingebrigtsen2021-08-21 15:24:15 +0200
committerLars Ingebrigtsen2021-08-21 15:24:15 +0200
commitcabd22f5c6c2f47b1f6efd627e9e760a31e8f015 (patch)
tree9d0344273c40748617a71cf4075eb57a49770f36 /src
parent3de577ad0079ecca815086b5f07403cd8e5701a2 (diff)
downloademacs-cabd22f5c6c2f47b1f6efd627e9e760a31e8f015.tar.gz
emacs-cabd22f5c6c2f47b1f6efd627e9e760a31e8f015.zip
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).
Diffstat (limited to 'src')
-rw-r--r--src/syntax.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/syntax.c b/src/syntax.c
index 7bba336744a..6cbe0f6855f 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -3547,8 +3547,10 @@ DEFUN ("parse-partial-sexp", Fparse_partial_sexp, Sparse_partial_sexp, 2, 6, 0,
3547 doc: /* Parse Lisp syntax starting at FROM until TO; return status of parse at TO. 3547 doc: /* Parse Lisp syntax starting at FROM until TO; return status of parse at TO.
3548Parsing stops at TO or when certain criteria are met; 3548Parsing stops at TO or when certain criteria are met;
3549 point is set to where parsing stops. 3549 point is set to where parsing stops.
3550If fifth arg OLDSTATE is omitted or nil, 3550
3551 parsing assumes that FROM is the beginning of a function. 3551If OLDSTATE is omitted or nil, parsing assumes that FROM is the
3552 beginning of a function. If not, OLDSTATE should be the state at
3553 FROM.
3552 3554
3553Value is a list of elements describing final state of parsing: 3555Value is a list of elements describing final state of parsing:
3554 0. depth in parens. 3556 0. depth in parens.
@@ -3594,6 +3596,9 @@ Sixth arg COMMENTSTOP non-nil means stop after the start of a comment.
3594 else 3596 else
3595 target = TYPE_MINIMUM (EMACS_INT); /* We won't reach this depth. */ 3597 target = TYPE_MINIMUM (EMACS_INT); /* We won't reach this depth. */
3596 3598
3599 if (XFIXNUM (to) < XFIXNUM (from))
3600 error ("End position should be larger than start position.");
3601
3597 validate_region (&from, &to); 3602 validate_region (&from, &to);
3598 internalize_parse_state (oldstate, &state); 3603 internalize_parse_state (oldstate, &state);
3599 scan_sexps_forward (&state, XFIXNUM (from), CHAR_TO_BYTE (XFIXNUM (from)), 3604 scan_sexps_forward (&state, XFIXNUM (from), CHAR_TO_BYTE (XFIXNUM (from)),