NetBSD-Bugs archive

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

Re: bin/58849: usr.bin/grep is broken (TOOL_GREP, MKBSDGREP=yes)



The following reply was made to PR bin/58849; it has been noted by GNATS.

From: mlelstv%serpens.de@localhost (Michael van Elst)
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: bin/58849: usr.bin/grep is broken (TOOL_GREP, MKBSDGREP=yes)
Date: Sat, 23 Nov 2024 07:58:31 -0000 (UTC)

 campbell+netbsd%mumble.net@localhost writes:
 
 >$ { echo __bss_start__; echo __bss_end__; echo hello; } | nbgrep -Fvx -e _end -e _fini -e _init -e __bss_end__ -e __bss_start__ -e __end__ -e _bss_end__
 >__bss_end__
 >hello
 
 # echo bla | nbgrep -x -e a -e bla
 # echo bla | nbgrep -x -e bla -e a
 bla
 
 The bug is in util.c:procline(). The code iterates over all patterns
 and continues the search where the previous search operation left
 off (the pattern match advances pmatch.rm_so).
 
 Checking for 'whole line' (-x) or 'word' (-w) is just a secondary test.
 
 So when one pattern matches but doesn't qualify -x or -w, the following
 patterns do not revisit the same place and may not match.
 
 This bug already existed when the code was taken from FreeBSD in
 rev 1.7, but the current FreeBSD code has fixed it and recalculates
 where to continue the search.
 


Home | Main Index | Thread Index | Old Index