GNU bug report logs - #3424
align-regexp: Infinite loop with default regexp

Previous Next

Package: emacs;

Reported by: Teemu Likonen <tlikonen <at> iki.fi>

Date: Sat, 30 May 2009 17:40:08 UTC

Severity: normal

Done: Teemu Likonen <tlikonen <at> iki.fi>

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 3424 in the body.
You can then email your comments to 3424 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-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#3424; Package emacs. (Sat, 30 May 2009 17:40:08 GMT) Full text and rfc822 format available.

Acknowledgement sent to Teemu Likonen <tlikonen <at> iki.fi>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Sat, 30 May 2009 17:40:08 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Teemu Likonen <tlikonen <at> iki.fi>
To: bug-gnu-emacs <at> gnu.org
Subject: align-regexp: Infinite loop with default regexp
Date: Sat, 30 May 2009 20:37:44 +0300
[Message part 1 (text/plain, inline)]
The align-regexp command enters infinite loop when it is used with the
default regexp and with REPEAT argument. It's seems to be because the
regexp \s-* matches also zero-length strings.

Steps to reproduce:

 1. Put the following line to the *scratch* buffer:

        foo bar

 2. Put the line inside a region

 3. Type command:

        C-u M-x align-regexp RET \(\s-*\) RET 1 RET 1 RET y

 4. Loop infinitely.


I suggest changing the default regexp to \(\s-+\), like the attached
patch illustrates.

[align-regexp.patch (text/x-diff, inline)]
diff --git i/lisp/align.el w/lisp/align.el
index 0917e7d..ea36302 100644
--- i/lisp/align.el
+++ w/lisp/align.el
@@ -933,7 +933,7 @@ region, call `align-regexp' and type in that regular expression."
     (list (region-beginning) (region-end))
     (if current-prefix-arg
 	(list (read-string "Complex align using regexp: "
-			   "\\(\\s-*\\)")
+			   "\\(\\s-+\\)")
 	      (string-to-number
 	       (read-string
 		"Parenthesis group to modify (justify if negative): " "1"))
@@ -941,7 +941,7 @@ region, call `align-regexp' and type in that regular expression."
 	       (read-string "Amount of spacing (or column if negative): "
 			    (number-to-string align-default-spacing)))
 	      (y-or-n-p "Repeat throughout line? "))
-      (list (concat "\\(\\s-*\\)"
+      (list (concat "\\(\\s-+\\)"
 		    (read-string "Align regexp: "))
 	    1 align-default-spacing nil))))
   (let ((rule

Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#3424; Package emacs. (Sat, 30 May 2009 18:30:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Lennart Borgman <lennart.borgman <at> gmail.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Sat, 30 May 2009 18:30:05 GMT) Full text and rfc822 format available.

Message #10 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Lennart Borgman <lennart.borgman <at> gmail.com>
To: Teemu Likonen <tlikonen <at> iki.fi>, 3424 <at> debbugs.gnu.org
Cc: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#3424: align-regexp: Infinite loop with default regexp
Date: Sat, 30 May 2009 20:24:43 +0200
On Sat, May 30, 2009 at 7:37 PM, Teemu Likonen <tlikonen <at> iki.fi> wrote:
> The align-regexp command enters infinite loop when it is used with the
> default regexp and with REPEAT argument. It's seems to be because the
> regexp \s-* matches also zero-length strings.
>
> Steps to reproduce:
>
>  1. Put the following line to the *scratch* buffer:
>
>        foo bar
>
>  2. Put the line inside a region
>
>  3. Type command:
>
>        C-u M-x align-regexp RET \(\s-*\) RET 1 RET 1 RET y
>
>  4. Loop infinitely.

This does not happen for me with the latest pretest Emacs 23. Have you
tested there?


> I suggest changing the default regexp to \(\s-+\), like the attached
> patch illustrates.
>
>




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#3424; Package emacs. (Sat, 30 May 2009 18:30:07 GMT) Full text and rfc822 format available.

Acknowledgement sent to Lennart Borgman <lennart.borgman <at> gmail.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Sat, 30 May 2009 18:30:07 GMT) Full text and rfc822 format available.

Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#3424; Package emacs. (Sat, 30 May 2009 18:50:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Teemu Likonen <tlikonen <at> iki.fi>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Sat, 30 May 2009 18:50:05 GMT) Full text and rfc822 format available.

Message #20 received at 3424 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Teemu Likonen <tlikonen <at> iki.fi>
To: Lennart Borgman <lennart.borgman <at> gmail.com>
Cc: 3424 <at> debbugs.gnu.org
Subject: Re: bug#3424: align-regexp: Infinite loop with default regexp
Date: Sat, 30 May 2009 21:46:27 +0300
On 2009-05-30 20:24 (+0200), Lennart Borgman wrote:

> On Sat, May 30, 2009 at 7:37 PM, Teemu Likonen <tlikonen <at> iki.fi> wrote:
>>  4. Loop infinitely.
>
> This does not happen for me with the latest pretest Emacs 23. Have you
> tested there?

Ah, true. I use Emacs 22.2 (as packaged by Debian) and only checked that
Emacs 23 uses the same regexp. Hence I assumed that it had the same
problem. Now I tried some quite up-to-date development version of Emacs
23 and it produces

    f o o  b a r

instead. So no infinite looping there. I think the result is not what
user expects, though. I'd still suggest changing the default regexp to
match one or more whitespaces: \s-+



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#3424; Package emacs. (Sat, 30 May 2009 18:50:08 GMT) Full text and rfc822 format available.

Acknowledgement sent to Lennart Borgman <lennart.borgman <at> gmail.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Sat, 30 May 2009 18:50:08 GMT) Full text and rfc822 format available.

Message #25 received at 3424 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Lennart Borgman <lennart.borgman <at> gmail.com>
To: Teemu Likonen <tlikonen <at> iki.fi>
Cc: 3424 <at> debbugs.gnu.org
Subject: Re: bug#3424: align-regexp: Infinite loop with default regexp
Date: Sat, 30 May 2009 20:47:45 +0200
On Sat, May 30, 2009 at 8:46 PM, Teemu Likonen <tlikonen <at> iki.fi> wrote:
> On 2009-05-30 20:24 (+0200), Lennart Borgman wrote:
>
>> On Sat, May 30, 2009 at 7:37 PM, Teemu Likonen <tlikonen <at> iki.fi> wrote:
>>>  4. Loop infinitely.
>>
>> This does not happen for me with the latest pretest Emacs 23. Have you
>> tested there?
>
> Ah, true. I use Emacs 22.2 (as packaged by Debian) and only checked that
> Emacs 23 uses the same regexp. Hence I assumed that it had the same
> problem. Now I tried some quite up-to-date development version of Emacs
> 23 and it produces
>
>    f o o  b a r
>
> instead. So no infinite looping there. I think the result is not what
> user expects, though. I'd still suggest changing the default regexp to
> match one or more whitespaces: \s-+

Seems like a good idea to me.



Reply sent to Teemu Likonen <tlikonen <at> iki.fi>:
You have taken responsibility. (Sun, 14 Jun 2009 05:55:06 GMT) Full text and rfc822 format available.

Notification sent to Teemu Likonen <tlikonen <at> iki.fi>:
bug acknowledged by developer. (Sun, 14 Jun 2009 05:55:06 GMT) Full text and rfc822 format available.

Message #30 received at 3424-done <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Teemu Likonen <tlikonen <at> iki.fi>
To: 3424-done <at> debbugs.gnu.org
Subject: Re: align-regexp: Infinite loop with default regexp
Date: Sun, 14 Jun 2009 08:52:52 +0300
On 2009-05-30 20:37 (+0300), Teemu Likonen wrote:

> The align-regexp command enters infinite loop when it is used with the
> default regexp and with REPEAT argument. It's seems to be because the
> regexp \s-* matches also zero-length strings.

I have misunderstood the behaviour of the regexp. The default space
group \s-* is about the spaces to modify before some other matching
regexp. It's a bit unexpected to me but I originally reported about
infinite loop which is indeed fixed in Emacs 23. So let's close this
bug.



bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> emacsbugs.donarmstrong.com. (Sun, 12 Jul 2009 14:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 15 years and 347 days ago.

Previous Next


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