Mercurial > public > mercurial-scm > hg-stable
diff mercurial/commands.py @ 7230:261a9f47b44b
grep: avoid infinite loop when trailing newline is missing
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 23 Oct 2008 14:56:16 -0500 |
parents | 9b72c732ed2f |
children | db6fbb785800 |
line wrap: on
line diff
--- a/mercurial/commands.py Sun Oct 19 19:12:07 2008 +0200 +++ b/mercurial/commands.py Thu Oct 23 14:56:16 2008 -0500 @@ -1094,9 +1094,9 @@ mstart, mend = match.span() linenum += body.count('\n', begin, mstart) + 1 lstart = body.rfind('\n', begin, mstart) + 1 or begin - lend = body.find('\n', mend) + begin = body.find('\n', mend) + 1 or len(body) + lend = begin - 1 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend] - begin = lend + 1 class linestate(object): def __init__(self, line, linenum, colstart, colend):