Move to a pre-release of num 1.4.

This commit is contained in:
Richard W.M. Jones 2020-04-30 08:42:26 +01:00
parent 3a24bfc56f
commit aa2067eae3
9 changed files with 174 additions and 47 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
/ocaml-num-1.1.tar.gz
/v1.3.tar.gz

23
0001-Bump-version.patch Normal file
View File

@ -0,0 +1,23 @@
From 43fec4792091c5f8afac787042a084cfd465fd0d Mon Sep 17 00:00:00 2001
From: David Allsopp <david.allsopp@metastack.com>
Date: Wed, 20 Nov 2019 08:31:22 +0000
Subject: [PATCH 1/5] Bump version
---
num.opam | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/num.opam b/num.opam
index b43dfb8..5f4e209 100644
--- a/num.opam
+++ b/num.opam
@@ -1,5 +1,5 @@
opam-version: "2.0"
-version: "1.3"
+version: "1.4~dev"
maintainer: "Xavier Leroy <xavier.leroy@inria.fr>"
authors: [
"Valérie Ménissier-Morain"
--
2.24.1

View File

@ -1,28 +0,0 @@
From 07639e9179347779ee723cffe50ba3dc7217b65e Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Wed, 8 Nov 2017 22:10:09 +0000
Subject: [PATCH 1/3] install: Use DESTDIR.
---
src/Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Makefile b/src/Makefile
index 97dc074..cff37f8 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -84,9 +84,9 @@ TOINSTALL_STUBS=dllnums.$(SO)
install:
$(OCAMLFIND) install num META
- $(INSTALL_DATA) $(TOINSTALL) $(STDLIBDIR)
+ $(INSTALL_DATA) $(TOINSTALL) $(DESTDIR)$(STDLIBDIR)
ifeq "$(SUPPORTS_SHARED_LIBRARIES)" "true"
- $(INSTALL_DLL) $(TOINSTALL_STUBS) $(STDLIBDIR)/stublibs
+ $(INSTALL_DLL) $(TOINSTALL_STUBS) $(DESTDIR)$(STDLIBDIR)/stublibs
endif
uninstall:
--
2.13.1

View File

@ -0,0 +1,75 @@
From 8a60d77c284822dae6291f1c8a8145a0d480212b Mon Sep 17 00:00:00 2001
From: Hugo Heuzard <hugo.heuzard@gmail.com>
Date: Sat, 23 Nov 2019 17:55:45 +0800
Subject: [PATCH 2/5] Fix usage of bytes vs string
Don't reuse strings after they get unsafely converted to bytes for mutation.
Intead, explicitly refer to the mutated bytes
---
src/ratio.ml | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/ratio.ml b/src/ratio.ml
index 04f9c5e..491cb96 100644
--- a/src/ratio.ml
+++ b/src/ratio.ml
@@ -438,13 +438,13 @@ let approx_ratio_fix n r =
(base_power_big_int
10 (succ n) (abs_big_int r.numerator))
r.denominator)) in
+ let s1 = Bytes.unsafe_of_string s1 in
(* Round up and add 1 in front if needed *)
let s2 =
- if round_futur_last_digit (Bytes.unsafe_of_string s1) 0
- (String.length s1)
- then "1" ^ s1
+ if round_futur_last_digit s1 0 (Bytes.length s1)
+ then Bytes.cat (Bytes.of_string "1") s1
else s1 in
- let l2 = String.length s2 - 1 in
+ let l2 = Bytes.length s2 - 1 in
(* if s2 without last digit is xxxxyyy with n 'yyy' digits:
<sign> xxxx . yyy
if s2 without last digit is yy with <= n digits:
@@ -452,15 +452,15 @@ let approx_ratio_fix n r =
if l2 > n then begin
let s = Bytes.make (l2 + 2) '0' in
Bytes.set s 0 (if sign_r = -1 then '-' else '+');
- String.blit s2 0 s 1 (l2 - n);
+ Bytes.blit s2 0 s 1 (l2 - n);
Bytes.set s (l2 - n + 1) '.';
- String.blit s2 (l2 - n) s (l2 - n + 2) n;
+ Bytes.blit s2 (l2 - n) s (l2 - n + 2) n;
Bytes.unsafe_to_string s
end else begin
let s = Bytes.make (n + 3) '0' in
Bytes.set s 0 (if sign_r = -1 then '-' else '+');
Bytes.set s 2 '.';
- String.blit s2 0 s (n + 3 - l2) l2;
+ Bytes.blit s2 0 s (n + 3 - l2) l2;
Bytes.unsafe_to_string s
end
end else begin
@@ -508,8 +508,8 @@ let approx_ratio_exp n r =
10 k (abs_big_int r.numerator))
r.denominator) in
string_of_nat nat) in
- if round_futur_last_digit (Bytes.unsafe_of_string s) 0
- (String.length s)
+ let s = Bytes.unsafe_of_string s in
+ if round_futur_last_digit s 0 (Bytes.length s)
then
let m = num_decimal_digits_int (succ msd) in
let str = Bytes.make (n + m + 4) '0' in
@@ -525,7 +525,7 @@ let approx_ratio_exp n r =
and p = n + 3 in
let str = Bytes.make (succ (m + p)) '0' in
(String.blit (if sign_r = -1 then "-0." else "+0.") 0 str 0 3);
- (String.blit s 0 str 3 n);
+ (Bytes.blit s 0 str 3 n);
Bytes.set str p 'e';
(if m = 0
then Bytes.set str (succ p) '0'
--
2.24.1

View File

@ -0,0 +1,48 @@
From 2def7803f0536aa961d3fb6e59dbfb1139cc3b42 Mon Sep 17 00:00:00 2001
From: Hugo Heuzard <hugo.heuzard@gmail.com>
Date: Sat, 23 Nov 2019 18:11:45 +0800
Subject: [PATCH 3/5] Get rid of Bytes.unsafe_of_string
---
src/big_int.ml | 2 +-
src/ratio.ml | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/big_int.ml b/src/big_int.ml
index 45cea9c..779e0ba 100644
--- a/src/big_int.ml
+++ b/src/big_int.ml
@@ -674,7 +674,7 @@ let approx_big_int prec bi =
(big_int_of_string "963295986"))
(big_int_of_string "100000000")))) in
let s =
- Bytes.unsafe_of_string
+ Bytes.of_string
(string_of_big_int (div_big_int bi (power_int_positive_int 10 n)))
in
let (sign, off) =
diff --git a/src/ratio.ml b/src/ratio.ml
index 491cb96..5943383 100644
--- a/src/ratio.ml
+++ b/src/ratio.ml
@@ -438,7 +438,7 @@ let approx_ratio_fix n r =
(base_power_big_int
10 (succ n) (abs_big_int r.numerator))
r.denominator)) in
- let s1 = Bytes.unsafe_of_string s1 in
+ let s1 = Bytes.of_string s1 in
(* Round up and add 1 in front if needed *)
let s2 =
if round_futur_last_digit s1 0 (Bytes.length s1)
@@ -508,7 +508,7 @@ let approx_ratio_exp n r =
10 k (abs_big_int r.numerator))
r.denominator) in
string_of_nat nat) in
- let s = Bytes.unsafe_of_string s in
+ let s = Bytes.of_string s in
if round_futur_last_digit s 0 (Bytes.length s)
then
let m = num_decimal_digits_int (succ msd) in
--
2.24.1

View File

@ -1,14 +1,14 @@
From db0abe753585fcec091793c476fa9b2ce38d5055 Mon Sep 17 00:00:00 2001
From f389970daa5f5cae428d686eca31122cb0d61076 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Wed, 8 Nov 2017 22:15:06 +0000
Subject: [PATCH 2/3] toplevel: Add -g flag.
Subject: [PATCH 4/5] toplevel: Add -g flag.
---
toplevel/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/toplevel/Makefile b/toplevel/Makefile
index 8c91b0b..a6aab63 100644
index 4af7905..96d37d8 100644
--- a/toplevel/Makefile
+++ b/toplevel/Makefile
@@ -2,7 +2,7 @@ OCAMLC=ocamlc
@ -21,5 +21,5 @@ index 8c91b0b..a6aab63 100644
-safe-string -strict-sequence -strict-formats
--
2.13.1
2.24.1

View File

@ -1,17 +1,17 @@
From 15f870dee4dffb64450a79556684309cb960264a Mon Sep 17 00:00:00 2001
From 0419c771916f4f53e6dd2d89cfd11384ecd2be96 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Wed, 8 Nov 2017 22:16:59 +0000
Subject: [PATCH 3/3] src: Add -g flag to mklib.
Subject: [PATCH 5/5] src: Add -g flag to mklib.
---
src/Makefile | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/Makefile b/src/Makefile
index cff37f8..3a8f445 100644
index 8ad0e2c..4dc802f 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -45,13 +45,13 @@ all:: nums.cmxs
@@ -42,13 +42,13 @@ all:: nums.cmxs
endif
libnums.$(A): $(COBJS)
@ -28,7 +28,7 @@ index cff37f8..3a8f445 100644
nums.cmxs: nums.cmxa libnums.$(A)
$(OCAMLOPT) $(CAMLOPTFLAGS) -I . -shared -o nums.cmxs nums.cmxa
@@ -68,7 +68,7 @@ nat_stubs.$(O): bng.h nat.h
@@ -65,7 +65,7 @@ nat_stubs.$(O): bng.h nat.h
%.cmx: %.ml
$(OCAMLOPT) $(CAMLOPTFLAGS) -c $*.ml
%.$(O): %.c
@ -38,5 +38,5 @@ index cff37f8..3a8f445 100644
# Legacy installation: files go into OCaml's stdlib directory; only META
# is installed via findlib
--
2.13.1
2.24.1

View File

@ -1,17 +1,21 @@
Name: ocaml-num
Version: 1.1
Release: 24%{?dist}
Version: 1.4
Release: 0.1%{?dist}
Summary: Legacy Num library for arbitrary-precision integer and rational arithmetic
License: LGPLv2+ with exceptions
URL: https://github.com/ocaml/num
Source0: https://github.com/ocaml/num/archive/v%{version}/%{name}-%{version}.tar.gz
#Source0: https://github.com/ocaml/num/archive/v%%{version}/%%{name}-%%{version}.tar.gz
Source0: https://github.com/ocaml/num/archive/v1.3.tar.gz
# All patches since 1.3 was released.
Patch1: 0001-Bump-version.patch
Patch2: 0002-Fix-usage-of-bytes-vs-string.patch
Patch3: 0003-Get-rid-of-Bytes.unsafe_of_string.patch
# Downstream patch to make DESTDIR installs work.
Patch1: 0001-install-Use-DESTDIR.patch
# Downstream patches to add -g flag.
Patch2: 0002-toplevel-Add-g-flag.patch
Patch3: 0003-src-Add-g-flag-to-mklib.patch
Patch4: 0004-toplevel-Add-g-flag.patch
Patch5: 0005-src-Add-g-flag-to-mklib.patch
BuildRequires: ocaml
BuildRequires: ocaml-findlib-devel
@ -41,7 +45,8 @@ developing applications that use %{name}.
%prep
%setup -q -n num-%{version}
#%%setup -q -n num-%%{version}
%setup -q -n num-1.3
%autopatch -p1
@ -91,6 +96,9 @@ find $OCAMLFIND_DESTDIR -name '*.cmti' -delete
%changelog
* Thu Apr 30 2020 Richard W.M. Jones <rjones@redhat.com> - 1.4-0.1
- Move to a pre-release of num 1.4.
* Tue Apr 21 2020 Richard W.M. Jones <rjones@redhat.com> - 1.1-24
- OCaml 4.11.0 pre-release attempt 2

View File

@ -1 +1 @@
SHA512 (ocaml-num-1.1.tar.gz) = e7ee54e83eaab15ee879c5bb6deb0d76a3adf1ffd2cbd3f93cda63e7bc7b3a90313b94b4be078ecddaeee90a8a98a986d80c2fd6f1ad38faa35a318f77ec890e
SHA512 (v1.3.tar.gz) = c88310f8c45700990095e6b2e9abf24c27347711b9abfd1dde75e540fbbfc6a365e6713bd69f66009af305728fcb36dc61eb37fdd0be7d73824b0e92fbe8c031