Page MenuHomeFreeBSD

bsdgrep(1): Add -z/--null-data support
ClosedPublic

Authored by kevans on Mar 22 2017, 8:29 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 20, 2:30 AM
Unknown Object (File)
Oct 19 2024, 9:53 PM
Unknown Object (File)
Oct 5 2024, 9:30 PM
Unknown Object (File)
Oct 3 2024, 10:59 PM
Unknown Object (File)
Oct 2 2024, 6:06 AM
Unknown Object (File)
Oct 1 2024, 10:13 PM
Unknown Object (File)
Oct 1 2024, 7:43 AM
Unknown Object (File)
Sep 30 2024, 10:19 AM
Subscribers

Details

Summary

Add -z/--null-data support to bsdgrep(1). This brings it more in line with gnugrep(1), and brings us closer to passing the current context tests with bsdgrep(1). 2/3 of the cases in context2 pass just from implementing -z.

Test Plan

Run kyua tests to make sure this introduced no other regressions

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Fix typo in grep(1), s/at/a/

Ping @emaste, @cem - this and D10105 are the remaining two patches to bring us up to regression test standards. =)

This one is fairly trivial and implements -z, treat \0 as newlines in input files -- i..e, \0 no longer indicates binary, and if we're supposed to be reading (or have read and then written, in case of util.c:495) eol then make sure it's \0 instead of \n.

usr.bin/grep/file.c
326 ↗(On Diff #26649)

Is this indentation correct? It looks wrong in phab.

usr.bin/grep/util.c
495 ↗(On Diff #26649)

Hm, should the nul input separater really be used for outputting matched lines?

And if so, shouldn't it also be used with oflag above?

usr.bin/grep/file.c
326 ↗(On Diff #26649)

It is not, but I didn't know if I should fix the next line while I'm here or not since I wasn't really doing anything with it. I will fix it with an update here shortly.

usr.bin/grep/util.c
495 ↗(On Diff #26649)

So, it depends. If we're supposed to be printing the matched lines, we need to do so faithful to the input file -- i.e., this line, and actually line 491 that I missed (!oflag, but color). Everything else is printing excerpts and should use the standard grep newline separator.

  • Missed a spot where we should be printing fileeol instead of \n
  • Fix indentation
This revision is now accepted and ready to land.Apr 7 2017, 10:59 PM

There are a few style(9) issues noted inline (line length and tabs vs spaces) which I will handle before commit.

usr.bin/grep/file.c
325 ↗(On Diff #27205)

Need to wrap at < 80 cols

usr.bin/grep/grep.c
112 ↗(On Diff #27205)

whitespace

219 ↗(On Diff #27205)

whitespace

usr.bin/grep/grep.h
119 ↗(On Diff #27205)

whitespace

usr.bin/grep/grep.1
33 ↗(On Diff #27205)

.Dd needs to be updated when man page content changes

This revision was automatically updated to reflect the committed changes.