[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#7378: 23.2; grep buffer misinterprets result if filename contains co

From: Stefan Monnier
Subject: bug#7378: 23.2; grep buffer misinterprets result if filename contains colon character
Date: Mon, 15 Nov 2010 11:29:21 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

>> 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.


=== 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
     ;; ("^\\(.+?\\)\\(:[ 
     ;;  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]*\\):\\).*?\
      2 3
      ;; Calculate column positions (beg . end) of first grep match on a line

reply via email to

[Prev in Thread] Current Thread [Next in Thread]