diff options
author | 2003-06-10 20:55:36 +0000 | |
---|---|---|
committer | 2003-06-10 20:55:36 +0000 | |
commit | 05b125d1855a127fa829ba13c76aa91eed590a3c (patch) | |
tree | 5c9f0e385543baa3caeff18a4fde38da98d8b887 /lib/util.ml | |
parent | f0aae98e826d8f095bffb9b2f869c7c085e2476d (diff) |
Ajout fonctions de recherche de sous-chaines (merci a Jacek)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@4106 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'lib/util.ml')
-rw-r--r-- | lib/util.ml | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/util.ml b/lib/util.ml index 32ebb30ad..46ac2e5ce 100644 --- a/lib/util.ml +++ b/lib/util.ml @@ -57,6 +57,33 @@ let explode s = let implode sl = String.concat "" sl +(* substring searching... *) + +(* gdzie = where, co = what *) +(* gdzie=gdzie(string) gl=gdzie(length) gi=gdzie(index) *) +let rec is_sub gdzie gl gi co cl ci = + (ci>=cl) || + ((String.unsafe_get gdzie gi = String.unsafe_get co ci) && + (is_sub gdzie gl (gi+1) co cl (ci+1))) + +let rec raw_str_index i gdzie l c co cl = + let i' = String.index_from gdzie i c in + if (i'+cl <= l) && (is_sub gdzie l i' co cl 0) then i' else + raw_str_index (i'+1) gdzie l c co cl + +let str_index_from gdzie i co = + if co="" then i else + raw_str_index i gdzie (String.length gdzie) + (String.unsafe_get co 0) co (String.length co) + +let string_string_contains ~where ~what = + try + let _ = str_index_from where 0 what in true + with + Not_found -> false + +(* string parsing *) + let parse_loadpath s = let len = String.length s in let rec decoupe_dirs n = |