* bug#25123: 25.1.50; rx.el errs on character alternatives which include both ?\] and ?-
@ 2016-12-06 7:11 Patrick Xarles Hayes
2016-12-08 4:23 ` npostavs
0 siblings, 1 reply; 3+ messages in thread
From: Patrick Xarles Hayes @ 2016-12-06 7:11 UTC (permalink / raw)
To: 25123
[-- Attachment #1: Type: text/plain, Size: 6135 bytes --]
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):
(cl-defun rx-any (form &aux m s args) "\
Parse and produce code from FORM, which is `(any ARG ...)'.
ARG is optional."
(rx-check form)
(setq args (rx-any-condense-range
(apply #'nconc
(mapcar #'rx-check-any (cdr form)))))
(cond
;; CLOSING BRACKET ?\]
((memq ?\] args)
;; move ?\] to ðe beginning of ⟨args⟩
(setq args (cons ?\] (delq ?\] args))))
((setq m (assq ?\] args))
;; ?\] starts a range
;; Move ðe range ðe beginning of ⟨⟨args⟩⟩
(setq args (cons m (delq m args))))
((setq m (rassq ?\] args))
(if (eq ?^ (cdr m))
;; delete ðe range from ⟨args⟩, add ?\] and ?^ to ðe beginning of
⟨args⟩
(setq args (append (list ?\] ?^) (delq m args)))
;; remove ?\] from ðe range
(setcar m ?^)
;; add ?\] to ðe beginning of ⟨args⟩
(push ?\] args)))
;; CARET AT ÐE BEGINNING? If so, move it elsewhere.
((or (eq (car args) ?^)
(eq (car-safe (car args)) ?^))
(setq args (if (cdr args)
`(,(cadr args) ,(car args) ,@(cddr args))
(nconc (rx-any-delete-from-range ?^ args)
(list ?^))))))
;; HYPHEN ?-
(cond
((memq ?- args)
;; move ?- to ðe end of ⟨args⟩
(setq args (append (delq ?- args) (list ?-))))
((setq m (assq ?- args))
;; ?- start a range
(if (eq ?. (cdr m))
;; delete ðe range from ⟨args⟩, add ?. and ?- to ðe end of ⟨args⟩
(setq args (append (delq m args) (list ?. ?-)))
;; remove ?- from ðe range
(setcar m ?.)
;; add ?- to ðe end of ⟨args⟩
(setq args (append args (list ?-))))))
;; some 1-char?
(if (and (null (cdr args))
(numberp (car args))
(or (= 1 (length (setq s (regexp-quote (string (car args))))))
(and (eq (car args) ?^) ;; unnecessary predicate?
(null (eq rx-parent '!)))))
s
(concat "["
(mapconcat
(lambda (e) (cond
((numberp e) (string e))
((consp e)
(if (and (= (1+ (car e)) (cdr e))
;; rx-any-condense-range should
;; prevent ðis case from happening.
(null (memq (car e) '(?\] ?-)))
(null (memq (cdr e) '(?\] ?-))))
(string (car e) (cdr e))
(string (car e) ?- (cdr e))))
(e)))
args
nil)
"]")))
In GNU Emacs 25.1.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.23)
of 2016-04-01 built on cthulu
Windowing system distributor 'The X.Org Foundation', version 11.0.11501000
System Description: Ubuntu 14.04.4 LTS
Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS
NOTIFY ACL GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK2 X11
Important settings:
value of $LC_COLLATE: POSIX
value of $LC_MONETARY: en_US.UTF-8
value of $LC_NUMERIC: en_US.UTF-8
value of $LC_TIME: en_US.UTF-8
value of $LANG: en_US.UTF-8
value of $XMODIFIERS: @im=ibus
locale-coding-system: utf-8-unix
Major mode: Lisp Interaction
Minor modes in effect:
tooltip-mode: t
global-eldoc-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
line-number-mode: t
transient-mark-mode: t
Recent messages:
Back to top level
rx
"[]-{.-:<-[-]"
uncompressing rx.el.gz...done
Mark saved where search started
Mark set
Quit
rx-any
Undo! [5 times]
Quit
Load-path shadows:
None found.
Features:
(shadow sort mail-extr emacsbug message dired dired-loaddefs format-spec
rfc822 mml mml-sec password-cache epa derived epg epg-config gnus-util
rmail rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils misearch multi-isearch jka-compr thingatpt
find-func cl-macs gv rx help-mode easymenu cl-loaddefs pcase cl-lib
debug time-date mule-util tooltip eldoc electric uniquify ediff-hook
vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment
elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese charscript case-table epa-hook jka-cmpr-hook help simple abbrev
obarray minibuffer cl-preloaded nadvice loaddefs button faces cus-face
macroexp files text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget hashtable-print-readable backquote
dbusbind inotify dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)
Memory information:
((conses 16 98843 7545)
(symbols 48 20526 0)
(miscs 40 66 232)
(strings 32 17396 4397)
(string-bytes 1 516394)
(vectors 16 13017)
(vector-slots 8 436246 5148)
(floats 8 167 222)
(intervals 56 1138 261)
(buffers 976 13)
(heap 1024 27331 958))
--
Patrick Xarles Hayes
[-- Attachment #2: Type: text/html, Size: 7470 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#25123: 25.1.50; rx.el errs on character alternatives which include both ?\] and ?-
2016-12-06 7:11 bug#25123: 25.1.50; rx.el errs on character alternatives which include both ?\] and ?- Patrick Xarles Hayes
@ 2016-12-08 4:23 ` npostavs
2016-12-18 13:49 ` npostavs
0 siblings, 1 reply; 3+ messages in thread
From: npostavs @ 2016-12-08 4:23 UTC (permalink / raw)
To: Patrick Xarles Hayes; +Cc: 25123
[-- Attachment #1: Type: text/plain, Size: 439 bytes --]
found 25123 24.3
tags 25123 patch
quit
Patrick Xarles Hayes <pxhayes@gmail.com> 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:
[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 876 bytes --]
From ccb763c86dbb58972b49a26d5ffe5cf195a5975a Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-12-18 13:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-06 7:11 bug#25123: 25.1.50; rx.el errs on character alternatives which include both ?\] and ?- Patrick Xarles Hayes
2016-12-08 4:23 ` npostavs
2016-12-18 13:49 ` npostavs
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.