From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Geoff Gole Newsgroups: gmane.emacs.bugs,gmane.emacs.pretest.bugs Subject: bug#1982: 23.0.60; Infinite loop in align-regexp Date: Thu, 22 Jan 2009 08:30:36 +0900 Message-ID: Reply-To: Geoff Gole , 1982@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=0016364175d9ffe55b0461068a1c X-Trace: ger.gmane.org 1232581460 3755 80.91.229.12 (21 Jan 2009 23:44:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 21 Jan 2009 23:44:20 +0000 (UTC) To: emacs-pretest-bug@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jan 22 00:45:32 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 1LPmlH-0000ly-EE for geb-bug-gnu-emacs@m.gmane.org; Thu, 22 Jan 2009 00:45:31 +0100 Original-Received: from localhost ([127.0.0.1]:37619 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LPmk0-0001Fl-3T for geb-bug-gnu-emacs@m.gmane.org; Wed, 21 Jan 2009 18:44:12 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LPmjM-0000x4-GJ for bug-gnu-emacs@gnu.org; Wed, 21 Jan 2009 18:43:32 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LPmjL-0000w5-0A for bug-gnu-emacs@gnu.org; Wed, 21 Jan 2009 18:43:31 -0500 Original-Received: from [199.232.76.173] (port=58675 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LPmjK-0000vx-QA for bug-gnu-emacs@gnu.org; Wed, 21 Jan 2009 18:43:30 -0500 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:45673) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LPmjK-00014X-3M for bug-gnu-emacs@gnu.org; Wed, 21 Jan 2009 18:43:30 -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 n0LNhS7v008736; Wed, 21 Jan 2009 15:43:28 -0800 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id n0LNe3Ev007682; Wed, 21 Jan 2009 15:40:03 -0800 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Geoff Gole Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Wed, 21 Jan 2009 23:40:03 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: report 1982 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by submit@emacsbugs.donarmstrong.com id=B.12325806436286 (code B ref -1); Wed, 21 Jan 2009 23:40:03 +0000 Original-Received: (at submit) by emacsbugs.donarmstrong.com; 21 Jan 2009 23:30:43 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-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 Original-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 Original-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 Original-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 Original-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= Original-Received: by 10.114.80.1 with SMTP id d1mr2094038wab.168.1232580636566; Wed, 21 Jan 2009 15:30:36 -0800 (PST) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Resent-Date: Wed, 21 Jan 2009 18:43:31 -0500 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:24369 gmane.emacs.pretest.bugs:23730 Archived-At: --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 IGdyb3VwLWMKIAkJIHNwYWNpbmcgc3BhY2luZy1jCiAJCSB0YWItc3RvcCB0YWItc3RvcC1jCkBA IC0xNDEyLDYgKzE0MTMsNyBAQAogCQkgICAgICA7OyB3aGlsZSB3ZSBjYW4gZmluZCB0aGUgcnVs ZSBpbiB0aGUgYWxpZ25tZW50CiAJCSAgICAgIDs7IHJlZ2lvbi4uCiAJCSAgICAgICh3aGlsZSAo YW5kICg8IChwb2ludCkgZW5kLW1hcmspCisJCQkJICAoc2V0cSBzZWFyY2gtb3JpZ2luIChwb2lu dCkpCiAJCQkJICAoaWYgcmVnZnVuYwogCQkJCSAgICAgIChmdW5jYWxsIHJlZ2Z1bmMgZW5kLW1h cmsgbmlsKQogCQkJCSAgICAocmUtc2VhcmNoLWZvcndhcmQgcmVnZXhwCkBAIC0xNDM2LDcgKzE0 MzgsOCBAQAogCQkJOzsgaWYgdGhlIHNlYXJjaCBlbmRlZCB1cyBvbiB0aGUgYmVnaW5uaW5nIG9m CiAJCQk7OyB0aGUgbmV4dCBsaW5lLCBtb3ZlIGJhY2s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