--- Begin Message ---
Subject: |
rx generates wrong regular expression for class |
Date: |
Sat, 04 Sep 2010 16:04:06 -0700 |
User-agent: |
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.8) Gecko/20100802 Thunderbird/3.1.2 |
(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*.
--- End Message ---
--- Begin Message ---
Subject: |
Re: bug#6984: rx generates wrong regular expression for class |
Date: |
Sun, 05 Sep 2010 11:44:42 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
>>>>> "Daniel" == Daniel Colascione <address@hidden> 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)))
--- End Message ---