From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: owner@emacsbugs.donarmstrong.com (Emacs bug Tracking System) Newsgroups: gmane.emacs.bugs Subject: bug#1982: marked as done (23.0.60; Infinite loop in align-regexp) Date: Sat, 24 Jan 2009 23:50:03 +0000 Message-ID: References: <87y6x0w9q3.fsf@cyd.mit.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----------=_1232841003-18192-0" X-Trace: ger.gmane.org 1232841892 30045 80.91.229.12 (25 Jan 2009 00:04:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 25 Jan 2009 00:04:52 +0000 (UTC) To: Chong Yidong Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jan 25 01:06:05 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LQsUv-0002L5-AD for geb-bug-gnu-emacs@m.gmane.org; Sun, 25 Jan 2009 01:05:26 +0100 Original-Received: from localhost ([127.0.0.1]:51475 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LQsTb-0006qc-QY for geb-bug-gnu-emacs@m.gmane.org; Sat, 24 Jan 2009 19:03:47 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LQsTO-0006ij-1Y for bug-gnu-emacs@gnu.org; Sat, 24 Jan 2009 19:03:34 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LQsTM-0006hs-S0 for bug-gnu-emacs@gnu.org; Sat, 24 Jan 2009 19:03:33 -0500 Original-Received: from [199.232.76.173] (port=45701 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LQsTM-0006hb-N2 for bug-gnu-emacs@gnu.org; Sat, 24 Jan 2009 19:03:32 -0500 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:49055) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LQsTL-0001Ug-O4 for bug-gnu-emacs@gnu.org; Sat, 24 Jan 2009 19:03:32 -0500 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id n0P03S5X021755; Sat, 24 Jan 2009 16:03:30 -0800 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id n0ONo3XL018278; Sat, 24 Jan 2009 15:50:03 -0800 X-Mailer: MIME-tools 5.420 (Entity 5.420) X-Loop: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: closed 1982 X-Emacs-PR-Package: emacs X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:24477 Archived-At: This is a multi-part message in MIME format... ------------=_1232841003-18192-0 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Your message dated Sat, 24 Jan 2009 18:44:04 -0500 with message-id <87y6x0w9q3.fsf@cyd.mit.edu> and subject line Re: 23.0.60; Infinite loop in align-regexp has caused the Emacs bug report #1982, regarding 23.0.60; Infinite loop in align-regexp to be marked as done. This means that you claim that the problem has been dealt with. If this is not the case it is now your responsibility to reopen the bug report if necessary, and/or fix the problem forthwith. (NB: If you are a system administrator and have no idea what this message is talking about, this may indicate a serious mail system misconfiguration somewhere. Please contact owner@emacsbugs.donarmstrong.com immediately.) --=20 1982: http://emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=3D1982 Emacs Bug Tracking System Contact owner@emacsbugs.donarmstrong.com with problems ------------=_1232841003-18192-0 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by emacsbugs.donarmstrong.com; 21 Jan 2009 23:30:43 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=0.1 required=4.0 tests=FOURLA,MURPHY_DRUGS_REL8 autolearn=no version=3.2.5-bugs.debian.org_2005_01_02 Received: from fencepost.gnu.org (fencepost.gnu.org [140.186.70.10]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id n0LNUeXG006280 for ; Wed, 21 Jan 2009 15:30:41 -0800 Received: from mail.gnu.org ([199.232.76.166]:48645 helo=mx10.gnu.org) by fencepost.gnu.org with esmtp (Exim 4.67) (envelope-from ) id 1LPmVR-00017l-9C for emacs-pretest-bug@gnu.org; Wed, 21 Jan 2009 18:29:09 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1LPmWs-00084P-F6 for emacs-pretest-bug@gnu.org; Wed, 21 Jan 2009 18:30:39 -0500 Received: from wa-out-1112.google.com ([209.85.146.176]:20310) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LPmWr-00084B-V9 for emacs-pretest-bug@gnu.org; Wed, 21 Jan 2009 18:30:38 -0500 Received: by wa-out-1112.google.com with SMTP id j32so2286005waf.26 for ; Wed, 21 Jan 2009 15:30:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=/LCJq/3NEyKy7Tn8JAJmdxETfVhaqQft5PD8GzlcOQI=; b=p63uxpZR6ycpJ+KXpavoUjzjHPnA6UPOt2FX9KQJdM6+v8j9TjruNN6ZgO1287PwOT 9UjoLWSNipc4a4WA3T30oNSdpAf15m3Ajlf8q/k/8vB5tMsvhJmZ2xmxd6GflfEMBWW0 XHUOI3c8PdWrk4HRUoVG7GNfcTVVa078xYu1o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=YIin2ZqeOIvwDEi+GCNUS3XzopZwfxKJ0XzERnyU+Py1P9GmTUF5czYIUF8yTRcYD9 pq4WVhqHCGiOoTYAZz56hIyiStUqLam743STVr00qbP9EnJ8MFdeIVGuPkxtY4iMT6qw x+9wACE6f/osb8MBoyuGOeDfI+JvHXID7uMik= MIME-Version: 1.0 Received: by 10.114.80.1 with SMTP id d1mr2094038wab.168.1232580636566; Wed, 21 Jan 2009 15:30:36 -0800 (PST) Date: Thu, 22 Jan 2009 08:30:36 +0900 Message-ID: Subject: 23.0.60; Infinite loop in align-regexp From: Geoff Gole To: emacs-pretest-bug@gnu.org Content-Type: multipart/mixed; boundary=0016364175d9ffe55b0461068a1c X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) --0016364175d9ffe55b0461068a1c Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit This was originally sent to emacs-devel. Since it's been a week with no response I'm going to assume that that was the wrong place, thus I'm copying it here. My apologies if the duplication is inappropriate. For certain choices of regexp and region text, align-regexp will enter an infinite loop. To reproduce: emacs -Q RET foo C-SPC C-a M-x align-regexp \< Note that the infinite loop won't occur for text at the beginning of the buffer, so make sure to test at least one newline down. I'm suprised that this hasn't come up before. I would have thought aligning to beginning-of-word would be a common case. Anyway, the problem seems to be that align-region assumes that a successful search will always move point forward. The following patch attempts to fix this: --- /home/ggole/src/emacs/lisp/align.el 2009-01-05 12:18:39.000000000 +0900 +++ loopfix-align.el 2009-01-22 08:15:59.000000000 +0900 @@ -1307,6 +1307,7 @@ (rulesep (assq 'separate rule)) (thissep (if rulesep (cdr rulesep) separate)) same (eol 0) + search-origin group group-c spacing spacing-c tab-stop tab-stop-c @@ -1412,6 +1413,7 @@ ;; while we can find the rule in the alignment ;; region.. (while (and (< (point) end-mark) + (setq search-origin (point)) (if regfunc (funcall regfunc end-mark nil) (re-search-forward regexp @@ -1436,7 +1438,8 @@ ;; if the search ended us on the beginning of ;; the next line, move back to the end of the ;; previous line. - (if (bolp) + (if (and (bolp) + (> (point) search-origin)) (forward-char -1)) ;; lookup the `group' attribute the first time @@ -1576,7 +1579,12 @@ ;; the next line; don't bother searching ;; anymore on this one (if (and (not repeat) (not (bolp))) - (forward-line))))) + (forward-line)) + + ;; if the search did not change point, + ;; move forward to avoid an infinite loop + (if (= (point) search-origin) + (forward-char))))) ;; when they are no more matches for this rule, ;; align whatever was left over --0016364175d9ffe55b0461068a1c Content-Type: text/x-patch; charset=US-ASCII; name="align-regexp-loopfix.diff" Content-Disposition: attachment; filename="align-regexp-loopfix.diff" Content-Transfer-Encoding: base64 X-Attachment-Id: f_fq8mheb00 LS0tIC9ob21lL2dnb2xlL3NyYy9lbWFjcy9saXNwL2FsaWduLmVsCTIwMDktMDEtMDUgMTI6MTg6 MzkuMDAwMDAwMDAwICswOTAwCisrKyBsb29wZml4LWFsaWduLmVsCTIwMDktMDEtMjIgMDg6MTU6 NTkuMDAwMDAwMDAwICswOTAwCkBAIC0xMzA3LDYgKzEzMDcsNyBAQAogCQkgKHJ1bGVzZXAgKGFz c3EgJ3NlcGFyYXRlIHJ1bGUpKQogCQkgKHRoaXNzZXAgKGlmIHJ1bGVzZXAgKGNkciBydWxlc2Vw KSBzZXBhcmF0ZSkpCiAJCSBzYW1lIChlb2wgMCkKKwkJIHNlYXJjaC1vcmlnaW4KIAkJIGdyb3Vw IGdyb3VwLWMKIAkJIHNwYWNpbmcgc3BhY2luZy1jCiAJCSB0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jaCBkaWQgbm90IGNoYW5nZSBw b2ludCwKKwkJCSAgICA7OyBtb3ZlIGZvcndhcmQgdG8gYXZvaWQgYW4gaW5maW5pdGUgbG9vcAor CQkJICAgIChpZiAoPSAocG9pbnQpIHNlYXJjaC1vcmlnaW4pCisJCQkJKGZvcndhcmQtY2hhcikp KSkpCiAKIAkJICAgICAgOzsgd2hlbiB0aGV5IGFyZSBubyBtb3JlIG1hdGNoZXMgZm9yIHRoaXMg cnVsZSwKIAkJICAgICAgOzsgYWxpZ24gd2hhdGV2ZXIgd2FzIGxlZnQgb3Zlcgo= --0016364175d9ffe55b0461068a1c-- ------------=_1232841003-18192-0 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 1982-done) by emacsbugs.donarmstrong.com; 24 Jan 2009 23:43:40 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=0.0 required=4.0 tests=MURPHY_DRUGS_REL8 autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 Received: from cyd.mit.edu (CYD.MIT.EDU [18.115.2.24]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id n0ONhbTI016933 for <1982-done@emacsbugs.donarmstrong.com>; Sat, 24 Jan 2009 15:43:38 -0800 Received: by cyd.mit.edu (Postfix, from userid 1000) id EEF6057E196; Sat, 24 Jan 2009 18:44:04 -0500 (EST) From: Chong Yidong To: Geoff Gole Cc: 1982-done@emacsbugs.donarmstrong.com Subject: Re: 23.0.60; Infinite loop in align-regexp Date: Sat, 24 Jan 2009 18:44:04 -0500 Message-ID: <87y6x0w9q3.fsf@cyd.mit.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii > For certain choices of regexp and region text, align-regexp will enter > an infinite loop... Anyway, the problem seems to be that align-region > assumes that a successful search will always move point forward. The > following patch attempts to fix this: Your patch looks OK, so I've checked it in. Thanks very much. ------------=_1232841003-18192-0--