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

Re: [Users] CDuce mailing list active? ... Here is a 3.11.0 version



Hi Richard,

On Sat, Dec 6, 2008 at 1:51 AM, Richard Jones <rich@annexia.org> wrote:
>
> I don't see any postings in the mailing list archive for CDuce since
> April 2008.  Am I looking in the right place?
>
> CDuce currently doesn't build with OCaml 3.11.0.  However I have made
> it build at least using the attached patch.  Note that although this
> builds I haven't really tested it very much, so someone who knows what
> they are doing needs to check this patch carefully.
>
> As usual you can find Fedora's build of cduce, plus any special
> patches we may be applying, here:
>
> http://cvs.fedoraproject.org/viewvc/devel/cduce/
>


Thank you very much. Your patch seems fine (although I'm not really an expert
of the OCaml/CDuce interface). I have a comment for the cduce_curl part :


diff -ur cduce-0.5.2.orig/parser/cduce_curl.ml
cduce-0.5.2.newcaml/parser/cduce_curl.ml
--- cduce-0.5.2.orig/parser/cduce_curl.ml       2008-02-25
10:10:42.000000000 +0000
+++ cduce-0.5.2.newcaml/parser/cduce_curl.ml    2008-12-05
14:34:07.000000000 +0000
@@ -9,7 +9,12 @@
     let buff = Buffer.create 4096 in
     let conn = Curl.init () in
     Curl.set_url conn s;
-    Curl.set_writefunction conn (Buffer.add_string buff);
+    Curl.set_writefunction conn (
+      fun str ->
+        Buffer.add_string buff str;
+       (* Not clear what Curl is expecting -- the string length? (RWMJ) *)
+       String.length str
+      );
     Curl.perform conn;
     Buffer.contents buff
   with Curl.CurlException (code, n, msg) ->

set_writefunction expects a function which returns the number of bytes
actually written,
and the handler compares it with the size of the data that was passed
to the function.
If they differ, the handler returns  CURLE_WRITE_ERROR
Here Buffer.add_string might fail if the amount of data stored in the
buffer is more than
Sys.max_string_length. This is not an issue on amd64 but on 32bit
architectures it would
mean reading a 16Mb document, which is not that uncommon.
Maybe you could update your patch with this :

      fun str ->
	try
          Buffer.add_string buff str;
	  (* Not clear what Curl is expecting -- the string length? (RWMJ) *)
	  String.length str
	with
	    Failure _ -> 0
      );

At least it wouldn't let the programmer puzzled with Failure
"Buffer.add : cannot grow buffer"
when trying to read a large XML file.


Cheers,
-- 
Kim


Reply to: