[Pkg-ocaml-maint-commits] [pgocaml] 01/05: Imported Upstream version 2.2

Mehdi Dogguy mehdi at moszumanska.debian.org
Sun Jan 17 22:58:07 UTC 2016


This is an automated email from the git hooks/post-receive script.

mehdi pushed a commit to branch master
in repository pgocaml.

commit 0ec0ee8a976a8d06fab5d2cb9d4419eda4dc97f8
Author: Mehdi Dogguy <mehdi at debian.org>
Date:   Sun Jan 17 23:39:12 2016 +0100

    Imported Upstream version 2.2
---
 CHANGELOG.txt           |   8 ++
 _oasis                  |  12 +--
 _tags                   |  51 ++++++++-----
 myocamlbuild.ml         |  88 ++++++++++++---------
 setup.ml                | 198 ++++++++++++++++++++++++++++--------------------
 src/META                |   8 +-
 src/PGOCaml_aux.ml      |  17 +++--
 src/PGOCaml_aux.mli     |   2 +-
 src/PGOCaml_generic.ml  |  40 ++++------
 src/PGOCaml_generic.mli |   2 +-
 10 files changed, 245 insertions(+), 181 deletions(-)

diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 358915a..66e7fb5 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,3 +1,11 @@
+Release 2.2
+===========
+
+* Jacques-Pascal Deplaix: Use Bytes instead of String when mutation
+  is required.
+* Jacques-Pascal Deplaix: fix bug in AuthenticationCryptPassword.
+
+
 Release 2.1
 ===========
 
diff --git a/_oasis b/_oasis
index ed69d46..bbdf288 100644
--- a/_oasis
+++ b/_oasis
@@ -1,12 +1,12 @@
-OASISFormat:		0.3
+OASISFormat:		0.4
 Name:			PG'OCaml
-Version:		2.1
+Version:		2.2
 Synopsis:		OCaml bindings for the PostgreSQL database
 Authors:		Richard W. M. Jones et al.
 Maintainers:		Dario Teixeira
 License:		LGPL-2.0 with OCaml linking exception
 LicenseFile:		LICENSE.txt
-Plugins:		META (0.3), DevFiles (0.3)
+Plugins:		META (0.4), DevFiles (0.4)
 BuildTools:		ocamlbuild, make, camlp4
 PreBuildCommand:	$make config
 
@@ -17,9 +17,9 @@ Flag "pgprof"
 Library "pgocaml"
   Path:			src
   Modules:		PGOCaml_aux, PGOCaml, PGOCaml_generic, PGOCaml_config
-  BuildDepends:		unix, calendar, csv, pcre
+  BuildDepends:		unix, calendar, csv, pcre, bytes
   FindlibName:		pgocaml
-  XMETARequires:	unix, calendar, csv, pcre
+  XMETARequires:	unix, calendar, csv, pcre, bytes
 
 Library "pa_pgsql"
   Path:			src
@@ -36,7 +36,7 @@ Document "APIDOC"
   Install:		true
   InstallDir:		$htmldir
   Title:		API reference for PG'OCaml
-  Type:			ocamlbuild (0.3)
+  Type:			ocamlbuild (0.4)
   BuildTools+:		ocamldoc
   XOCamlbuildPath:	src
   XOCamlbuildLibraries:	pgocaml
diff --git a/_tags b/_tags
index f6b3968..b1b74dd 100644
--- a/_tags
+++ b/_tags
@@ -1,8 +1,9 @@
 # OASIS_START
-# DO NOT EDIT (digest: 3857d58a649db5119e8a9082760b68c2)
+# DO NOT EDIT (digest: 2195434e610096d70cae76da7908ab60)
 # Ignore VCS directories, you can use the same kind of rule outside
 # OASIS_START/STOP if you want to exclude directories that contains
 # useless stuff for the build process
+true: annot, bin_annot
 <**/.svn>: -traverse
 <**/.svn>: not_hygienic
 ".bzr": -traverse
@@ -17,31 +18,36 @@
 "src/pgocaml.cmxs": use_pgocaml
 # Library pa_pgsql
 "src/pa_pgsql.cmxs": use_pa_pgsql
-<src/*.ml{,i}>: pkg_calendar
-<src/*.ml{,i}>: pkg_camlp4.extend
-<src/*.ml{,i}>: pkg_camlp4.quotations
-<src/*.ml{,i}>: pkg_csv
-<src/*.ml{,i}>: pkg_pcre
-<src/*.ml{,i}>: pkg_unix
-<src/*.ml{,i}>: use_pgocaml
+<src/*.ml{,i,y}>: pkg_bytes
+<src/*.ml{,i,y}>: pkg_calendar
+<src/*.ml{,i,y}>: pkg_camlp4.extend
+<src/*.ml{,i,y}>: pkg_camlp4.quotations
+<src/*.ml{,i,y}>: pkg_csv
+<src/*.ml{,i,y}>: pkg_pcre
+<src/*.ml{,i,y}>: pkg_unix
+<src/*.ml{,i,y}>: use_pgocaml
 # Executable pgocaml_prof
+"utils/pgocaml_prof.byte": pkg_bytes
 "utils/pgocaml_prof.byte": pkg_calendar
 "utils/pgocaml_prof.byte": pkg_csv
 "utils/pgocaml_prof.byte": pkg_pcre
 "utils/pgocaml_prof.byte": pkg_unix
 "utils/pgocaml_prof.byte": use_pgocaml
-<utils/*.ml{,i}>: pkg_calendar
-<utils/*.ml{,i}>: pkg_csv
-<utils/*.ml{,i}>: pkg_pcre
-<utils/*.ml{,i}>: pkg_unix
-<utils/*.ml{,i}>: use_pgocaml
+<utils/*.ml{,i,y}>: pkg_bytes
+<utils/*.ml{,i,y}>: pkg_calendar
+<utils/*.ml{,i,y}>: pkg_csv
+<utils/*.ml{,i,y}>: pkg_pcre
+<utils/*.ml{,i,y}>: pkg_unix
+<utils/*.ml{,i,y}>: use_pgocaml
 # Executable test_pgocaml_lowlevel
+"tests/test_pgocaml_lowlevel.byte": pkg_bytes
 "tests/test_pgocaml_lowlevel.byte": pkg_calendar
 "tests/test_pgocaml_lowlevel.byte": pkg_csv
 "tests/test_pgocaml_lowlevel.byte": pkg_pcre
 "tests/test_pgocaml_lowlevel.byte": pkg_unix
 "tests/test_pgocaml_lowlevel.byte": use_pgocaml
 # Executable test_pgocaml_highlevel
+"tests/test_pgocaml_highlevel.byte": pkg_bytes
 "tests/test_pgocaml_highlevel.byte": pkg_calendar
 "tests/test_pgocaml_highlevel.byte": pkg_camlp4.extend
 "tests/test_pgocaml_highlevel.byte": pkg_camlp4.quotations
@@ -50,14 +56,17 @@
 "tests/test_pgocaml_highlevel.byte": pkg_unix
 "tests/test_pgocaml_highlevel.byte": use_pa_pgsql
 "tests/test_pgocaml_highlevel.byte": use_pgocaml
-<tests/*.ml{,i}>: pkg_calendar
-<tests/*.ml{,i}>: pkg_camlp4.extend
-<tests/*.ml{,i}>: pkg_camlp4.quotations
-<tests/*.ml{,i}>: pkg_csv
-<tests/*.ml{,i}>: pkg_pcre
-<tests/*.ml{,i}>: pkg_unix
-<tests/*.ml{,i}>: use_pa_pgsql
-<tests/*.ml{,i}>: use_pgocaml
+<tests/*.ml{,i,y}>: pkg_bytes
+<tests/*.ml{,i,y}>: pkg_calendar
+<tests/*.ml{,i,y}>: pkg_camlp4.extend
+<tests/*.ml{,i,y}>: pkg_camlp4.quotations
+<tests/*.ml{,i,y}>: pkg_csv
+<tests/*.ml{,i,y}>: pkg_pcre
+<tests/*.ml{,i,y}>: pkg_unix
+<tests/*.ml{,i,y}>: use_pa_pgsql
+<tests/*.ml{,i,y}>: use_pgocaml
 # OASIS_STOP
 <src/pa_pgsql.ml>: syntax_camlp4o
 <tests/test_pgocaml_highlevel.ml>: syntax_camlp4o, pkg_pgocaml.syntax
+
+true: safe_string
diff --git a/myocamlbuild.ml b/myocamlbuild.ml
index 174291a..c65fb7e 100644
--- a/myocamlbuild.ml
+++ b/myocamlbuild.ml
@@ -1,5 +1,5 @@
 (* OASIS_START *)
-(* DO NOT EDIT (digest: 43d333dec891efc29775898a6cd6223d) *)
+(* DO NOT EDIT (digest: f841356cd28294705cfe988a752cc54d) *)
 module OASISGettext = struct
 (* # 22 "src/oasis/OASISGettext.ml" *)
 
@@ -249,6 +249,9 @@ module MyOCamlbuildFindlib = struct
     *)
   open Ocamlbuild_plugin
 
+  type conf =
+    { no_automatic_syntax: bool;
+    }
 
   (* these functions are not really officially exported *)
   let run_and_read =
@@ -315,7 +318,7 @@ module MyOCamlbuildFindlib = struct
 
   (* This lists all supported packages. *)
   let find_packages () =
-    List.map before_space (split_nl & run_and_read "ocamlfind list")
+    List.map before_space (split_nl & run_and_read (exec_from_conf "ocamlfind" ^ " list"))
 
 
   (* Mock to list available syntaxes. *)
@@ -338,7 +341,7 @@ module MyOCamlbuildFindlib = struct
   ]
 
 
-  let dispatch =
+  let dispatch conf =
     function
       | After_options ->
           (* By using Before_options one let command line options have an higher
@@ -357,31 +360,39 @@ module MyOCamlbuildFindlib = struct
            * -linkpkg *)
           flag ["ocaml"; "link"; "program"] & A"-linkpkg";
 
-          (* For each ocamlfind package one inject the -package option when
-           * compiling, computing dependencies, generating documentation and
-           * linking. *)
-          List.iter
-            begin fun pkg ->
-              let base_args = [A"-package"; A pkg] in
-              (* TODO: consider how to really choose camlp4o or camlp4r. *)
-              let syn_args = [A"-syntax"; A "camlp4o"] in
-              let args =
-              (* Heuristic to identify syntax extensions: whether they end in
-                 ".syntax"; some might not.
-               *)
-                if Filename.check_suffix pkg "syntax" ||
-                   List.mem pkg well_known_syntax then
-                  syn_args @ base_args
-                else
-                  base_args
-              in
-              flag ["ocaml"; "compile";  "pkg_"^pkg] & S args;
-              flag ["ocaml"; "ocamldep"; "pkg_"^pkg] & S args;
-              flag ["ocaml"; "doc";      "pkg_"^pkg] & S args;
-              flag ["ocaml"; "link";     "pkg_"^pkg] & S base_args;
-              flag ["ocaml"; "infer_interface"; "pkg_"^pkg] & S args;
-            end
-            (find_packages ());
+          if not (conf.no_automatic_syntax) then begin
+            (* For each ocamlfind package one inject the -package option when
+             * compiling, computing dependencies, generating documentation and
+             * linking. *)
+            List.iter
+              begin fun pkg ->
+                let base_args = [A"-package"; A pkg] in
+                (* TODO: consider how to really choose camlp4o or camlp4r. *)
+                let syn_args = [A"-syntax"; A "camlp4o"] in
+                let (args, pargs) =
+                  (* Heuristic to identify syntax extensions: whether they end in
+                     ".syntax"; some might not.
+                  *)
+                  if Filename.check_suffix pkg "syntax" ||
+                     List.mem pkg well_known_syntax then
+                    (syn_args @ base_args, syn_args)
+                  else
+                    (base_args, [])
+                in
+                flag ["ocaml"; "compile";  "pkg_"^pkg] & S args;
+                flag ["ocaml"; "ocamldep"; "pkg_"^pkg] & S args;
+                flag ["ocaml"; "doc";      "pkg_"^pkg] & S args;
+                flag ["ocaml"; "link";     "pkg_"^pkg] & S base_args;
+                flag ["ocaml"; "infer_interface"; "pkg_"^pkg] & S args;
+
+                (* TODO: Check if this is allowed for OCaml < 3.12.1 *)
+                flag ["ocaml"; "compile";  "package("^pkg^")"] & S pargs;
+                flag ["ocaml"; "ocamldep"; "package("^pkg^")"] & S pargs;
+                flag ["ocaml"; "doc";      "package("^pkg^")"] & S pargs;
+                flag ["ocaml"; "infer_interface"; "package("^pkg^")"] & S pargs;
+              end
+              (find_packages ());
+          end;
 
           (* Like -package but for extensions syntax. Morover -syntax is useless
            * when linking. *)
@@ -546,12 +557,13 @@ module MyOCamlbuildBase = struct
 
                    (* When ocaml link something that use the C library, then one
                       need that file to be up to date.
+                      This holds both for programs and for libraries.
                     *)
-                   dep ["link"; "ocaml"; "program"; tag_libstubs lib]
-                     [dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)];
+  		 dep ["link"; "ocaml"; tag_libstubs lib]
+  		     [dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)];
 
-                   dep  ["compile"; "ocaml"; "program"; tag_libstubs lib]
-                     [dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)];
+  		 dep  ["compile"; "ocaml"; tag_libstubs lib]
+  		      [dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)];
 
                    (* TODO: be more specific about what depends on headers *)
                    (* Depends on .h files *)
@@ -580,18 +592,18 @@ module MyOCamlbuildBase = struct
             ()
 
 
-  let dispatch_default t =
+  let dispatch_default conf t =
     dispatch_combine
       [
         dispatch t;
-        MyOCamlbuildFindlib.dispatch;
+        MyOCamlbuildFindlib.dispatch conf;
       ]
 
 
 end
 
 
-# 594 "myocamlbuild.ml"
+# 606 "myocamlbuild.ml"
 open Ocamlbuild_plugin;;
 let package_default =
   {
@@ -603,8 +615,10 @@ let package_default =
   }
   ;;
 
-let dispatch_default = MyOCamlbuildBase.dispatch_default package_default;;
+let conf = {MyOCamlbuildFindlib.no_automatic_syntax = false}
+
+let dispatch_default = MyOCamlbuildBase.dispatch_default conf package_default;;
 
-# 609 "myocamlbuild.ml"
+# 623 "myocamlbuild.ml"
 (* OASIS_STOP *)
 Ocamlbuild_plugin.dispatch dispatch_default;;
diff --git a/setup.ml b/setup.ml
index 4851e5f..398c8c9 100644
--- a/setup.ml
+++ b/setup.ml
@@ -1,9 +1,9 @@
 (* setup.ml generated for the first time by OASIS v0.3.0~rc6 *)
 
 (* OASIS_START *)
-(* DO NOT EDIT (digest: f74db3e169dd9abe1ee5fa718712b010) *)
+(* DO NOT EDIT (digest: bb76fd3ff2c896e5074a6dc636bcc5e8) *)
 (*
-   Regenerated by OASIS v0.4.4
+   Regenerated by OASIS v0.4.5
    Visit http://oasis.forge.ocamlcore.org for more information and
    documentation about functions used in this file.
 *)
@@ -242,11 +242,9 @@ module OASISString = struct
 
 
   let replace_chars f s =
-    let buf = String.make (String.length s) 'X' in
-      for i = 0 to String.length s - 1 do
-        buf.[i] <- f s.[i]
-      done;
-      buf
+    let buf = Buffer.create (String.length s) in
+    String.iter (fun c -> Buffer.add_char buf (f c)) s;
+    Buffer.contents buf
 
 
 end
@@ -1729,6 +1727,13 @@ module OASISFeatures = struct
       (fun () ->
         s_ "Allows the OASIS section comments and digest to be omitted in \
             generated files.")
+
+  let no_automatic_syntax =
+    create "no_automatic_syntax" alpha
+      (fun () ->
+         s_ "Disable the automatic inclusion of -syntax camlp4o for packages \
+             that matches the internal heuristic (if a dependency ends with \
+             a .syntax or is a well known syntax).")
 end
 
 module OASISUnixPath = struct
@@ -2099,16 +2104,6 @@ module OASISLibrary = struct
         lst
     in
 
-    (* The headers that should be compiled along *)
-    let headers =
-      if lib.lib_pack then
-        []
-      else
-        find_modules
-          lib.lib_modules
-          "cmi"
-    in
-
     (* The .cmx that be compiled along *)
     let cmxs =
       let should_be_built =
@@ -2134,12 +2129,32 @@ module OASISLibrary = struct
       []
     in
 
+    (* The headers and annot/cmt files that should be compiled along *)
+    let headers =
+      let sufx =
+        if lib.lib_pack
+        then [".cmti"; ".cmt"; ".annot"]
+        else [".cmi"; ".cmti"; ".cmt"; ".annot"]
+      in
+      List.map
+        begin
+          List.fold_left
+            begin fun accu s ->
+              let dot = String.rindex s '.' in
+              let base = String.sub s 0 dot in
+              List.map ((^) base) sufx @ accu
+            end
+            []
+        end
+        (find_modules lib.lib_modules "cmi")
+    in
+
     (* Compute what libraries should be built *)
     let acc_nopath =
       (* Add the packed header file if required *)
       let add_pack_header acc =
         if lib.lib_pack then
-          [cs.cs_name^".cmi"] :: acc
+          [cs.cs_name^".cmi"; cs.cs_name^".cmti"; cs.cs_name^".cmt"] :: acc
         else
           acc
       in
@@ -2499,13 +2514,13 @@ module OASISFindlib = struct
     in
 
     let library_name_of_findlib_name =
-      Lazy.lazy_from_fun
-        (fun () ->
-           (* Revert findlib_name_of_library_name. *)
-           MapString.fold
-             (fun k v mp -> MapString.add v k mp)
-             fndlb_name_of_lib_name
-             MapString.empty)
+      lazy begin
+        (* Revert findlib_name_of_library_name. *)
+        MapString.fold
+          (fun k v mp -> MapString.add v k mp)
+          fndlb_name_of_lib_name
+          MapString.empty
+      end
     in
     let library_name_of_findlib_name fndlb_nm =
       try
@@ -2875,7 +2890,7 @@ module OASISFileUtil = struct
 end
 
 
-# 2878 "setup.ml"
+# 2893 "setup.ml"
 module BaseEnvLight = struct
 (* # 22 "src/base/BaseEnvLight.ml" *)
 
@@ -2980,7 +2995,7 @@ module BaseEnvLight = struct
 end
 
 
-# 2983 "setup.ml"
+# 2998 "setup.ml"
 module BaseContext = struct
 (* # 22 "src/base/BaseContext.ml" *)
 
@@ -5391,7 +5406,7 @@ module BaseSetup = struct
 end
 
 
-# 5394 "setup.ml"
+# 5409 "setup.ml"
 module InternalConfigurePlugin = struct
 (* # 22 "src/plugins/internal/InternalConfigurePlugin.ml" *)
 
@@ -5827,6 +5842,17 @@ module InternalInstallPlugin = struct
           lst
     in
 
+    let make_fnames modul sufx =
+      List.fold_right
+        begin fun sufx accu ->
+          (String.capitalize modul ^ sufx) ::
+          (String.uncapitalize modul ^ sufx) ::
+          accu
+        end
+        sufx
+        []
+    in
+
     (** Install all libraries *)
     let install_libs pkg =
 
@@ -5847,27 +5873,29 @@ module InternalInstallPlugin = struct
                   OASISHostPath.of_unix bs.bs_path
                 in
                   List.fold_left
-                    (fun acc modul ->
-                       try
-                         List.find
-                           OASISFileUtil.file_exists_case
-                           (List.map
-                              (Filename.concat path)
-                              [modul^".mli";
-                               modul^".ml";
-                               String.uncapitalize modul^".mli";
-                               String.capitalize   modul^".mli";
-                               String.uncapitalize modul^".ml";
-                               String.capitalize   modul^".ml"])
-                         :: acc
-                       with Not_found ->
-                         begin
-                           warning
-                             (f_ "Cannot find source header for module %s \
-                                  in library %s")
-                             modul cs.cs_name;
-                           acc
-                         end)
+                    begin fun acc modul ->
+                      begin
+                        try
+                          [List.find
+                            OASISFileUtil.file_exists_case
+                            (List.map
+                               (Filename.concat path)
+                               (make_fnames modul [".mli"; ".ml"]))]
+                        with Not_found ->
+                          warning
+                            (f_ "Cannot find source header for module %s \
+                                 in library %s")
+                            modul cs.cs_name;
+                          []
+                      end
+                      @
+                      List.filter
+                        OASISFileUtil.file_exists_case
+                        (List.map
+                           (Filename.concat path)
+                           (make_fnames modul [".annot";".cmti";".cmt"]))
+                      @ acc
+                    end
                     acc
                     lib.lib_modules
               in
@@ -5915,27 +5943,29 @@ module InternalInstallPlugin = struct
                   OASISHostPath.of_unix bs.bs_path
                 in
                   List.fold_left
-                    (fun acc modul ->
-                       try
-                         List.find
-                           OASISFileUtil.file_exists_case
-                           (List.map
-                              (Filename.concat path)
-                              [modul^".mli";
-                               modul^".ml";
-                               String.uncapitalize modul^".mli";
-                               String.capitalize   modul^".mli";
-                               String.uncapitalize modul^".ml";
-                               String.capitalize   modul^".ml"])
-                         :: acc
-                       with Not_found ->
-                         begin
-                           warning
-                             (f_ "Cannot find source header for module %s \
-                                  in object %s")
-                             modul cs.cs_name;
-                           acc
-                         end)
+                    begin fun acc modul ->
+                      begin
+                        try
+                          [List.find
+                             OASISFileUtil.file_exists_case
+                             (List.map
+                                (Filename.concat path)
+                                (make_fnames modul [".mli"; ".ml"]))]
+                        with Not_found ->
+                          warning
+                            (f_ "Cannot find source header for module %s \
+                                 in object %s")
+                            modul cs.cs_name;
+                          []
+                      end
+                      @
+                      List.filter
+                        OASISFileUtil.file_exists_case
+                        (List.map
+                           (Filename.concat path)
+                           (make_fnames modul [".annot";".cmti";".cmt"]))
+                      @ acc
+                    end
                     acc
                     obj.obj_modules
               in
@@ -6240,7 +6270,7 @@ module InternalInstallPlugin = struct
 end
 
 
-# 6243 "setup.ml"
+# 6273 "setup.ml"
 module OCamlbuildCommon = struct
 (* # 22 "src/plugins/ocamlbuild/OCamlbuildCommon.ml" *)
 
@@ -6298,6 +6328,11 @@ module OCamlbuildCommon = struct
         else
           [];
 
+        if bool_of_string (tests ()) then
+          ["-tag"; "tests"]
+        else
+          [];
+
         if bool_of_string (profile ()) then
           ["-tag"; "profile"]
         else
@@ -6613,7 +6648,7 @@ module OCamlbuildDocPlugin = struct
 end
 
 
-# 6616 "setup.ml"
+# 6651 "setup.ml"
 module CustomPlugin = struct
 (* # 22 "src/plugins/custom/CustomPlugin.ml" *)
 
@@ -6761,7 +6796,7 @@ module CustomPlugin = struct
 end
 
 
-# 6764 "setup.ml"
+# 6799 "setup.ml"
 open OASISTypes;;
 
 let setup_t =
@@ -6844,13 +6879,13 @@ let setup_t =
      distclean_doc = [];
      package =
        {
-          oasis_version = "0.3";
+          oasis_version = "0.4";
           ocaml_version = None;
           findlib_version = None;
           alpha_features = [];
           beta_features = [];
           name = "PG'OCaml";
-          version = "2.1";
+          version = "2.2";
           license =
             OASISLicense.DEP5License
               (OASISLicense.DEP5Unit
@@ -6931,7 +6966,8 @@ let setup_t =
                            FindlibPackage ("unix", None);
                            FindlibPackage ("calendar", None);
                            FindlibPackage ("csv", None);
-                           FindlibPackage ("pcre", None)
+                           FindlibPackage ("pcre", None);
+                           FindlibPackage ("bytes", None)
                         ];
                       bs_build_tools =
                         [
@@ -7009,7 +7045,7 @@ let setup_t =
                      cs_plugin_data = []
                   },
                    {
-                      doc_type = (`Doc, "ocamlbuild", Some "0.3");
+                      doc_type = (`Doc, "ocamlbuild", Some "0.4");
                       doc_custom =
                         {
                            pre_command = [(OASISExpr.EBool true, None)];
@@ -7205,14 +7241,14 @@ let setup_t =
                    })
             ];
           plugins =
-            [(`Extra, "META", Some "0.3"); (`Extra, "DevFiles", Some "0.3")];
+            [(`Extra, "META", Some "0.4"); (`Extra, "DevFiles", Some "0.4")];
           disable_oasis_section = [];
           schema_data = PropList.Data.create ();
           plugin_data = []
        };
      oasis_fn = Some "_oasis";
-     oasis_version = "0.4.4";
-     oasis_digest = Some "\251\024\216\184Z\220\235\232\225Z|!AS=9";
+     oasis_version = "0.4.5";
+     oasis_digest = Some "=#\021(1\214^*s;\006\230\026P3.";
      oasis_exec = None;
      oasis_setup_args = [];
      setup_update = false
@@ -7220,6 +7256,6 @@ let setup_t =
 
 let setup () = BaseSetup.setup setup_t;;
 
-# 7224 "setup.ml"
+# 7260 "setup.ml"
 (* OASIS_STOP *)
 let () = setup ();;
diff --git a/src/META b/src/META
index 9b388f7..63e25a5 100644
--- a/src/META
+++ b/src/META
@@ -1,15 +1,15 @@
 # OASIS_START
-# DO NOT EDIT (digest: cb1509fc9b26fe21e7753dabd32b93d7)
-version = "2.1"
+# DO NOT EDIT (digest: 023ae9385c9c2cfcf39a4b5db8ae0c35)
+version = "2.2"
 description = "OCaml bindings for the PostgreSQL database"
-requires = "unix calendar csv pcre"
+requires = "unix calendar csv pcre bytes"
 archive(byte) = "pgocaml.cma"
 archive(byte, plugin) = "pgocaml.cma"
 archive(native) = "pgocaml.cmxa"
 archive(native, plugin) = "pgocaml.cmxs"
 exists_if = "pgocaml.cma"
 package "syntax" (
- version = "2.1"
+ version = "2.2"
  description = "Syntax extension for PG'OCaml"
  requires = "pgocaml camlp4"
  archive(syntax, preprocessor) = "pa_pgsql.cma"
diff --git a/src/PGOCaml_aux.ml b/src/PGOCaml_aux.ml
index b1507c1..44ff860 100644
--- a/src/PGOCaml_aux.ml
+++ b/src/PGOCaml_aux.ml
@@ -20,11 +20,9 @@ struct
   let join = concat
 
   let implode xs =
-    let res = create (List.length xs) in
-      let rec aux i = function
-        | [] -> res
-        | hd :: tl -> res.[i] <- hd; aux (i + 1) tl in
-      aux 0 xs
+    let buf = Buffer.create (List.length xs) in
+    List.iter (Buffer.add_char buf) xs;
+    Buffer.contents buf
 
   let fold_left f init str =
     let len = length str in
@@ -33,6 +31,14 @@ struct
       then accum
       else loop (i + 1) (f accum str.[i]) in
     loop 0 init
+
+  (* Only available in the standard library since OCaml 4.02 *)
+  let init n f =
+    let s = Bytes.create n in
+    for i = 0 to n - 1 do
+      Bytes.unsafe_set s i (f i)
+    done;
+    Bytes.to_string s
 end
 
 module Option =
@@ -66,4 +72,3 @@ struct
       | hd :: tl -> let hd' = f i hd in hd' :: loop (i+1) tl in
     loop 0 xs
 end
-
diff --git a/src/PGOCaml_aux.mli b/src/PGOCaml_aux.mli
index f9e04ad..28a01b1 100644
--- a/src/PGOCaml_aux.mli
+++ b/src/PGOCaml_aux.mli
@@ -6,6 +6,7 @@ module String :
     val join : string -> string list -> string
     val implode : char list -> string
     val fold_left : ('a -> char -> 'a) -> 'a -> string -> 'a
+    val init: int -> (int -> char) -> string
   end
 
 module Option :
@@ -23,4 +24,3 @@ module List :
     val iteri : (int -> 'a -> unit) -> 'a list -> unit
     val mapi : (int -> 'a -> 'b) -> 'a list -> 'b list
   end
-
diff --git a/src/PGOCaml_generic.ml b/src/PGOCaml_generic.ml
index a071d83..1a4435c 100644
--- a/src/PGOCaml_generic.ml
+++ b/src/PGOCaml_generic.ml
@@ -39,7 +39,7 @@ module type THREAD = sig
   val flush : out_channel -> unit t
   val input_char : in_channel -> char t
   val input_binary_int : in_channel -> int t
-  val really_input : in_channel -> string -> int -> int -> unit t
+  val really_input : in_channel -> Bytes.t -> int -> int -> unit t
   val close_in : in_channel -> unit t
 end
 
@@ -459,7 +459,7 @@ let receive_message { ichan = ichan; chan = chan } =
   if len > !max_message_length then (
     (* Skip the message so we stay in synch with the stream. *)
     let bufsize = 65_536 in
-    let buf = String.create bufsize in
+    let buf = Bytes.create bufsize in
     let rec loop n =
       if n > 0 then begin
         let m = min n bufsize in
@@ -475,9 +475,9 @@ let receive_message { ichan = ichan; chan = chan } =
   ) else (
 
     (* Read the binary message content. *)
-    let msg = String.create len in
+    let msg = Bytes.create len in
     really_input ichan msg 0 len >>= fun () ->
-    return (typ, msg)
+    return (typ, Bytes.to_string msg)
   )
 
 (* Send a message and expect a single result. *)
@@ -633,13 +633,7 @@ let parse_backend_message (typ, msg) =
     in
     loop ()
   in
-  let get_n_bytes n =
-    let str = String.create n in
-    for i = 0 to n-1 do
-      str.[i] <- get_char "get_n_bytes"
-    done;
-    str
-  in
+  let get_n_bytes n = String.init n (fun _ -> get_char "get_n_bytes") in
   let get_char () = get_char "get_char" in
   (*let get_byte () = get_byte "get_byte" in*)
 
@@ -652,16 +646,10 @@ let parse_backend_message (typ, msg) =
 	 | 2l -> AuthenticationKerberosV5
 	 | 3l -> AuthenticationCleartextPassword
 	 | 4l ->
-	     let salt = String.create 2 in
-	     for i = 0 to 2 do
-	       salt.[i] <- get_char ()
-	     done;
+	     let salt = String.init 2 (fun _ -> get_char ()) in
 	     AuthenticationCryptPassword salt
 	 | 5l ->
-	     let salt = String.create 4 in
-	     for i = 0 to 3 do
-	       salt.[i] <- get_char ()
-	     done;
+	     let salt = String.init 4 (fun _ -> get_char ()) in
 	     AuthenticationMD5Password salt
 	 | 6l -> AuthenticationSCMCredential
 	 | _ -> UnknownMessage (typ, msg)
@@ -832,7 +820,9 @@ let pg_error ?conn fields =
 
 type 'a retexn = Ret of 'a | Exn of exn
 
-(* profile_op : string -> string -> string list -> (unit -> 'a) -> 'a *)
+(* profile_op :
+ *   string -> string -> string list -> (unit -> 'a Thread.t) -> 'a Thread.t
+ *)
 let profile_op uuid op detail f =
   let chan =
     try
@@ -847,7 +837,9 @@ let profile_op uuid op detail f =
   | None -> f ()			(* No profiling - just run it. *)
   | Some chan ->			(* Profiling. *)
       let start_time = Unix.gettimeofday () in
-      let ret = try Ret (f ()) with exn -> Exn exn in
+      catch
+        (fun () -> f () >>= fun x -> return (Ret x))
+        (fun exn -> return (Exn exn)) >>= fun ret ->
       let end_time = Unix.gettimeofday () in
 
       let elapsed_time_ms = int_of_float (1000. *. (end_time -. start_time)) in
@@ -871,8 +863,8 @@ let profile_op uuid op detail f =
 
       (* Return result or re-raise the exception. *)
       match ret with
-      | Ret r -> r
-      | Exn exn -> raise exn
+      | Ret r -> return r
+      | Exn exn -> fail exn
 
 (*----- Connection. -----*)
 
@@ -1736,7 +1728,7 @@ let any_array_of_string str =
         None
       else
         let n = String.length x in
-        if n >= 2 && x.[0] = '"' 
+        if n >= 2 && x.[0] = '"'
         then Some (String.sub x 1 (n-2))
         else Some x in
     field :: accum in
diff --git a/src/PGOCaml_generic.mli b/src/PGOCaml_generic.mli
index c41708b..e1d33cc 100644
--- a/src/PGOCaml_generic.mli
+++ b/src/PGOCaml_generic.mli
@@ -39,7 +39,7 @@ module type THREAD = sig
   val flush : out_channel -> unit t
   val input_char : in_channel -> char t
   val input_binary_int : in_channel -> int t
-  val really_input : in_channel -> string -> int -> int -> unit t
+  val really_input : in_channel -> Bytes.t -> int -> int -> unit t
   val close_in : in_channel -> unit t
 end
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ocaml-maint/packages/pgocaml.git



More information about the Pkg-ocaml-maint-commits mailing list