diff options
author | Damien Doligez <damien.doligez-inria.fr> | 2008-11-18 10:29:26 +0000 |
---|---|---|
committer | Damien Doligez <damien.doligez-inria.fr> | 2008-11-18 10:29:26 +0000 |
commit | 04f20f8b83e4e18a84e30944ca45ae1ed8232840 (patch) | |
tree | 7a5fc53923da7c21bdc6416139cd9b3670b6d172 | |
parent | e3e377bdf53ade80cb4fc4cb60f7b38ef6b1ff42 (diff) | |
download | ocaml-04f20f8b83e4e18a84e30944ca45ae1ed8232840.tar.gz |
PR#4582, PR#4637 - revert functions to old behaviour
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@9132 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r-- | stdlib/string.ml | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/stdlib/string.ml b/stdlib/string.ml index 2c140c206c..0cb67d289f 100644 --- a/stdlib/string.ml +++ b/stdlib/string.ml @@ -154,7 +154,7 @@ let index s c = index_rec s (length s) 0 c;; let index_from s i c = let l = length s in - if i < 0 || i >= l then invalid_arg "String.index_from" else + if i < 0 || i > l then invalid_arg "String.index_from" else index_rec s l i c;; let rec rindex_rec s i c = @@ -164,22 +164,18 @@ let rec rindex_rec s i c = let rindex s c = rindex_rec s (length s - 1) c;; let rindex_from s i c = - let l = length s in - if i < 0 || i >= l then invalid_arg "String.rindex_from" else + if i < -1 || i >= length s then invalid_arg "String.rindex_from" else rindex_rec s i c;; let contains_from s i c = let l = length s in - if i < 0 || i >= l then invalid_arg "String.contains_from" else + if i < 0 || i > l then invalid_arg "String.contains_from" else try ignore (index_rec s l i c); true with Not_found -> false;; -let contains s c = - let l = length s in - l <> 0 && contains_from s 0 c;; +let contains s c = contains_from s 0 c;; let rcontains_from s i c = - let l = length s in - if i < 0 || i >= l then invalid_arg "String.rcontains_from" else + if i < 0 || i >= length s then invalid_arg "String.rcontains_from" else try ignore (rindex_rec s i c); true with Not_found -> false;; type t = string |