git: 3b2ace437838 - main - textproc/htmlc: switch away from using unsafe strings for OCaml 4.06+.
Alexey Dokuchaev
danfe at FreeBSD.org
Fri Sep 3 04:41:13 UTC 2021
The branch main has been updated by danfe:
URL: https://cgit.FreeBSD.org/ports/commit/?id=3b2ace4378388235beb5a68a6ec136038f92e0b6
commit 3b2ace4378388235beb5a68a6ec136038f92e0b6
Author: Alexey Dokuchaev <danfe at FreeBSD.org>
AuthorDate: 2021-09-03 04:39:54 +0000
Commit: Alexey Dokuchaev <danfe at FreeBSD.org>
CommitDate: 2021-09-03 04:39:56 +0000
textproc/htmlc: switch away from using unsafe strings for OCaml 4.06+.
---
textproc/htmlc/Makefile | 5 +--
textproc/htmlc/files/patch-immutable-strings | 66 ++++++++++++++++++++++++++++
2 files changed, 68 insertions(+), 3 deletions(-)
diff --git a/textproc/htmlc/Makefile b/textproc/htmlc/Makefile
index 1fb60712a09e..8f9e848a13f9 100644
--- a/textproc/htmlc/Makefile
+++ b/textproc/htmlc/Makefile
@@ -12,14 +12,13 @@ COMMENT= Text file generator
BUILD_DEPENDS= ocamlc:lang/ocaml
USES= gmake tar:tgz
+HAS_CONFIGURE= yes
+CONFIGURE_ARGS= --prefix ${LOCALBASE}
PLIST_FILES= bin/htmlc bin/htmlc.byt share/htmlc/env
PORTDOCS= LICENSE INSTALL README JoeCaml.gif rocq.gif copyright-eng.htm \
copyright-fra.htm eng.htm fra.htm index.htm
-HAS_CONFIGURE= yes
-CONFIGURE_ARGS= --prefix ${LOCALBASE}
-
OPTIONS_DEFINE= DOCS
post-patch:
diff --git a/textproc/htmlc/files/patch-immutable-strings b/textproc/htmlc/files/patch-immutable-strings
new file mode 100644
index 000000000000..70f2ba5392b6
--- /dev/null
+++ b/textproc/htmlc/files/patch-immutable-strings
@@ -0,0 +1,66 @@
+--- compiler/execute.ml.orig 2009-02-19 20:28:11 UTC
++++ compiler/execute.ml
+@@ -18,11 +18,11 @@
+
+ let htmlc_command htmlc_add_string src_name ob command_name =
+ let ic = Unix.open_process_in command_name in
+- let ib = String.create Configuration.line_buffer_length in
++ let ib = Bytes.create Configuration.line_buffer_length in
+ let status =
+ let rec loop () =
+ let n = input ic ib 0 Configuration.line_buffer_length in
+- if n > 0 then (htmlc_add_string ob (String.sub ib 0 n); loop ())
++ if n > 0 then (htmlc_add_string ob (Bytes.sub_string ib 0 n); loop ())
+ else raise End_of_file in
+ try loop () with
+ | End_of_file ->
+--- compiler/htmlc.ml.orig 2009-08-13 14:27:53 UTC
++++ compiler/htmlc.ml
+@@ -236,11 +236,11 @@ let decimal_to_hexa i =
+ ;;
+
+ let hexa_char c =
+- let s = String.make 3 '%'
++ let s = Bytes.make 3 '%'
+ and i = int_of_char c in
+ s.[1] <- decimal_to_hexa (i / 16);
+ s.[2] <- decimal_to_hexa (i mod 16);
+- s
++ Bytes.to_string s
+ ;;
+
+ let url_encode ob s =
+--- compiler/lib_strings.ml.orig 2008-11-05 10:42:35 UTC
++++ compiler/lib_strings.ml
+@@ -95,25 +95,25 @@ let center_gen c s len_in =
+ let len_s = String.length s in
+ if len_in < len_s then not_enough_room "center" len_s len_in else
+ let idx = (len_in - len_s) / 2 in
+- let b = String.make len_in c in
++ let b = Bytes.make len_in c in
+ String.blit s 0 b idx len_s;
+- b;;
++ Bytes.to_string b;;
+ let center s len_in = center_gen ' ' s len_in;;
+
+ let flush_left_gen c s len_in =
+ let len_s = String.length s in
+ if len_in < len_s then not_enough_room "flush_left" len_s len_in else
+ let idx = 0 in
+- let b = String.make len_in c in
++ let b = Bytes.make len_in c in
+ String.blit s 0 b idx len_s;
+- b;;
++ Bytes.to_string b;;
+ let flush_left s len_in = flush_left_gen ' ' s len_in;;
+
+ let flush_right_gen c s len_in =
+ let len_s = String.length s in
+ if len_in < len_s then not_enough_room "flush_right" len_s len_in else
+ let idx = len_in - len_s in
+- let b = String.make len_in c in
++ let b = Bytes.make len_in c in
+ String.blit s 0 b idx len_s;
+- b;;
++ Bytes.to_string b;;
+ let flush_right s len_in = flush_right_gen ' ' s len_in;;
More information about the dev-commits-ports-all
mailing list