change the semantics of CCString.find_all (allow overlaps)

This commit is contained in:
Simon Cruanes 2016-03-10 16:34:29 +01:00
parent ce6d981973
commit 7c9633f06f
2 changed files with 3 additions and 2 deletions

View file

@ -222,7 +222,7 @@ let find_all ?(start=0) ~sub =
let res = Find.find ~pattern s !i in let res = Find.find ~pattern s !i in
if res = ~-1 then None if res = ~-1 then None
else ( else (
i := res + Find.pattern_length pattern; i := res + 1; (* possible overlap *)
Some res Some res
) )

View file

@ -109,7 +109,8 @@ val find : ?start:int -> sub:string -> string -> int
*) *)
val find_all : ?start:int -> sub:string -> string -> int gen val find_all : ?start:int -> sub:string -> string -> int gen
(** [find_all ~sub s] finds all occurrences of [sub] in [s] (** [find_all ~sub s] finds all occurrences of [sub] in [s], even overlapping
instances.
@param start starting position in [s] @param start starting position in [s]
@since NEXT_RELEASE *) @since NEXT_RELEASE *)