- Fix Invalid_argument("String.index_from") with patch from upstream.

This commit is contained in:
Richard W.M. Jones 2008-11-20 17:52:37 +00:00
parent f7302e68d1
commit 08dd76f674
2 changed files with 58 additions and 1 deletions

View File

@ -0,0 +1,47 @@
--- 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

View File

@ -2,7 +2,7 @@
Name: ocaml
Version: 3.11.0+beta1
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Objective Caml compiler and programming environment
@ -32,6 +32,12 @@ Patch3: ocaml-3.11.0-ppc64.patch
# A similar fix went upstream in 3.11.0:
#Patch5: ocaml-3.11-dev12-no-executable-stack.patch
# This is a patch from upstream which fixes PR#4637, PR#4582.
# http://camlcvs.inria.fr/cgi-bin/cvsweb/ocaml/stdlib/string.ml.diff?r1=text&tr1=1.29&r2=text&tr2=1.28
# commonly manifested as errors thrown saying:
# Invalid_argument("String.index_from")
Patch6: ocaml-3.11.0-string-index-from.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: ncurses-devel
@ -206,6 +212,7 @@ man pages and info files.
%patch3 -p1 -b .ppc64
#%patch4 -p1 -b .map32bit
#%patch5 -p0 -b .noexecstack
%patch6 -p1 -b .stringindexfrom
cp %{SOURCE2} refman.pdf
@ -446,6 +453,9 @@ fi
%changelog
* Thu Nov 20 2008 Richard W.M. Jones <rjones@redhat.com> - 3.11.0+beta1-2
- Fix Invalid_argument("String.index_from") with patch from upstream.
* Tue Nov 18 2008 Richard W.M. Jones <rjones@redhat.com> - 3.11.0+beta1-1
- Rebuild for major new upstream release of 3.11.0 for Fedora 11.