Skip to content

Commit 291cd7c

Browse files
authored
Merge pull request #61 from anmonteiro/anmonteiro/support-beta-rc-versions
discover.exe: support beta/rc versions of postgresql
2 parents 5cdfd8c + b23bc13 commit 291cd7c

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

lib/config/discover.ml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,29 @@ let major_minor_from_pgconfig () =
5555
in
5656
Fun.protect ~finally:(fun () -> close_in ic) (fun () -> pg_major_minor ic)
5757

58+
let keep_digits =
59+
let rec aux version_line len i =
60+
if i < len then
61+
match version_line.[i] with
62+
| '0' .. '9' | '.' -> aux version_line len (i + 1)
63+
| _ -> i
64+
else i
65+
in
66+
fun version_line ->
67+
let len = String.length version_line in
68+
let cut = aux version_line len 0 in
69+
String.sub version_line 0 cut
70+
5871
let major_minor_from_pkg_config () =
5972
let bin = Sys.getenv_opt "PKG_CONFIG" |> Option.value ~default:"pkg-config" in
6073
let args = Sys.getenv_opt "PKG_CONFIG_ARGN" |> Option.value ~default:"" in
6174
let cmd = Format.asprintf "%s %s --modversion libpq" bin args in
6275
let ic = Unix.open_process_in cmd in
6376
Fun.protect ~finally:(fun () -> close_in ic) @@ fun () ->
6477
let version_line = input_line ic in
65-
match String.split_on_char '.' version_line with
78+
match String.split_on_char '.' (keep_digits version_line) with
79+
| [major] ->
80+
("-DPG_OCAML_MAJOR_VERSION=" ^ major, "-DPG_OCAML_MINOR_VERSION=0")
6681
| major :: minor :: _ ->
6782
("-DPG_OCAML_MAJOR_VERSION=" ^ major, "-DPG_OCAML_MINOR_VERSION=" ^ minor)
6883
| _ ->

0 commit comments

Comments
 (0)