Skip to content

. does not match a newline under --null-data like GNU #25

Closed

Description

@sylvestre

With --null-data (-z), records are separated by NUL (\0), so a newline \n is ordinary data. GNU's . matches any byte except the active record separator, so under --null-data . matches \n. uu_grep's . never matches \n, so it skips the newline bytes inside a NUL-delimited record.

Found by the differential fuzzer (fuzz_grep).

Input is a single NUL-record containing a, a newline, and b (output piped through tr '\0' '/' for readability).

Rust (incorrect)

$ printf 'a\nb' | ./target/release/grep -e '.' -o --null-data | tr '\0' '/'
a/b/
# the '\n' between a and b is not matched

GNU (correct)

$ printf 'a\nb' | LC_ALL=C /usr/bin/grep -e '.' -o --null-data | tr '\0' '/'
a/
/b/
# '\n' is matched as an ordinary character

Control (no --null-data, so \n is the separator): grep -e '.' -o yields a/b/ in both — the newline is correctly excluded only when it is the record separator.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions