Skip to content

Commit

Permalink
Require at least OCaml 4.06
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris00 committed Feb 6, 2019
1 parent d40d9d8 commit b101398
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 25 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ env:
- PACKAGE=freetds
matrix:
- OCAML_VERSION=4.06
- OCAML_VERSION=4.05
- OCAML_VERSION=4.04
- OCAML_VERSION=4.07

install: wget https://raw.githubusercontent.com/ocaml/ocaml-ci-scripts/master/.travis-opam.sh
script: bash -ex .travis-opam.sh
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ environment:
# TDSVER: 4.2
TDSVER: 7.4
matrix:
- OPAM_SWITCH: 4.04.2+mingw64c
# - OPAM_SWITCH: 4.04.2+msvc64c
- OPAM_SWITCH: 4.06.1+mingw64c
# - OPAM_SWITCH: 4.06.1+msvc64c

install:
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/$env:FORK_USER/ocaml-ci-scripts/$env:FORK_BRANCH/appveyor-install.ps1"))
Expand Down
5 changes: 0 additions & 5 deletions config/discover.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ let conf c =
C.die "The value of REG_ROW was not found in the C hreader file. \
Please make sure the development files of FreeTDS are \
installed in a location where the C compiler finds them." in
let ocaml_ver = C.ocaml_config_var_exn c "version" in
let major, minor = Scanf.sscanf ocaml_ver "%d.%d" (fun m n -> m, n) in
let cflags = if major > 4 || (major = 4 && minor >= 6) then
"-DOCAML406" :: cflags
else cflags in
let fh = open_out "reg_row.txt" in
fprintf fh "%d" reg_row;
close_out fh;
Expand Down
2 changes: 1 addition & 1 deletion freetds.opam
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ depends: [
"dune" {build & >= "1.4.0"}
"cppo" {build}
"ounit" {with-test & >= "2.0.0"}
"ocaml" {>= "4.02.3"}
"ocaml" {>= "4.06.0"}
]
depexts: [
["freetds-dev"] {os-distribution = "alpine"}
Expand Down
19 changes: 5 additions & 14 deletions src/ct_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,6 @@
#include <caml/fail.h>
#include <caml/custom.h>

#ifdef OCAML406
#define COPY_VAL_STRING(str, len, data) \
str = caml_alloc_initialized_string(len, data)
#else
#define COPY_VAL_STRING(str, len, data) \
str = alloc_string(len); \
memcpy((char *) String_val(str), data, len)
#endif

void mltds_ct_ctx_finalize(value ctx);
void mltds_ct_con_finalize(value conn);
void mltds_ct_cmd_finalize(value cmd);
Expand Down Expand Up @@ -649,7 +640,7 @@ CAMLprim value mltds_buffer_contents( value buffer )
case CS_DECIMAL_TYPE:
case CS_FLOAT_TYPE:
case CS_REAL_TYPE:
COPY_VAL_STRING(str, buf->copied, buf->data);
str = caml_alloc_initialized_string(buf->copied, buf->data);

result = alloc(2, 0);
Store_field(result, 0, hash_variant("Decimal"));
Expand All @@ -660,7 +651,7 @@ CAMLprim value mltds_buffer_contents( value buffer )
case CS_CHAR_TYPE:
case CS_VARCHAR_TYPE:
default:
COPY_VAL_STRING(str, buf->copied, buf->data);
str = caml_alloc_initialized_string(buf->copied, buf->data);

result = alloc(2, 0);
Store_field(result, 0, hash_variant("String"));
Expand All @@ -680,7 +671,7 @@ CAMLprim value mltds_buffer_contents( value buffer )
case CS_NUMERIC_TYPE:
case CS_DECIMAL_TYPE:
default:
COPY_VAL_STRING(str, buf->copied, buf->data);
str = caml_alloc_initialized_string(buf->copied, buf->data);

result = alloc(2, 0);
Store_field(result, 0, hash_variant("Binary"));
Expand Down Expand Up @@ -747,7 +738,7 @@ static value get_client_message(CS_CONNECTION* conn, CS_INT msgno)
retval_inspect(
"ct_diag", ct_diag(conn, CS_GET, CS_CLIENTMSG_TYPE, msgno, &msg) );

COPY_VAL_STRING(str, msg.msgstringlen, msg.msgstring);
str = caml_alloc_initialized_string(msg.msgstringlen, msg.msgstring);

result = alloc(2, 0);
Store_field(result, 0, value_of_severity(msg.severity));
Expand All @@ -765,7 +756,7 @@ static value get_server_message(CS_CONNECTION* conn, CS_INT msgno)
retval_inspect(
"ct_diag", ct_diag(conn, CS_GET, CS_SERVERMSG_TYPE, msgno, &msg) );

COPY_VAL_STRING(str, msg.textlen, msg.text);
str = caml_alloc_initialized_string(msg.textlen, msg.text);

result = alloc(2, 0);
Store_field(result, 0, value_of_severity(msg.severity));
Expand Down
2 changes: 1 addition & 1 deletion test/test_dblib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ let test_exception_in_callback params _ =
Dblib.sqlexec conn "\x81"
with
| Dblib.Error(CONVERSION, _) -> ()
| _ -> assert false
| e -> raise e
end;
Dblib.sqlexec conn "SELECT 1")

Expand Down

0 comments on commit b101398

Please sign in to comment.