Dear maintainers:

Bug summary: GNU grep 3.0-2 matches too lazily when invoked with -zoP and matching backreference followed by newline

Steps to reproduce:

Create file cases:

foo
bar
  cases:
    1: foo
    2: bar
baz
  cases:
    3: baz
quux

And run grep -zoP '(\s*)cases:\n(\1.*\n)*' cases

Expected output:

  cases:
    1: foo
    2: bar
  cases:
    3: baz

Actual output:
  cases:

  cases:
Best regards,

Johannes Riecken