48 lines
1.7 KiB
Diff
48 lines
1.7 KiB
Diff
|
--- ocaml/stdlib/string.ml 2008/07/22 11:29:00 1.28
|
||
|
+++ ocaml/stdlib/string.ml 2008/11/18 10:29:26 1.29
|
||
|
@@ -11,7 +11,7 @@
|
||
|
(* *)
|
||
|
(***********************************************************************)
|
||
|
|
||
|
-(* $Id: ocaml-3.11.0-string-index-from.patch,v 1.1 2008/11/20 17:52:37 rjones Exp $ *)
|
||
|
+(* $Id: ocaml-3.11.0-string-index-from.patch,v 1.1 2008/11/20 17:52:37 rjones Exp $ *)
|
||
|
|
||
|
(* String operations *)
|
||
|
|
||
|
@@ -154,7 +154,7 @@ let index s c = index_rec s (length s) 0
|
||
|
|
||
|
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
|