changeset 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 7946503ec76e
children 8e7130a10f3b
files mercurial/commands.py
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
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):