Grep patch

Borin, Rogerio rogerio.borin at avocent.com
Fri Oct 26 20:54:54 UTC 2007


Hello,

 

I'm sending a patch to grep which was not working correctly when
multiple patterns were used.

In the main searching loop the program read a line of text and then in
an inner loop it tried to match against each of the patterns. However,
if a match were found it didn't stop the inner loop, in a way that only
the last pattern was honored. The patched just added a 'break' to this
loop.

 

The bug was only visible when using -F flag (literal matching) because
the variable 'ret' was never reset when this flag was not passed (normal
regexp matching).

 

In order to experience the bug, try 'grep -F -e "txt1" -e "txt2"
input.txt', where input.txt is:

--------

txt1

txt2

--------

The output will be 'txt2' only.

 

Regards,

 

Rogerio

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.busybox.net/pipermail/busybox/attachments/20071026/98dde498/attachment-0001.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: grep.patch
Type: application/octet-stream
Size: 1238 bytes
Desc: grep.patch
Url : http://lists.busybox.net/pipermail/busybox/attachments/20071026/98dde498/attachment-0002.obj 


More information about the busybox mailing list