Subject: Re: bug#25123: 25.1.50; rx.el errs on character alternatives which include both ?\] and ?-

From: [email-masked]
Date: Wed, 07 Dec 2016 23:23:41 -0500

found 25123 24.3
tags 25123 patch
quit

Patrick Xarles Hayes <[email-masked]> writes:

> The following fails in both Emacs 24.3.1 and 25.1.50.1:
>
> (require 'rx)
> (rx-any '(char (93 . 123) (60 . 91) (45 . 58)))
>
> I rewrote `rx-any' to the following, and it seems to work (though it may
> be introducing new bugs I'm not noticing):
>

There seems to be a lot of changes there, I can't really follow it.
Here's a more minimal patch:

>From ccb763c86dbb58972b49a26d5ffe5cf195a5975a Mon Sep 17 00:00:00 2001
From: Noam Postavsky <[email-masked]>
Date: Wed, 7 Dec 2016 23:17:37 -0500
Subject: [PATCH v1] Fix rx-any with range with ?\] and ?-

* lisp/emacs-lisp/rx.el: Make sure not to produce a circular list.
---
 lisp/emacs-lisp/rx.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el
index 66d295e..d305597 100644
--- a/lisp/emacs-lisp/rx.el
+++ b/lisp/emacs-lisp/rx.el
@@ -521,7 +521,7 @@ rx-any
 	     (setq args (nconc (delq ?- args) (list ?-))))
 	    ((setq m (assq ?- args))
 	     ;; next to the bracket's range, make the second range
-	     (setcdr args (cons m (delq m args))))))
+	     (setcdr args (cons m (delq m (cdr args)))))))
      ;; bracket in the end range
      ;;	 => "[]...-]"
      ((setq m (rassq ?\] args))
-- 
2.9.3