public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Problem with grep -Fwf (version 2.5.1a-1 and 2.5.1a-2)
@ 2006-07-28 19:05 Daniel Einspanjer
  2006-07-28 19:53 ` Christopher Faylor
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Einspanjer @ 2006-07-28 19:05 UTC (permalink / raw)
  To: cygwin


Using the following files both of which had dos2unix run on them to be sure 
there were no line-ending issues:

===== data.txt =======
abc
defghi
======================

===== filter.txt =====
abc
deghi
======================

These commands work as expected:
$ fgrep -f filter.txt data.txt
$ tail -1 data.txt | fgrep -wf filter.txt

But this command fails to return ghi:
$ fgrep -wf filter.txt data.txt
So it seems that after a match is discarded because it is not a full word 
(due to the -w flag), subsequent full word matches are also discarded.

I've tested this with the grep 2.5.1 installed on a recent Gentoo GNU/Linux 
machine and it behaves properly so I am guessing it might be a problem 
specific to the cygwin port.  I have not worked with Cygwin source yet, so 
I'm reporting the problem, and if I finish with the work tasks that surfaced 
the problem, I'll be happy to dig into the source and attempt to create a 
patch, but I'm hoping there might be someone out there that can quickly 
determine the problem and solution. :)
-- 
Daniel Einspanjer 



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Problem with grep -Fwf (version 2.5.1a-1 and 2.5.1a-2)
  2006-07-28 19:05 Problem with grep -Fwf (version 2.5.1a-1 and 2.5.1a-2) Daniel Einspanjer
@ 2006-07-28 19:53 ` Christopher Faylor
  2006-07-28 20:31   ` Daniel Einspanjer
  0 siblings, 1 reply; 5+ messages in thread
From: Christopher Faylor @ 2006-07-28 19:53 UTC (permalink / raw)
  To: cygwin

On Fri, Jul 28, 2006 at 01:53:32PM -0400, Daniel Einspanjer wrote:
>Using the following files both of which had dos2unix run on them to be sure 
>there were no line-ending issues:
>
>===== data.txt =======
>abc
>defghi
   ^
>======================
>
>===== filter.txt =====
>abc
>deghi
>======================
>
>These commands work as expected:
>$ fgrep -f filter.txt data.txt
>$ tail -1 data.txt | fgrep -wf filter.txt
>
>But this command fails to return ghi:
>$ fgrep -wf filter.txt data.txt
>So it seems that after a match is discarded because it is not a full word 
>(due to the -w flag), subsequent full word matches are also discarded.

Maybe it's a typo in your simplified test case but fgrep -w shouldn't match
defghi since the input is deghi.

>I've tested this with the grep 2.5.1 installed on a recent Gentoo GNU/Linux 
>machine and it behaves properly so I am guessing it might be a problem 
>specific to the cygwin port.

I tried this test on Cygwin, Gentoo, and FC5 and got consistent results
on all.  If I remove the 'f' in defghi from data.txt then it also works
consistently on all three systems, i.e., it returns:

abc
deghi

cgf

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Problem with grep -Fwf (version 2.5.1a-1 and 2.5.1a-2)
  2006-07-28 19:53 ` Christopher Faylor
@ 2006-07-28 20:31   ` Daniel Einspanjer
  2006-07-28 21:31     ` Christopher Faylor
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Einspanjer @ 2006-07-28 20:31 UTC (permalink / raw)
  To: cygwin

I'm sorry, the message appeared to be formatted properly when I posted it 
but something must have happened during transmission.  Each file should have 
three lines. the data file has abc, def, and ghi.  The filter file has abc, 
de, and ghi.  The de line is significant to test the -w whole word matching 
flag.
I appreciate your looking at this and I'm sorry for the confusion.  Could 
you try it again with the files the way I just described and see if you 
might be able to reproduce the problem?

===== data.txt =====
abc
def
ghi
==========
===== filter.txt =====
abc
de
ghi
==========

Daniel

"Christopher Faylor" <cgf-no-personal-reply-please@cygwin.com> wrote in 
message news:20060728190502.GA8071@trixie.casa.cgf.cx...
> On Fri, Jul 28, 2006 at 01:53:32PM -0400, Daniel Einspanjer wrote:
>>Using the following files both of which had dos2unix run on them to be 
>>sure
>>there were no line-ending issues:
>>
>>===== data.txt =======
>>abc
>>defghi
>   ^
>>======================
>>
>>===== filter.txt =====
>>abc
>>deghi
>>======================
>>
>>These commands work as expected:
>>$ fgrep -f filter.txt data.txt
>>$ tail -1 data.txt | fgrep -wf filter.txt
>>
>>But this command fails to return ghi:
>>$ fgrep -wf filter.txt data.txt
>>So it seems that after a match is discarded because it is not a full word
>>(due to the -w flag), subsequent full word matches are also discarded.
>
> Maybe it's a typo in your simplified test case but fgrep -w shouldn't 
> match
> defghi since the input is deghi.
>
>>I've tested this with the grep 2.5.1 installed on a recent Gentoo 
>>GNU/Linux
>>machine and it behaves properly so I am guessing it might be a problem
>>specific to the cygwin port.
>
> I tried this test on Cygwin, Gentoo, and FC5 and got consistent results
> on all.  If I remove the 'f' in defghi from data.txt then it also works
> consistently on all three systems, i.e., it returns:
>
> abc
> deghi
>
> cgf
> 



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Problem with grep -Fwf (version 2.5.1a-1 and 2.5.1a-2)
  2006-07-28 20:31   ` Daniel Einspanjer
@ 2006-07-28 21:31     ` Christopher Faylor
  2006-07-29  0:21       ` Daniel Einspanjer
  0 siblings, 1 reply; 5+ messages in thread
From: Christopher Faylor @ 2006-07-28 21:31 UTC (permalink / raw)
  To: cygwin

On Fri, Jul 28, 2006 at 04:12:24PM -0400, Daniel Einspanjer wrote:
>I'm sorry, the message appeared to be formatted properly when I posted it 
>but something must have happened during transmission.  Each file should 
>have three lines. the data file has abc, def, and ghi.  The filter file has 
>abc, de, and ghi.  The de line is significant to test the -w whole word 
>matching flag.
>I appreciate your looking at this and I'm sorry for the confusion.  Could 
>you try it again with the files the way I just described and see if you 
>might be able to reproduce the problem?
>
>===== data.txt =====
>abc
>def
>ghi
>==========
>===== filter.txt =====
>abc
>de
>ghi
>==========

Yes, I can reproduce it now and see that it goes away if I update the
grep sources with patches from the FC5 release.  I'll release a new
version of grep this weekend.

I wonder why every test case I tried worked.  I didn't think I had the
standard developer's blind spot for grep.

cgf

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Problem with grep -Fwf (version 2.5.1a-1 and 2.5.1a-2)
  2006-07-28 21:31     ` Christopher Faylor
@ 2006-07-29  0:21       ` Daniel Einspanjer
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Einspanjer @ 2006-07-29  0:21 UTC (permalink / raw)
  To: cygwin

"Christopher Faylor" <cgf-no-personal-reply-please@cygwin.com> wrote in 
message news:20060728203124.GB8071@trixie.casa.cgf.cx...

> Yes, I can reproduce it now and see that it goes away if I update the
> grep sources with patches from the FC5 release.  I'll release a new
> version of grep this weekend.
>
> I wonder why every test case I tried worked.  I didn't think I had the
> standard developer's blind spot for grep.
>
> cgf


Meh! it seems that programs always have n + 1 edges so this is just another 
edge case.
I appreciate your persistence after my initial reporting goof and I'm glad 
to hear that a fix was easy to track down.

Thanks!

Daniel 



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-07-28 21:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-28 19:05 Problem with grep -Fwf (version 2.5.1a-1 and 2.5.1a-2) Daniel Einspanjer
2006-07-28 19:53 ` Christopher Faylor
2006-07-28 20:31   ` Daniel Einspanjer
2006-07-28 21:31     ` Christopher Faylor
2006-07-29  0:21       ` Daniel Einspanjer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).