Skip to content

Commit

Permalink
Merge pull request #14 from RasmusWL/fix-debug_regexp
Browse files Browse the repository at this point in the history
fix infinite loop in debug_regexp
  • Loading branch information
phillipberndt committed Jan 22, 2015
2 parents cf2b326 + 29789df commit 8e23d69
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions autorandr.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ def debug_regexp(pattern, string):
bounds = ( 0, len(string) )
while bounds[0] != bounds[1]:
half = int((bounds[0] + bounds[1]) / 2)
if half == bounds[0]:
break
bounds = (half, bounds[1]) if regex.search(pattern, string[:half], partial=True) else (bounds[0], half - 1)
partial_length = bounds[0]
return ("Regular expression matched until position "
Expand Down

0 comments on commit 8e23d69

Please sign in to comment.