comparison mercurial/commands.py @ 17931:35ba170c0f82 stable

grep: don't search past the end of the searched string '*' causes the resulting RE to match 0 or more repetitions of the preceding RE: >>> bool(re.search('.*', '')) >>> True This causes an infinite loop because currently we're only checking if there was a match without looking at where we are in the searched string.
author Idan Kamara <idankk86@gmail.com>
date Mon, 12 Nov 2012 19:27:03 +0200
parents ba0a1701c81a
children c8ffde272653 407209261f63
comparison
equal deleted inserted replaced
17924:45bd0cd7ca04 17931:35ba170c0f82
2933 getfile = util.lrucachefunc(repo.file) 2933 getfile = util.lrucachefunc(repo.file)
2934 2934
2935 def matchlines(body): 2935 def matchlines(body):
2936 begin = 0 2936 begin = 0
2937 linenum = 0 2937 linenum = 0
2938 while True: 2938 while True and begin < len(body):
2939 match = regexp.search(body, begin) 2939 match = regexp.search(body, begin)
2940 if not match: 2940 if not match:
2941 break 2941 break
2942 mstart, mend = match.span() 2942 mstart, mend = match.span()
2943 linenum += body.count('\n', begin, mstart) + 1 2943 linenum += body.count('\n', begin, mstart) + 1