GNU bug report logs - #6984
rx generates wrong regular expression for class

Previous Next

Package: emacs;

Reported by: Daniel Colascione <dan.colascione <at> gmail.com>

Date: Sat, 4 Sep 2010 23:03:01 UTC

Severity: normal

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#6984: closed (rx generates wrong regular expression for class)
Date: Sun, 05 Sep 2010 13:35:03 +0000
[Message part 1 (text/plain, inline)]
Your message dated Sun, 05 Sep 2010 11:44:42 +0200
with message-id <jwvaanwh6jq.fsf-monnier+emacs <at> gnu.org>
and subject line Re: bug#6984: rx generates wrong regular expression for class
has caused the GNU bug report #6984,
regarding rx generates wrong regular expression for class
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
6984: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6984
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Daniel Colascione <dan.colascione <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: rx generates wrong regular expression for class
Date: Sat, 04 Sep 2010 16:04:06 -0700
(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*.


[Message part 3 (message/rfc822, inline)]
From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Daniel Colascione <dan.colascione <at> gmail.com>
Subject: Re: bug#6984: rx generates wrong regular expression for class
Date: Sun, 05 Sep 2010 11:44:42 +0200
>>>>> "Daniel" == Daniel Colascione <dan.colascione <at> gmail.com> 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)))



This bug report was last modified 14 years and 258 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.