[Pkg-ocaml-maint-commits] [ocaml-csv] 02/06: Imported Upstream version 1.3.2

Stéphane Glondu glondu at moszumanska.debian.org
Sun Jan 26 14:13:13 UTC 2014


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

glondu pushed a commit to branch master
in repository ocaml-csv.

commit b5256cf891eeccf0409a59e6af804791fad3fc27
Author: Stephane Glondu <steph at glondu.net>
Date:   Sun Jan 26 14:57:02 2014 +0100

    Imported Upstream version 1.3.2
---
 Makefile    |   2 +-
 README.md   |   8 ++---
 _oasis      |   2 +-
 setup.ml    |   6 ++--
 src/META    |   4 +--
 src/csv.ml  | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------
 src/csv.mli |   4 +--
 7 files changed, 106 insertions(+), 22 deletions(-)

diff --git a/Makefile b/Makefile
index 8545cb3..c0bb1d6 100644
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,7 @@ all byte native: configure
 	ocaml setup.ml -build
 
 configure: setup.ml
-	ocaml $< -configure
+	ocaml $< -configure --enable-tests
 
 setup.ml: _oasis
 	oasis setup -setup-update dynamic
diff --git a/README.md b/README.md
index a779f75..0576834 100644
--- a/README.md
+++ b/README.md
@@ -14,15 +14,15 @@ This package uses [oasis](https://github.com/ocaml/oasis) to generate
 its configure, build and install scripts.  You do not need oasis to
 install and use the library.  Simply run
 
-  ocaml setup.ml -configure
-  ocaml setup.ml -build
+    ocaml setup.ml -configure
+    ocaml setup.ml -build
 
 Install
 -------
 
-  ocaml setup.ml -install
+    ocaml setup.ml -install
 
 Uninstall
 ---------
 
-  ocaml setup.ml -uninstall
+    ocaml setup.ml -uninstall
diff --git a/_oasis b/_oasis
index 688b6f0..48bb2e2 100644
--- a/_oasis
+++ b/_oasis
@@ -1,7 +1,7 @@
 #								-*-conf-*-
 OASISFormat: 0.3
 Name:        csv
-Version:     1.3.1
+Version:     1.3.2
 Synopsis:    A pure OCaml library to read and write CSV files.
 Description: This is a pure OCaml library to read and write CSV files, 
   including all extensions used by Excel — e.g. quotes, newlines, 
diff --git a/setup.ml b/setup.ml
index 00382f6..31de332 100644
--- a/setup.ml
+++ b/setup.ml
@@ -4,7 +4,7 @@ let () =
   with Not_found -> ();;
 
 (* OASIS_START *)
-(* DO NOT EDIT (digest: 7e9b0897d218cfb9341510fddd0e8e92) *)
+(* DO NOT EDIT (digest: 6f4cb2c8f6c74abd9ee546e9f8eb86c4) *)
 (*
    Regenerated by OASIS v0.3.0
    Visit http://oasis.forge.ocamlcore.org for more information and
@@ -5747,7 +5747,7 @@ let setup_t =
           ocaml_version = None;
           findlib_version = None;
           name = "csv";
-          version = "1.3.1";
+          version = "1.3.2";
           license =
             OASISLicense.DEP5License
               (OASISLicense.DEP5Unit
@@ -5978,7 +5978,7 @@ let setup_t =
           };
      oasis_fn = Some "_oasis";
      oasis_version = "0.3.0";
-     oasis_digest = Some "\176\200\189{W\210r\201\176R'\\\190sn\170";
+     oasis_digest = Some "\212\178\238\1387\180*\022\005\228\158\155\n>O\169";
      oasis_exec = None;
      oasis_setup_args = [];
      setup_update = false;
diff --git a/src/META b/src/META
index 12d7807..650d1f8 100644
--- a/src/META
+++ b/src/META
@@ -1,6 +1,6 @@
 # OASIS_START
-# DO NOT EDIT (digest: 89bb1bc1c854dfa0d6d1f7365dca585c)
-version = "1.3.1"
+# DO NOT EDIT (digest: 2e5599ee740dd369f8fbe4dce85222f8)
+version = "1.3.2"
 description = "A pure OCaml library to read and write CSV files."
 archive(byte) = "csv.cma"
 archive(byte, plugin) = "csv.cma"
diff --git a/src/csv.ml b/src/csv.ml
index 53813f4..2aaf0f8 100644
--- a/src/csv.ml
+++ b/src/csv.ml
@@ -6,8 +6,8 @@
      email: rjones at redhat.com
 
      Christophe Troestler
-     email: Christophe.Troestler at umh.ac.be
-     WWW: http://math.umh.ac.be/an/software/
+     email: Christophe.Troestler at umons.ac.be
+     WWW: http://math.umons.ac.be/anum/software/
 
    This library is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License version 2.1 or
@@ -47,6 +47,88 @@ type t = string list list
 (* Specialize to int for speed *)
 let max i j = if (i:int) < j then j else i
 
+(* Enhance the List module with tail rec functions. *)
+module List = struct
+  include List
+
+  (* Implementation of [map] in JSC Core. *)
+  let map_slow l ~f = List.rev (List.rev_map f l)
+
+  let rec count_map ~f l ctr =
+    match l with
+    | [] -> []
+    | [x1] ->
+       let f1 = f x1 in
+       [f1]
+    | [x1; x2] ->
+       let f1 = f x1 in
+       let f2 = f x2 in
+       [f1; f2]
+    | [x1; x2; x3] ->
+       let f1 = f x1 in
+       let f2 = f x2 in
+       let f3 = f x3 in
+       [f1; f2; f3]
+    | [x1; x2; x3; x4] ->
+       let f1 = f x1 in
+       let f2 = f x2 in
+       let f3 = f x3 in
+       let f4 = f x4 in
+       [f1; f2; f3; f4]
+    | x1 :: x2 :: x3 :: x4 :: x5 :: tl ->
+       let f1 = f x1 in
+       let f2 = f x2 in
+       let f3 = f x3 in
+       let f4 = f x4 in
+       let f5 = f x5 in
+       f1 :: f2 :: f3 :: f4 :: f5 :: (if ctr > 1000
+                                      then map_slow ~f tl
+                                      else count_map ~f tl (ctr + 1))
+
+  let map f l = count_map ~f l 0
+
+  (* Implementation of [append] in JSC core. *)
+  let slow_append l1 l2 = List.rev_append (List.rev l1) l2
+
+  let rec count_append l1 l2 count =
+    match l1 with
+    | []               ->                         l2
+    | [x1]             -> x1                   :: l2
+    | [x1; x2]         -> x1 :: x2             :: l2
+    | [x1; x2; x3]     -> x1 :: x2 :: x3       :: l2
+    | [x1; x2; x3; x4] -> x1 :: x2 :: x3 :: x4 :: l2
+    | x1 :: x2 :: x3 :: x4 :: x5 :: tl ->
+       x1 :: x2 :: x3 :: x4 :: x5 :: (if count > 1000
+                                      then slow_append tl l2
+                                      else count_append tl l2 (count + 1))
+
+  let append l1 l2 = count_append l1 l2 0
+
+  (* Tail recursive [combine]. *)
+  let rec rev_combine acc l1 l2 =
+    match l1, l2 with
+    | ([], []) -> acc
+    | (a1::l1, a2::l2) -> rev_combine ((a1, a2) :: acc) l1 l2
+    | (_, _) -> invalid_arg "List.combine"
+
+  let slow_combine l1 l2 = List.rev (rev_combine [] l1 l2)
+
+  let rec count_combine l1 l2 count =
+    match l1, l2 with
+    | ([], []) -> []
+    | ([x1], [y1]) -> [x1, y1]
+    | ([x1; x2], [y1; y2]) -> [x1, y1; x2, y2]
+    | ([x1; x2; x3], [y1; y2; y3]) -> [x1, y1; x2, y2; x3, y3]
+    | ([x1; x2; x3; x4], [y1; y2; y3; y4]) -> [x1, y1; x2, y2; x3, y3; x4, y4]
+    | (x1 :: x2 :: x3 :: x4 :: tl1), (y1 :: y2 :: y3 :: y4 :: tl2) ->
+       (x1, y1) :: (x2, y2) :: (x3, y3) :: (x4, y4)
+       :: (if count > 1000 then slow_combine tl1 tl2
+           else count_combine tl1 tl2 (count + 1))
+    | (_, _) -> invalid_arg "List.combine"
+
+  let combine l1 l2 = count_combine l1 l2 0
+
+end
 
 class type in_obj_channel =
 object
@@ -548,7 +630,9 @@ let save ?separator ?excel_tricks fname t =
 let lines = List.length
 
 let columns csv =
-  List.fold_left max 0 (List.map List.length csv)
+  let m = ref 0 in
+  List.iter (fun row -> m := max !m (List.length row)) csv;
+  !m
 
 
 let rec dropwhile f = function
@@ -557,12 +641,12 @@ let rec dropwhile f = function
   | xs -> xs
 
 
+let rec empty_row = function
+  | [] -> true
+  | "" :: xs -> empty_row xs
+  | _ :: _ -> false
+
 let trim ?(top=true) ?(left=true) ?(right=true) ?(bottom=true) csv =
-  let rec empty_row = function
-    | [] -> true
-    | x :: _ when x <> "" -> false
-    | _ :: xs -> empty_row xs
-  in
   let csv = if top then dropwhile empty_row csv else csv in
   let csv =
     if right then
@@ -771,7 +855,7 @@ let save_out_readable chan csv =
             let rp =
               try List.combine r1 r2
               with
-                Invalid_argument "List.combine" ->
+                Invalid_argument _ ->
                   failwith (Printf.sprintf "Csv.save_out_readable: internal \
                               error: length r1 = %d, length r2 = %d"
                               (List.length r1) (List.length r2)) in
diff --git a/src/csv.mli b/src/csv.mli
index ec3d6a1..8cc671c 100644
--- a/src/csv.mli
+++ b/src/csv.mli
@@ -6,8 +6,8 @@
      email: rjones at redhat.com
 
      Christophe Troestler
-     email: Christophe.Troestler at umh.ac.be
-     WWW: http://math.umh.ac.be/an/software/
+     email: Christophe.Troestler at umons.ac.be
+     WWW: http://math.umons.ac.be/anum/software/
 
    This library is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License version 2.1 or

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



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