GNU bug report logs - #25123
25.1.50; rx.el errs on character alternatives which include both ?\] and ?-

Previous Next

Package: emacs;

Reported by: Patrick Xarles Hayes <pxhayes <at> gmail.com>

Date: Tue, 6 Dec 2016 07:14:01 UTC

Severity: normal

Tags: fixed, patch

Found in versions 24.3, 25.1.50

Fixed in version 26.1

Done: npostavs <at> users.sourceforge.net

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 25123 in the body.
You can then email your comments to 25123 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#25123; Package emacs. (Tue, 06 Dec 2016 07:14:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Patrick Xarles Hayes <pxhayes <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 06 Dec 2016 07:14:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Patrick Xarles Hayes <pxhayes <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.1.50; rx.el errs on character alternatives which include both ?\]
 and ?-
Date: Tue, 6 Dec 2016 02:11:29 -0500
[Message part 1 (text/plain, inline)]
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
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25123; Package emacs. (Thu, 08 Dec 2016 04:23:01 GMT) Full text and rfc822 format available.

Message #8 received at 25123 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Patrick Xarles Hayes <pxhayes <at> gmail.com>
Cc: 25123 <at> debbugs.gnu.org
Subject: Re: bug#25123: 25.1.50;
 rx.el errs on character alternatives which include both ?\] and ?-
Date: Wed, 07 Dec 2016 23:23:41 -0500
[Message part 1 (text/plain, inline)]
found 25123 24.3
tags 25123 patch
quit

Patrick Xarles Hayes <pxhayes <at> 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:

[v1-0001-Fix-rx-any-with-range-with-and.patch (text/plain, inline)]
From ccb763c86dbb58972b49a26d5ffe5cf195a5975a Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> 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


bug Marked as found in versions 24.3. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Thu, 08 Dec 2016 04:23:02 GMT) Full text and rfc822 format available.

Added tag(s) patch. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Thu, 08 Dec 2016 04:23:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25123; Package emacs. (Sun, 18 Dec 2016 13:49:02 GMT) Full text and rfc822 format available.

Message #15 received at 25123 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Patrick Xarles Hayes <pxhayes <at> gmail.com>
Cc: 25123 <at> debbugs.gnu.org
Subject: Re: bug#25123: 25.1.50;
 rx.el errs on character alternatives which include both ?\] and ?-
Date: Sun, 18 Dec 2016 08:49:01 -0500
tags 25123 fixed
close 25123 26.1
quit

> Here's a more minimal patch:

Since there's been further feedback, I've pushed to master as
a7523ba95500.




Added tag(s) fixed. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Sun, 18 Dec 2016 13:49:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 26.1, send any further explanations to 25123 <at> debbugs.gnu.org and Patrick Xarles Hayes <pxhayes <at> gmail.com> Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Sun, 18 Dec 2016 13:49:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 16 Jan 2017 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 8 years and 157 days ago.

Previous Next


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