diff --git a/src/glob.ml b/src/glob.ml index 17539a3..3eb6326 100644 --- a/src/glob.ml +++ b/src/glob.ml @@ -215,12 +215,12 @@ let matches ?options glob path = | Some l -> l - i | None -> rest_len in + (* Star may consume 0..break_len characters: try each length in + order and let the suffix decide. *) let rec backtrack j = - if j >= break_len then None - else - begin if matches (i + j + 1) path rest then Some j - else backtrack (j + 1) - end + if matches (i + j) path rest then Some j + else if j >= break_len then None + else backtrack (j + 1) in Option.is_some (backtrack 0) | Question :: rest ->