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

glondu pushed a commit to branch master
in repository camlpdf.

commit 20e5e37a50b2a0696fc25d731aff51b29d551c64
Author: Stephane Glondu <st...@glondu.net>
Date:   Wed Mar 26 17:11:39 2014 +0100

    Imported Upstream version 1.7.2
---
 Makefile          | 14 +++++++-------
 examples/Makefile |  2 +-
 pdf.ml            |  9 +--------
 pdfafm.ml         |  2 +-
 pdfcodec.ml       | 16 ++++++++--------
 pdfcrypt.ml       | 31 ++-----------------------------
 pdfflate.ml       |  3 ---
 pdfgenlex.ml      |  4 +---
 pdfimage.ml       |  2 +-
 pdfio.ml          | 16 ++++++++++------
 pdfio.mli         |  5 ++++-
 pdfpage.ml        |  8 +++++++-
 pdfpagelabels.ml  |  9 +++++++++
 pdfpagelabels.mli | 23 +++++++++++++++++------
 pdfread.ml        |  2 +-
 pdfunits.ml       |  2 +-
 pdfutil.ml        | 31 +++++--------------------------
 pdfwrite.ml       |  2 +-
 18 files changed, 77 insertions(+), 104 deletions(-)

diff --git a/Makefile b/Makefile
index c453cc5..b736b1e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,9 @@
 # Build the camlpdf library as byte code and native code
-PDFMODS = pdfutil pdfio pdftransform pdfunits pdfpaper pdf pdfcrypt pdfflate \
-pdfcodec pdfwrite pdfgenlex pdfread pdfjpeg pdfops pdfdest pdfmarks \
-pdfpagelabels pdfpage pdfannot pdffun pdfspace pdfimage pdfafm pdfafmdata \
-pdfglyphlist pdftext pdfstandard14 pdfgraphics pdfshapes pdfdate pdfocg \
-pdfcff pdftype1 pdftruetype pdftype0 pdfmerge
+PDFMODS = pdfutil pdfio pdftransform pdfunits pdfpaper pdf \
+pdfcrypt pdfflate pdfcodec pdfwrite pdfgenlex pdfread pdfjpeg pdfops pdfdest \
+pdfmarks pdfpagelabels pdfpage pdfannot pdffun pdfspace pdfimage pdfafm \
+pdfafmdata pdfglyphlist pdftext pdfstandard14 pdfgraphics pdfshapes pdfdate \
+pdfocg pdfcff pdftype1 pdftruetype pdftype0 pdfmerge
 
 SOURCES = flatestubs.c $(foreach x,$(PDFMODS),$(x).ml $(x).mli)
 
@@ -12,8 +12,8 @@ PACKS = bigarray
 RESULT = camlpdf
 
 LIBINSTALL_FILES = camlpdf.a camlpdf.cma camlpdf.cmxa libcamlpdf_stubs.a \
-dllcamlpdf_stubs.* \
-$(foreach x,$(PDFMODS),$x.mli) $(foreach x,$(PDFMODS),$x.cmi)
+dllcamlpdf_stubs.* $(foreach x,$(PDFMODS),$x.mli) \
+$(foreach x,$(PDFMODS),$x.cmi)
 
 OCAMLNCFLAGS = -g
 OCAMLBCFLAGS = -g
diff --git a/examples/Makefile b/examples/Makefile
index 218f752..f00cb89 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -1,4 +1,4 @@
-export PACKS = bigarray camlpdf
+export PACKS = camlpdf
 export OCAMLBCFLAGS = -g
 export OCAMLNCFLAGS = -g 
 export OCAMLLDFLAGS = -g
diff --git a/pdf.ml b/pdf.ml
index c1a656f..c593f24 100644
--- a/pdf.ml
+++ b/pdf.ml
@@ -699,7 +699,7 @@ let rec add_dict_entry dict key value =
   | _ -> raise (PDFError "add_dict_entry: not a dictionary.")
 
 (* Find the contents of a stream as a bytes. *)
-let rec bigarray_of_stream s =
+let bigarray_of_stream s =
   getstream s;
   match s with
   | Stream {contents = _, Got bytes} -> bytes
@@ -800,13 +800,6 @@ let rec contents_of_nametree pdf tree =
           flatten (map (contents_of_nametree pdf) kids)
       | _ -> raise (PDFError "contents_of_nametree: neither names nor kids")
 
-let copy_pdf from =
-  {major = from.major;
-   minor = from.minor;
-   root = from.root;
-   objects = from.objects;
-   trailerdict = from.trailerdict}
-
 let deep_copy_pdfobjects frompdf from =
   let deep_copy_objdata objdata =
     let deep_copy_pdfobject = function
diff --git a/pdfafm.ml b/pdfafm.ml
index cd2a525..72e3d64 100644
--- a/pdfafm.ml
+++ b/pdfafm.ml
@@ -22,7 +22,7 @@ let read_char_metrics_line l =
       (name, (charnum, width))
   | x -> iter print_lexeme x; failwith "badline"
 
-let rec lookup_charnum table name =
+let lookup_charnum table name =
   match Hashtbl.find table name with (c', _) -> c'
 
 let read_kern_line_lexer = Genlex.make_lexer ["KPX"]
diff --git a/pdfcodec.ml b/pdfcodec.ml
index 100f5c3..543a1b6 100644
--- a/pdfcodec.ml
+++ b/pdfcodec.ml
@@ -988,7 +988,7 @@ let encode_runlength stream =
           in
               while !runs <> [] do
                 begin match hd !runs with
-                | (l, x) when l < 1 ->
+                | (l, _) when l < 1 ->
                     assert false
                 | (l, x) when l < 3 ->
                     if l + !chunksize > 128 then writechunk ();
@@ -1129,7 +1129,7 @@ let decode_one pdf dict source =
   | None | Some (Pdf.Array []) ->
       begin match source with
       | StreamSource s -> s
-      | InputSource i -> raise (DecodeNotSupported "decode_one")
+      | InputSource _ -> raise (DecodeNotSupported "decode_one")
       end
   | Some (Pdf.Name n) | Some (Pdf.Array (Pdf.Name n::_)) ->
       let decoded = decoder pdf dict source n in
@@ -1196,13 +1196,13 @@ let remove_decoder d =
     | _ -> raise (Pdf.PDFError "PDF.remove_decoder: malformed /DecodeParms")
 
 (* Decode at most one stage. *)
-let rec decode_pdfstream_onestage pdf stream =
+let decode_pdfstream_onestage pdf stream =
   Pdf.getstream stream;
   match stream with
   | Pdf.Stream ({contents = (Pdf.Dictionary d as dict, Pdf.Got s)} as 
stream_contents) ->
       begin match Pdf.direct pdf (Pdf.lookup_fail "no /Length" pdf "/Length" 
dict) with
-      | Pdf.Integer l -> () (*i if l <> bytes_size s then raise (PDFError 
"Wrong /Length") i*)
-      | x -> raise (Pdf.PDFError "No /Length")
+      | Pdf.Integer _ -> () (*i if l <> bytes_size s then raise (PDFError 
"Wrong /Length") i*)
+      | _ -> raise (Pdf.PDFError "No /Length")
       end;
       let stream' = decode_one pdf dict (StreamSource s) in
         let d' =
@@ -1242,13 +1242,13 @@ let decode_pdfstream_until_unknown pdf s =
 (* Decode from an input. *)
 let decode_from_input i dict =
   match Pdf.lookup_direct_orelse (Pdf.empty ()) "/F" "/Filter" dict with
-  | Some (Pdf.Name n) ->
+  | Some (Pdf.Name _) ->
       Some (decode_one (Pdf.empty ()) dict (InputSource i))
-  | Some (Pdf.Array (h::t)) ->
+  | Some (Pdf.Array (_::t)) ->
       let stream = decode_one (Pdf.empty ()) dict (InputSource i) in
         let rec decode_rest stream = function
           | [] -> stream
-          | Pdf.Name n::more ->
+          | Pdf.Name _::more ->
               (* Removing the filter just done, and its decodeparms. Note that
               /F can denote a file specification, but this can never be in an
               inline image (which is currrently the only use of
diff --git a/pdfcrypt.ml b/pdfcrypt.ml
index 3a5e06d..6f31a95 100644
--- a/pdfcrypt.ml
+++ b/pdfcrypt.ml
@@ -11,11 +11,6 @@ type encryption =
   | AESV2 (* v = 4, r = 4 *)
   | AESV3 of bool (* v = 5, r = 5 or v = 5, r = 6 if true *)
 
-let string_of_encryption = function
-  | ARC4 (kl, r) -> Printf.sprintf "ARC4, keylength = %i, r = %i\n" kl r;
-  | AESV2 -> "AESV2"
-  | AESV3 b -> Printf.sprintf "AESV3 iso=%b" b
-
 (* Given an object number, generation number, input key and key length in bits,
 apply Algorithm 3.1 from the PDF Reference manual to obtain the hash to be used
 by the encryption function. *)
@@ -281,10 +276,6 @@ let rcon =
     word_of_bytes 0x4d 0x00 0x00 0x00;
     word_of_bytes 0x9a 0x00 0x00 0x00 |]
 
-let testkey =
-  [| 0x60; 0x3d; 0xeb; 0x10; 0x15; 0xca; 0x71; 0xbe; 0x2b; 0x73; 0xae; 0xf0; 
0x85; 0x7d; 0x77; 0x81;
-     0x1f; 0x35; 0x2c; 0x07; 0x3b; 0x61; 0x08; 0xd7; 0x2d; 0x98; 0x10; 0xa3; 
0x09; 0x14; 0xdf; 0xf4|] 
-
 (* Key expansion *)
 let key_expansion nk key =
   try
@@ -500,20 +491,6 @@ let cipher_raw nr data_in pos_in data_out pos_out =
   output_from_state_raw data_out pos_out
 
 (* Decryption cipher. Assumes key already expanded. *)
-let inv_cipher nr data_in =
-  input_to_state data_in;
-  add_round_key (nr * 4);
-  for round = (nr - 1) downto 1 do
-    inv_shift_rows ();
-    inv_sub_bytes ();
-    add_round_key (round * 4);
-    inv_mix_columns ();
-  done;
-  inv_shift_rows ();
-  inv_sub_bytes ();
-  add_round_key 0;
-  output_from_state ()
-
 let inv_cipher_raw nr data_in pos_in data_out pos_out =
   input_to_state_raw data_in pos_in;
   add_round_key (nr * 4);
@@ -1015,10 +992,6 @@ let k =
     0x19a4c116l; 0x1e376c08l; 0x2748774cl; 0x34b0bcb5l; 0x391c0cb3l; 
0x4ed8aa4al; 0x5b9cca4fl; 0x682e6ff3l;
     0x748f82eel; 0x78a5636fl; 0x84c87814l; 0x8cc70208l; 0x90befffal; 
0xa4506cebl; 0xbef9a3f7l; 0xc67178f2l |]
 
-let rotate x n = lor32 (lsr32 x n) (lsl32 x (32 - n))
-
-let shift = lsr32
-
 let ch x y z = lxor32 (land32 x y) (land32 (lnot32 x) z)
 
 let maj x y z = lxor32 (land32 x y) (lxor32 (land32 x z) (land32 y z))
@@ -1509,7 +1482,7 @@ let decrypt_pdf ?keyfromowner user_pw pdf =
          | AESV2 -> 4, 128, None
          | AESV3 iso ->
              begin match oe, ue with
-             | Some oe, Some ue ->
+             | Some _, Some ue ->
                  begin match keyfromowner with
                  | Some k -> 5, 256, Some k
                  | None ->
@@ -1524,7 +1497,7 @@ let decrypt_pdf ?keyfromowner user_pw pdf =
                              match p_of_perms key perms with
                              | None -> raise (Failure "/Perms file permissions 
corrupted")
                              | Some x when x = p -> 5, 256, Some 
(string_of_bytes key)
-                             | Some x -> raise (Failure "Mismatched /Perms and 
/P permissions")
+                             | Some _ -> raise (Failure "Mismatched /Perms and 
/P permissions")
                  end
              | _ -> raise (Failure "decrypt_pdf: no oe")
              end
diff --git a/pdfflate.ml b/pdfflate.ml
index 7d8daa6..a6175bd 100644
--- a/pdfflate.ml
+++ b/pdfflate.ml
@@ -26,9 +26,6 @@ external inflate:
   = "camlzip_inflate_bytecode" "camlzip_inflate"
 external inflate_end: stream -> unit = "camlzip_inflateEnd"
 
-external update_crc: int32 -> string -> int -> int -> int32
-                   = "camlzip_update_crc32"
-
 let buffer_size = 1024
 
 let compress ?(level = 6) ?(header = true) refill flush =
diff --git a/pdfgenlex.ml b/pdfgenlex.ml
index ec7177b..d682be2 100644
--- a/pdfgenlex.ml
+++ b/pdfgenlex.ml
@@ -109,9 +109,7 @@ let getuntil i =
     let l = lengthuntil i 0 in
       i.Pdfio.seek_in p;
       let s = if l <= 16 then Array.unsafe_get strings l else String.create l 
in
-        for x = 0 to l - 1 do
-          String.unsafe_set s x (Char.unsafe_chr (i.Pdfio.input_byte ()))
-        done;
+        Pdfio.setinit_string i s 0 l;
         s
 
 (* The same, but don't return anything. *)
diff --git a/pdfimage.ml b/pdfimage.ml
index 1817b91..fce28d7 100644
--- a/pdfimage.ml
+++ b/pdfimage.ml
@@ -429,7 +429,7 @@ let rec read_raw_image size colspace bpc pdf resources 
width height dict data =
      flush stdout; i*)
      raise (Pdf.PDFError "No image\n")
 
-let rec get_raw_image pdf resources width height dict data =
+let get_raw_image pdf resources width height dict data =
   try
   let size =
     bytes_size data
diff --git a/pdfio.ml b/pdfio.ml
index 6bb2992..bb0bdbd 100644
--- a/pdfio.ml
+++ b/pdfio.ml
@@ -381,12 +381,6 @@ let read_char_back i =
 let rewind i =
   i.seek_in (i.pos_in () - 1)
 
-let rewind2 i =
-  i.seek_in (i.pos_in () - 2)
-
-let rewind3 i =
-  i.seek_in (i.pos_in () - 3)
-
 (* Read a character, leaving the position unchanged. *)
 let peek_char i =
   let r = i.input_char () in
@@ -460,6 +454,16 @@ let setinit i s o l =
       | Long s ->
           for x = o to o + l - 1 do bigarray_unsafe_set s x (i.input_byte ()) 
done
 
+let setinit_string i s o l =
+  let max = String.length s - 1
+  and last = o + 1 - 1 in
+    if o > max || o < 0 || last < 0 || last > max then raise (Failure 
"setinit") else
+      match i.caml_channel with
+      | Some ch ->
+          really_input ch s o l
+      | None ->
+          for x = o to o + l - 1 do String.unsafe_set s x (Char.unsafe_chr 
(i.input_byte ())) done
+
 let getinit i s o l =
   let max = bytes_size s - 1
   and last = o + 1 - 1 in
diff --git a/pdfio.mli b/pdfio.mli
index c19a11f..ba69d86 100644
--- a/pdfio.mli
+++ b/pdfio.mli
@@ -9,7 +9,7 @@
 - [input_char ()] returns None if end of input, or the next byte of the input 
as a character.
 - [input_byte ()] returns the next byte as an integer, or [Pdfio.no_more] in 
case of end of input. 
 - [in_channel_length] is the length of the channel.
-- [set_offset] shifts the channel so permissions run from offset to 
channel_length + offset - 1 instead of 0 to channel_length - 1.
+- [set_offset] shifts the channel so positions run from offset to 
channel_length + offset - 1 instead of 0 to channel_length - 1.
 - [caml_channel] is the underlying OCaml channel (if any) of the input.
 - [source] is a string used to inficate the original source of the data, for 
debugging purposes.
 
@@ -142,6 +142,9 @@ val bset_unsafe : bytes -> int -> int -> unit
 (** [setinit f s o l] sets s o...o + l - 1 to values generated by f *)
 val setinit : input -> bytes -> int -> int -> unit
 
+(** [setinit_string f s o l] sets s o...o + l - 1 to values generated by f *)
+val setinit_string : input -> string -> int -> int -> unit
+
 (** Make bytes from a string. *)
 val bytes_of_string : string -> bytes
 
diff --git a/pdfpage.ml b/pdfpage.ml
index 46dd0a3..dd3ea3a 100644
--- a/pdfpage.ml
+++ b/pdfpage.ml
@@ -262,9 +262,15 @@ let change_operator pdf lookup lookup_option seqnum = 
function
   | Pdfops.Op_BDC (n, Pdf.Name p) ->
       Pdfops.Op_BDC (n, Pdf.Name (lookup "/Properties" seqnum p))
   | Pdfops.InlineImage (dict, bytes) ->
-      (* Replace any "/CS" or "/ColorSpace" with a new "/CS" *)
+      (* Replace any indirect "/CS" or "/ColorSpace" with a new "/CS" *)
       let dict' =
         match Pdf.lookup_direct_orelse pdf "/CS" "/ColorSpace" dict with
+        | Some (Pdf.Name "/DeviceGray")
+        | Some (Pdf.Name "/DeviceRGB")
+        | Some (Pdf.Name "/DeviceCMYK")
+        | Some (Pdf.Name "/G")
+        | Some (Pdf.Name "/RGB")
+        | Some (Pdf.Name "/CMYK") -> dict
         | Some (Pdf.Name n) ->
             Pdf.add_dict_entry
               (Pdf.remove_dict_entry
diff --git a/pdfpagelabels.ml b/pdfpagelabels.ml
index 666cc64..871db7a 100644
--- a/pdfpagelabels.ml
+++ b/pdfpagelabels.ml
@@ -206,3 +206,12 @@ let write pdf labels =
           pdf.Pdf.trailerdict <-
             Pdf.add_dict_entry pdf.Pdf.trailerdict "/Root" (Pdf.Indirect 
rootnum)
 
+let remove pdf =
+  let root = Pdf.lookup_obj pdf pdf.Pdf.root in
+    let rootnum =
+      Pdf.addobj pdf (Pdf.remove_dict_entry root "/PageLabels")
+    in
+      pdf.Pdf.root <- rootnum;
+      pdf.Pdf.trailerdict <-
+        Pdf.add_dict_entry pdf.Pdf.trailerdict "/Root" (Pdf.Indirect rootnum)
+  
diff --git a/pdfpagelabels.mli b/pdfpagelabels.mli
index 9763329..aa4b71f 100644
--- a/pdfpagelabels.mli
+++ b/pdfpagelabels.mli
@@ -1,10 +1,17 @@
 (** Page Labels *)
 
-(** The type for page labels. The page labels of a document, if well-formed, 
are a list of [t]s where the [startpage] values are in increasing numerical 
order. In the most basic case, [startvalue] will always be equal to 
[startpage]. The default labelstyle is [DecimalArabic]. The default 
[labelprefix] is the empty string.
-
-For example, a document might have five pages of introduction with roman 
numerals, followed by the rest of the pages in decimal arabic, numbered from 
one.
-
-For more details, see ISO 32000 12.4.2, but note that in our implementation, 
pages are 1-based. *)
+(** The type for page labels. The page labels of a document, if well-formed,
+are a list of [t]s where the [startpage] values are in increasing numerical
+order. In the most basic case, [startvalue] will always be equal to
+[startpage]. The default labelstyle is [DecimalArabic]. The default
+[labelprefix] is the empty string.
+
+For example, a document might have five pages of introduction with roman
+numerals, followed by the rest of the pages in decimal arabic, numbered from
+one.
+
+For more details, see ISO 32000 12.4.2, but note that in our implementation,
+pages are 1-based. *)
 type labelstyle =
   | DecimalArabic
   | UppercaseRoman
@@ -44,6 +51,10 @@ val coalesce : t list -> t list
 (** Merge some page labels for some PDFs and page ranges. *)
 val merge_pagelabels : Pdf.t list -> int list list -> t list
 
-(** Write page labels to a document, replacing any there. *)
+(** Write page labels to a document, replacing any there. The list must contain
+at least one element. *)
 val write : Pdf.t -> t list -> unit
 
+(** Remove all page labels. *)
+val remove : Pdf.t -> unit
+
diff --git a/pdfread.ml b/pdfread.ml
index 0fd1c67..76b0e44 100644
--- a/pdfread.ml
+++ b/pdfread.ml
@@ -437,7 +437,7 @@ let lex_malformed_stream_data i =
       let pos = find_endstream i in (* returns first char of endstream 
sequence *)
         i.seek_in curr;
         let arr = mkbytes (pos - curr) in
-          for x = 0 to bytes_size arr - 1 do bset arr x (i.input_byte ()) done;
+          for x = 0 to bytes_size arr - 1 do bset_unsafe arr x (i.input_byte 
()) done;
           LexStream (Pdf.Got arr)
   with
     e -> raise (Pdf.PDFError ("Couldn't read malformed stream  - " ^ 
Printexc.to_string e))
diff --git a/pdfunits.ml b/pdfunits.ml
index e4f74fa..0a736bd 100644
--- a/pdfunits.ml
+++ b/pdfunits.ml
@@ -84,7 +84,7 @@ let breadth_first index conv_array u =
 (* Given source and destination units, we return a conversion function. This
  follows the appropriate arcs, accumulating the total multiplier. Obviously, 
the
  user can provide a third argument to do the computation immediately. *)
-let rec convert dpi u u' =
+let convert dpi u u' =
   let conversions = conversions dpi in
     let index = index conversions in
       let conv_array = conv_array index conversions in
diff --git a/pdfutil.ml b/pdfutil.ml
index 0391848..dc04f06 100644
--- a/pdfutil.ml
+++ b/pdfutil.ml
@@ -21,29 +21,6 @@ let string_replace_all x x' s =
         done;
         Buffer.contents output
 
-(* New function to write an integer as a string - avoids the format parsing in
-Pervasives.string_of_int. Faster in native code, slower in bytecode. *)
-let s = String.make 20 'X'
-
-(* Never called with p < 0 *)
-let rec chars_of_int p = function
-  | 0 -> p - 1
-  | n ->
-      String.unsafe_set s p (Char.unsafe_chr (n mod 10 + 48));
-      chars_of_int (p + 1) (n / 10)
-
-let rec output_int_as_string output = function
-  | 0 -> output '0'
-  | n when n = min_int ->
-      String.iter output (Pervasives.string_of_int min_int)
-  | n when n < 0 ->
-     output '-';
-     output_int_as_string output ~-n
-  | n ->
-     for x = chars_of_int 0 n downto 0 do
-       output (String.unsafe_get s x)
-     done
-
 (* Print something and then flush standard output. *)
 let flprint s =
   print_string s; flush stdout
@@ -254,7 +231,9 @@ let implode l =
 
 (* String of character. *)
 let string_of_char c =
-  implode [c]
+  let s = String.create 1 in
+    String.unsafe_set s 0 c;
+    s
 
 (* Long-integer function abbreviations *)
 let i32ofi = Int32.of_int
@@ -499,7 +478,7 @@ let pairs l =
 let mem = List.mem
 
 (* The same, with reversed arguments. *)
-let rec mem' l x = mem x l
+let mem' l x = mem x l
 
 (* Return the set of distinct  elements in a list. Does not preserve order. *)
 let setify_simple l =
@@ -639,7 +618,7 @@ let pair f l =
 
 (* A version of [pair] which adds a unary function for the singleton, much
 like [couple_ext]. *)
-let rec pair_ext f g l =
+let pair_ext f g l =
   let rec pair_ext_inner r f g = function
     | [] -> rev r
     | [a] -> pair_ext_inner (g a::r) f g []
diff --git a/pdfwrite.ml b/pdfwrite.ml
index 6d8a552..df7564b 100644
--- a/pdfwrite.ml
+++ b/pdfwrite.ml
@@ -70,7 +70,7 @@ let hexchar = function
   | 8 -> '8' | 9 -> '9' | 10 -> 'A' | 11 -> 'B' | 12 -> 'C' | 13 -> 'D' | 14 
-> 'E' | 15 -> 'F'
   | _ -> raise (Failure "hexchar")
 
-let rec make_pdf_name_inner b s =
+let make_pdf_name_inner b s =
   for x = 1 to String.length s - 1 do (* skip / *)
     match String.get s x with
     | '\000' ->

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

_______________________________________________
Pkg-ocaml-maint-commits mailing list
Pkg-ocaml-maint-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-ocaml-maint-commits

Reply via email to