[RFC] Refactor buflist_findpat "two-iteration loop" anti-pattern

Another occurence of Issue #572. This code is much clearer but longer.
Couple of questions though:
* line 1731 - 1750: Even though the code is clearer, this still looks like something that should be replaced by a for loop?
* The infinite for loop (line 1730) could be replaced either by moving the above mentioned code into another method, or by using a goto statement (gasp). Would the first be preferable?
Extracting the loop body and turning it into a function that takes the loop variable (`attempt`) as parameter is equivalent to the old code. A refactoring of this anti-pattern means that there will be a big reduction in conditional code. Conditional code still exists inside the `attempt_match` function.