diff options
Diffstat (limited to 'src/boot/util')
| -rw-r--r-- | src/boot/util/common.ml | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/boot/util/common.ml b/src/boot/util/common.ml index f51d818e..838caa73 100644 --- a/src/boot/util/common.ml +++ b/src/boot/util/common.ml @@ -180,6 +180,31 @@ let new_fixup (s:string) (* + * Auxiliary string functions. + *) + +let split_string (c:char) (s:string) : string list = + let ls = ref [] in + let b = Buffer.create (String.length s) in + let flush _ = + if Buffer.length b <> 0 + then + begin + ls := (Buffer.contents b) :: (!ls); + Buffer.clear b + end + in + let f ch = + if c = ch + then flush() + else Buffer.add_char b ch + in + String.iter f s; + flush(); + List.rev (!ls) +;; + +(* * Auxiliary hashtable functions. *) |