pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/graphics/camlimages graphics/camlimages: make it build...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/5b167d826460
branches:  trunk
changeset: 771751:5b167d826460
user:      dholland <dholland%pkgsrc.org@localhost>
date:      Sun Dec 26 05:28:23 2021 +0000

description:
graphics/camlimages: make it build again

Hasn't in a long time, so no PKGREVISION bump (it's at 96!)

It is fairly likely that these changes and/or OCaml internal changes
regarding immutable strings have changed the behavior if you abuse
internal interfaces or try to share graphics memory with the library
and scribble on it. Don't do that.

There are probably more data copies as well (meaning "slow") but I've
tried to avoid that as much as possible.

diffstat:

 graphics/camlimages/distinfo                                |   50 +-
 graphics/camlimages/patches/patch-examples_crop_crop.ml     |   15 +
 graphics/camlimages/patches/patch-examples_liv_icon.ml      |   17 +
 graphics/camlimages/patches/patch-examples_liv_livsh.ml     |   21 +
 graphics/camlimages/patches/patch-examples_liv_livshtype.ml |   15 +
 graphics/camlimages/patches/patch-examples_liv_scandir.ml   |   16 +
 graphics/camlimages/patches/patch-examples_tiffps_tiffps.ml |   57 ++
 graphics/camlimages/patches/patch-src_bitmap.ml             |  268 ++++++++++++
 graphics/camlimages/patches/patch-src_bitmap.mli            |   26 +
 graphics/camlimages/patches/patch-src_bmp.ml                |  237 ++++++++++
 graphics/camlimages/patches/patch-src_bmp.mli               |   15 +
 graphics/camlimages/patches/patch-src_cmyk32.ml             |   33 +
 graphics/camlimages/patches/patch-src_cmyk32.mli            |   15 +
 graphics/camlimages/patches/patch-src_genimage.ml           |   35 +
 graphics/camlimages/patches/patch-src_gif.ml                |   99 ++++
 graphics/camlimages/patches/patch-src_gif.mli               |   15 +
 graphics/camlimages/patches/patch-src_gifread.c             |   46 +-
 graphics/camlimages/patches/patch-src_gifwrite.c            |   38 +-
 graphics/camlimages/patches/patch-src_image__intf.mli       |   53 ++
 graphics/camlimages/patches/patch-src_imagegdk.ml           |   34 +
 graphics/camlimages/patches/patch-src_images.ml             |   15 +
 graphics/camlimages/patches/patch-src_index16.ml            |   25 +
 graphics/camlimages/patches/patch-src_index16.mli           |   15 +
 graphics/camlimages/patches/patch-src_index8.ml             |   29 +
 graphics/camlimages/patches/patch-src_index8.mli            |   16 +
 graphics/camlimages/patches/patch-src_jpeg.ml               |  162 +++++++
 graphics/camlimages/patches/patch-src_jpeg.mli              |   15 +
 graphics/camlimages/patches/patch-src_jpegread.c            |   69 ++-
 graphics/camlimages/patches/patch-src_jpegwrite.c           |   46 ++
 graphics/camlimages/patches/patch-src_mstring.ml            |   75 +++
 graphics/camlimages/patches/patch-src_oImages.ml            |   15 +
 graphics/camlimages/patches/patch-src_oImages.mli           |   15 +
 graphics/camlimages/patches/patch-src_png.ml                |   68 +++
 graphics/camlimages/patches/patch-src_rgb24.ml              |   37 +
 graphics/camlimages/patches/patch-src_rgb24.mli             |   22 +
 graphics/camlimages/patches/patch-src_rgba32.ml             |   33 +
 graphics/camlimages/patches/patch-src_rgba32.mli            |   15 +
 graphics/camlimages/patches/patch-src_tiff.ml               |   77 +++
 graphics/camlimages/patches/patch-src_tiff.mli              |   15 +
 graphics/camlimages/patches/patch-src_tiffread.c            |   86 ++-
 graphics/camlimages/patches/patch-src_tiffwrite.c           |   54 +-
 graphics/camlimages/patches/patch-src_units.ml              |   15 +
 graphics/camlimages/patches/patch-src_xpm.ml                |   52 ++
 graphics/camlimages/patches/patch-src_xvthumb.ml            |   48 ++
 44 files changed, 2052 insertions(+), 72 deletions(-)

diffs (truncated from 2386 to 300 lines):

diff -r 1b5774bec0ae -r 5b167d826460 graphics/camlimages/distinfo
--- a/graphics/camlimages/distinfo      Sun Dec 26 05:27:37 2021 +0000
+++ b/graphics/camlimages/distinfo      Sun Dec 26 05:28:23 2021 +0000
@@ -1,13 +1,51 @@
-$NetBSD: distinfo,v 1.18 2021/10/26 10:46:01 nia Exp $
+$NetBSD: distinfo,v 1.19 2021/12/26 05:28:23 dholland Exp $
 
 BLAKE2s (camlimages-4.0.1a/v4.0.1.tar.gz) = 0d8e3e7a10f89ff6afd5161a840ea9951a563daf8388f2717d2f75257b6276d4
 SHA512 (camlimages-4.0.1a/v4.0.1.tar.gz) = c4e2a816911ed128c0414308d1ace914bbb51e40b6d70a3c492690b38c860f79e3e01efa3f1be7d57654c78f8acca6f30bffb9e6b8fd423d1d36d6a477d0fd8d
 Size (camlimages-4.0.1a/v4.0.1.tar.gz) = 2190274 bytes
 SHA1 (patch-OMakefile) = f650eca9bf8edbc64f9f5352718ee2046c368667
-SHA1 (patch-src_gifread.c) = 63aac1a76e809676f0000f37af63c79c4edbe316
-SHA1 (patch-src_gifwrite.c) = ab92107467b059d9541edacf60a5f73ed71fd687
-SHA1 (patch-src_jpegread.c) = 2b32040ce34218437bb4947d8a87fe2b840223b4
+SHA1 (patch-examples_crop_crop.ml) = 52d7fc9c39c394ecac22fe3d401aaef73c64b50d
+SHA1 (patch-examples_liv_icon.ml) = 29e1a5b7325f0b468dc76291563697ae301de664
+SHA1 (patch-examples_liv_livsh.ml) = b804ef21be7e55b3c63011f614cc1e3e6902cb16
+SHA1 (patch-examples_liv_livshtype.ml) = 9b1ef9063955b243162336b527c94cf74d9c46cc
+SHA1 (patch-examples_liv_scandir.ml) = 7579833c57347acd3520a4905696e0a6edbaf7ab
+SHA1 (patch-examples_tiffps_tiffps.ml) = ed9b8cafbd4ebd7a09270c5983f01a683da151a3
+SHA1 (patch-src_bitmap.ml) = 763d7e6ac20142e4bb97b7e154bc1eebc4acf8c8
+SHA1 (patch-src_bitmap.mli) = d1e3cb5521028d18992be2a581692062b69e3765
+SHA1 (patch-src_bmp.ml) = e2c18f97e675b5c51b783fbc8e585b9549e09d8c
+SHA1 (patch-src_bmp.mli) = b56b5a6e7ed02714fe530f31d10bb2ac8a06eb44
+SHA1 (patch-src_cmyk32.ml) = 2cbc055ee1bad6f8d3789f32f8ff5c47f0c22dfc
+SHA1 (patch-src_cmyk32.mli) = 4ba75d4520538581882b832c09a1c708a904719d
+SHA1 (patch-src_genimage.ml) = d9de0188a077f89045c819e8f638db7a28c0449f
+SHA1 (patch-src_gif.ml) = 05c3970e16de2dbca0fb35a5e778d3a4fd91b92e
+SHA1 (patch-src_gif.mli) = 07c8422510de110f22d27edae20228780f57e532
+SHA1 (patch-src_gifread.c) = 917730ca374bcf258cd86e2d1608d22467ac3ec2
+SHA1 (patch-src_gifwrite.c) = 555f5221ffa3a5e3bd5f59b1e6e3cc3f6b6ac80f
+SHA1 (patch-src_image__intf.mli) = 784ada5f15c0a13c367f98e9e01275719a67012f
+SHA1 (patch-src_imagegdk.ml) = 1a3e79fb72b475985dd9460870bceb6b20d4d67e
+SHA1 (patch-src_images.ml) = 95182ba6a8d7184ed4e6937a3c584406bea553d8
+SHA1 (patch-src_index16.ml) = dbef2ab65fc3b1c6a4b8a982c7f2767507c16d42
+SHA1 (patch-src_index16.mli) = 6fe184ae5c65f1438f8e8317cc9162e3b27eb173
+SHA1 (patch-src_index8.ml) = 298c22edebcc40db3f48f832482af3a910a69fef
+SHA1 (patch-src_index8.mli) = 3d6121e5758aeedef6aa39ecb717669cc85d35cc
+SHA1 (patch-src_jpeg.ml) = 4b87eb4ffc0b41e3bcac077e436f4629af79a885
+SHA1 (patch-src_jpeg.mli) = 0541546c398bbf54a04cab41fe27ca804407301e
+SHA1 (patch-src_jpegread.c) = a0cf27be87c288bd990d8060ab56974064337e46
+SHA1 (patch-src_jpegwrite.c) = acafaace41c8b69d6f0f71e7e0ebf3311dbf8e33
+SHA1 (patch-src_mstring.ml) = 84ec525bd572ea1a5d44869c4f5a4afc6ae94d2e
+SHA1 (patch-src_oImages.ml) = 40d0b13cfa54647da850172142c054576a8ce073
+SHA1 (patch-src_oImages.mli) = 0b6290c409eadf60ee3dcece8895dbab90ae36be
+SHA1 (patch-src_png.ml) = 613dc0b5bace73423f3ccad0f393881220fcc877
 SHA1 (patch-src_pngread.c) = 00d753b8570b5ff9ffa71e6e62328496b03f9654
 SHA1 (patch-src_pngwrite.c) = 4df4f69851769e0eefc2249a30ac8dd53aa8d755
-SHA1 (patch-src_tiffread.c) = 4dab0fe8da42fe7d0720d5edddf45743c7fa41fd
-SHA1 (patch-src_tiffwrite.c) = 2bc3de2b56a8f8d46fac3ac8d7c1b9ae9c4bd52c
+SHA1 (patch-src_rgb24.ml) = 9b30ac9f92992e30e0dc33fe4f0b09fffc4504d5
+SHA1 (patch-src_rgb24.mli) = 8a9e765a8b9c787796c7f7f3effc9d7fe542c32b
+SHA1 (patch-src_rgba32.ml) = 00ad9906236c1f85e79d26cab68f76f541f9aba5
+SHA1 (patch-src_rgba32.mli) = 4cb8e6b36d463c019299a9553a5622e6a4f22edf
+SHA1 (patch-src_tiff.ml) = a668e0a414121ba566d270eede9c4a0213419d54
+SHA1 (patch-src_tiff.mli) = 51938d692d0589134c9ef5bdd4ca25013fc74406
+SHA1 (patch-src_tiffread.c) = 42e5891b57bf46705a597d1515016e6fe84e65fe
+SHA1 (patch-src_tiffwrite.c) = c35f55594ab56373dd0f00d55c125209f7a88377
+SHA1 (patch-src_units.ml) = 65f6b69092f2618756848ad7291432c84a230bce
+SHA1 (patch-src_xpm.ml) = f5eee2983770100f1f7999c1c2fbb6e1155b83cf
+SHA1 (patch-src_xvthumb.ml) = b1142f4aae2e1692ec4b6fe25633fc84aeff604f
diff -r 1b5774bec0ae -r 5b167d826460 graphics/camlimages/patches/patch-examples_crop_crop.ml
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics/camlimages/patches/patch-examples_crop_crop.ml   Sun Dec 26 05:28:23 2021 +0000
@@ -0,0 +1,15 @@
+$NetBSD: patch-examples_crop_crop.ml,v 1.1 2021/12/26 05:28:23 dholland Exp $
+
+Update for immutable strings.
+
+--- examples/crop/crop.ml~     2011-06-22 18:04:32.000000000 +0000
++++ examples/crop/crop.ml
+@@ -46,7 +46,7 @@ let edge edgename img24 =
+     match edgename with
+     | Some _ ->
+         Some (new rgb24_with img24#width img24#height
+-                [] (String.copy img24#dump))
++                [] img24#dump)
+     | None -> None in
+   let edge = Array.init img24#width (fun _ -> Array.create img24#height 0) in
+ 
diff -r 1b5774bec0ae -r 5b167d826460 graphics/camlimages/patches/patch-examples_liv_icon.ml
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics/camlimages/patches/patch-examples_liv_icon.ml    Sun Dec 26 05:28:23 2021 +0000
@@ -0,0 +1,17 @@
+$NetBSD: patch-examples_liv_icon.ml,v 1.1 2021/12/26 05:28:23 dholland Exp $
+
+Use "Stdlib" instead of "Pervasives".
+
+--- examples/liv/icon.ml~      2011-06-22 18:04:32.000000000 +0000
++++ examples/liv/icon.ml
+@@ -98,8 +98,8 @@ let create_livthumb name =
+       | Rgb24 i -> i
+       | _ -> assert false in
+     img#resize None
+-      (Pervasives.truncate (float w *. ratio))
+-      (Pervasives.truncate (float h *. ratio)) in
++      (Stdlib.truncate (float w *. ratio))
++      (Stdlib.truncate (float h *. ratio)) in
+   img#save thumbpath (Some Jpeg) [Save_Quality 75];
+   img#destroy;;
+ 
diff -r 1b5774bec0ae -r 5b167d826460 graphics/camlimages/patches/patch-examples_liv_livsh.ml
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics/camlimages/patches/patch-examples_liv_livsh.ml   Sun Dec 26 05:28:23 2021 +0000
@@ -0,0 +1,21 @@
+$NetBSD: patch-examples_liv_livsh.ml,v 1.1 2021/12/26 05:28:23 dholland Exp $
+
+Sort.list is so old it's not even in the deprecations section of the
+manual any more. Use List.sort.
+
+--- examples/liv/livsh.ml~     2011-06-22 18:04:32.000000000 +0000
++++ examples/liv/livsh.ml
+@@ -365,10 +365,10 @@ class livsh init_dir func =
+         | "special", "lnkdir" -> 0
+         | "special", _ -> 10
+         | _ -> 100 in
+-      if typval a = typval b then a#name < b#name
+-      else typval a < typval b in
++      if typval a = typval b then compare a#name b#name
++      else compare (typval a) (typval b) in
+ 
+-    items <-  Sort.list sortf items_unsort;
++    items <-  List.sort sortf items_unsort;
+     self#set_text "";
+     self#deactivate ()
+ 
diff -r 1b5774bec0ae -r 5b167d826460 graphics/camlimages/patches/patch-examples_liv_livshtype.ml
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics/camlimages/patches/patch-examples_liv_livshtype.ml       Sun Dec 26 05:28:23 2021 +0000
@@ -0,0 +1,15 @@
+$NetBSD: patch-examples_liv_livshtype.ml,v 1.1 2021/12/26 05:28:23 dholland Exp $
+
+Silence nuisance warning about lowercase.
+
+--- examples/liv/livshtype.ml~ 2011-06-22 18:04:32.000000000 +0000
++++ examples/liv/livshtype.ml
+@@ -119,7 +119,7 @@ let guess link_as_link f =
+       try from_header f
+       with
+       | _ ->
+-        Hashtbl.find suffixes (String.lowercase (snd (Livmisc.get_extension f)))
++        Hashtbl.find suffixes (String.lowercase_ascii (snd (Livmisc.get_extension f)))
+     end;;
+ 
+ let guess = guess false
diff -r 1b5774bec0ae -r 5b167d826460 graphics/camlimages/patches/patch-examples_liv_scandir.ml
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics/camlimages/patches/patch-examples_liv_scandir.ml Sun Dec 26 05:28:23 2021 +0000
@@ -0,0 +1,16 @@
+$NetBSD: patch-examples_liv_scandir.ml,v 1.1 2021/12/26 05:28:23 dholland Exp $
+
+Sort.list is so old it's not even in the deprecations section of the
+manual any more. Use List.sort.
+
+--- examples/liv/scandir.ml~   2011-06-22 18:04:32.000000000 +0000
++++ examples/liv/scandir.ml
+@@ -31,7 +31,7 @@ let scan_dir f fn =
+         | e -> prerr_endline ("readdir: " ^ Printexc.to_string e)
+       end;
+       closedir dh;
+-      let files = Sort.list (>) !files in
++      let files = List.sort (fun x y -> -compare x y) !files in
+       let subdirs = ref [] in
+       let treat fn' =
+         if not (fn' = ".." || fn' = ".") then begin
diff -r 1b5774bec0ae -r 5b167d826460 graphics/camlimages/patches/patch-examples_tiffps_tiffps.ml
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics/camlimages/patches/patch-examples_tiffps_tiffps.ml       Sun Dec 26 05:28:23 2021 +0000
@@ -0,0 +1,57 @@
+$NetBSD: patch-examples_tiffps_tiffps.ml,v 1.1 2021/12/26 05:28:23 dholland Exp $
+
+Update for immutable strings.
+
+Silence nuisance warning about lowercase.
+
+--- examples/tiffps/tiffps.ml~ 2011-06-22 18:04:32.000000000 +0000
++++ examples/tiffps/tiffps.ml
+@@ -51,7 +51,7 @@ let parse_length s = (* return in pt *)
+     let digit, unit =
+       if l > 2 then String.sub s 0 2, String.sub s (l-2) 2 else "", "" in
+     try
+-      List.assoc (String.lowercase unit) units *. float_of_string digit
++      List.assoc (String.lowercase_ascii unit) units *. float_of_string digit
+     with
+     | Not_found -> (* think it is in "pt" *) float_of_string s in
+   prerr_endline (Printf.sprintf "%s -> %fpt" s v);
+@@ -59,7 +59,7 @@ let parse_length s = (* return in pt *)
+ 
+ (* Scanlined loader *)
+ type scanlined_loader = {
+-    read_next_line: (string -> unit);
++    read_next_line: (Bytes.t -> unit);
+     close: (unit -> unit)
+   };;
+ 
+@@ -396,7 +396,7 @@ let main () =
+       p "{ currentfile scanline readhexstring pop } false 3";
+       p "colorimage";
+ 
+-      let buf = String.create (imgw * 3) in
++      let buf = Bytes.create (imgw * 3) in
+       for y = 0 to y1 - 1 do th.read_next_line buf done;
+       let prevperdec = ref (-1) in
+       for y = y1 to y1 + h - 1 do
+@@ -411,7 +411,7 @@ let main () =
+             function x ->
+               let adrs = x * 3 in
+               for i = 0 to 2 do
+-                print_string (sprintf "%02x" (Char.code buf.[adrs+i]))
++                print_string (sprintf "%02x" (Char.code (Bytes.get buf (adrs+i))))
+               done
+           else
+             let mono r g b =
+@@ -419,9 +419,9 @@ let main () =
+             function x ->
+               let adrs = x * 3 in
+               let m =
+-                mono (Char.code buf.[adrs])
+-                     (Char.code buf.[adrs + 1])
+-                     (Char.code buf.[adrs + 2]) in
++                mono (Char.code (Bytes.get buf (adrs)))
++                     (Char.code (Bytes.get buf (adrs + 1)))
++                     (Char.code (Bytes.get buf (adrs + 2))) in
+               for i = 0 to 2 do print_string (sprintf "%02x" m) done in
+         if not conf.mirror
+         then for x = x1 to x1 + w - 1 do print_pixel x done
diff -r 1b5774bec0ae -r 5b167d826460 graphics/camlimages/patches/patch-src_bitmap.ml
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics/camlimages/patches/patch-src_bitmap.ml   Sun Dec 26 05:28:23 2021 +0000
@@ -0,0 +1,268 @@
+$NetBSD: patch-src_bitmap.ml,v 1.1 2021/12/26 05:28:23 dholland Exp $
+
+Update for immutable strings.
+
+Sort.list is so old it's not even in the deprecations section of the
+manual any more. Use List.sort.
+
+--- src/bitmap.ml.orig 2011-06-22 18:04:32.000000000 +0000
++++ src/bitmap.ml
+@@ -20,7 +20,7 @@ let maximum_block_size = ref (!maximum_l
+ (* see Temp to set temp file directory *)
+ 
+ type block_data =
+-   | InMemory of string
++   | InMemory of Bytes.t
+    | Swapped
+    | Destroyed;;
+ 
+@@ -35,9 +35,9 @@ type block = {
+ 
+ let swappable_blocks = ref [];;
+ 
+-(* wrapped String.create *)
+-let string_create s =
+-  try String.create s with Invalid_argument _ -> raise Out_of_memory;;
++(* wrapped Bytes.create *)
++let bytes_create s =
++  try Bytes.create s with Invalid_argument _ -> raise Out_of_memory;;
+ 
+ module Block = struct
+   type t = {
+@@ -67,7 +67,7 @@ module Make(B:Bitdepth) = struct
+     blocks_x : int;
+     blocks_y : int;
+     data : block array array;
+-    access : int -> int -> (string * int);
++    access : int -> int -> (Bytes.t * int);
+     };;
+ 
+   (****************************************************************************)
+@@ -92,20 +92,20 @@ module Make(B:Bitdepth) = struct
+            if blk == blk' then st else blk' :: st)
+         !swappable_blocks [];;
+ 
+-  let fill_string buf init =
+-    (* fill string with init quickly (hopefully) *)
+-    let fulllength = String.length buf in
++  let fill_bytes (buf: Bytes.t) (init: string) =
++    (* fill a Bytes with init quickly (hopefully) *)
++    let fulllength = Bytes.length buf in
+     let halflength = fulllength / 2 in
+     let rec sub = function
+       | 0 ->
+         let len = String.length init in
+-        String.unsafe_blit init 0 buf 0 len;
++        Bytes.unsafe_blit_string init 0 buf 0 len;
+         sub len
+       | x when x <= halflength ->
+-        String.unsafe_blit buf 0 buf x x;
++        Bytes.unsafe_blit buf 0 buf x x;
+         sub (x * 2)
+       | x (* when x > halflength *) ->
+-        String.unsafe_blit buf 0 buf x (fulllength - x) in
++        Bytes.unsafe_blit buf 0 buf x (fulllength - x) in
+     sub 0;;
+ 
+   let check_init init =
+@@ -115,7 +115,7 @@ module Make(B:Bitdepth) = struct
+         then failwith "bitmap fill value is incorrect"
+     | None -> ();;



Home | Main Index | Thread Index | Old Index