all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Robin Green <greenrd@greenrd.org>
Cc: 7378@debbugs.gnu.org
Subject: bug#7378: 23.2; grep buffer misinterprets result if filename contains colon character
Date: Mon, 15 Nov 2010 11:29:21 -0500	[thread overview]
Message-ID: <jwvhbfiimqr.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <877hgha7fm.wl%greenrd@greenrd.org> (Robin Green's message of "Sat, 13 Nov 2010 09:39:41 +0000")

>> AFAIK we do try to figure out what was meant, even though in general
>> grep's output is simply ambiguous when the file name has colons.
>> So, could you give the exact file name you used
> ./installed/data/x11-libs---nx/3.4.0:0:C.30253.1289557929.792611.C/nx-3.4.0.exheres-0

I guess strictly speaking it's not ambiguous since grep normally starts
counting from 1, so the ":0:" cannot actually be the line number
(e.g. the patch below could help).
But I also expect that among your file names, the ":0:" is just an
accident and it could just as well be ":5:" instead, in which case
greps' output will be *really* ambiguous.

I.e. to resolve this kind of ambiguity, grep-mode would have to check
all the possible interpretations and see which ones lead to an existing
file name.  Such a change would require a good bit more work on grep.
Furthermore such ambiguity would need to be resolved not only when
the ":N:" comes from the file name but also when it comes from the
file's content.


        Stefan


=== modified file 'lisp/progmodes/grep.el'
--- lisp/progmodes/grep.el	2010-05-21 20:43:04 +0000
+++ lisp/progmodes/grep.el	2010-11-15 16:28:07 +0000
@@ -348,7 +348,11 @@
     ;; produces them
     ;; ("^\\(.+?\\)\\(:[ \t]*\\)\\([0-9]+\\)\\2\\(?:\\([0-9]+\\)\\(?:-\\([0-9]+\\)\\)?\\2\\)?"
     ;;  1 3 (4 . 5))
-    ("^\\(\\(.+?\\):\\([0-9]+\\):\\).*?\
+    ;; Note that we want to use as tight a regexp as we can to try and
+    ;; handle weird file names (with colons in them) as well as possible.
+    ;; E.g. we use [1-9][0-9]* rather than [0-9]+ so as to accept ":034:" in
+    ;; file names.
+    ("^\\(\\(.+?\\):\\([1-9][0-9]*\\):\\).*?\
 \\(\033\\[01;31m\\(?:\033\\[K\\)?\\)\\(.*?\\)\\(\033\\[[0-9]*m\\)"
      2 3
      ;; Calculate column positions (beg . end) of first grep match on a line






  reply	other threads:[~2010-11-15 16:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-11 20:47 bug#7378: 23.2; grep buffer misinterprets result if filename contains colon character Robin Green
2010-11-11 23:09 ` Stefan Monnier
2010-11-13  9:39   ` Robin Green
2010-11-15 16:29     ` Stefan Monnier [this message]
2011-09-07 23:48       ` Juri Linkov
2011-09-08  2:52         ` Stefan Monnier
2017-06-28 12:00           ` npostavs
2017-07-20  0:04             ` bug#6843: " npostavs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvhbfiimqr.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=7378@debbugs.gnu.org \
    --cc=greenrd@greenrd.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.