diff --git a/configure b/configure index 207c4df..4cdd5e5 100755 --- a/configure +++ b/configure @@ -632,6 +632,7 @@ CURLLIBS ac_prefix_program OCAML_PKG_lwt_ppx OCAML_PKG_lwt_unix +OCAML_PKG_bytes OCAMLFIND OCAMLBUILD OCAMLDOC @@ -4091,6 +4092,30 @@ fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OCaml findlib package bytes" >&5 +$as_echo_n "checking for OCaml findlib package bytes... " >&6; } + + unset found + unset pkg + found=no + for pkg in bytes ; do + if $OCAMLFIND query $pkg >/dev/null 2>/dev/null; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 +$as_echo "found" >&6; } + OCAML_PKG_bytes=$pkg + found=yes + break + fi + done + if test "$found" = "no" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + OCAML_PKG_bytes=no + fi + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OCaml findlib package lwt.unix" >&5 $as_echo_n "checking for OCaml findlib package lwt.unix... " >&6; } @@ -4241,6 +4266,7 @@ fi + if test "$OCAMLFIND" == "no"; then : $OCAMLC -I +compiler-libs ocamlcommon.cma print_ext.ml -o print_ext else diff --git a/configure.ac b/configure.ac index 363969d..750b283 100644 --- a/configure.ac +++ b/configure.ac @@ -28,6 +28,7 @@ AC_PROG_INSTALL() AC_PROG_OCAML() AC_PROG_FINDLIB() +AC_CHECK_OCAML_PKG([bytes]) AC_CHECK_OCAML_PKG([lwt.unix]) AC_CHECK_OCAML_PKG([lwt.ppx]) @@ -39,6 +40,7 @@ AC_SUBST(CURLLIBS) AC_SUBST(OCAMLLIB) AC_SUBST(INSTALLDIR) AC_SUBST(OCAMLFIND) +AC_SUBST(OCAML_PKG_bytes) AC_SUBST(OCAML_PKG_lwt_unix) AC_SUBST(OCAML_PKG_lwt_ppx) diff --git a/examples/Makefile.in b/examples/Makefile.in index 560e285..86a5a6b 100644 --- a/examples/Makefile.in +++ b/examples/Makefile.in @@ -16,7 +16,10 @@ LFLAGS = -g -I .. -ccopt -L.. OCURLLIB = curl.cma unix.cma threads.cma OCURLOPTLIB = curl.cmxa unix.cmxa threads.cmxa -TARGETS = ocurl oput ominimal ossl ocurl_test_threads opar test_cb_exn test_memory_leaks +TARGETS = ocurl ominimal ossl ocurl_test_threads opar test_cb_exn test_memory_leaks +ifneq (@OCAML_PKG_bytes@,no) +TARGETS += oput +endif ifneq (@OCAML_PKG_lwt_unix@,no) TARGETS += test_lwt_unit ifneq (@OCAML_PKG_lwt_ppx@,no) @@ -25,7 +28,10 @@ endif endif ifeq (@OCAMLBEST@,opt) -TARGETS += ocurl.opt oput.opt ominimal.opt ossl.opt ocurl_test_threads.opt opar.opt test_cb_exn.opt test_memory_leaks.opt +TARGETS += ocurl.opt ominimal.opt ossl.opt ocurl_test_threads.opt opar.opt test_cb_exn.opt test_memory_leaks.opt +ifneq (@OCAML_PKG_bytes@,no) +TARGETS += oput.opt +endif ifneq (@OCAML_PKG_lwt_unix@,no) TARGETS += test_lwt_unit.opt ifneq (@OCAML_PKG_lwt_ppx@,no) @@ -50,6 +56,12 @@ test_lwt_unit: ../curl.cma ../curl_lwt.cmo test_lwt_unit.ml test_lwt_unit.opt: ../curl.cmxa ../curl_lwt.cmx test_lwt_unit.ml $(FINDLIB) opt $(FINDLIB_LWT_FLAGS) $(LFLAGS) $^ -o $@ +oput: ../curl.cma oput.ml + $(FINDLIB) c -custom -package bytes -linkpkg $(LFLAGS) $^ -o $@ + +oput.opt: ../curl.cmxa oput.ml + $(FINDLIB) opt -package bytes -linkpkg $(LFLAGS) $^ -o $@ + %: %.cmo ../curl.cma $(OCBYTE) -custom $(LFLAGS) $(OCURLLIB) $< -o $@ diff --git a/examples/oput.ml b/examples/oput.ml index 25b043b..c1da561 100644 --- a/examples/oput.ml +++ b/examples/oput.ml @@ -7,14 +7,15 @@ let counter = ref 0 let reader file maxBytes = - let buffer = String.make maxBytes ' ' in + let buffer = Bytes.create maxBytes in let readBytes = input file buffer 0 maxBytes in - if readBytes = 0 then "" - else - begin - counter := !counter + readBytes; - String.sub buffer 0 readBytes - end + if readBytes = 0 then + "" + else + begin + counter := !counter + readBytes; + Bytes.sub_string buffer 0 readBytes + end let _ = if Array.length Sys.argv = 3 then