diff options
| author | Lars Ingebrigtsen | 2021-08-21 15:24:15 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2021-08-21 15:24:15 +0200 |
| commit | cabd22f5c6c2f47b1f6efd627e9e760a31e8f015 (patch) | |
| tree | 9d0344273c40748617a71cf4075eb57a49770f36 /src | |
| parent | 3de577ad0079ecca815086b5f07403cd8e5701a2 (diff) | |
| download | emacs-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.c | 9 |
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. |
| 3548 | Parsing stops at TO or when certain criteria are met; | 3548 | Parsing 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. |
| 3550 | If fifth arg OLDSTATE is omitted or nil, | 3550 | |
| 3551 | parsing assumes that FROM is the beginning of a function. | 3551 | If 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 | ||
| 3553 | Value is a list of elements describing final state of parsing: | 3555 | Value 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)), |