bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#49944: parse-partial-sexp fails to signal an error when (> START LIM


From: Alan Mackenzie
Subject: bug#49944: parse-partial-sexp fails to signal an error when (> START LIMIT).
Date: Sun, 22 Aug 2021 10:50:23 +0000

Hello, Basil.

On Sat, Aug 21, 2021 at 23:11:55 +0100, Basil L. Contovounesios wrote:
> Lars Ingebrigtsen [2021-08-21 15:24 +0200] wrote:

[ .... ]

> > I've now made this change (and the doc string clarification discussed).
> > There are no test failures after the change, and I'm not getting any
> > errors when running it normally, either.

> Found one :).

> 0. emacs -Q
> 1. M-x toggle-debug-on-error RET
> 2. M-x ielm RET RET

> Debugger entered--Lisp error:
>     (error "End position should be larger than start position.")
>   parse-partial-sexp(#<marker at 64 in *ielm*> 64)
>   ielm-return()
>   funcall-interactively(ielm-return)
>   call-interactively(ielm-return nil nil)
>   command-execute(ielm-return)

> One option is to replace XFIXNUM with fix_position, which is what the
> subsequent validate_region also does.  Another option is to
> CHECK_FIXNUM_COERCE_MARKER before the comparison.  Any preference?

I think the use of fix_position is the best here, and your patch is
right.  Importantly, it corrects the error message, such that it does not
give the impression that End position == Start position would signal an
error.

> >From 34c87c83fa86263da863da6c0a920c746b8af02b Mon Sep 17 00:00:00 2001
> From: "Basil L. Contovounesios" <contovob@tcd.ie>
> Date: Sat, 21 Aug 2021 22:55:58 +0100
> Subject: [PATCH] Fix recent parse-partial-sexp argument validation

> * src/syntax.c (parse-partial-sexp): Also handle markers as
> arguments (bug#49944).  Tweak error message to follow conventions in
> "(elisp) Signaling Errors".
> ---
>  src/syntax.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

> diff --git a/src/syntax.c b/src/syntax.c
> index adc0da730e..057a4c3b1f 100644
> --- a/src/syntax.c
> +++ b/src/syntax.c
> @@ -3595,8 +3595,8 @@ DEFUN ("parse-partial-sexp", Fparse_partial_sexp, 
> Sparse_partial_sexp, 2, 6, 0,
>    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.");
> +  if (fix_position (to) < fix_position (from))
> +    error ("End position is smaller than start position");

>    validate_region (&from, &to);
>    internalize_parse_state (oldstate, &state);
> -- 
> 2.32.0



> Thanks,

> -- 
> Basil

-- 
Alan Mackenzie (Nuremberg, Germany).





reply via email to

[Prev in Thread] Current Thread [Next in Thread]