git: dd7c628b2137 - main - devel/cil: prepare for OCaml 4.06+ (strings are immutable by default)
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 07 Apr 2022 09:27:49 UTC
The branch main has been updated by danfe:
URL: https://cgit.FreeBSD.org/ports/commit/?id=dd7c628b2137da8f908fc858752c7e4622b6bbbf
commit dd7c628b2137da8f908fc858752c7e4622b6bbbf
Author: Alexey Dokuchaev <danfe@FreeBSD.org>
AuthorDate: 2022-04-07 09:26:36 +0000
Commit: Alexey Dokuchaev <danfe@FreeBSD.org>
CommitDate: 2022-04-07 09:26:36 +0000
devel/cil: prepare for OCaml 4.06+ (strings are immutable by default)
---
devel/cil/files/patch-ocamlutil_errormsg.ml | 25 +++++++++++++++++
devel/cil/files/patch-ocamlutil_pretty.ml | 43 +++++++++++++++++++++++++++++
devel/cil/files/patch-src_cil.ml | 23 +++++++++++++++
devel/cil/files/patch-src_formatlex.mll | 17 ++++++++++++
4 files changed, 108 insertions(+)
diff --git a/devel/cil/files/patch-ocamlutil_errormsg.ml b/devel/cil/files/patch-ocamlutil_errormsg.ml
new file mode 100644
index 000000000000..8faa3e27dd39
--- /dev/null
+++ b/devel/cil/files/patch-ocamlutil_errormsg.ml
@@ -0,0 +1,25 @@
+--- ocamlutil/errormsg.ml.orig 2013-07-24 15:07:11 UTC
++++ ocamlutil/errormsg.ml
+@@ -211,16 +211,17 @@ let cleanFileName str =
+ if str <> "" && String.get str 0 = '"' (* '"' ( *)
+ then rem_quotes str else str in
+ let l = String.length str1 in
++ let str1 = Bytes.of_string str1 in
+ let rec loop (copyto: int) (i: int) =
+ if i >= l then
+- String.sub str1 0 copyto
++ Bytes.to_string (Bytes.sub str1 0 copyto)
+ else
+- let c = String.get str1 i in
++ let c = Bytes.get str1 i in
+ if c <> '\\' then begin
+- String.set str1 copyto c; loop (copyto + 1) (i + 1)
++ Bytes.set str1 copyto c; loop (copyto + 1) (i + 1)
+ end else begin
+- String.set str1 copyto '/';
+- if i < l - 2 && String.get str1 (i + 1) = '\\' then
++ Bytes.set str1 copyto '/';
++ if i < l - 2 && Bytes.get str1 (i + 1) = '\\' then
+ loop (copyto + 1) (i + 2)
+ else
+ loop (copyto + 1) (i + 1)
diff --git a/devel/cil/files/patch-ocamlutil_pretty.ml b/devel/cil/files/patch-ocamlutil_pretty.ml
new file mode 100644
index 000000000000..96aa594f2abd
--- /dev/null
+++ b/devel/cil/files/patch-ocamlutil_pretty.ml
@@ -0,0 +1,43 @@
+--- ocamlutil/pretty.ml.orig 2013-07-24 15:07:11 UTC
++++ ocamlutil/pretty.ml
+@@ -725,31 +725,31 @@ let gprintf (finish : doc -> 'b)
+ invalid_arg ("dprintf: unimplemented format "
+ ^ (String.sub format i (j-i+1)));
+ let j' = succ j in (* eat the d,i,x etc. *)
+- let format_spec = "% " in
+- String.set format_spec 1 (fget j'); (* format_spec = "%x", etc. *)
++ let format_spec = Bytes.of_string "% " in
++ Bytes.set format_spec 1 (fget j'); (* format_spec = "%x", etc. *)
+ Obj.magic(fun n ->
+ collect (dctext1 acc
+- (Int64.format format_spec n))
++ (Int64.format (Bytes.to_string format_spec) n))
+ (succ j'))
+ | 'l' ->
+ if j != i + 1 then invalid_arg ("dprintf: unimplemented format "
+ ^ (String.sub format i (j-i+1)));
+ let j' = succ j in (* eat the d,i,x etc. *)
+- let format_spec = "% " in
+- String.set format_spec 1 (fget j'); (* format_spec = "%x", etc. *)
++ let format_spec = Bytes.of_string "% " in
++ Bytes.set format_spec 1 (fget j'); (* format_spec = "%x", etc. *)
+ Obj.magic(fun n ->
+ collect (dctext1 acc
+- (Int32.format format_spec n))
++ (Int32.format (Bytes.to_string format_spec) n))
+ (succ j'))
+ | 'n' ->
+ if j != i + 1 then invalid_arg ("dprintf: unimplemented format "
+ ^ (String.sub format i (j-i+1)));
+ let j' = succ j in (* eat the d,i,x etc. *)
+- let format_spec = "% " in
+- String.set format_spec 1 (fget j'); (* format_spec = "%x", etc. *)
++ let format_spec = Bytes.of_string "% " in
++ Bytes.set format_spec 1 (fget j'); (* format_spec = "%x", etc. *)
+ Obj.magic(fun n ->
+ collect (dctext1 acc
+- (Nativeint.format format_spec n))
++ (Nativeint.format (Bytes.to_string format_spec) n))
+ (succ j'))
+ | 'f' | 'e' | 'E' | 'g' | 'G' ->
+ Obj.magic(fun f ->
diff --git a/devel/cil/files/patch-src_cil.ml b/devel/cil/files/patch-src_cil.ml
new file mode 100644
index 000000000000..f2be5cf6eda5
--- /dev/null
+++ b/devel/cil/files/patch-src_cil.ml
@@ -0,0 +1,23 @@
+--- src/cil.ml.orig 2013-07-24 15:07:11 UTC
++++ src/cil.ml
+@@ -5033,7 +5033,7 @@ let loadBinaryFile (filename : string) : file =
+ (* Take the name of a file and make a valid symbol name out of it. There are
+ * a few characters that are not valid in symbols *)
+ let makeValidSymbolName (s: string) =
+- let s = String.copy s in (* So that we can update in place *)
++ let b = Bytes.copy (Bytes.of_string s) in (* So that we can update in place *)
+ let l = String.length s in
+ for i = 0 to l - 1 do
+ let c = String.get s i in
+@@ -5043,9 +5043,9 @@ let makeValidSymbolName (s: string) =
+ | _ -> false
+ in
+ if isinvalid then
+- String.set s i '_';
++ Bytes.set b i '_';
+ done;
+- s
++ Bytes.to_string b
+
+ let rec addOffset (toadd: offset) (off: offset) : offset =
+ match off with
diff --git a/devel/cil/files/patch-src_formatlex.mll b/devel/cil/files/patch-src_formatlex.mll
new file mode 100644
index 000000000000..c1045cac852d
--- /dev/null
+++ b/devel/cil/files/patch-src_formatlex.mll
@@ -0,0 +1,17 @@
+--- src/formatlex.mll.orig 2013-07-24 15:07:11 UTC
++++ src/formatlex.mll
+@@ -145,11 +145,11 @@ let scan_oct_escape str =
+ * We convert L"Hi" to "H\000i\000" *)
+ let wbtowc wstr =
+ let len = String.length wstr in
+- let dest = String.make (len * 2) '\000' in
++ let dest = Bytes.make (len * 2) '\000' in
+ for i = 0 to len-1 do
+- dest.[i*2] <- wstr.[i] ;
++ Bytes.set dest (i*2) (String.get wstr i)
+ done ;
+- dest
++ Bytes.to_string dest
+
+ (* This function converst the "Hi" in L"Hi" to { L'H', L'i', L'\0' } *)
+ let wstr_to_warray wstr =