From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Ivan Andrus Newsgroups: gmane.emacs.bugs Subject: bug#24223: 25.1; Error in ansi-color-filter-apply when control sequences are dropped Date: Sat, 13 Aug 2016 23:43:20 -0600 Message-ID: <27FDE7BF-9477-4987-B62A-B492DEFD0597@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1471153461 6706 195.159.176.226 (14 Aug 2016 05:44:21 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 14 Aug 2016 05:44:21 +0000 (UTC) To: 24223@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Aug 14 07:44:17 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bYoDY-0001bj-DZ for geb-bug-gnu-emacs@m.gmane.org; Sun, 14 Aug 2016 07:44:16 +0200 Original-Received: from localhost ([::1]:59666 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bYoDV-0003xz-Jf for geb-bug-gnu-emacs@m.gmane.org; Sun, 14 Aug 2016 01:44:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33075) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bYoDO-0003xt-5h for bug-gnu-emacs@gnu.org; Sun, 14 Aug 2016 01:44:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bYoDK-0003Zz-T1 for bug-gnu-emacs@gnu.org; Sun, 14 Aug 2016 01:44:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:59026) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bYoDK-0003Zv-PX for bug-gnu-emacs@gnu.org; Sun, 14 Aug 2016 01:44:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bYoDK-00019w-Jp for bug-gnu-emacs@gnu.org; Sun, 14 Aug 2016 01:44:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ivan Andrus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 14 Aug 2016 05:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 24223 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.14711534194418 (code B ref -1); Sun, 14 Aug 2016 05:44:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 14 Aug 2016 05:43:39 +0000 Original-Received: from localhost ([127.0.0.1]:56738 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bYoCx-00019C-Iv for submit@debbugs.gnu.org; Sun, 14 Aug 2016 01:43:39 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:42071) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bYoCv-00018z-AB for submit@debbugs.gnu.org; Sun, 14 Aug 2016 01:43:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bYoCp-0003Qq-2k for submit@debbugs.gnu.org; Sun, 14 Aug 2016 01:43:31 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:36892) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bYoCo-0003Qm-Vr for submit@debbugs.gnu.org; Sun, 14 Aug 2016 01:43:31 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33042) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bYoCm-0003r0-RK for bug-gnu-emacs@gnu.org; Sun, 14 Aug 2016 01:43:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bYoCi-0003QF-K0 for bug-gnu-emacs@gnu.org; Sun, 14 Aug 2016 01:43:27 -0400 Original-Received: from mail-it0-x242.google.com ([2607:f8b0:4001:c0b::242]:36170) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bYoCi-0003PE-El for bug-gnu-emacs@gnu.org; Sun, 14 Aug 2016 01:43:24 -0400 Original-Received: by mail-it0-x242.google.com with SMTP id j124so1602955ith.3 for ; Sat, 13 Aug 2016 22:43:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-transfer-encoding:subject:date:message-id:cc:to :mime-version; bh=nGtqHHXxw5Mxvzfd4cck++xULdPh23cbOK5DhFh7VY4=; b=pRwvQW39Gl6V9SHtgl6wtSZTT8kAZZDctHdpWu+YLjrkyjygD0p6TDMF7mQ6vGi0Lt tsgNSJoWVg1Eci0npFPuv00U0LBAlFfwRCMXxgjb4OIb/xrqM4OP6tra72B1hoWWAUNt 2P+SpfsYfVjm+5zB0ytzvzgVP2qadIBzxtxyqYFWYKA39CDVErl2HGqKebDvjbIYMZBU hXzkkzxmrRdj/C1cu1XjZAKzC1g97d3a3kCOga3KgZXT5xFdplULjE1oIEr18pkuCnTz OihHMqLsTZqZVmpeGjAbpkjyOOd9FS1QV/LialdXbvNWJk0qLx8IH7ndheAyVuiFIL0X ExPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:content-transfer-encoding:subject:date :message-id:cc:to:mime-version; bh=nGtqHHXxw5Mxvzfd4cck++xULdPh23cbOK5DhFh7VY4=; b=LswlE+RtZtIaupbbuLt+/nS7Txr2n8rKsh8TPLZ2ffc0Fz6r5pqKt6Qjge4vQMlmWM 6ecgzQ8ZBFGYsIH1dhkPE+GbK4HsUaRVTACdktfCvuZY14P1NDnAWWNR8BrlSHmj63dh EUTPRvpnc6jU3GxNHQHBJ/ogoNXDai+VKIMEDNY2I/aUfZAptg8yAqHXIfJrsm63K/Du op129e2ME4MAVW92jI+18TBeGlnaqn4GcSc8folabQZSJn110NaC9L3JAJmVBkZ2Mqh8 tDHrOquxYfB0IbW0gsMNlQ6XqIWbA57qFsgGyxQXwU2QEShVllABOMxE8G9H0BUfW2P1 n+PQ== X-Gm-Message-State: AEkoouvRUr/QX/JAHiT7xZCBhvupWnHUBUxfEtusXZ3qsvFWn1n7Wm8oDsrkza/FxBNZqw== X-Received: by 10.36.144.68 with SMTP id x65mr6849715itd.70.1471153403304; Sat, 13 Aug 2016 22:43:23 -0700 (PDT) Original-Received: from [192.168.0.3] (97-117-19-144.slkc.qwest.net. [97.117.19.144]) by smtp.gmail.com with ESMTPSA id e66sm4660977itd.22.2016.08.13.22.43.22 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 13 Aug 2016 22:43:22 -0700 (PDT) X-Mailer: Apple Mail (2.3124) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:122195 Archived-At: In `ansi-color-filter-apply' the block "eliminate unrecognized escape sequences" occurs after the "find the next escape sequence" block. This is problematic because the variable start is set in the "next sequence" block and used in the "save context, add the remainder of the string to the result" block. However, dropping control sequences with `ansi-color-drop-regexp' can cause the string to shorten and start to point past the end of the string. I merely swapped the order of the first two blocks mentioned and was able to get past the error. But there are likely other places that need to be fixed as well. I have commit access, and can make the change (as well as tracking down other places where it might be necessary), but I would like some feedback on whether this is the right way solve it. Presumably there was a reason escape sequences were dropped after start was set up. -Ivan diff --git a/lisp/ansi-color.el b/lisp/ansi-color.el index 788a7bd..7cea2d9 100644 --- a/lisp/ansi-color.el +++ b/lisp/ansi-color.el @@ -258,14 +258,14 @@ ansi-color-filter-apply (if (cadr ansi-color-context) (setq string (concat (cadr ansi-color-context) string) ansi-color-context nil)) - ;; find the next escape sequence - (while (setq end (string-match ansi-color-regexp string start)) - (setq result (concat result (substring string start end)) - start (match-end 0))) ;; eliminate unrecognized escape sequences (while (string-match ansi-color-drop-regexp string) (setq string (replace-match "" nil nil string))) + ;; find the next escape sequence + (while (setq end (string-match ansi-color-regexp string start)) + (setq result (concat result (substring string start end)) + start (match-end 0))) ;; save context, add the remainder of the string to the result (let (fragment) (if (string-match "\033" string start) In GNU Emacs 25.1.2 (x86_64-apple-darwin15.5.0, NS appkit-1404.47 = Version 10.11.6 (Build 15G31)) of 2016-08-04 built on iandrus-osx Repository revision: 784291b06c4e4fe52f4c1aa15bc99874abc517c4 Windowing system distributor 'Apple', version 10.3.1404 Configured using: 'configure --with-ns --with-modules PKG_CONFIG_PATH=3D/opt/X11/lib/pkgconfig' Configured features: JPEG RSVG IMAGEMAGICK DBUS NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix