remove compilation warnings for OCaml version >= 4.02.0

Summary:
public
Add the backwards-compatibility Bytes module if we detect OCaml version <
4.02.0.

Reviewed By: jberdine

Differential Revision: D2728924

fb-gh-sync-id: 39cf76b
master
Jules Villard 9 years ago committed by facebook-github-bot-1
parent 4b82e208ff
commit 8dabf716e0

@ -54,6 +54,15 @@ AC_ASSERT_OCAML_PKG([easy-format])
AC_ASSERT_OCAML_PKG([ptrees]) AC_ASSERT_OCAML_PKG([ptrees])
AC_ASSERT_OCAML_PKG([yojson]) AC_ASSERT_OCAML_PKG([yojson])
OCAMLVERSION_MAJOR=$(printf $OCAMLVERSION | cut -d . -f 1)
OCAMLVERSION_MINOR=$(printf $OCAMLVERSION | cut -d . -f 2)
OCAML_PKG_bytes=no
# need the bytes package for OCaml version < 4.02.0
if test "$OCAMLVERSION_MAJOR" -le 4 && test "$OCAMLVERSION_MINOR" -lt 2; then
AC_ASSERT_OCAML_PKG([bytes])
fi
AC_CHECK_TOOL([ATDGEN], [atdgen], [no]) AC_CHECK_TOOL([ATDGEN], [atdgen], [no])
AC_ASSERT_PROG([atdgen], [$ATDGEN]) AC_ASSERT_PROG([atdgen], [$ATDGEN])
AC_SUBST([ATDGEN]) AC_SUBST([ATDGEN])

@ -42,6 +42,13 @@ EASYFORMAT_INCLUDE_DIR = @OCAML_PKG_PATH_easy_format@
OCAML_INCLUDES = -I,$(EASYFORMAT_INCLUDE_DIR),-I,$(BINIOU_INCLUDE_DIR),-I,$(YOJSON_INCLUDE_DIR),-I,$(ATDGEN_INCLUDE_DIR) OCAML_INCLUDES = -I,$(EASYFORMAT_INCLUDE_DIR),-I,$(BINIOU_INCLUDE_DIR),-I,$(YOJSON_INCLUDE_DIR),-I,$(ATDGEN_INCLUDE_DIR)
OCAML_LIBS = unix str atdgen OCAML_LIBS = unix str atdgen
OCAML_MODS = easy_format bi_util bi_share bi_outbuf bi_inbuf bi_vint bi_io yojson ag_oj_run ag_ob_run ag_util OCAML_MODS = easy_format bi_util bi_share bi_outbuf bi_inbuf bi_vint bi_io yojson ag_oj_run ag_ob_run ag_util
# backwards compatibility with OCaml version < 4.02.0
ifneq (@OCAML_PKG_bytes@,no)
BYTES_INCLUDE_DIR = @OCAML_PKG_PATH_bytes@
OCAML_INCLUDES := $(OCAML_INCLUDES),-I,$(BYTES_INCLUDE_DIR)
endif
OCAMLBUILD_OPTIONS = -lflags -annot \ OCAMLBUILD_OPTIONS = -lflags -annot \
-cflags -annot,-bin-annot,-warn-error,@5@8@10..12@20@26@39 \ -cflags -annot,-bin-annot,-warn-error,@5@8@10..12@20@26@39 \
-lflags $(OCAML_INCLUDES) \ -lflags $(OCAML_INCLUDES) \

@ -206,7 +206,7 @@ let create_dir dir =
let read_whole_file fd = let read_whole_file fd =
let stats = Unix.fstat fd in let stats = Unix.fstat fd in
let size = stats.Unix.st_size in let size = stats.Unix.st_size in
let buf = String.create size in let buf = Bytes.create size in
let nread = Unix.read fd buf 0 size in let nread = Unix.read fd buf 0 size in
if nread != size then if nread != size then
begin begin

@ -112,7 +112,7 @@ let strip_special_chars s =
if String.contains st c then begin if String.contains st c then begin
let idx = String.index st c in let idx = String.index st c in
try try
String.set st idx c'; Bytes.set st idx c';
st st
with Invalid_argument _ -> L.out "@\n@\n Invalid argument!!! @\n @.@.@."; assert false with Invalid_argument _ -> L.out "@\n@\n Invalid argument!!! @\n @.@.@."; assert false
end else st in end else st in

@ -49,7 +49,7 @@ module Inference = struct
let update_boolvec_str _s size index bval = let update_boolvec_str _s size index bval =
let s = if _s = "" then String.make size '0' else _s in let s = if _s = "" then String.make size '0' else _s in
String.set s index (if bval then '1' else '0'); Bytes.set s index (if bval then '1' else '0');
s s
let mark_file update_str dir fname = let mark_file update_str dir fname =

Loading…
Cancel
Save