Subject: bug#6984: closed (Re: bug#6984: rx generates wrong regular expression for class)

From: [email-masked] (GNU bug Tracking System)
Date: Sun, 05 Sep 2010 13:35:03 +0000

Your bug report

#6984: rx generates wrong regular expression for class

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
6984: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6984
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#6984: rx generates wrong regular expression for class
From: Stefan Monnier <[email-masked]>
To: Daniel Colascione <[email-masked]>
Date: Sun, 05 Sep 2010 11:44:42 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

>>>>> "Daniel" == Daniel Colascione <[email-masked]> writes:

> (rx (in (?0 . ?3) ?, ?-))
> generates

> "[,-0-3]"

Thanks.  I've just installed the patch below in the emacs-23 branch,
which should fix it (in two different ways).

        Stefan

=== modified file 'lisp/emacs-lisp/rx.el'
--- lisp/emacs-lisp/rx.el	2010-06-29 12:09:07 +0000
+++ lisp/emacs-lisp/rx.el	2010-09-05 09:37:06 +0000
@@ -427,7 +427,7 @@
 	    (mapcar (lambda (e)
 		      (cond
 		       ((= (car e) (cdr e)) (list (car e)))
-		       ;; ((= (1+ (car e)) (cdr e)) (list (car e) (cdr e)))
+		       ((= (1+ (car e)) (cdr e)) (list (car e) (cdr e)))
 		       ((list e))))
 		    l))
      (delete-dups str))))
@@ -545,7 +545,10 @@
 			    ((numberp e) (string e))
 			    ((consp e)
 			     (if (and (= (1+ (car e)) (cdr e))
-				      (null (memq (car e) '(?\] ?-))))
+                                      ;; rx-any-condense-range should
+                                      ;; prevent this case from happening.
+				      (null (memq (car e) '(?\] ?-)))
+                                      (null (memq (cdr e) '(?\] ?-))))
 				 (string (car e) (cdr e))
 			       (string (car e) ?- (cdr e))))
 			    (e)))

Subject: rx generates wrong regular expression for class
From: Daniel Colascione <[email-masked]>
To: [email-masked]
Date: Sat, 04 Sep 2010 16:04:06 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

(rx (in (?0 . ?3) ?, ?-))

generates

"[,-0-3]"

but it should generate
"[,0-3-]"

More generally, if "-" occurs in a class, it
should always go *last*.